From ab0c7b2b9d3661ba790c38350f972818f0144185 Mon Sep 17 00:00:00 2001 From: Joao Marcal Date: Tue, 12 Aug 2025 15:39:41 +0100 Subject: [PATCH] feat: Add ingester_chunks_flush_requests_total (#18696) --- pkg/ingester/flush.go | 1 + pkg/ingester/metrics.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/pkg/ingester/flush.go b/pkg/ingester/flush.go index bc56c1d65a..4bcd7d2378 100644 --- a/pkg/ingester/flush.go +++ b/pkg/ingester/flush.go @@ -508,6 +508,7 @@ func (i *Ingester) encodeChunk(ctx context.Context, ch *chunk.Chunk, desc *chunk // If the flush isn't successful, the operation for this userID is requeued allowing this and all other unflushed // chunk to have another opportunity to be flushed. func (i *Ingester) flushChunk(ctx context.Context, ch *chunk.Chunk) error { + i.metrics.chunksFlushRequestsTotal.Inc() if err := i.store.Put(ctx, []chunk.Chunk{*ch}); err != nil { i.metrics.chunksFlushFailures.Inc() return fmt.Errorf("store put chunk: %w", err) diff --git a/pkg/ingester/metrics.go b/pkg/ingester/metrics.go index 5f144038bc..d71e0cbfe2 100644 --- a/pkg/ingester/metrics.go +++ b/pkg/ingester/metrics.go @@ -48,6 +48,7 @@ type ingesterMetrics struct { chunkAge prometheus.Histogram chunkEncodeTime prometheus.Histogram chunksFlushFailures prometheus.Counter + chunksFlushRequestsTotal prometheus.Counter chunksFlushedPerReason *prometheus.CounterVec chunkLifespan prometheus.Histogram chunksEncoded *prometheus.CounterVec @@ -242,6 +243,11 @@ func newIngesterMetrics(r prometheus.Registerer, metricsNamespace string) *inges Name: "ingester_chunks_flush_failures_total", Help: "Total number of flush failures.", }), + chunksFlushRequestsTotal: promauto.With(r).NewCounter(prometheus.CounterOpts{ + Namespace: constants.Loki, + Name: "ingester_chunks_flush_requests_total", + Help: "Total number of flush requests (successful or not).", + }), chunksFlushedPerReason: promauto.With(r).NewCounterVec(prometheus.CounterOpts{ Namespace: constants.Loki, Name: "ingester_chunks_flushed_total",