Integrate Scopes with Prometheus datasource (#84888)

This commit is contained in:
Bogdan Matei 2024-03-21 14:02:57 +02:00 committed by GitHub
parent db791e8955
commit 30a1178624
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import { Scope } from '@grafana/data';
import * as common from '@grafana/schema';
export enum QueryEditorMode {
@ -41,7 +42,5 @@ export interface Prometheus extends common.DataQuery {
* Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series
*/
range?: boolean;
scope?: {
matchers: string;
};
scope?: Scope;
}

View File

@ -30,6 +30,7 @@ import {
import {
BackendDataSourceResponse,
BackendSrvRequest,
config,
DataSourceWithBackend,
FetchResponse,
getBackendSrv,
@ -363,6 +364,11 @@ export class PrometheusDatasource
// We need to pass utcOffsetSec to backend to calculate aligned range
utcOffsetSec: request.range.to.utcOffset() * 60,
};
if (config.featureToggles.promQLScope) {
processedTarget.scope = request.scope;
}
if (target.instant && target.range) {
// We have query type "Both" selected
// We should send separate queries with different refId

View File

@ -1,3 +1,4 @@
import { Scope } from '@grafana/data';
import * as common from '@grafana/schema';
export enum QueryEditorMode {
@ -41,7 +42,8 @@ export interface Prometheus extends common.DataQuery {
* Returns a Range vector, comprised of a set of time series containing a range of data points over time for each time series
*/
range?: boolean;
scope?: {
matchers: string;
};
/**
* A scope object that will be used by Prometheus
*/
scope?: Scope;
}

View File

@ -30,6 +30,7 @@ import {
import {
BackendDataSourceResponse,
BackendSrvRequest,
config,
DataSourceWithBackend,
FetchResponse,
getBackendSrv,
@ -363,6 +364,11 @@ export class PrometheusDatasource
// We need to pass utcOffsetSec to backend to calculate aligned range
utcOffsetSec: request.range.to.utcOffset() * 60,
};
if (config.featureToggles.promQLScope) {
processedTarget.scope = request.scope;
}
if (target.instant && target.range) {
// We have query type "Both" selected
// We should send separate queries with different refId