Skip to content

Add Prometheus namespace with five new endpoints - #6293

Open
MattDevy wants to merge 6 commits into
mainfrom
add-prometheus-endpoints
Open

MattDevy wants to merge 6 commits into
mainfrom
add-prometheus-endpoints

Conversation

@MattDevy

Copy link
Copy Markdown
Contributor

Summary

Adds a new prometheus/ namespace with five endpoints for the Prometheus HTTP API compatibility layer introduced in Elasticsearch 9.4.0. All are Tech Preview (stability=experimental, visibility=public) and available in both stack and serverless.

Endpoint Operation URLs
prometheus.remote_write POST /_prometheus/api/v1/write, /_prometheus/metrics/{dataset}/api/v1/write, /_prometheus/metrics/{dataset}/{namespace}/api/v1/write
prometheus.query GET /_prometheus/api/v1/query, /_prometheus/{index}/api/v1/query
prometheus.query_range GET /_prometheus/api/v1/query_range, /_prometheus/{index}/api/v1/query_range
prometheus.series GET /_prometheus/api/v1/series, /_prometheus/{index}/api/v1/series
prometheus.labels GET /_prometheus/api/v1/labels, /_prometheus/{index}/api/v1/labels

All response bodies are typed as UserDefinedValue (opaque) since the Prometheus HTTP API JSON envelope is complex. The remote_write request body is protobuf — no request_media_type is declared as there is no protobuf entry in the MediaType enum; a follow-up can add one if needed.

ES PRs: elastic/elasticsearch#141957, elastic/elasticsearch#145321, elastic/elasticsearch#144416, elastic/elasticsearch#144494, elastic/elasticsearch#144952 (all labeled v9.4.0)

Test plan

  • Verify all five endpoints appear in the generated schema under the prometheus namespace
  • Verify stability=experimental and visibility=public for both stack and serverless on all five
  • Verify remote_write has three URL variants; all others have two
  • Verify series has match[] as required; labels has match[] as optional
  • Verify query_range has start, end, step as required query params

The schema compiler requires every Request interface to have a @doc_id
annotation pointing to a registered entry in _doc_ids/table.csv. The
five prometheus request files were missing these, causing CI to fail.

Added #TODO placeholder URLs following the same pattern used by other
new 9.4.0 endpoints (e.g. the reindex management APIs).
@MattDevy
MattDevy marked this pull request as ready for review May 21, 2026 09:56
@MattDevy
MattDevy requested review from flobernd and l-trotta May 21, 2026 09:56
@MattDevy
MattDevy marked this pull request as draft May 21, 2026 10:28
@MattDevy
MattDevy force-pushed the add-prometheus-endpoints branch from af4f50f to ec044ac Compare May 21, 2026 11:11
@MattDevy
MattDevy marked this pull request as ready for review May 21, 2026 11:13
@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Following you can find the validation changes against the target branch for the APIs.

API Status Request Response
prometheus.labels ➕ ⚪ Missing test Missing test
prometheus.query ➕ ⚪ Missing test Missing test
prometheus.query_range ➕ ⚪ Missing test Missing test
prometheus.remote_write ➕ ⚪ Missing test Missing test
prometheus.series ➕ ⚪ Missing test Missing test

You can validate these APIs yourself by using the make validate target.

/**
* Get label names.
*
* Return a list of label names that match a certain set of selectors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Return a list of label names that match a certain set of selectors.
* Return a sorted list of label names that match a certain set of selectors.

since the endpoint java doc in the server code specifies that the list is sorted we can also add it here

*/
'match[]'?: string[]
/**
* The start of the time range. Defaults to `now - 24h`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should use the server default annotation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

from the server code it looks like it's "end-24h" (which yes it's "now-24h" in case both are empty, but still)

*/
start?: string
/**
* The end of the time range. Defaults to now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should use the server default annotation


export class Response {
/** @codegen_name body */
body: UserDefinedValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it really completely unmappable? I'm looking at the server code and it seems like there is some structure, there's also the error case which we could map using the exceptions field.

*/
query: string
/**
* The evaluation timestamp. Defaults to the current server time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should use the server default annotation (default to now)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this one is likely missing the body, the request_media_type and the response_media_type. from the server code it's not immediately clear what's expecting, let's gather more info first.


export class Response {
/** @codegen_name body */
body: UserDefinedValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this one just returns and empty response, from reading the server code, but again, not super clear, need more info.

]
path_parts: {
/**
* An index pattern that restricts the query to a specific index.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same as the others

Comment on lines +51 to +69
query_parameters: {
/**
* Repeated series selector arguments that select the series to return.
* @codegen_name match
*/
'match[]': string[]
/**
* The start of the time range. Defaults to `now - 24h`.
*/
start?: string
/**
* The end of the time range. Defaults to now.
*/
end?: string
/**
* The maximum number of results to return. `0` means no limit.
*/
limit?: integer
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same comments in labels request apply


export class Response {
/** @codegen_name body */
body: UserDefinedValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

*
* Return a list of label names that match a certain set of selectors.
* @rest_spec_name prometheus.labels
* @availability stack since=9.4.0 stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've now got "tech_preview" available per #6312

Suggested change
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability stack since=9.4.0 stability=tech_preview visibility=public

* Return a list of label names that match a certain set of selectors.
* @rest_spec_name prometheus.labels
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability serverless stability=experimental visibility=public
* @availability serverless stability=tech_preview visibility=public

*
* Evaluate a PromQL expression at a single point in time.
* @rest_spec_name prometheus.query
* @availability stack since=9.4.0 stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability stack since=9.4.0 stability=tech_preview visibility=public

* Evaluate a PromQL expression at a single point in time.
* @rest_spec_name prometheus.query
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability serverless stability=experimental visibility=public
* @availability serverless stability=tech_preview visibility=public

* Evaluate a PromQL expression over a time range.
* @rest_spec_name prometheus.query_range
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability serverless stability=experimental visibility=public
* @availability serverless stability=tech_preview visibility=public

*
* Evaluate a PromQL expression over a time range.
* @rest_spec_name prometheus.query_range
* @availability stack since=9.4.0 stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability stack since=9.4.0 stability=tech_preview visibility=public

* Accepts a Prometheus remote write request (protobuf-encoded) and indexes the
* time series data into Elasticsearch.
* @rest_spec_name prometheus.remote_write
* @availability stack since=9.4.0 stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability stack since=9.4.0 stability=tech_preview visibility=public

* time series data into Elasticsearch.
* @rest_spec_name prometheus.remote_write
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability serverless stability=experimental visibility=public
* @availability serverless stability=tech_preview visibility=public

*
* Return the list of time series that match a certain set of selectors.
* @rest_spec_name prometheus.series
* @availability stack since=9.4.0 stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability stack since=9.4.0 stability=tech_preview visibility=public

* Return the list of time series that match a certain set of selectors.
* @rest_spec_name prometheus.series
* @availability stack since=9.4.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=public

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @availability serverless stability=experimental visibility=public
* @availability serverless stability=tech_preview visibility=public

* Ingest Prometheus remote write data.
*
* Accepts a Prometheus remote write request (protobuf-encoded) and indexes the
* time series data into Elasticsearch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not mandatory, but might be nice to link to the narrative docs:

Suggested change
* time series data into Elasticsearch.
* time series data into Elasticsearch. For an overview, refer to [Prometheus remote write endpoint](https://www.elastic.co/docs/manage-data/data-store/data-streams/tsds-ingest-prometheus-remote-write).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants