Add GET /api/v1/features endpoint#7507
Open
ayushkcs wants to merge 2 commits into
Open
Conversation
This commit introduces the GET /api/v1/features endpoint to expose which capabilities are enabled in the Cortex instance. The endpoint is registered on both the legacy and prometheus HTTP prefixes and returns a JSON payload listing features such as remote_write_v2, streaming_ingestion, parquet_queryable, tenant_federation, and distributed_execution, based on the current Cortex configuration. Signed-off-by: Ayush Kumar <kayush2k02@gmail.com>
friedrichg
requested changes
May 11, 2026
Member
friedrichg
left a comment
There was a problem hiding this comment.
Thanks for the PR
Remember Cortex is a prometheus compatible system.
We should reply something like See https://github.com/prometheus/prometheus/blob/main/cmd/prometheus/testdata/features.json
We don't need cortex features in the first PR
Refactored the GET /api/v1/features endpoint to return the standard Prometheus nested map format (map[string]map[string]bool) instead of a flat string slice. This aligns the discovery endpoint with Prometheus's client expectations. - Removed Cortex-specific features (e.g. parquet_queryable) - Dynamically build promql_functions from the parser - Updated unit tests and the handler JSON encoder Signed-off-by: Ayush Kumar <kayush2k02@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it
This PR implements the
GET /api/v1/featuresendpoint for Cortex.Background:
Prometheus introduced this endpoint (prometheus/prometheus#10022) to allow client applications (like Grafana) to programmatically discover which features and experimental capabilities a backend supports, rather than relying on brittle version-string parsing from
/status/buildinfo.Since Cortex uses a heavily modular and feature-gated architecture where version numbers do not directly map to feature availability, this endpoint is highly critical for ensuring clients can gracefully enable or disable UI features (e.g. streaming ingestion, exemplars, parquet querying) based on the actual runtime configuration of the Cortex cluster.
Technical Details & Changes Made
This PR introduces the feature endpoint and accurately maps Cortex's backend configuration flags to the standard JSON feature response format:
Feature Computation (
pkg/cortex/modules.go):cortexFeatures()function that scans the rootcortex.Configto build a list of currently enabled features.remote_write_v2(cfg.Distributor.RemoteWriteV2Enabled)streaming_ingestion(cfg.Distributor.UseStreamPush)parquet_queryable(cfg.Querier.EnableParquetQueryable)tenant_federation(cfg.TenantFederation.Enabled)distributed_execution(cfg.Querier.DistributedExecEnabled)promql_experimental_functions(cfg.Querier.EnablePromQLExperimentalFunctions)API Routing & Handlers (
pkg/api/api.go&pkg/api/handlers.go):Featureslist intoapi.Config.featuresHandlerto serialize and serve the{"status": "success", "data": [...]}JSON payload.GET /api/v1/featuresroute on both the standard Prometheus (/prometheus/api/v1/features) and legacy (/api/prom/api/v1/features) HTTP prefixes viaRegisterQueryAPI.Which issue this PR fixes
Fixes #7467
Verification & Testing
make lintexecuted successfully withgolangci-lintandfaillint).TestFeaturesAPIinhandlers_test.goto verify the HTTP handler's JSON marshalling and structure across various feature states.TestCortexFeaturesinmodules_test.goto test the internal configuration-to-string mapping logic for all individual and combined flags.go test -v -tags "netgo slicelabels"for bothpkg/api/...andpkg/cortex/....Notes
VerticalShardSize) is configured on a per-tenant limit override basis rather than a global boolean flag, so it was omitted from the global features list to prevent false-positives for tenants where it is disabled.