Loki: Fix issues with using query patterns (#50414)

* WIP

* Loki: Fix running of query patterns

* Remove console.log

* Add test

* Update empty line filter test
This commit is contained in:
Ivana Huckova
2022-06-11 21:36:44 +02:00
committed by GitHub
parent 1231e0dd69
commit 88279dda1c
5 changed files with 36 additions and 10 deletions

View File

@@ -360,7 +360,13 @@ function handleVectorAggregation(expr: string, node: SyntaxNode, context: Contex
let funcName = getString(expr, nameNode);
const grouping = node.getChild('Grouping');
const labels: string[] = [];
const params = [];
const numberNode = node.getChild('Number');
if (numberNode) {
params.push(Number(getString(expr, numberNode)));
}
if (grouping) {
const byModifier = grouping.getChild(`By`);
@@ -373,11 +379,11 @@ function handleVectorAggregation(expr: string, node: SyntaxNode, context: Contex
funcName = `__${funcName}_without`;
}
labels.push(...getAllByType(expr, grouping, 'Identifier'));
params.push(...getAllByType(expr, grouping, 'Identifier'));
}
const metricExpr = node.getChild('MetricExpr');
const op: QueryBuilderOperation = { id: funcName, params: labels };
const op: QueryBuilderOperation = { id: funcName, params };
if (metricExpr) {
handleExpression(expr, metricExpr, context);