Skip to content

Commit cc4a348

Browse files
committed
Ingester: Added -blocks-storage.tsdb.head-chunks-write-queue-size allowing to configure the size of the in-memory queue used before flushing chunks to the disk . #5000
Signed-off-by: tanghengjian <[email protected]>
1 parent d595cba commit cc4a348

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
* [FEATURE] QueryFrontend: Support vertical sharding for subqueries. #4955
7474
* [FEATURE] Querier: Added a new limit `-querier.max-fetched-data-bytes-per-query` allowing to limit the maximum size of all data in bytes that a query can fetch from each ingester and storage. #4854
7575
* [FEATURE] Added 2 flags `-alertmanager.alertmanager-client.grpc-compression` and `-querier.store-gateway-client.grpc-compression` to configure compression methods for grpc clients. #4889
76+
* [FEATURE] Ingester: Added `-blocks-storage.tsdb.head-chunks-write-queue-size` allowing to configure the size of the in-memory queue used before flushing chunks to the disk . #5000
7677
* [BUGFIX] Storage/Bucket: Enable AWS SDK for go authentication for s3 to fix IMDSv1 authentication. #4897
7778
* [BUGFIX] Memberlist: Add join with no retrying when starting service. #4804
7879
* [BUGFIX] Ruler: Fix /ruler/rule_groups returns YAML with extra fields. #4767

pkg/ingester/ingester.go

+1
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,7 @@ func (i *Ingester) createTSDB(userID string) (*userTSDB, error) {
18461846
EnableExemplarStorage: enableExemplars,
18471847
IsolationDisabled: true,
18481848
MaxExemplars: int64(i.cfg.BlocksStorageConfig.TSDB.MaxExemplars),
1849+
HeadChunksWriteQueueSize: i.cfg.BlocksStorageConfig.TSDB.HeadChunksWriteQueueSize,
18491850
}, nil)
18501851
if err != nil {
18511852
return nil, errors.Wrapf(err, "failed to open TSDB: %s", udir)

pkg/ingester/metrics.go

+26-19
Original file line numberDiff line numberDiff line change
@@ -336,25 +336,26 @@ type tsdbMetrics struct {
336336
uploadFailures *prometheus.Desc // sum(thanos_shipper_upload_failures_total)
337337

338338
// Metrics aggregated from TSDB.
339-
tsdbCompactionsTotal *prometheus.Desc
340-
tsdbCompactionDuration *prometheus.Desc
341-
tsdbFsyncDuration *prometheus.Desc
342-
tsdbPageFlushes *prometheus.Desc
343-
tsdbPageCompletions *prometheus.Desc
344-
tsdbWALTruncateFail *prometheus.Desc
345-
tsdbWALTruncateTotal *prometheus.Desc
346-
tsdbWALTruncateDuration *prometheus.Desc
347-
tsdbWALCorruptionsTotal *prometheus.Desc
348-
tsdbWALWritesFailed *prometheus.Desc
349-
tsdbHeadTruncateFail *prometheus.Desc
350-
tsdbHeadTruncateTotal *prometheus.Desc
351-
tsdbHeadGcDuration *prometheus.Desc
352-
tsdbActiveAppenders *prometheus.Desc
353-
tsdbSeriesNotFound *prometheus.Desc
354-
tsdbChunks *prometheus.Desc
355-
tsdbChunksCreatedTotal *prometheus.Desc
356-
tsdbChunksRemovedTotal *prometheus.Desc
357-
tsdbMmapChunkCorruptionTotal *prometheus.Desc
339+
tsdbCompactionsTotal *prometheus.Desc
340+
tsdbCompactionDuration *prometheus.Desc
341+
tsdbFsyncDuration *prometheus.Desc
342+
tsdbPageFlushes *prometheus.Desc
343+
tsdbPageCompletions *prometheus.Desc
344+
tsdbWALTruncateFail *prometheus.Desc
345+
tsdbWALTruncateTotal *prometheus.Desc
346+
tsdbWALTruncateDuration *prometheus.Desc
347+
tsdbWALCorruptionsTotal *prometheus.Desc
348+
tsdbWALWritesFailed *prometheus.Desc
349+
tsdbHeadTruncateFail *prometheus.Desc
350+
tsdbHeadTruncateTotal *prometheus.Desc
351+
tsdbHeadGcDuration *prometheus.Desc
352+
tsdbActiveAppenders *prometheus.Desc
353+
tsdbSeriesNotFound *prometheus.Desc
354+
tsdbChunks *prometheus.Desc
355+
tsdbChunksCreatedTotal *prometheus.Desc
356+
tsdbChunksRemovedTotal *prometheus.Desc
357+
tsdbMmapChunkCorruptionTotal *prometheus.Desc
358+
tsdbChunkwriteQueueOperationsTotal *prometheus.Desc
358359

359360
tsdbExemplarsTotal *prometheus.Desc
360361
tsdbExemplarsInStorage *prometheus.Desc
@@ -478,6 +479,10 @@ func newTSDBMetrics(r prometheus.Registerer) *tsdbMetrics {
478479
"cortex_ingester_tsdb_mmap_chunk_corruptions_total",
479480
"Total number of memory-mapped TSDB chunk corruptions.",
480481
nil, nil),
482+
tsdbChunkwriteQueueOperationsTotal: prometheus.NewDesc(
483+
"cortex_ingester_tsdb_chunk_write_queue_operations_total",
484+
"Number of currently tsdb chunk write queues.",
485+
[]string{"user", "operation"}, nil),
481486
tsdbLoadedBlocks: prometheus.NewDesc(
482487
"cortex_ingester_tsdb_blocks_loaded",
483488
"Number of currently loaded data blocks",
@@ -579,6 +584,7 @@ func (sm *tsdbMetrics) Describe(out chan<- *prometheus.Desc) {
579584
out <- sm.tsdbChunksCreatedTotal
580585
out <- sm.tsdbChunksRemovedTotal
581586
out <- sm.tsdbMmapChunkCorruptionTotal
587+
out <- sm.tsdbChunkwriteQueueOperationsTotal
582588
out <- sm.tsdbLoadedBlocks
583589
out <- sm.tsdbSymbolTableSize
584590
out <- sm.tsdbReloads
@@ -628,6 +634,7 @@ func (sm *tsdbMetrics) Collect(out chan<- prometheus.Metric) {
628634
data.SendSumOfCountersPerUser(out, sm.tsdbChunksCreatedTotal, "prometheus_tsdb_head_chunks_created_total")
629635
data.SendSumOfCountersPerUser(out, sm.tsdbChunksRemovedTotal, "prometheus_tsdb_head_chunks_removed_total")
630636
data.SendSumOfCounters(out, sm.tsdbMmapChunkCorruptionTotal, "prometheus_tsdb_mmap_chunk_corruptions_total")
637+
data.SendSumOfCountersPerUserWithLabels(out, sm.tsdbChunkwriteQueueOperationsTotal, "prometheus_tsdb_chunk_write_queue_operations_total", "operation")
631638
data.SendSumOfGauges(out, sm.tsdbLoadedBlocks, "prometheus_tsdb_blocks_loaded")
632639
data.SendSumOfGaugesPerUser(out, sm.tsdbSymbolTableSize, "prometheus_tsdb_symbol_table_size_bytes")
633640
data.SendSumOfCounters(out, sm.tsdbReloads, "prometheus_tsdb_reloads_total")

pkg/storage/tsdb/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ type TSDBConfig struct {
136136
WALSegmentSizeBytes int `yaml:"wal_segment_size_bytes"`
137137
FlushBlocksOnShutdown bool `yaml:"flush_blocks_on_shutdown"`
138138
CloseIdleTSDBTimeout time.Duration `yaml:"close_idle_tsdb_timeout"`
139+
//The size of the in-memory queue used before flushing chunks to the disk.
140+
HeadChunksWriteQueueSize int `yaml:"head_chunks_write_queue_size"`
139141

140142
// MaxTSDBOpeningConcurrencyOnStartup limits the number of concurrently opening TSDB's during startup.
141143
MaxTSDBOpeningConcurrencyOnStartup int `yaml:"max_tsdb_opening_concurrency_on_startup"`

0 commit comments

Comments
 (0)