mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: variable query editor interpolate variables in label values (#69735)
update regex for label values query type to support variable interpolation
This commit is contained in:
committed by
GitHub
parent
d31a9b66e4
commit
2656c06e0b
@@ -29,6 +29,23 @@ describe('PromVariableQueryEditor', () => {
|
||||
expect(migration).toEqual(expected);
|
||||
});
|
||||
|
||||
test('Allows for use of variables to interpolate label names in the label values query type.', () => {
|
||||
const query: StandardPromVariableQuery = {
|
||||
query: 'label_values($label_name)',
|
||||
refId: 'StandardVariableQuery',
|
||||
};
|
||||
|
||||
const migration: PromVariableQuery = variableMigration(query);
|
||||
|
||||
const expected: PromVariableQuery = {
|
||||
qryType: PromVariableQueryType.LabelValues,
|
||||
label: '$label_name',
|
||||
refId: 'PrometheusDatasource-VariableQuery',
|
||||
};
|
||||
|
||||
expect(migration).toEqual(expected);
|
||||
});
|
||||
|
||||
test('Migrates from jsonnet grafana as code variable to custom variable query', () => {
|
||||
const query = 'label_names()';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PromVariableQuery, PromVariableQueryType as QueryType } from '../types';
|
||||
|
||||
const labelNamesRegex = /^label_names\(\)\s*$/;
|
||||
const labelValuesRegex = /^label_values\((?:(.+),\s*)?([a-zA-Z_][a-zA-Z0-9_]*)\)\s*$/;
|
||||
const labelValuesRegex = /^label_values\((?:(.+),\s*)?([a-zA-Z_$][a-zA-Z0-9_]*)\)\s*$/;
|
||||
const metricNamesRegex = /^metrics\((.+)\)\s*$/;
|
||||
const queryResultRegex = /^query_result\((.+)\)\s*$/;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user