AnnotationSupport interface

Since Grafana 7.2

This offers a generic approach to annotation processing

Signature

  1. export interface AnnotationSupport<TQuery extends DataQuery = DataQuery, TAnno = AnnotationQuery<TQuery>>

Import

  1. import { AnnotationSupport } from '@grafana/data';

Properties

PropertyTypeDescription
QueryEditorComponentType<QueryEditorProps<any, TQuery>>Specify a custom QueryEditor for the annotation page. If not specified, the standard one will be used

Methods

MethodDescription
prepareAnnotation(json)This hook lets you manipulate any existing stored values before running them though the processor. This is particularly helpful when dealing with migrating old formats. ie query as a string vs object
prepareQuery(anno)Convert the stored JSON model to a standard datasource query object. This query will be executed in the datasource and the results converted into events. Returning an undefined result will quietly skip query execution
processEvents(anno, data)When the standard frame > event processing is insufficient, this allows explicit control of the mappings

QueryEditor property

Specify a custom QueryEditor for the annotation page. If not specified, the standard one will be used

Signature

  1. QueryEditor?: ComponentType<QueryEditorProps<any, TQuery>>;

prepareAnnotation method

This hook lets you manipulate any existing stored values before running them though the processor. This is particularly helpful when dealing with migrating old formats. ie query as a string vs object

Signature

  1. prepareAnnotation?(json: any): TAnno;

Parameters

ParameterTypeDescription
jsonany

Returns:

TAnno

prepareQuery method

Convert the stored JSON model to a standard datasource query object. This query will be executed in the datasource and the results converted into events. Returning an undefined result will quietly skip query execution

Signature

  1. prepareQuery?(anno: TAnno): TQuery | undefined;

Parameters

ParameterTypeDescription
annoTAnno

Returns:

TQuery | undefined

processEvents method

When the standard frame > event processing is insufficient, this allows explicit control of the mappings

Signature

  1. processEvents?(anno: TAnno, data: DataFrame[]): Observable<AnnotationEvent[] | undefined>;

Parameters

ParameterTypeDescription
annoTAnno
dataDataFrame[]

Returns:

Observable<AnnotationEvent[] | undefined>