Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Enterprise Open source

AnnotationSupport interface

Since Grafana 7.2

This offers a generic approach to annotation processing

Signature

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

Import

typescript
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

typescript
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

typescript
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

typescript
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

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

Parameters

ParameterTypeDescription
annoTAnno
dataDataFrame[]

Returns:

Observable<AnnotationEvent[] | undefined>