Skip to content

Add native PromQL (/api/v1/query_range) endpoint#144303

Merged
felixbarny merged 5 commits intoelastic:mainfrom
felixbarny:promql-query-range-pr3
Mar 23, 2026
Merged

Add native PromQL (/api/v1/query_range) endpoint#144303
felixbarny merged 5 commits intoelastic:mainfrom
felixbarny:promql-query-range-pr3

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 16, 2026

Summary

This is PR 3 of 4 in a stacked series that adds the Prometheus query_range endpoint.
See the overview PR #144294 for context.
Stacks on top of #144302 — please review that PR first.

Wires the Prometheus range query endpoint into the Elasticsearch REST layer.

PrometheusQueryRangeRestAction

Handles GET requests to /_prometheus/api/v1/query_range and delegates to EsqlQueryAction with PromQL parameters.

PrometheusPlugin

Registers PrometheusQueryRangeRestAction alongside the existing remote-write handler when the plugin is enabled.

Tests

  • PrometheusQueryRangeRestActionTests
  • PrometheusQueryRangeRestIT

Stacking order

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Mar 16, 2026
@felixbarny felixbarny self-assigned this Mar 16, 2026
Wires the Prometheus range query endpoint into the Elasticsearch REST layer:

- `PrometheusQueryRangeRestAction` handles GET/POST requests to
  `/_prometheus/api/v1/query_range`.  It validates the required `query`,
  `start`, `end`, and `step` params, accepts an optional `index` param
  (defaults to `*`), builds a parameterised ES|QL PROMQL command, and
  delegates to `EsqlQueryAction` → `PrometheusQueryRangeResponseListener`.
  Column-name constants (`VALUE_COLUMN`, `STEP_PARAM`) are referenced from
  `PrometheusQueryRangeResponseListener` to keep the contract in one place.
- `PrometheusPlugin.getRestHandlers` now returns `PrometheusQueryRangeRestAction`
  alongside the existing remote-write handler when the plugin is enabled.
- `PrometheusQueryRangeRestActionTests` covers missing-parameter validation,
  the ESQL_QUERY constant value, and `buildQueryParams`.
- `PrometheusQueryRangeRestIT` is an end-to-end integration test: it remote-writes
  Prometheus metrics, issues a `query_range` request, and asserts the returned
  Prometheus matrix JSON contains the expected time series and sample values.
felixbarny and others added 2 commits March 19, 2026 13:41
Drop the {dataset}/{namespace} path params and the TYPE_METRICS constant.
The long-term design is /_prometheus/{index}/api/v1/... (arbitrary index
pattern), which requires restructuring remote write paths first. For now
the endpoint searches * by default, keeping the PR shippable. Index
filtering will be added once the path structure is settled.
@felixbarny felixbarny marked this pull request as ready for review March 19, 2026 15:59
@felixbarny felixbarny requested a review from kkrik-es March 19, 2026 15:59
@felixbarny felixbarny changed the title Prometheus: Add /_prometheus/api/v1/query_range REST endpoint + integration tests Add native PromQL (/api/v1/query_range) endpoint Mar 19, 2026
@felixbarny felixbarny enabled auto-merge (squash) March 23, 2026 07:43
@felixbarny felixbarny merged commit c9e4e3e into elastic:main Mar 23, 2026
40 checks passed
@felixbarny felixbarny deleted the promql-query-range-pr3 branch March 23, 2026 09:08
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