Skip to content

Prometheus labels API: add plan builder#144950

Merged
felixbarny merged 11 commits intoelastic:mainfrom
felixbarny:prometheus-labels-api-plan-builder
Mar 30, 2026
Merged

Prometheus labels API: add plan builder#144950
felixbarny merged 11 commits intoelastic:mainfrom
felixbarny:prometheus-labels-api-plan-builder

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 25, 2026

Adds PrometheusLabelsPlanBuilder and PrometheusPlanBuilderUtils, which translate a Prometheus labels API request (metric name, match selectors, time range, limit) into a LogicalPlan that can be executed via ES|QL. The plan builder is covered by unit tests in PrometheusLabelsPlanBuilderTests.

This is part of a stack implementing the Prometheus labels API endpoint:

Stacking order

@felixbarny felixbarny self-assigned this Mar 25, 2026
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team Team:StorageEngine labels Mar 25, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@felixbarny felixbarny requested review from kkrik-es and sidosera March 26, 2026 07:20
felixbarny and others added 6 commits March 26, 2026 08:46
- 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.
@felixbarny felixbarny enabled auto-merge (squash) March 30, 2026 07:07
@felixbarny felixbarny merged commit 61505d2 into elastic:main Mar 30, 2026
40 checks passed
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :StorageEngine/PromQL PromQL support for Elastic Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants