Skip to content

Add PrometheusSeriesRestAction for /_prometheus/api/v1/series endpoint#144494

Merged
felixbarny merged 21 commits intoelastic:mainfrom
felixbarny:prometheus-series-rest-action
Mar 31, 2026
Merged

Add PrometheusSeriesRestAction for /_prometheus/api/v1/series endpoint#144494
felixbarny merged 21 commits intoelastic:mainfrom
felixbarny:prometheus-series-rest-action

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 18, 2026

Implements the GET /_prometheus/api/v1/series REST handler that accepts Prometheus series selectors and returns matching label sets. See also https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers. This is typically used for auto-completion in web UIs.

This is specifically not adding the POST variant of the endpoint because we're rejecting all application/x-www-form-urlencoded request bodies in RestController as a CORS protection.

Note

This PR depends on #144415, #144506, #144492, and #144493 being merged first. It won't compile standalone.


Stack:

Implements the GET/POST /_prometheus/api/v1/series REST handler that
accepts Prometheus series selectors and returns matching label sets.
Registers the action in PrometheusPlugin and adds an integration test
covering basic series lookup.
@felixbarny felixbarny self-assigned this Mar 18, 2026
@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team v9.4.0 labels Mar 18, 2026
felixbarny and others added 10 commits March 19, 2026 17:01
Drop the {dataset}/{namespace} path params and the INDEX_PREFIX 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 metrics-*-* by default, keeping the PR shippable.
Index filtering will be added once the path structure is settled.
Adds a second route `/_prometheus/{index}/api/v1/series` that lets
callers scope queries to a specific index pattern instead of the default `*`.
Replaces the manual URI query-string parsing with a simple
request.param("match[]") call. Multi-value support is deferred
to a follow-up once the framework-level multi-value param API lands.

Also resolves the merge conflict in PrometheusPlugin that was
registering either the series or query-range handler but not both,
and fixes the recursive varargs helper methods in PrometheusSeriesRestIT.
@felixbarny felixbarny marked this pull request as ready for review March 30, 2026 12:58
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@felixbarny felixbarny requested review from kkrik-es and sidosera March 30, 2026 12:59
PrometheusSeriesRestAction action = new PrometheusSeriesRestAction();

// prepareRequest should not throw — multiple selectors are valid
action.prepareRequest(request, null);
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.

This is all good, but we need to add IT for PromQL native at some point.. do we have a tracking item?

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.

What's missing from PrometheusSeriesRestIT?

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.

I guess this test (PrometheusSeriesRestActionTests) is somewhat redundant...

The flag was removed in elastic#144311 which enabled the Prometheus plugin by
default. The test cluster setup no longer needs to explicitly enable it.
@felixbarny felixbarny force-pushed the prometheus-series-rest-action branch from 7e5908a to 312cb3f Compare March 30, 2026 17:24
@felixbarny felixbarny enabled auto-merge (squash) March 30, 2026 17:24
@felixbarny felixbarny merged commit 856f071 into elastic:main Mar 31, 2026
35 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 31, 2026
…rics

* upstream/main: (428 commits)
  ESQL: DS: Add inference/RERANK tests (elastic#145229)
  Unmute MMR logical plan test (elastic#145311)
  Do not attempt marking store as corrupted if the check is rejected due to shutdown (elastic#145209)
  feat(tsdb): add pipeline runtime and rename stage interfaces (elastic#145175)
  Fix UnresolvedException on PromQL by(step) grouping (elastic#145307)
  ES|QL: Optimize MMR by reducing cache size and lookup (elastic#145014)
  Prometheus labels/series APIs: support multiple match[] selectors (elastic#145298)
  Move ClientScrollablePaginatedHitSource into Reindex Module (elastic#144100)
  mute test class for elastic#145277
  CPS mode for ViewResolver (elastic#145219)
  [ESQL] Disables GroupedTopNBenchmark temporarily (elastic#145124)
  Make exponential_histogram the default histogram type for HTTP OTLP endpoint (elastic#145065)
  More tests requiring an explicit confidence interval (elastic#145232)
  ES|QL: Adding `USER_AGENT` command (elastic#144384)
  ESQL: enable Generative IT after more fixes (elastic#145112)
  Rework FieldMapper parameter tests to not use merge builders (elastic#145213)
  [ESQL] Fix ORC type support gaps (elastic#145074)
  [Test] Unmute FollowingEngineTests.testProcessOnceOnPrimary (elastic#145192)
  Add PrometheusSeriesRestAction for /_prometheus/api/v1/series endpoint (elastic#144494)
  Prometheus labels API: add rest action (elastic#144952)
  ...
ncordon pushed a commit to ncordon/elasticsearch that referenced this pull request Apr 1, 2026
elastic#144494)

Implements the GET/POST /_prometheus/api/v1/series REST handler that
accepts Prometheus series selectors and returns matching label sets.
Registers the action in PrometheusPlugin and adds an integration test
covering basic series lookup.
@felixbarny felixbarny deleted the prometheus-series-rest-action branch April 1, 2026 10:23
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/TSDB You know, for Metrics Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants