Skip to content

Commit be0fc7f

Browse files
authored
Make ooo native ingestion automatically enabled (#6663)
Signed-off-by: SungJin1212 <[email protected]>
1 parent 263cd12 commit be0fc7f

File tree

9 files changed

+12
-145
lines changed

9 files changed

+12
-145
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* [FEATURE] Query Frontend: Add dynamic interval size for query splitting. This is enabled by configuring experimental flags `querier.max-shards-per-query` and/or `querier.max-fetched-data-duration-per-query`. The split interval size is dynamically increased to maintain a number of shards and total duration fetched below the configured values. #6458
66
* [FEATURE] Querier/Ruler: Add `query_partial_data` and `rules_partial_data` limits to allow queries/rules to be evaluated with data from a single zone, if other zones are not available. #6526
77
* [FEATURE] Update prometheus alertmanager version to v0.28.0 and add new integration msteamsv2, jira, and rocketchat. #6590
8-
* [FEATURE] Ingester: Add a `-ingester.enable-ooo-native-histograms` flag to enable out-of-order native histogram ingestion per tenant. It only takes effect when `-blocks-storage.tsdb.enable-native-histograms=true` and `-ingester.out-of-order-time-window` > 0. It is applied after the restart if it is changed at runtime through the runtime config. #6626
8+
* [FEATURE] Ingester: Support out-of-order native histogram ingestion. It automatically enabled when `-ingester.out-of-order-time-window > 0` and `-blocks-storage.tsdb.enable-native-histograms=true`. #6626 #6663
99
* [ENHANCEMENT] Querier: limit label APIs to query only ingesters if `start` param is not been specified. #6618
1010
* [ENHANCEMENT] Alertmanager: Add new limits `-alertmanager.max-silences-count` and `-alertmanager.max-silences-size-bytes` for limiting silences per tenant. #6605
1111
* [ENHANCEMENT] Update prometheus version to v3.1.0. #6583

docs/configuration/config-file-reference.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,13 +3526,6 @@ The `limits_config` configures default and per-tenant limits imposed by Cortex s
35263526
# CLI flag: -ingester.max-exemplars
35273527
[max_exemplars: <int> | default = 0]
35283528
3529-
# [Experimental] Enable out-of-order native histogram ingestion, it only takes
3530-
# effect when -blocks-storage.tsdb.enable-native-histograms=true and
3531-
# -ingester.out-of-order-time-window > 0. It is applied after the restart if it
3532-
# is changed at runtime through the runtime config.
3533-
# CLI flag: -ingester.enable-ooo-native-histograms
3534-
[enable_ooo_native_histograms: <boolean> | default = false]
3535-
35363529
# Maximum number of chunks that can be fetched in a single query from ingesters
35373530
# and long-term storage. This limit is enforced in the querier, ruler and
35383531
# store-gateway. 0 to disable.

docs/configuration/v1-guarantees.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ Currently experimental features are:
104104
- `-blocks-storage.tsdb.out-of-order-cap-max` (int) CLI flag
105105
- `-ingester.out-of-order-time-window` (duration) CLI flag
106106
- `out_of_order_time_window` (duration) field in runtime config file
107-
- `enable_ooo_native_histograms` (bool) field in runtime config file
108107
- Store Gateway Zone Stable Shuffle Sharding
109108
- `-store-gateway.sharding-ring.zone-stable-shuffle-sharding` CLI flag
110109
- `zone_stable_shuffle_sharding` (boolean) field in config file

docs/guides/native-histograms.md

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,14 @@ overrides:
5555
5656
## How to enable out-of-order native histograms ingestion
5757
Like samples out-of-order ingestion, the Cortex allows out-of-order ingestion for the native histogram.
58-
To enable it, set the flag `-ingester.enable-ooo-native-histograms`.
58+
It is automatically enabled when `-blocks-storage.tsdb.enable-native-histograms=true` and `-ingester.out-of-order-time-window > 0`.
5959
6060
And via yaml:
61+
6162
```yaml
63+
blocks_storage:
64+
tsdb:
65+
enable_native_histograms: true
6266
limits:
63-
enable_ooo_native_histograms: <bool>
64-
```
65-
66-
Is it only works if when `-blocks-storage.tsdb.enable-native-histograms=true` and `-ingester.out-of-order-time-window > 0`.
67-
68-
To enable it per tenant, you can utilize a [runtime config](../configuration/arguments.md#runtime-configuration-file).
69-
70-
For example, the following yaml file specifies enabling out-of-order native histogram ingestion for `user-1`, but not for `user-2`.
71-
72-
```
73-
overrides:
74-
user-1:
75-
enable_ooo_native_histograms: true
76-
user-2:
77-
enable_ooo_native_histograms: false
78-
```
79-
80-
**Caution**: It is applied after the Ingester restart if it is changed at runtime through the runtime config.
81-
For example, if you have changed the `enable_ooo_native_histograms` value to `false` of the `user-1` via the below yaml file, then the Ingester stops the out-of-order ingestion not until the Ingester restarts.
82-
83-
```
84-
overrides:
85-
user-1:
86-
enable_ooo_native_histograms: false
87-
user-2:
88-
enable_ooo_native_histograms: false
67+
out_of_order_time_window: 5m
8968
```

integration/native_histogram_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func TestOOONativeHistogramIngestion(t *testing.T) {
3333

3434
flags := mergeFlags(baseFlags, map[string]string{
3535
// ooo setting
36-
"-ingester.enable-ooo-native-histograms": "true",
3736
"-blocks-storage.tsdb.enable-native-histograms": "true",
3837
"-ingester.out-of-order-time-window": "5m",
3938
// alert manager

pkg/ingester/ingester.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,8 +2424,8 @@ func (i *Ingester) createTSDB(userID string) (*userTSDB, error) {
24242424
EnableMemorySnapshotOnShutdown: i.cfg.BlocksStorageConfig.TSDB.MemorySnapshotOnShutdown,
24252425
OutOfOrderTimeWindow: time.Duration(oooTimeWindow).Milliseconds(),
24262426
OutOfOrderCapMax: i.cfg.BlocksStorageConfig.TSDB.OutOfOrderCapMax,
2427-
EnableOOONativeHistograms: i.limits.EnableOOONativeHistograms(userID),
2428-
EnableOverlappingCompaction: false, // Always let compactors handle overlapped blocks, e.g. OOO blocks.
2427+
EnableOOONativeHistograms: i.cfg.BlocksStorageConfig.TSDB.EnableNativeHistograms, // Automatically enabled when EnableNativeHistograms is true.
2428+
EnableOverlappingCompaction: false, // Always let compactors handle overlapped blocks, e.g. OOO blocks.
24292429
EnableNativeHistograms: i.cfg.BlocksStorageConfig.TSDB.EnableNativeHistograms,
24302430
BlockChunkQuerierFunc: i.blockChunkQuerierFunc(userID),
24312431
}, nil)

pkg/ingester/ingester_test.go

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,6 @@ func TestIngester_Push(t *testing.T) {
10281028
maxExemplars int
10291029
oooTimeWindow time.Duration
10301030
disableNativeHistogram bool
1031-
enableOOONativeHistograms bool
10321031
}{
10331032
"should record native histogram discarded": {
10341033
reqs: []*cortexpb.WriteRequest{
@@ -1517,65 +1516,6 @@ func TestIngester_Push(t *testing.T) {
15171516
cortex_ingester_active_series{user="test"} 1
15181517
`,
15191518
},
1520-
"native histogram ooo disabled, should soft fail": {
1521-
reqs: []*cortexpb.WriteRequest{
1522-
cortexpb.ToWriteRequest(
1523-
[]labels.Labels{metricLabels},
1524-
nil,
1525-
nil,
1526-
[]cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969, tsdbutil.GenerateTestHistogram(1))},
1527-
cortexpb.API),
1528-
cortexpb.ToWriteRequest(
1529-
[]labels.Labels{metricLabels},
1530-
nil,
1531-
nil,
1532-
[]cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969-(10), tsdbutil.GenerateTestHistogram(1))},
1533-
cortexpb.API),
1534-
},
1535-
oooTimeWindow: 5 * time.Minute,
1536-
enableOOONativeHistograms: false,
1537-
expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrOOONativeHistogramsDisabled, model.Time(1575043969-(10)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()),
1538-
expectedIngested: []cortexpb.TimeSeries{
1539-
{Labels: metricLabelAdapters, Histograms: []cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969, tsdbutil.GenerateTestHistogram(1))}},
1540-
},
1541-
additionalMetrics: []string{
1542-
"cortex_ingester_tsdb_head_samples_appended_total",
1543-
"cortex_ingester_active_series",
1544-
},
1545-
expectedMetrics: `
1546-
# HELP cortex_ingester_ingested_samples_failures_total The total number of samples that errored on ingestion.
1547-
# TYPE cortex_ingester_ingested_samples_failures_total counter
1548-
cortex_ingester_ingested_samples_failures_total 0
1549-
# HELP cortex_ingester_ingested_samples_total The total number of samples ingested.
1550-
# TYPE cortex_ingester_ingested_samples_total counter
1551-
cortex_ingester_ingested_samples_total 0
1552-
# HELP cortex_ingester_ingested_native_histograms_total The total number of native histograms ingested.
1553-
# TYPE cortex_ingester_ingested_native_histograms_total counter
1554-
cortex_ingester_ingested_native_histograms_total 1
1555-
# HELP cortex_ingester_ingested_native_histograms_failures_total The total number of native histograms that errored on ingestion.
1556-
# TYPE cortex_ingester_ingested_native_histograms_failures_total counter
1557-
cortex_ingester_ingested_native_histograms_failures_total 1
1558-
# HELP cortex_ingester_memory_users The current number of users in memory.
1559-
# TYPE cortex_ingester_memory_users gauge
1560-
cortex_ingester_memory_users 1
1561-
# HELP cortex_ingester_tsdb_head_samples_appended_total Total number of appended samples.
1562-
# TYPE cortex_ingester_tsdb_head_samples_appended_total counter
1563-
cortex_ingester_tsdb_head_samples_appended_total{type="float",user="test"} 0
1564-
cortex_ingester_tsdb_head_samples_appended_total{type="histogram",user="test"} 1
1565-
# HELP cortex_ingester_memory_series The current number of series in memory.
1566-
# TYPE cortex_ingester_memory_series gauge
1567-
cortex_ingester_memory_series 1
1568-
# HELP cortex_ingester_memory_series_created_total The total number of series that were created per user.
1569-
# TYPE cortex_ingester_memory_series_created_total counter
1570-
cortex_ingester_memory_series_created_total{user="test"} 1
1571-
# HELP cortex_ingester_memory_series_removed_total The total number of series that were removed per user.
1572-
# TYPE cortex_ingester_memory_series_removed_total counter
1573-
cortex_ingester_memory_series_removed_total{user="test"} 0
1574-
# HELP cortex_ingester_active_series Number of currently active series per user.
1575-
# TYPE cortex_ingester_active_series gauge
1576-
cortex_ingester_active_series{user="test"} 1
1577-
`,
1578-
},
15791519
"native histogram ooo enabled, should soft fail on sample too old": {
15801520
reqs: []*cortexpb.WriteRequest{
15811521
cortexpb.ToWriteRequest(
@@ -1591,9 +1531,8 @@ func TestIngester_Push(t *testing.T) {
15911531
[]cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969-(600*1000), tsdbutil.GenerateTestHistogram(1))},
15921532
cortexpb.API),
15931533
},
1594-
oooTimeWindow: 5 * time.Minute,
1595-
enableOOONativeHistograms: true,
1596-
expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrTooOldSample, model.Time(1575043969-(600*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()),
1534+
oooTimeWindow: 5 * time.Minute,
1535+
expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrTooOldSample, model.Time(1575043969-(600*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()),
15971536
expectedIngested: []cortexpb.TimeSeries{
15981537
{Labels: metricLabelAdapters, Histograms: []cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969, tsdbutil.GenerateTestHistogram(1))}},
15991538
},
@@ -1654,8 +1593,7 @@ func TestIngester_Push(t *testing.T) {
16541593
[]cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969-(10), tsdbutil.GenerateTestHistogram(1))},
16551594
cortexpb.API),
16561595
},
1657-
oooTimeWindow: 5 * time.Minute,
1658-
enableOOONativeHistograms: true,
1596+
oooTimeWindow: 5 * time.Minute,
16591597
expectedIngested: []cortexpb.TimeSeries{
16601598
{Labels: metricLabelAdapters, Histograms: []cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969-(10), tsdbutil.GenerateTestHistogram(1)), cortexpb.HistogramToHistogramProto(1575043969, tsdbutil.GenerateTestHistogram(1))}},
16611599
},
@@ -2005,7 +1943,6 @@ func TestIngester_Push(t *testing.T) {
20051943
limits := defaultLimitsTestConfig()
20061944
limits.MaxExemplars = testData.maxExemplars
20071945
limits.OutOfOrderTimeWindow = model.Duration(testData.oooTimeWindow)
2008-
limits.EnableOOONativeHistograms = testData.enableOOONativeHistograms
20091946
limits.LimitsPerLabelSet = []validation.LimitsPerLabelSet{
20101947
{
20111948
LabelSet: labels.FromMap(map[string]string{model.MetricNameLabel: "test"}),

pkg/util/validation/limits.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ type Limits struct {
159159
OutOfOrderTimeWindow model.Duration `yaml:"out_of_order_time_window" json:"out_of_order_time_window"`
160160
// Exemplars
161161
MaxExemplars int `yaml:"max_exemplars" json:"max_exemplars"`
162-
// Native Histogram
163-
EnableOOONativeHistograms bool `yaml:"enable_ooo_native_histograms" json:"enable_ooo_native_histograms"`
164162

165163
// Querier enforced limits.
166164
MaxChunksPerQuery int `yaml:"max_fetched_chunks_per_query" json:"max_fetched_chunks_per_query"`
@@ -260,7 +258,6 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) {
260258
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.")
261259
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 blocks-storage.tsdb.max-exemplars value.")
262260
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.")
263-
f.BoolVar(&l.EnableOOONativeHistograms, "ingester.enable-ooo-native-histograms", false, "[Experimental] Enable out-of-order native histogram ingestion, it only takes effect when -blocks-storage.tsdb.enable-native-histograms=true and -ingester.out-of-order-time-window > 0. It is applied after the restart if it is changed at runtime through the runtime config.")
264261

265262
f.IntVar(&l.MaxLocalMetricsWithMetadataPerUser, "ingester.max-metadata-per-user", 8000, "The maximum number of active metrics with metadata per user, per ingester. 0 to disable.")
266263
f.IntVar(&l.MaxLocalMetadataPerMetric, "ingester.max-metadata-per-metric", 10, "The maximum number of metadata per metric, per ingester. 0 to disable.")
@@ -906,11 +903,6 @@ func (o *Overrides) MaxExemplars(userID string) int {
906903
return o.GetOverridesForUser(userID).MaxExemplars
907904
}
908905

909-
// EnableOOONativeHistograms returns whether to ingest out-of-order native histogram for a given user.
910-
func (o *Overrides) EnableOOONativeHistograms(userID string) bool {
911-
return o.GetOverridesForUser(userID).EnableOOONativeHistograms
912-
}
913-
914906
// Notification limits are special. Limits are returned in following order:
915907
// 1. per-tenant limits for given integration
916908
// 2. default limits for given integration

pkg/util/validation/limits_test.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -606,38 +606,6 @@ tenant2:
606606
require.Equal(t, 5, ov.MaxExemplars("tenant3"))
607607
}
608608

609-
func TestEnableOOONativeHistograms(t *testing.T) {
610-
SetDefaultLimitsForYAMLUnmarshalling(Limits{
611-
MaxLabelNameLength: 100,
612-
})
613-
614-
baseYAML := `
615-
enable_ooo_native_histograms: false`
616-
overridesYAML := `
617-
tenant1:
618-
enable_ooo_native_histograms: true
619-
tenant2:
620-
enable_ooo_native_histograms: false
621-
`
622-
623-
l := Limits{}
624-
err := yaml.UnmarshalStrict([]byte(baseYAML), &l)
625-
require.NoError(t, err)
626-
627-
overrides := map[string]*Limits{}
628-
err = yaml.Unmarshal([]byte(overridesYAML), &overrides)
629-
require.NoError(t, err, "parsing overrides")
630-
631-
tl := newMockTenantLimits(overrides)
632-
633-
ov, err := NewOverrides(l, tl)
634-
require.NoError(t, err)
635-
636-
require.Equal(t, true, ov.EnableOOONativeHistograms("tenant1"))
637-
require.Equal(t, false, ov.EnableOOONativeHistograms("tenant2"))
638-
require.Equal(t, false, ov.EnableOOONativeHistograms("tenant3"))
639-
}
640-
641609
func TestMaxDownloadedBytesPerRequestOverridesPerTenant(t *testing.T) {
642610
SetDefaultLimitsForYAMLUnmarshalling(Limits{
643611
MaxLabelNameLength: 100,

0 commit comments

Comments
 (0)