Prometheus: Add PrometheusQueryRangeResponseListener (ES|QL → Prometheus matrix JSON) + unit tests#144302
Merged
felixbarny merged 4 commits intoelastic:mainfrom Mar 19, 2026
Merged
Conversation
Collaborator
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
This was referenced Mar 16, 2026
Adds the ES|QL → Prometheus matrix JSON conversion layer:
- `PrometheusQueryRangeResponseListener` converts an `EsqlQueryResponse`
(columnar PROMQL output) into the Prometheus range query JSON format.
Handles two column modes:
* `_timeseries` JSON column — unwraps the `labels` namespace and
dot-flattens other namespaces.
* Individual label columns — maps each column name to a metric label.
Also converts epoch-ms timestamps to epoch-second doubles and formats
NaN / ±Inf sample values as Prometheus expects.
- `PrometheusQueryRangeResponseListenerTests` covers every conversion path,
edge cases (empty result, missing columns), error JSON building, and
special float formatting.
7df326b to
63bdd0f
Compare
This was referenced Mar 16, 2026
sidosera
reviewed
Mar 19, 2026
.../java/org/elasticsearch/xpack/prometheus/rest/PrometheusQueryRangeResponseListenerTests.java
Outdated
Show resolved
Hide resolved
…/prometheus/rest/PrometheusQueryRangeResponseListenerTests.java Co-authored-by: Sergey Sidorov <SERGEY.IVANOVICH.SIDOROV@gmail.com>
kkrik-es
approved these changes
Mar 19, 2026
Contributor
kkrik-es
left a comment
There was a problem hiding this comment.
Please apply comments from the parent, as applicable.
ncordon
pushed a commit
to ncordon/elasticsearch
that referenced
this pull request
Mar 20, 2026
michalborek
pushed a commit
to michalborek/elasticsearch
that referenced
this pull request
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 2 of 4 in a stacked series that adds the Prometheus
query_rangeendpoint.See the overview PR #144294 for context.
Stacks on top of #144301 — please review that PR first.
Adds the ES|QL → Prometheus matrix JSON conversion layer, independently reviewable without needing to know the REST wiring.
PrometheusQueryRangeResponseListenerListens for an
EsqlQueryResponseand converts its columnar PROMQL output into the Prometheus range query JSON format.PrometheusQueryRangeResponseListenerTestsUnit tests covering conversion paths, edge cases, error JSON mapping, and special float formatting.
Stacking order
/api/v1/query_range) endpoint #144303