From dbfdf9faa6e0d9f792986dc6d40da3c70ebffa5c Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Thu, 9 May 2019 15:59:54 +0530 Subject: [PATCH] Add a histogram for chunk encoding time Signed-off-by: Goutham Veeramachaneni --- pkg/ingester/flush.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/ingester/flush.go b/pkg/ingester/flush.go index d056d25d042a..a87c29a158e7 100644 --- a/pkg/ingester/flush.go +++ b/pkg/ingester/flush.go @@ -45,6 +45,12 @@ var ( // so buckets at 1min, 5min, 10min, 30min, 1hr, 2hr, 4hr, 10hr, 12hr, 16hr Buckets: []float64{60, 300, 600, 1800, 3600, 7200, 14400, 36000, 43200, 57600}, }) + chunkEncodeTime = promauto.NewHistogram(prometheus.HistogramOpts{ + Name: "loki_ingester_chunk_encode_time_seconds", + Help: "Distribution of chunk encode times.", + // 10ms to 10s. + Buckets: prometheus.ExponentialBuckets(0.01, 4, 6), + }) ) const ( @@ -261,9 +267,11 @@ func (i *Ingester) flushChunks(ctx context.Context, fp model.Fingerprint, labelP model.TimeFromUnixNano(lastTime.UnixNano()), ) + start := time.Now() if err := c.Encode(); err != nil { return err } + chunkEncodeTime.Observe(time.Since(start).Seconds()) wireChunks = append(wireChunks, c) }