mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
ece8609e7c
commit
ba2e226ba9
@ -6,8 +6,11 @@ import { catchError, filter, map, tap } from 'rxjs/operators';
|
|||||||
import semver from 'semver/preload';
|
import semver from 'semver/preload';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AbstractQuery,
|
||||||
AnnotationEvent,
|
AnnotationEvent,
|
||||||
|
AnnotationQueryRequest,
|
||||||
CoreApp,
|
CoreApp,
|
||||||
|
DataFrame,
|
||||||
DataQueryError,
|
DataQueryError,
|
||||||
DataQueryRequest,
|
DataQueryRequest,
|
||||||
DataQueryResponse,
|
DataQueryResponse,
|
||||||
@ -16,32 +19,29 @@ import {
|
|||||||
DataSourceWithQueryImportSupport,
|
DataSourceWithQueryImportSupport,
|
||||||
dateMath,
|
dateMath,
|
||||||
DateTime,
|
DateTime,
|
||||||
AbstractQuery,
|
dateTime,
|
||||||
LoadingState,
|
LoadingState,
|
||||||
|
QueryFixAction,
|
||||||
rangeUtil,
|
rangeUtil,
|
||||||
ScopedVars,
|
ScopedVars,
|
||||||
TimeRange,
|
TimeRange,
|
||||||
DataFrame,
|
|
||||||
dateTime,
|
|
||||||
AnnotationQueryRequest,
|
|
||||||
QueryFixAction,
|
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
|
BackendDataSourceResponse,
|
||||||
BackendSrvRequest,
|
BackendSrvRequest,
|
||||||
|
DataSourceWithBackend,
|
||||||
FetchError,
|
FetchError,
|
||||||
FetchResponse,
|
FetchResponse,
|
||||||
getBackendSrv,
|
getBackendSrv,
|
||||||
DataSourceWithBackend,
|
|
||||||
BackendDataSourceResponse,
|
|
||||||
toDataQueryResponse,
|
|
||||||
isFetchError,
|
isFetchError,
|
||||||
|
toDataQueryResponse,
|
||||||
} from '@grafana/runtime';
|
} from '@grafana/runtime';
|
||||||
import { Badge, BadgeColor, Tooltip } from '@grafana/ui';
|
import { Badge, BadgeColor, Tooltip } from '@grafana/ui';
|
||||||
import { safeStringifyValue } from 'app/core/utils/explore';
|
import { safeStringifyValue } from 'app/core/utils/explore';
|
||||||
import { discoverDataSourceFeatures } from 'app/features/alerting/unified/api/buildInfo';
|
import { discoverDataSourceFeatures } from 'app/features/alerting/unified/api/buildInfo';
|
||||||
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
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 { addLabelToQuery } from './add_label_to_query';
|
||||||
import { AnnotationQueryEditor } from './components/AnnotationQueryEditor';
|
import { AnnotationQueryEditor } from './components/AnnotationQueryEditor';
|
||||||
@ -895,13 +895,15 @@ export class PrometheusDatasource
|
|||||||
return uniqueLabels.map((value: any) => ({ text: value }));
|
return uniqueLabels.map((value: any) => ({ text: value }));
|
||||||
} else {
|
} else {
|
||||||
// Get all tags
|
// 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 })) ?? [];
|
return result?.data?.data?.map((value: any) => ({ text: value })) ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTagValues(options: { key?: string } = {}) {
|
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 })) ?? [];
|
return result?.data?.data?.map((value: any) => ({ text: value })) ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user