feat: add MetricsQL canonical frontend - #368
Merged
Merged
Conversation
zzylol
marked this pull request as ready for review
September 10, 2026 04:16
zzylol
force-pushed
the
feat/metricsql-frontend
branch
from
September 10, 2026 05:46
70cc256 to
da63b34
Compare
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.
Why
VictoriaMetrics queries need a real MetricsQL grammar boundary that feeds the existing canonical planner without changing
QueryExpr, SDS, or physical summary DAG semantics. The parser must remain consumable from the backend on stable Rust, and its compatibility with official VictoriaMetrics syntax must be measured rather than inferred from a third-party crate name.What
asap-frontend-metricsql, backed by the Apache-2.0 Rust MetricsQL port fromccollie/metricsqlcommit3046709308e449a42c56bfbfd45f95af848e6768QueryExpr; no source-to-source PromQL conversion and no change to shared IR semantics__name__validation,WITHstring interpolation, and numeric separatorscanonical_metricsqlfor stable plan identityBefore this PR
ASAPPlanner had PromQL and SQL frontends. A VictoriaMetrics request had no native MetricsQL parser boundary. The initial integration also depended on a non-propagating workspace
[patch], could lose metric names infoo{job="a" or job="b"}, and had no automated comparison with the official parser.After this PR
sum by (job) (rate(http_requests_total[5m]))produces the existing canonical aggregation DAG.WITH (prefix="http_") {__name__=prefix+"requests_total"}expands to the same scan ashttp_requests_total. OR matcher branches retain their metric name, official numeric separators parse, and unsupported MetricsQL semantics return a typed error for exact VictoriaMetrics fallback. A separate stable Rust project can consume the frontend without Cargo patches or CPU feature flags.Verification
cargo test --workspace --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test -p asap-frontend-metricsql --testsbash tools/verify_metricsql_external_consumer.shpython3 tools/verify_metricsql_vendored_baseline.py(21 library and 3 doctest names/signatures verified)cargo fmt --all -- --checkgit diff --checkThe pinned upstream parser needs a compile-only
HashSetExtimport correction before its own suite runs. With that correction and its declared nightly toolchain, upstream is 230 passed/23 failed for library tests and 2 passed/3 failed for doctests. This PR fixes two numeric-separator failures; CI now verifies the exact remaining 21 library and 3 doctest failures by name and fails on any drift.Limitations
default_rollup(metric)and step-relative windows need runtime evaluation-step context and currently fall backkeep_metric_namesneeds metric-name lineage and currently falls backif,ifnot,default, aggregate limits, or-delimited matchers, binary match modifiers, and multi-input aggregates parse natively but currently fall backUPSTREAM.md