Skip to content

Commit 6b06010

Browse files
devnevbwplotka
authored andcommitted
Initialze and correctly register all index cache metrics. (#1069)
1 parent c838f07 commit 6b06010

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

pkg/store/cache.go

+15-5
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,50 @@ func newIndexCache(reg prometheus.Registerer, maxBytes uint64) (*indexCache, err
5656
Name: "thanos_store_index_cache_items_evicted_total",
5757
Help: "Total number of items that were evicted from the index cache.",
5858
}, []string{"item_type"})
59+
evicted.WithLabelValues(cacheTypePostings)
60+
evicted.WithLabelValues(cacheTypeSeries)
5961

6062
c.added = prometheus.NewCounterVec(prometheus.CounterOpts{
6163
Name: "thanos_store_index_cache_items_added_total",
6264
Help: "Total number of items that were added to the index cache.",
6365
}, []string{"item_type"})
66+
c.added.WithLabelValues(cacheTypePostings)
67+
c.added.WithLabelValues(cacheTypeSeries)
6468

6569
c.requests = prometheus.NewCounterVec(prometheus.CounterOpts{
6670
Name: "thanos_store_index_cache_requests_total",
6771
Help: "Total number of requests to the cache.",
6872
}, []string{"item_type"})
73+
c.requests.WithLabelValues(cacheTypePostings)
74+
c.requests.WithLabelValues(cacheTypeSeries)
6975

7076
c.overflow = prometheus.NewCounterVec(prometheus.CounterOpts{
7177
Name: "thanos_store_index_cache_items_overflowed_total",
7278
Help: "Total number of items that could not be added to the cache due to being too big.",
7379
}, []string{"item_type"})
80+
c.overflow.WithLabelValues(cacheTypePostings)
81+
c.overflow.WithLabelValues(cacheTypeSeries)
7482

7583
c.hits = prometheus.NewCounterVec(prometheus.CounterOpts{
7684
Name: "thanos_store_index_cache_hits_total",
7785
Help: "Total number of requests to the cache that were a hit.",
7886
}, []string{"item_type"})
87+
c.hits.WithLabelValues(cacheTypePostings)
88+
c.hits.WithLabelValues(cacheTypeSeries)
7989

8090
c.current = prometheus.NewGaugeVec(prometheus.GaugeOpts{
8191
Name: "thanos_store_index_cache_items",
8292
Help: "Current number of items in the index cache.",
8393
}, []string{"item_type"})
94+
c.current.WithLabelValues(cacheTypePostings)
95+
c.current.WithLabelValues(cacheTypeSeries)
8496

8597
c.currentSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
8698
Name: "thanos_store_index_cache_items_size_bytes",
8799
Help: "Current byte size of items in the index cache.",
88100
}, []string{"item_type"})
89-
90-
// Initialize eviction metric with 0.
91-
evicted.WithLabelValues(cacheTypePostings)
92-
evicted.WithLabelValues(cacheTypeSeries)
101+
c.currentSize.WithLabelValues(cacheTypePostings)
102+
c.currentSize.WithLabelValues(cacheTypeSeries)
93103

94104
// Initialize LRU cache with a high size limit since we will manage evictions ourselves
95105
// based on stored size.
@@ -116,7 +126,7 @@ func newIndexCache(reg prometheus.Registerer, maxBytes uint64) (*indexCache, err
116126
}, func() float64 {
117127
return float64(maxBytes)
118128
}))
119-
reg.MustRegister(c.requests, c.hits, c.added, evicted, c.current, c.currentSize)
129+
reg.MustRegister(c.requests, c.hits, c.added, evicted, c.current, c.currentSize, c.overflow)
120130
}
121131
return c, nil
122132
}

0 commit comments

Comments
 (0)