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:
Lukas Siatka
2020-05-25 12:23:35 +02:00
committed by GitHub
parent 9a59f387d9
commit 60e7b63c33
3 changed files with 29 additions and 6 deletions

View File

@@ -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 };
}