Skip to content

Add PrometheusSeriesPlanBuilder for series endpoint#144493

Merged
felixbarny merged 10 commits intoelastic:mainfrom
felixbarny:prometheus-series-plan-builder
Mar 30, 2026
Merged

Add PrometheusSeriesPlanBuilder for series endpoint#144493
felixbarny merged 10 commits intoelastic:mainfrom
felixbarny:prometheus-series-plan-builder

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 18, 2026

Translates a Prometheus series selector into an ESQL logical plan that fetches matching label combinations. Also extends TranslatePromqlToEsqlPlan to expose the plan-building logic needed by the series endpoint.


Stack:

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

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

@sidosera
Copy link
Copy Markdown
Contributor

sidosera commented Mar 24, 2026

@felixbarny Could you please add more context why do we need this? IIUC this is for prometheus compatible APIs to read metric metadata (https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers)?

@felixbarny
Copy link
Copy Markdown
Member Author

Yes, more context on the PR that adds the rest action: #144494

Extend the prometheus plugin with compile-time dependencies on x-pack-esql,
x-pack-esql-core, and esql:compute so that the series endpoint can build
and execute ESQL logical plans.
PrometheusSeriesPlanBuilder translates a Prometheus series selector into an
ESQL logical plan that fetches matching label combinations. Also extends
TranslatePromqlToEsqlPlan to expose the plan-building logic needed by the
series endpoint.
Shared logic (tsSource, filterExpression, buildSelectorCondition, etc.)
moved to a new PrometheusPlanBuilderUtils utility class so it can be
reused by the upcoming labels plan builder.
@felixbarny felixbarny force-pushed the prometheus-series-plan-builder branch from e7fe3a3 to 2bc5e05 Compare March 25, 2026 10:08
@felixbarny felixbarny requested review from a team as code owners March 25, 2026 10:08
@felixbarny felixbarny changed the base branch from promql-query-range-parsed-statement to main March 25, 2026 10:08
@felixbarny felixbarny removed request for a team March 25, 2026 10:12
@felixbarny felixbarny requested review from sidosera and removed request for a team March 25, 2026 10:12
Copy link
Copy Markdown
Contributor

@kkrik-es kkrik-es left a comment

Choose a reason for hiding this comment

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

Please wait for Sergey to stamp too.

- 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.
- Add limit field to PrometheusSeriesResponseListener constructor; extract
  buildSuccessResponse as a static package-private method for testability.
- Update plan-builder and response-listener unit tests accordingly.
@felixbarny felixbarny enabled auto-merge (squash) March 30, 2026 07:13
@felixbarny felixbarny merged commit 86de866 into elastic:main Mar 30, 2026
36 checks passed
felixbarny added a commit to felixbarny/elasticsearch that referenced this pull request Mar 30, 2026
PrometheusSeriesPlanBuilder translates a Prometheus series selector into an
ESQL logical plan that fetches matching label combinations. Also extends
TranslatePromqlToEsqlPlan to expose the plan-building logic needed by the
series endpoint.
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
PrometheusSeriesPlanBuilder translates a Prometheus series selector into an
ESQL logical plan that fetches matching label combinations. Also extends
TranslatePromqlToEsqlPlan to expose the plan-building logic needed by the
series endpoint.
@felixbarny felixbarny deleted the prometheus-series-plan-builder branch April 1, 2026 10:23
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/TSDB You know, for Metrics Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants