Annotations: Add annotations support to Loki (#18949)

This commit is contained in:
Andrej Ocenas
2019-09-10 11:04:44 +02:00
committed by GitHub
parent eccc6adfde
commit 0e3e874eee
12 changed files with 240 additions and 15 deletions
@@ -68,4 +68,10 @@ export class DataFrameView<T = any> implements Vector<T> {
toJSON(): T[] {
return this.toArray();
}
forEachRow(iterator: (row: T) => void) {
for (let i = 0; i < this.data.length; i++) {
iterator(this.get(i));
}
}
}
@@ -8,6 +8,7 @@ import {
LogRowModel,
LoadingState,
DataFrameDTO,
AnnotationEvent,
} from '@grafana/data';
import { PluginMeta, GrafanaPlugin } from './plugin';
import { PanelData } from './panel';
@@ -276,6 +277,12 @@ export abstract class DataSourceApi<
* Used in explore
*/
languageProvider?: any;
/**
* Can be optionally implemented to allow datasource to be a source of annotations for dashboard. To be visible
* in the annotation editor `annotations` capability also needs to be enabled in plugin.json.
*/
annotationQuery?(options: AnnotationQueryRequest<TQuery>): Promise<AnnotationEvent[]>;
}
export interface QueryEditorProps<
@@ -542,3 +549,18 @@ export interface DataSourceSelectItem {
meta: DataSourcePluginMeta;
sort: string;
}
/**
* Options passed to the datasource.annotationQuery method. See docs/plugins/developing/datasource.md
*/
export interface AnnotationQueryRequest<MoreOptions = {}> {
range: TimeRange;
rangeRaw: RawTimeRange;
// Should be DataModel but cannot import that here from the main app. Needs to be moved to package first.
dashboard: any;
annotation: {
datasource: string;
enable: boolean;
name: string;
} & MoreOptions;
}