Prometheus: Add query_range REST endpoint backed by ES|QL PROMQL command#144294
Prometheus: Add query_range REST endpoint backed by ES|QL PROMQL command#144294felixbarny wants to merge 7 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
95fb6f3 to
10009ee
Compare
Switch the prometheus endpoint to use a parameterized ESQL_QUERY constant instead of buildEsqlQuery(), and append | EVAL step = TO_LONG(step) to avoid date-parsing ambiguity.
…ponseListener Moves the shared column-name constants from PrometheusQueryRangeRestAction to PrometheusQueryRangeResponseListener, which is the class that validates those column names in the ES|QL response. PrometheusQueryRangeRestAction now references them from the listener. This makes the listener independently compilable and keeps the contract for expected column names in one place.
10009ee to
9a4f271
Compare
Allow internal callers to supply a pre-built EsqlStatement that bypasses ES|QL string construction and parsing. EsqlSession now checks for a parsed statement before invoking the parser.
Replace ES|QL string construction and parameter binding with a directly constructed logical plan. This adds a Project node to restore the original PromqlCommand column order after the Eval that converts step to long.
|
@felixbarny Do we have a plan to also add an async endpoint for this? |
|
No, I don't think so. PromQL doesn't support any kind of async endpoint so there would be no consumers for it. |
Yes, but this could become an issue with our Cloud given the 5-minute hard proxy timeout. |
|
I don't know what's the alternative to it though. This endpoint is mainly so that we can integrate well into other dashboarding systems that know how to deal with the |
Yeah, I think we can skip the async endpoint for this now. |
...eus/src/javaRestTest/java/org/elasticsearch/xpack/prometheus/PrometheusQueryRangeRestIT.java
Show resolved
Hide resolved
.../main/java/org/elasticsearch/xpack/prometheus/rest/PrometheusQueryRangeResponseListener.java
Show resolved
Hide resolved
...c/test/java/org/elasticsearch/xpack/prometheus/rest/PrometheusQueryRangeRestActionTests.java
Show resolved
Hide resolved
...c/test/java/org/elasticsearch/xpack/prometheus/rest/PrometheusQueryRangeRestActionTests.java
Show resolved
Hide resolved
|
Closing this PR as this was just meant to provide an overview and how the pieces fit together. Superseded by the sub-PRs. |
Overview
This PR provides a full overview of the change. For easier reviewing, the implementation is split into focused PRs:
/api/v1/query_range) endpoint #144303What this adds
A Prometheus-compatible
/_prometheus/api/v1/query_rangeendpoint that:query,start,end,step, optionalindex).PROMQLcommand and executes it viaEsqlQueryAction.Follow-up in #144416 switches the endpoint from query-string construction to direct execution of a parsed
EsqlStatementplan.