Add native PromQL (/api/v1/query_range) endpoint#144303
Merged
felixbarny merged 5 commits intoelastic:mainfrom Mar 23, 2026
Merged
Add native PromQL (/api/v1/query_range) endpoint#144303felixbarny merged 5 commits intoelastic:mainfrom
/api/v1/query_range) endpoint#144303felixbarny merged 5 commits intoelastic:mainfrom
Conversation
Collaborator
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
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.
f9a38fd to
aad4417
Compare
This was referenced Mar 16, 2026
felixbarny
commented
Mar 18, 2026
...us/src/main/java/org/elasticsearch/xpack/prometheus/rest/PrometheusQueryRangeRestAction.java
Outdated
Show resolved
Hide resolved
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.
/api/v1/query_range) endpoint
kkrik-es
approved these changes
Mar 23, 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.
Summary
This is PR 3 of 4 in a stacked series that adds the Prometheus
query_rangeendpoint.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.
PrometheusQueryRangeRestActionHandles
GETrequests to/_prometheus/api/v1/query_rangeand delegates toEsqlQueryActionwith PromQL parameters.PrometheusPluginRegisters
PrometheusQueryRangeRestActionalongside the existing remote-write handler when the plugin is enabled.Tests
PrometheusQueryRangeRestActionTestsPrometheusQueryRangeRestITStacking order
/api/v1/query_range) endpoint #144303 ← this PR