From 940bb238741b4900a87c15c7c25b1478affa61d9 Mon Sep 17 00:00:00 2001 From: Sungjin1212 Date: Wed, 25 Nov 2026 16:11:24 +0900 Subject: [PATCH 1/3] Ingester: enable native histogram ingestion by default Signed-off-by: Sungjin1212 --- CHANGELOG.md | 1 + docs/configuration/config-file-reference.md | 5 +++-- docs/guides/native-histograms.md | 1 + pkg/util/validation/exporter_test.go | 2 +- pkg/util/validation/limits.go | 2 +- pkg/util/validation/limits_test.go | 25 +++++++++++++++++++++ schemas/cortex-config-schema.json | 4 ++-- 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61c6092f8bf..1d7adec3b76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * [CHANGE] Ingester: Make `close_idle_tsdb_timeout` a per-tenant limit (`-limits.close-idle-tsdb-timeout`). `-blocks-storage.tsdb.close-idle-tsdb-timeout` is deprecated and will be removed in v1.24.0. A positive `close_idle_tsdb_timeout` must now be at least `query_store_after` when `query_ingesters_within` is 0. #7813 * [CHANGE] Compactor: Add the `time_range_milliseconds` label to `cortex_compactor_remaining_planned_compactions` and `cortex_compactor_oldest_partition_offset`, reporting them per compaction time range instead of summed over all of them. #7959 +* [CHANGE] Ingester: Enable native histogram ingestion by default (`-blocks-storage.tsdb.enable-native-histograms=true`). Set it to `false`, globally or per tenant via `enable_native_histograms`, to keep discarding native histogram samples. Native histogram series that were previously discarded now count towards the series limits; tenants sending them can be found with `cortex_discarded_samples_total{reason="native-histogram-sample"}` before upgrading. If a native histogram series limit (`-ingester.max-native-histogram-series-per-user` or `-ingester.max-global-native-histogram-series-per-user`) is set, reaching it also rejects new float series. During a rolling upgrade, recent native histogram samples may be missing from query results because ingesters still running the previous version discard them. * [FEATURE] Ruler: Add experimental support for federated rule groups. A rule group listing tenants in its `source_tenants` field is evaluated against those tenants while the resulting series and alerts are written to the tenant owning the rule group. Enabled with `-ruler.enable-federated-rules` (requires `-tenant-federation.enabled`), and restricted to selected tenants with `-ruler.allowed-federated-tenants` and `-ruler.disallowed-federated-tenants`. #7828 * [FEATURE] Distributor: Add experimental OTLP metrics ingestion over gRPC (`opentelemetry.proto.collector.metrics.v1.MetricsService/Export`) on the gRPC server port. Enable it with `-distributor.otlp.grpc-enabled`. The tenant is read from the `X-Scope-OrgID` gRPC metadata, and the request size is limited by `-server.grpc-max-recv-msg-size-bytes`. #7873 * [FEATURE] Storage: Add support for Alibaba Cloud OSS as a backend for blocks, ruler, and alertmanager storage. Configured via `-.oss.*` flags with `backend: oss`. #7907 diff --git a/docs/configuration/config-file-reference.md b/docs/configuration/config-file-reference.md index 9fd5b281df8..1c4b0bfa785 100644 --- a/docs/configuration/config-file-reference.md +++ b/docs/configuration/config-file-reference.md @@ -4682,9 +4682,10 @@ The `limits_config` configures default and per-tenant limits imposed by Cortex s # series matching its matchers and exposes the count as a metric. [active_series_trackers: | default = []] -# True to enable native histogram. +# Enable ingestion of native histogram samples. When disabled, native histogram +# samples are discarded. # CLI flag: -blocks-storage.tsdb.enable-native-histograms -[enable_native_histograms: | default = false] +[enable_native_histograms: | default = true] # Maximum length (in bytes) of an unoptimized regex pattern. This is a # pre-flight check to reject expensive regex queries. 0 to disable. This is only diff --git a/docs/guides/native-histograms.md b/docs/guides/native-histograms.md index 0353d426637..45295912087 100644 --- a/docs/guides/native-histograms.md +++ b/docs/guides/native-histograms.md @@ -21,6 +21,7 @@ And via yaml: limits: enable_native_histograms: ``` + By default, it is disabled, so make sure to enable it if you need native histograms for your system monitoring. When a `write request` contains both `samples` and `native histogram`, the ingestion behavior is as follows: diff --git a/pkg/util/validation/exporter_test.go b/pkg/util/validation/exporter_test.go index 76c44e37997..cb82ad7687c 100644 --- a/pkg/util/validation/exporter_test.go +++ b/pkg/util/validation/exporter_test.go @@ -54,7 +54,7 @@ func TestOverridesExporter_withConfig(t *testing.T) { cortex_overrides{limit_name="compactor_partition_series_count",user="tenant-a"} 0 cortex_overrides{limit_name="compactor_tenant_shard_size",user="tenant-a"} 0 cortex_overrides{limit_name="creation_grace_period",user="tenant-a"} 600 - cortex_overrides{limit_name="enable_native_histograms",user="tenant-a"} 0 + cortex_overrides{limit_name="enable_native_histograms",user="tenant-a"} 1 cortex_overrides{limit_name="enable_start_timestamp",user="tenant-a"} 0 cortex_overrides{limit_name="enable_type_and_unit_labels",user="tenant-a"} 0 cortex_overrides{limit_name="enforce_metadata_metric_name",user="tenant-a"} 1 diff --git a/pkg/util/validation/limits.go b/pkg/util/validation/limits.go index 53e25252903..305f1527243 100644 --- a/pkg/util/validation/limits.go +++ b/pkg/util/validation/limits.go @@ -314,7 +314,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) { f.IntVar(&l.MaxGlobalSeriesPerMetric, "ingester.max-global-series-per-metric", 0, "The maximum number of active series per metric name, across the cluster before replication. 0 to disable.") f.IntVar(&l.MaxLocalNativeHistogramSeriesPerUser, "ingester.max-native-histogram-series-per-user", 0, "The maximum number of active native histogram series per user, per ingester. 0 to disable. Supported only if ingester.active-series-metrics-enabled is true.") f.IntVar(&l.MaxGlobalNativeHistogramSeriesPerUser, "ingester.max-global-native-histogram-series-per-user", 0, "The maximum number of active native histogram series per user, across the cluster before replication. 0 to disable. Supported only if -distributor.shard-by-all-labels and ingester.active-series-metrics-enabled is true.") - f.BoolVar(&l.EnableNativeHistograms, "blocks-storage.tsdb.enable-native-histograms", false, "True to enable native histogram.") + f.BoolVar(&l.EnableNativeHistograms, "blocks-storage.tsdb.enable-native-histograms", true, "Enable ingestion of native histogram samples. When disabled, native histogram samples are discarded.") f.IntVar(&l.MaxExemplars, "ingester.max-exemplars", 0, "Enables support for exemplars in TSDB and sets the maximum number that will be stored. less than zero means disabled. If the value is set to zero, cortex will fallback to the deprecated blocks-storage.tsdb.max-exemplars value; that fallback is removed in v1.24.0.") f.Var(&l.OutOfOrderTimeWindow, "ingester.out-of-order-time-window", "[Experimental] Configures the allowed time window for ingestion of out-of-order samples. Disabled (0s) by default.") diff --git a/pkg/util/validation/limits_test.go b/pkg/util/validation/limits_test.go index 6f376085b83..0e19315895f 100644 --- a/pkg/util/validation/limits_test.go +++ b/pkg/util/validation/limits_test.go @@ -235,6 +235,31 @@ func TestOverrides_MaxChunksPerQueryFromStore(t *testing.T) { assert.Equal(t, 2000000, overrides.MaxChunksPerQueryFromStore("test")) } +func TestOverrides_EnableNativeHistograms(t *testing.T) { + defaults := Limits{} + flagext.DefaultValues(&defaults) + SetDefaultLimitsForYAMLUnmarshalling(defaults) + + var yamlUnset, yamlDisabled, jsonUnset, jsonDisabled Limits + require.NoError(t, yaml.UnmarshalStrict([]byte(`ingestion_rate: 1`), &yamlUnset)) + require.NoError(t, yaml.UnmarshalStrict([]byte(`enable_native_histograms: false`), &yamlDisabled)) + require.NoError(t, json.Unmarshal([]byte(`{"ingestion_rate": 1}`), &jsonUnset)) + require.NoError(t, json.Unmarshal([]byte(`{"enable_native_histograms": false}`), &jsonDisabled)) + + overrides := NewOverrides(defaults, newMockTenantLimits(map[string]*Limits{ + "yaml-unset": &yamlUnset, + "yaml-disabled": &yamlDisabled, + "json-unset": &jsonUnset, + "json-disabled": &jsonDisabled, + })) + + assert.True(t, overrides.EnableNativeHistograms("no-override")) + assert.True(t, overrides.EnableNativeHistograms("yaml-unset")) + assert.False(t, overrides.EnableNativeHistograms("yaml-disabled")) + assert.True(t, overrides.EnableNativeHistograms("json-unset")) + assert.False(t, overrides.EnableNativeHistograms("json-disabled")) +} + func TestOverridesManager_GetOverrides(t *testing.T) { tenantLimits := map[string]*Limits{} diff --git a/schemas/cortex-config-schema.json b/schemas/cortex-config-schema.json index 4a45fe56684..5e3e76c19b7 100644 --- a/schemas/cortex-config-schema.json +++ b/schemas/cortex-config-schema.json @@ -5739,8 +5739,8 @@ "x-cli-flag": "distributor.drop-label" }, "enable_native_histograms": { - "default": false, - "description": "True to enable native histogram.", + "default": true, + "description": "Enable ingestion of native histogram samples. When disabled, native histogram samples are discarded.", "type": "boolean", "x-cli-flag": "blocks-storage.tsdb.enable-native-histograms" }, From f0092b047e88ddb781554efef4ee5fd8a6cd5e9f Mon Sep 17 00:00:00 2001 From: Sungjin1212 Date: Wed, 25 Nov 2026 16:14:42 +0900 Subject: [PATCH 2/3] integration: rely on default native histogram ingestion Signed-off-by: Sungjin1212 --- integration/native_histogram_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/integration/native_histogram_test.go b/integration/native_histogram_test.go index 91afee12981..03994ba8ef0 100644 --- a/integration/native_histogram_test.go +++ b/integration/native_histogram_test.go @@ -32,8 +32,7 @@ func TestOOONativeHistogramIngestion(t *testing.T) { flags := mergeFlags(baseFlags, map[string]string{ // ooo setting - "-blocks-storage.tsdb.enable-native-histograms": "true", - "-ingester.out-of-order-time-window": "5m", + "-ingester.out-of-order-time-window": "5m", // alert manager "-alertmanager.web.external-url": "http://localhost/alertmanager", // consul @@ -117,10 +116,9 @@ func TestNativeHistogramIngestionAndQuery(t *testing.T) { // Configure the blocks storage to frequently compact TSDB head // and ship blocks to the storage. flags := mergeFlags(BlocksStorageFlags(), map[string]string{ - "-blocks-storage.tsdb.block-ranges-period": blockRangePeriod.String(), - "-blocks-storage.tsdb.ship-interval": "1s", - "-blocks-storage.tsdb.retention-period": ((blockRangePeriod * 2) - 1).String(), - "-blocks-storage.tsdb.enable-native-histograms": "true", + "-blocks-storage.tsdb.block-ranges-period": blockRangePeriod.String(), + "-blocks-storage.tsdb.ship-interval": "1s", + "-blocks-storage.tsdb.retention-period": ((blockRangePeriod * 2) - 1).String(), }) // Start dependencies. From 3d66cd805c7ba2346f31a3d8559ca9f5c25ff347 Mon Sep 17 00:00:00 2001 From: Sungjin1212 Date: Wed, 25 Nov 2026 16:18:09 +0900 Subject: [PATCH 3/3] Shorten changelog entry and add PR number Signed-off-by: Sungjin1212 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7adec3b76..d6695529e3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * [CHANGE] Ingester: Make `close_idle_tsdb_timeout` a per-tenant limit (`-limits.close-idle-tsdb-timeout`). `-blocks-storage.tsdb.close-idle-tsdb-timeout` is deprecated and will be removed in v1.24.0. A positive `close_idle_tsdb_timeout` must now be at least `query_store_after` when `query_ingesters_within` is 0. #7813 * [CHANGE] Compactor: Add the `time_range_milliseconds` label to `cortex_compactor_remaining_planned_compactions` and `cortex_compactor_oldest_partition_offset`, reporting them per compaction time range instead of summed over all of them. #7959 -* [CHANGE] Ingester: Enable native histogram ingestion by default (`-blocks-storage.tsdb.enable-native-histograms=true`). Set it to `false`, globally or per tenant via `enable_native_histograms`, to keep discarding native histogram samples. Native histogram series that were previously discarded now count towards the series limits; tenants sending them can be found with `cortex_discarded_samples_total{reason="native-histogram-sample"}` before upgrading. If a native histogram series limit (`-ingester.max-native-histogram-series-per-user` or `-ingester.max-global-native-histogram-series-per-user`) is set, reaching it also rejects new float series. During a rolling upgrade, recent native histogram samples may be missing from query results because ingesters still running the previous version discard them. +* [CHANGE] Ingester: Enable native histogram ingestion by default (`-blocks-storage.tsdb.enable-native-histograms=true`). Set it to `false`, globally or per tenant via `enable_native_histograms`, to keep discarding native histogram samples. During a rolling upgrade, recent native histogram samples may be missing from query results because ingesters still running the previous version discard them. #7968 * [FEATURE] Ruler: Add experimental support for federated rule groups. A rule group listing tenants in its `source_tenants` field is evaluated against those tenants while the resulting series and alerts are written to the tenant owning the rule group. Enabled with `-ruler.enable-federated-rules` (requires `-tenant-federation.enabled`), and restricted to selected tenants with `-ruler.allowed-federated-tenants` and `-ruler.disallowed-federated-tenants`. #7828 * [FEATURE] Distributor: Add experimental OTLP metrics ingestion over gRPC (`opentelemetry.proto.collector.metrics.v1.MetricsService/Export`) on the gRPC server port. Enable it with `-distributor.otlp.grpc-enabled`. The tenant is read from the `X-Scope-OrgID` gRPC metadata, and the request size is limited by `-server.grpc-max-recv-msg-size-bytes`. #7873 * [FEATURE] Storage: Add support for Alibaba Cloud OSS as a backend for blocks, ruler, and alertmanager storage. Configured via `-.oss.*` flags with `backend: oss`. #7907