Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store-gateway: remove cortex_bucket_store_blocks_loaded_by_duration #7309

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* [CHANGE] Distributor: default the optimization `-distributor.write-requests-buffer-pooling-enabled` to `true`. #7165
* [CHANGE] Tracing: Move query information to span attributes instead of span logs. #7046
* [CHANGE] Distributor: the default value of circuit breaker's CLI flag `-ingester.client.circuit-breaker.cooldown-period` has been changed from `1m` to `10s`. #7310
* [CHANGE] Store-gateway: remove `cortex_bucket_store_blocks_loaded_by_duration`. `cortex_bucket_store_series_blocks_queried` is better suited for detecting when compactors are not able to keep up with the number of blocks to compact. #7309
* [FEATURE] Introduce `-server.log-source-ips-full` option to log all IPs from `Forwarded`, `X-Real-IP`, `X-Forwarded-For` headers. #7250
* [FEATURE] Introduce `-tenant-federation.max-tenants` option to limit the max number of tenants allowed for requests when federation is enabled. #6959
* [FEATURE] Cardinality API: added a new `count_method` parameter which enables counting active label values. #7085
Expand Down
36 changes: 10 additions & 26 deletions pkg/storegateway/bucket_stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/model"
tsdb_errors "github.com/prometheus/prometheus/tsdb/errors"
"github.com/prometheus/prometheus/tsdb/hashcache"
"github.com/thanos-io/objstore"
Expand Down Expand Up @@ -78,12 +77,11 @@ type BucketStores struct {
stores map[string]*BucketStore

// Metrics.
syncTimes prometheus.Histogram
syncLastSuccess prometheus.Gauge
tenantsDiscovered prometheus.Gauge
tenantsSynced prometheus.Gauge
blocksLoaded *prometheus.Desc
blocksLoadedByDuration *prometheus.Desc
syncTimes prometheus.Histogram
syncLastSuccess prometheus.Gauge
tenantsDiscovered prometheus.Gauge
tenantsSynced prometheus.Gauge
blocksLoaded *prometheus.Desc
}

// NewBucketStores makes a new BucketStores.
Expand Down Expand Up @@ -157,11 +155,6 @@ func NewBucketStores(cfg tsdb.BlocksStorageConfig, shardingStrategy ShardingStra
"Number of currently loaded blocks.",
nil, nil,
)
u.blocksLoadedByDuration = prometheus.NewDesc(
"cortex_bucket_store_blocks_loaded_by_duration",
"Number of currently loaded blocks, bucketed by block duration.",
[]string{"duration"}, nil,
)

// Init the index cache.
if u.indexCache, err = tsdb.NewIndexCache(cfg.BucketStore.IndexCache, logger, reg); err != nil {
Expand Down Expand Up @@ -547,39 +540,30 @@ func (u *BucketStores) closeBucketStoreAndDeleteLocalFilesForExcludedTenants(inc
}
}

// countBlocksLoaded returns the total number of blocks loaded and the number of blocks
// loaded bucketed by the provided block durations, summed for all users.
func (u *BucketStores) countBlocksLoaded(durations []time.Duration) (int, map[time.Duration]int) {
byDuration := make(map[time.Duration]int)
// countBlocksLoaded returns the total number of blocks loaded, summed for all users.
func (u *BucketStores) countBlocksLoaded(durations []time.Duration) int {
total := 0

u.storesMu.RLock()
defer u.storesMu.RUnlock()

for _, store := range u.stores {
stats := store.Stats(durations)
for d, n := range stats.BlocksLoaded {
byDuration[d] += n
for _, n := range stats.BlocksLoaded {
total += n
}
}

return total, byDuration
return total
}

func (u *BucketStores) Describe(descs chan<- *prometheus.Desc) {
descs <- u.blocksLoaded
descs <- u.blocksLoadedByDuration
}

func (u *BucketStores) Collect(metrics chan<- prometheus.Metric) {
total, byDuration := u.countBlocksLoaded(defaultBlockDurations)
total := u.countBlocksLoaded(defaultBlockDurations)
metrics <- prometheus.MustNewConstMetric(u.blocksLoaded, prometheus.GaugeValue, float64(total))
for d, n := range byDuration {
// Convert time.Duration to model.Duration here since the string format is nicer
// to read for round numbers than the stdlib version. E.g. "2h" vs "2h0m0s"
metrics <- prometheus.MustNewConstMetric(u.blocksLoadedByDuration, prometheus.GaugeValue, float64(n), model.Duration(d).String())
}
}

func getUserIDFromGRPCContext(ctx context.Context) string {
Expand Down
Loading