[ES|QL] PromQL parser initial implementation#246552
Merged
vadimkibana merged 6 commits intoelastic:mainfrom Dec 17, 2025
Merged
[ES|QL] PromQL parser initial implementation#246552vadimkibana merged 6 commits intoelastic:mainfrom
vadimkibana merged 6 commits intoelastic:mainfrom
Conversation
Contributor
|
Pinging @elastic/kibana-esql (Team:ESQL) |
Contributor
💔 Build Failed
Failed CI StepsHistory |
stratoula
approved these changes
Dec 17, 2025
Contributor
stratoula
left a comment
There was a problem hiding this comment.
Fascinating! This looks awesome! Thanks Vadim
src/platform/packages/shared/kbn-esql-ast/src/promql/parser/README.md
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/kbn-esql-ast/src/promql/parser/cst_to_ast_converter.ts
Outdated
Show resolved
Hide resolved
…ADME.md Co-authored-by: Stratou <stratoula1@gmail.com>
mbondyra
added a commit
to mbondyra/kibana
that referenced
this pull request
Dec 17, 2025
…donly * commit 'bb1f55fa520b30ceb923af069ef403b24dcb1606': (52 commits) [CPS][Maps] Support CPS Picker in Maps (elastic#246382) [APM] Migrate the Transaction Overview tests to Scout/Playwright/Component/API tests (elastic#245972) [Cases] Change nested field search to be case insensitive (elastic#246643) [ES|QL] PromQL parser initial implementation (elastic#246552) [Agent Builder] Adds keyboard shortcut and toggle behavior to AI Agent button (elastic#246659) Retry on "all shards failed" from ES (elastic#246533) [Streams] Test enable wired streams flow (elastic#246113) [Agent Builder] Fast-follow bugfixes for MCP Tool type (elastic#246665) [Entity Store][API] Fix snake case on CRUD API List response (elastic#246003) [ResponseOps][Slack] Simplify channel configuration (elastic#245423) Add Canonical Name Badge to Documentation (elastic#246647) [Streams] Add simulation filtering by conditions (elastic#245400) [o11y AI] Add `get_hosts` tool (elastic#246541) [agent builder] create_visualization: support heatmap and regionmap (elastic#246671) [AI Infra] Chat experience: Selection modal title change (elastic#246683) [Background search] Change polling behavior (elastic#244760) [ES|QL ] Common Lookup Join Fields Are Not Listed First (elastic#246582) Add missing `dynamic: false` (elastic#246685) [Metrics in Discover] Unskip metrics api test (elastic#246593) [ES|QL] Show next actions after simple field assignment in RERANK ON Clause (elastic#246676) ...
KodeRad
pushed a commit
to KodeRad/kibana
that referenced
this pull request
Dec 17, 2025
## Summary Partially addresses elastic#243932 This PR adds PromQL language parsing support to `kbn-esql-ast`. The parser is mostly complete with one known TODO in the CST-to-AST converter for `SubqueryResolutionContext` and `NonReservedContext` handling. Also, there might be some AST interface tweaks going forward, but overall the parser works. Note: The PromQL ANTLR grammar we use, which is ported from Elasticsearch repo, does not exactly match the Prometheus PromQL language (some language features are missing, some implemented slightly differently). The parser allows to provide `offset` option, which bumps all `.location` positions of AST nodes by that value. This will allow us to parse nested PromQL queries within ES|QL and set their `.location` correctly. The PromQL AST nodes contain an extra `dialect: 'promql'` field, which helps to differentiate them from the ES|QL nodes. Most AST nodes re-use the existing node shape from the ES|QL AST nodes (e.g. numbers, string, identifiers), however, other are specific for PromQL (function with grouping, selector, etc..), so they have their own interface and node type. ### Testing ```sh yarn test:jest src/platform/packages/shared/kbn-esql-ast/src/promql ``` ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Stratou <stratoula1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Partially addresses #243932
This PR adds PromQL language parsing support to
kbn-esql-ast. The parser is mostly complete with one known TODO in the CST-to-AST converter forSubqueryResolutionContextandNonReservedContexthandling. Also, there might be some AST interface tweaks going forward, but overall the parser works.Note: The PromQL ANTLR grammar we use, which is ported from Elasticsearch repo, does not exactly match the Prometheus PromQL language (some language features are missing, some implemented slightly differently).
The parser allows to provide
offsetoption, which bumps all.locationpositions of AST nodes by that value. This will allow us to parse nested PromQL queries within ES|QL and set their.locationcorrectly.The PromQL AST nodes contain an extra
dialect: 'promql'field, which helps to differentiate them from the ES|QL nodes.Most AST nodes re-use the existing node shape from the ES|QL AST nodes (e.g. numbers, string, identifiers), however, other are specific for PromQL (function with grouping, selector, etc..), so they have their own interface and node type.
Testing
Checklist