Prometheus labels API: add plan builder#144950
Merged
felixbarny merged 11 commits intoelastic:mainfrom Mar 30, 2026
Merged
Conversation
Collaborator
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
This was referenced Mar 25, 2026
felixbarny
commented
Mar 26, 2026
...etheus/src/main/java/org/elasticsearch/xpack/prometheus/rest/PrometheusPlanBuilderUtils.java
Show resolved
Hide resolved
- DEFAULT_LIMIT will be changed to 0 in the REST action (separate commit). - When limit=0 (unlimited), always emit an explicit Limit(Integer.MAX_VALUE) so that ESQL's AddImplicitLimit rule sees an existing node and does not silently inject its own 1 000-row default with a warning header. - When limit>0, use limit+1 as a sentinel so the response listener can detect truncation: if ESQL returns exactly limit+1 rows the result was truncated, a warnings field is added, and the extra row is stripped. - Update response listener truncation check from size()==limit to size()==limit+1, and trim the sentinel row before serialising. - Update plan-builder and response-listener unit tests accordingly.
Update the class-level plan diagram from [Limit(n)] (which implied the node was optional) to Limit(limit==0 ? MAX_VALUE : limit+1) to match the style introduced in the LabelValues plan builder. Also update the @param limit doc to note that 0 defers to the ESQL max setting.
sidosera
reviewed
Mar 27, 2026
.../src/main/java/org/elasticsearch/xpack/prometheus/rest/PrometheusLabelsResponseListener.java
Outdated
Show resolved
Hide resolved
sidosera
approved these changes
Mar 27, 2026
sidosera
reviewed
Mar 27, 2026
...theus/src/main/java/org/elasticsearch/xpack/prometheus/rest/PrometheusLabelsPlanBuilder.java
Show resolved
Hide resolved
mamazzol
pushed a commit
to mamazzol/elasticsearch
that referenced
this pull request
Mar 30, 2026
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.
Adds
PrometheusLabelsPlanBuilderandPrometheusPlanBuilderUtils, which translate a Prometheus labels API request (metric name, match selectors, time range, limit) into aLogicalPlanthat can be executed via ES|QL. The plan builder is covered by unit tests inPrometheusLabelsPlanBuilderTests.This is part of a stack implementing the Prometheus labels API endpoint:
Stacking order