mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Fix bug when adding a query in mixed datasource (#69424)
default query needs to not be a function separate from ds
This commit is contained in:
parent
770ae4bbc9
commit
4fdccef7b3
@ -1265,7 +1265,12 @@ export class PrometheusDatasource
|
||||
}
|
||||
|
||||
getDefaultQuery(app: CoreApp): PromQuery {
|
||||
const defaults = promDefaultBaseQuery();
|
||||
const defaults = {
|
||||
refId: 'A',
|
||||
expr: '',
|
||||
range: true,
|
||||
instant: false,
|
||||
};
|
||||
|
||||
if (app === CoreApp.UnifiedAlerting) {
|
||||
return {
|
||||
@ -1335,12 +1340,3 @@ export function prometheusRegularEscape(value: any) {
|
||||
export function prometheusSpecialRegexEscape(value: any) {
|
||||
return typeof value === 'string' ? value.replace(/\\/g, '\\\\\\\\').replace(/[$^*{}\[\]\'+?.()|]/g, '\\\\$&') : value;
|
||||
}
|
||||
|
||||
export function promDefaultBaseQuery(): PromQuery {
|
||||
return {
|
||||
refId: 'A',
|
||||
expr: '',
|
||||
range: true,
|
||||
instant: false,
|
||||
};
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
|
||||
|
||||
import { CoreApp } from '@grafana/data';
|
||||
|
||||
import { promDefaultBaseQuery } from '../../datasource';
|
||||
import { PromQuery } from '../../types';
|
||||
import { getQueryWithDefaults } from '../state';
|
||||
|
||||
@ -107,7 +106,15 @@ function setup(queryOverrides: Partial<PromQuery> = {}, app: CoreApp = CoreApp.P
|
||||
const props = {
|
||||
app,
|
||||
query: {
|
||||
...getQueryWithDefaults(promDefaultBaseQuery(), CoreApp.PanelEditor),
|
||||
...getQueryWithDefaults(
|
||||
{
|
||||
refId: 'A',
|
||||
expr: '',
|
||||
range: true,
|
||||
instant: false,
|
||||
} as PromQuery,
|
||||
CoreApp.PanelEditor
|
||||
),
|
||||
...queryOverrides,
|
||||
},
|
||||
onRunQuery: jest.fn(),
|
||||
|
Loading…
Reference in New Issue
Block a user