From 31cb2757905c7fc17404f9d05abc8c15a935aa9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=B2=20Harry=20=F0=9F=8C=8A=20John=20=F0=9F=8F=94?= Date: Mon, 18 Sep 2023 09:04:15 -0700 Subject: [PATCH] Add a metric to track block sync duration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 🌲 Harry 🌊 John 🏔 --- pkg/store/bucket.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index 54150d178a..031420bac3 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -122,6 +122,7 @@ type bucketStoreMetrics struct { lastLoadedBlock prometheus.Gauge blockDrops prometheus.Counter blockDropFailures prometheus.Counter + blockLoadDuration prometheus.Histogram seriesDataTouched *prometheus.HistogramVec seriesDataFetched *prometheus.HistogramVec seriesDataSizeTouched *prometheus.HistogramVec @@ -179,6 +180,11 @@ func newBucketStoreMetrics(reg prometheus.Registerer) *bucketStoreMetrics { Name: "thanos_bucket_store_blocks_last_loaded_timestamp_seconds", Help: "Timestamp when last block got loaded.", }) + m.blockLoadDuration = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{ + Name: "thanos_bucket_store_block_load_duration_seconds", + Help: "The total time taken to load a block in seconds.", + Buckets: []float64{0.1, 0.5, 1, 10, 20, 30, 60, 120}, + }) m.seriesDataTouched = promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{ Name: "thanos_bucket_store_series_data_touched", @@ -709,6 +715,7 @@ func (s *BucketStore) addBlock(ctx context.Context, meta *metadata.Meta) (err er level.Warn(s.logger).Log("msg", "loading block failed", "elapsed", time.Since(start), "id", meta.ULID, "err", err) } else { level.Info(s.logger).Log("msg", "loaded new block", "elapsed", time.Since(start), "id", meta.ULID) + s.metrics.blockLoadDuration.Observe(time.Since(start).Seconds()) } }() s.metrics.blockLoads.Inc()