Skip to content

Add approx_topk and multi-variant expressions to LogQL parser#882

Open
btaani wants to merge 5 commits intoobservatorium:mainfrom
btaani:new-logql-features
Open

Add approx_topk and multi-variant expressions to LogQL parser#882
btaani wants to merge 5 commits intoobservatorium:mainfrom
btaani:new-logql-features

Conversation

@btaani
Copy link
Contributor

@btaani btaani commented Feb 27, 2026

Add support for LogQL features included in Loki between v3.1.0 and v3.6.5

$ git log --oneline v3.1.0..v3.6.5 -- pkg/logql/syntax/expr.y pkg/logql/syntax/syntax.y
417d0a5252 chore: add multi-variant query support to LogQL (#16196)
1187a73667 chore: LogQL syntax and AST simplification and cosistency (#16028)
7b53f20f70 feat: Introduce shardable probabilistic topk for instant queries. (#14243)

Ref: LOG-8712

@btaani
Copy link
Contributor Author

btaani commented Feb 27, 2026

/hold
fixing & adding more tests

Copy link
Contributor

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approx_topk seems to still be in experimental feature according to the docs. It works when sent directly to the querier, but fails with parse error at line 1, col 1: syntax error: unexpected IDENTIFIER when sent through query-frontend.

I verified this by calling both components directly over mTLS with the same query: the querier returned 200 and valid results, while the query-frontend returned 400. This points to a query-frontend bug... likely related to approx_topk being rewritten into internal non-LogQL expressions during frontend processing and then reparsed on a code path that expects normal LogQL.

/cc @xperimental with this shall we add support for approx_topk? I'm on the fence because I'm not sure if grafana will eventually support it or drop it... at the same time if we don't add support we would need to remember that

multi-variant worked perfectly 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants