Annotations: improve datasource annotation types and add basic query properties (#27342)

This commit is contained in:
Ryan McKinley
2020-09-03 10:41:25 -07:00
committed by GitHub
parent cac0e6ecd0
commit b867050cfb
3 changed files with 29 additions and 10 deletions

View File

@@ -8,10 +8,11 @@ import coreModule from 'app/core/core_module';
import { dedupAnnotations } from './events_processing';
// Types
import { DashboardModel, PanelModel } from '../dashboard/state';
import { AnnotationEvent, AppEvents, DataSourceApi, PanelEvents, TimeRange } from '@grafana/data';
import { AnnotationEvent, AppEvents, DataSourceApi, PanelEvents, TimeRange, CoreApp } from '@grafana/data';
import { getBackendSrv, getDataSourceSrv } from '@grafana/runtime';
import { appEvents } from 'app/core/core';
import { getTimeSrv } from '../dashboard/services/TimeSrv';
import kbn from 'app/core/utils/kbn';
export class AnnotationsSrv {
globalAnnotationsPromise: any;
@@ -113,6 +114,9 @@ export class AnnotationsSrv {
const promises = [];
const dsPromises = [];
// No more points than pixels
const maxDataPoints = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
for (const annotation of dashboard.annotations.list) {
if (!annotation.enable) {
continue;
@@ -130,7 +134,12 @@ export class AnnotationsSrv {
return [];
}
// Add interval to annotation queries
const interval = kbn.calculateInterval(range, maxDataPoints, datasource.interval);
return datasource.annotationQuery({
...interval,
app: CoreApp.Dashboard,
range,
rangeRaw: range.raw,
annotation: annotation,

View File

@@ -539,6 +539,9 @@ function makeAnnotationQueryRequest(): AnnotationQueryRequest<LokiQuery> {
raw: timeRange,
},
rangeRaw: timeRange,
app: 'test',
interval: '1m',
intervalMs: 6000,
};
}