Skip to content

Prometheus label values API: add rest action#144958

Merged
felixbarny merged 3 commits intoelastic:mainfrom
felixbarny:prometheus-label-values-api-rest-action
Mar 27, 2026
Merged

Prometheus label values API: add rest action#144958
felixbarny merged 3 commits intoelastic:mainfrom
felixbarny:prometheus-label-values-api-rest-action

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 25, 2026

Adds PrometheusLabelValuesRestAction, the REST handler for GET /_prometheus/api/v1/label/{name}/values. It wires together the plan builder and response listener from the prerequisite PRs and registers the action with the Prometheus plugin. Integration tests are covered by PrometheusLabelValuesRestIT.

This is part of a stack implementing the Prometheus label values API endpoint:

Stacking order

Implements the REST handler for GET /_prometheus/api/v1/label/{name}/values,
wiring together the plan builder and response listener. Registers the action
in PrometheusPlugin and adds integration tests.
@felixbarny felixbarny self-assigned this Mar 25, 2026
@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Mar 25, 2026
@felixbarny felixbarny marked this pull request as ready for review March 27, 2026 08:35
@felixbarny felixbarny requested review from kkrik-es and sidosera March 27, 2026 08:36
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

: end.minus(DEFAULT_LOOKBACK_HOURS, HOURS);

// Optional limit; default to DEFAULT_LIMIT to avoid unbounded ESQL scans
int limit = request.paramAsInt(LIMIT_PARAM, DEFAULT_LIMIT);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need the default limit? TS transpilation should lead to the respective limits being applied?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TimeSeriesAggregate does not fit here: it requires _tsid/tbucket groupings and TimeSeriesAggregateFunction aggregates, while we are doing a plain deduplication (GROUP BY label). With a regular Aggregate, AddImplicitLimit's isTsAggregate check is false, so without the explicit default ESQL would cap at 1,000 rows and emit a "No limit defined" header warning. The DEFAULT_LIMIT = 10_000 is needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How can users adjust it? For the other limits, we use cluster settings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There’s a limit query parameter for the api

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So it's possible to request 10b results? We should probably add an upper bound and control it through a cluster setting. That can happen in a follow-up.

@felixbarny felixbarny merged commit 3eabbfa into elastic:main Mar 27, 2026
40 checks passed
@felixbarny felixbarny deleted the prometheus-label-values-api-rest-action branch March 27, 2026 12:58
DaveCTurner added a commit that referenced this pull request Mar 27, 2026
@DaveCTurner
Copy link
Copy Markdown
Member

This broke compilation of main, not sure how, but I have reverted it. See https://gradle-enterprise.elastic.co/s/bvmx5kt52zf3o

mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
Implements the REST handler for GET /_prometheus/api/v1/label/{name}/values,
wiring together the plan builder and response listener. Registers the action
in PrometheusPlugin and adds integration tests.
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants