Skip to content

Commit

Permalink
Add a metric to track block sync duration
Browse files Browse the repository at this point in the history
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
  • Loading branch information
harry671003 committed Sep 18, 2023
1 parent 9524124 commit 31cb275
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 31cb275

Please sign in to comment.