Prometheus: Send time range params when requesting labels (#59648)

* Send time range params when requesting labels

* Update public/app/plugins/datasource/prometheus/datasource.tsx

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Send params when calling values too

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
This commit is contained in:
ismail simsek 2022-12-02 21:11:34 +03:00 committed by GitHub
parent ece8609e7c
commit ba2e226ba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,8 +6,11 @@ import { catchError, filter, map, tap } from 'rxjs/operators';
import semver from 'semver/preload';
import {
AbstractQuery,
AnnotationEvent,
AnnotationQueryRequest,
CoreApp,
DataFrame,
DataQueryError,
DataQueryRequest,
DataQueryResponse,
@ -16,32 +19,29 @@ import {
DataSourceWithQueryImportSupport,
dateMath,
DateTime,
AbstractQuery,
dateTime,
LoadingState,
QueryFixAction,
rangeUtil,
ScopedVars,
TimeRange,
DataFrame,
dateTime,
AnnotationQueryRequest,
QueryFixAction,
} from '@grafana/data';
import {
BackendDataSourceResponse,
BackendSrvRequest,
DataSourceWithBackend,
FetchError,
FetchResponse,
getBackendSrv,
DataSourceWithBackend,
BackendDataSourceResponse,
toDataQueryResponse,
isFetchError,
toDataQueryResponse,
} from '@grafana/runtime';
import { Badge, BadgeColor, Tooltip } from '@grafana/ui';
import { safeStringifyValue } from 'app/core/utils/explore';
import { discoverDataSourceFeatures } from 'app/features/alerting/unified/api/buildInfo';
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
import { PromApplication, PromApiFeatures } from 'app/types/unified-alerting-dto';
import { PromApiFeatures, PromApplication } from 'app/types/unified-alerting-dto';
import { addLabelToQuery } from './add_label_to_query';
import { AnnotationQueryEditor } from './components/AnnotationQueryEditor';
@ -895,13 +895,15 @@ export class PrometheusDatasource
return uniqueLabels.map((value: any) => ({ text: value }));
} else {
// Get all tags
const result = await this.metadataRequest('/api/v1/labels');
const params = this.getTimeRangeParams();
const result = await this.metadataRequest('/api/v1/labels', params);
return result?.data?.data?.map((value: any) => ({ text: value })) ?? [];
}
}
async getTagValues(options: { key?: string } = {}) {
const result = await this.metadataRequest(`/api/v1/label/${options.key}/values`);
const params = this.getTimeRangeParams();
const result = await this.metadataRequest(`/api/v1/label/${options.key}/values`, params);
return result?.data?.data?.map((value: any) => ({ text: value })) ?? [];
}