mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki/Prometheus: updates addLabelToQuery method to prevent it from adding labels outside of selector when using Loki datasource (#25059)
* Chore: updates add label to query method in prometheus datasource to fix loki label insert * Chore: adds addLabelToQuery test covering differences between adding label to loki vs non-loki queries * Chore: adds an additional comment to addLabelToQuery * Chore: renames isLokiDatasource to hasNoMetrics in addLabelToQuery
This commit is contained in:
@@ -347,17 +347,16 @@ export class LokiDatasource extends DataSourceApi<LokiQuery, LokiOptions> {
|
||||
let expression = query.expr ?? '';
|
||||
switch (action.type) {
|
||||
case 'ADD_FILTER': {
|
||||
expression = addLabelToQuery(expression, action.key, action.value);
|
||||
expression = addLabelToQuery(expression, action.key, action.value, undefined, true);
|
||||
break;
|
||||
}
|
||||
case 'ADD_FILTER_OUT': {
|
||||
expression = addLabelToQuery(expression, action.key, action.value, '!=');
|
||||
expression = addLabelToQuery(expression, action.key, action.value, '!=', true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return { ...query, expr: expression };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user