mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Fixes default step value for annotation query (#21934)
Fixes #21914
This commit is contained in:
@@ -6,11 +6,6 @@ import $ from 'jquery';
|
||||
import kbn from 'app/core/utils/kbn';
|
||||
import {
|
||||
AnnotationEvent,
|
||||
dateMath,
|
||||
DateTime,
|
||||
LoadingState,
|
||||
TimeRange,
|
||||
TimeSeries,
|
||||
CoreApp,
|
||||
DataQueryError,
|
||||
DataQueryRequest,
|
||||
@@ -18,9 +13,14 @@ import {
|
||||
DataQueryResponseData,
|
||||
DataSourceApi,
|
||||
DataSourceInstanceSettings,
|
||||
dateMath,
|
||||
DateTime,
|
||||
LoadingState,
|
||||
ScopedVars,
|
||||
TimeRange,
|
||||
TimeSeries,
|
||||
} from '@grafana/data';
|
||||
import { from, merge, Observable, of, forkJoin } from 'rxjs';
|
||||
import { forkJoin, from, merge, Observable, of } from 'rxjs';
|
||||
import { filter, map, tap } from 'rxjs/operators';
|
||||
|
||||
import PrometheusMetricFindQuery from './metric_find_query';
|
||||
@@ -37,6 +37,8 @@ import templateSrv from 'app/features/templating/template_srv';
|
||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import TableModel from 'app/core/table_model';
|
||||
|
||||
export const ANNOTATION_QUERY_STEP_DEFAULT = '60s';
|
||||
|
||||
interface RequestOptions {
|
||||
method?: string;
|
||||
url?: string;
|
||||
@@ -520,9 +522,21 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
||||
};
|
||||
}
|
||||
|
||||
createAnnotationQueryOptions = (options: any): DataQueryRequest<PromQuery> => {
|
||||
const annotation = options.annotation;
|
||||
const interval =
|
||||
annotation && annotation.step && typeof annotation.step === 'string'
|
||||
? annotation.step
|
||||
: ANNOTATION_QUERY_STEP_DEFAULT;
|
||||
return {
|
||||
...options,
|
||||
interval,
|
||||
};
|
||||
};
|
||||
|
||||
async annotationQuery(options: any) {
|
||||
const annotation = options.annotation;
|
||||
const { expr = '', tagKeys = '', titleFormat = '', textFormat = '', step = '60s' } = annotation;
|
||||
const { expr = '', tagKeys = '', titleFormat = '', textFormat = '' } = annotation;
|
||||
|
||||
if (!expr) {
|
||||
return Promise.resolve([]);
|
||||
@@ -530,10 +544,7 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
||||
|
||||
const start = this.getPrometheusTime(options.range.from, false);
|
||||
const end = this.getPrometheusTime(options.range.to, true);
|
||||
const queryOptions = {
|
||||
...options,
|
||||
interval: step,
|
||||
};
|
||||
const queryOptions = this.createAnnotationQueryOptions(options);
|
||||
|
||||
// Unsetting min interval for accurate event resolution
|
||||
const minStep = '1s';
|
||||
|
||||
Reference in New Issue
Block a user