Skip to content

Prometheus labels API: add rest action#144952

Merged
felixbarny merged 8 commits intoelastic:mainfrom
felixbarny:prometheus-labels-api-rest-action
Mar 31, 2026
Merged

Prometheus labels API: add rest action#144952
felixbarny merged 8 commits intoelastic:mainfrom
felixbarny:prometheus-labels-api-rest-action

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 25, 2026

Adds PrometheusLabelsRestAction, the REST handler for GET /_prometheus/api/v1/labels. 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 PrometheusLabelsRestIT.

Note

This PR depends on #144950 and #144951 being merged first. It will not compile until both are merged.

Stacking order

@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 and others added 4 commits March 27, 2026 16:23
Per Prometheus API semantics, omitting the limit parameter means no limit
(equivalent to limit=0). Change DEFAULT_LIMIT from 10_000 to 0 so that
clients which do not pass limit receive all matching label names.

The plan builder (in the parent branch) already handles limit=0 by emitting
an explicit Limit(Integer.MAX_VALUE) node, avoiding the AddImplicitLimit
rule's silent 1 000-row cap.
Expand the terse "0 means unlimited" comment to explain the full
sentinel semantics: limit=0 defers to ESQL result_truncation_max_size,
limit>0 uses limit+1 as a sentinel for truncation detection.
@felixbarny felixbarny marked this pull request as ready for review March 30, 2026 13:10
@felixbarny felixbarny requested review from kkrik-es and sidosera March 30, 2026 13:10
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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


List<String> data = queryLabelsData("labels_round_trip_gauge");

assertThat(data, hasItem("__name__"));
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.

Check also returned values per 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.

The labels API only returns the label names. There's another PR to add the label values API, which returns all values for a particular label.

Replace partial hasItem checks with containsInAnyOrder to verify the
complete set of returned labels, catching unexpected additions.

Also remove erroneous FeatureFlag.PROMETHEUS_FEATURE_FLAG reference that
does not exist in the FeatureFlag enum.
@felixbarny felixbarny force-pushed the prometheus-labels-api-rest-action branch from e68e2e3 to 85ddf4b Compare March 30, 2026 17:33
@felixbarny felixbarny enabled auto-merge (squash) March 30, 2026 17:33
@felixbarny felixbarny merged commit 3c4919d into elastic:main Mar 31, 2026
39 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
Per Prometheus API semantics, omitting the limit parameter means no limit
(equivalent to limit=0). Change DEFAULT_LIMIT from 10_000 to 0 so that
clients which do not pass limit receive all matching label names.

The plan builder (in the parent branch) already handles limit=0 by emitting
an explicit Limit(Integer.MAX_VALUE) node, avoiding the AddImplicitLimit
rule's silent 1 000-row cap.
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 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants