Skip to content

Commit 0a6c79c

Browse files
committed
Adding total on all metric
Signed-off-by: alanprot <[email protected]>
1 parent 960f7b6 commit 0a6c79c

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

pkg/ingester/ingester_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5553,22 +5553,22 @@ func TestExpendedPostingsCache(t *testing.T) {
55535553

55545554
if c.expectedHeadPostingCall > 0 || c.expectedBlockPostingCall > 0 {
55555555
metric := `
5556-
# HELP cortex_ingester_expanded_postings_cache_requests Total number of requests to the cache.
5557-
# TYPE cortex_ingester_expanded_postings_cache_requests counter
5556+
# HELP cortex_ingester_expanded_postings_cache_requests_total Total number of requests to the cache.
5557+
# TYPE cortex_ingester_expanded_postings_cache_requests_total counter
55585558
`
55595559
if c.expectedBlockPostingCall > 0 {
55605560
metric += `
5561-
cortex_ingester_expanded_postings_cache_requests{cache="block"} 4
5561+
cortex_ingester_expanded_postings_cache_requests_total{cache="block"} 4
55625562
`
55635563
}
55645564

55655565
if c.expectedHeadPostingCall > 0 {
55665566
metric += `
5567-
cortex_ingester_expanded_postings_cache_requests{cache="head"} 4
5567+
cortex_ingester_expanded_postings_cache_requests_total{cache="head"} 4
55685568
`
55695569
}
55705570

5571-
err = testutil.GatherAndCompare(r, bytes.NewBufferString(metric), "cortex_ingester_expanded_postings_cache_requests")
5571+
err = testutil.GatherAndCompare(r, bytes.NewBufferString(metric), "cortex_ingester_expanded_postings_cache_requests_total")
55725572
require.NoError(t, err)
55735573
}
55745574

@@ -5583,22 +5583,22 @@ func TestExpendedPostingsCache(t *testing.T) {
55835583

55845584
if c.expectedHeadPostingCall > 0 || c.expectedBlockPostingCall > 0 {
55855585
metric := `
5586-
# HELP cortex_ingester_expanded_postings_cache_hits Total number of hit requests to the cache.
5587-
# TYPE cortex_ingester_expanded_postings_cache_hits counter
5586+
# HELP cortex_ingester_expanded_postings_cache_hits_total Total number of hit requests to the cache.
5587+
# TYPE cortex_ingester_expanded_postings_cache_hits_total counter
55885588
`
55895589
if c.expectedBlockPostingCall > 0 {
55905590
metric += `
5591-
cortex_ingester_expanded_postings_cache_hits{cache="block"} 4
5591+
cortex_ingester_expanded_postings_cache_hits_total{cache="block"} 4
55925592
`
55935593
}
55945594

55955595
if c.expectedHeadPostingCall > 0 {
55965596
metric += `
5597-
cortex_ingester_expanded_postings_cache_hits{cache="head"} 4
5597+
cortex_ingester_expanded_postings_cache_hits_total{cache="head"} 4
55985598
`
55995599
}
56005600

5601-
err = testutil.GatherAndCompare(r, bytes.NewBufferString(metric), "cortex_ingester_expanded_postings_cache_hits")
5601+
err = testutil.GatherAndCompare(r, bytes.NewBufferString(metric), "cortex_ingester_expanded_postings_cache_hits_total")
56025602
require.NoError(t, err)
56035603
}
56045604

@@ -5644,10 +5644,10 @@ func TestExpendedPostingsCache(t *testing.T) {
56445644
require.Equal(t, postingsForMatchersCalls.Load(), int64(c.expectedBlockPostingCall))
56455645
if c.cacheConfig.Head.Enabled {
56465646
err = testutil.GatherAndCompare(r, bytes.NewBufferString(`
5647-
# HELP cortex_ingester_expanded_postings_non_cacheable_queries Total number of non cacheable queries.
5648-
# TYPE cortex_ingester_expanded_postings_non_cacheable_queries counter
5649-
cortex_ingester_expanded_postings_non_cacheable_queries{cache="head"} 1
5650-
`), "cortex_ingester_expanded_postings_non_cacheable_queries")
5647+
# HELP cortex_ingester_expanded_postings_non_cacheable_queries_total Total number of non cacheable queries.
5648+
# TYPE cortex_ingester_expanded_postings_non_cacheable_queries_total counter
5649+
cortex_ingester_expanded_postings_non_cacheable_queries_total{cache="head"} 1
5650+
`), "cortex_ingester_expanded_postings_non_cacheable_queries_total")
56515651
require.NoError(t, err)
56525652
}
56535653

pkg/storage/tsdb/expanded_postings_cache.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@ type ExpandedPostingsCacheMetrics struct {
4747
func NewPostingCacheMetrics(r prometheus.Registerer) *ExpandedPostingsCacheMetrics {
4848
return &ExpandedPostingsCacheMetrics{
4949
CacheRequests: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
50-
Name: "cortex_ingester_expanded_postings_cache_requests",
50+
Name: "cortex_ingester_expanded_postings_cache_requests_total",
5151
Help: "Total number of requests to the cache.",
5252
}, []string{"cache"}),
5353
CacheHits: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
54-
Name: "cortex_ingester_expanded_postings_cache_hits",
54+
Name: "cortex_ingester_expanded_postings_cache_hits_total",
5555
Help: "Total number of hit requests to the cache.",
5656
}, []string{"cache"}),
5757
CacheMiss: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
58-
Name: "cortex_ingester_expanded_postings_cache_miss",
58+
Name: "cortex_ingester_expanded_postings_cache_miss_total",
5959
Help: "Total number of miss requests to the cache.",
6060
}, []string{"cache", "reason"}),
6161
CacheEvicts: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
62-
Name: "cortex_ingester_expanded_postings_cache_evicts",
62+
Name: "cortex_ingester_expanded_postings_cache_evicts_total",
6363
Help: "Total number of evictions in the cache, excluding items that got evicted due to TTL.",
6464
}, []string{"cache", "reason"}),
6565
NonCacheableQueries: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
66-
Name: "cortex_ingester_expanded_postings_non_cacheable_queries",
66+
Name: "cortex_ingester_expanded_postings_non_cacheable_queries_total",
6767
Help: "Total number of non cacheable queries.",
6868
}, []string{"cache"}),
6969
}

pkg/storage/tsdb/expanded_postings_cache_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ func TestFifoCacheExpire(t *testing.T) {
154154

155155
if c.expectedFinalItems != numberOfKeys {
156156
err := testutil.GatherAndCompare(r, bytes.NewBufferString(fmt.Sprintf(`
157-
# HELP cortex_ingester_expanded_postings_cache_evicts Total number of evictions in the cache, excluding items that got evicted due to TTL.
158-
# TYPE cortex_ingester_expanded_postings_cache_evicts counter
159-
cortex_ingester_expanded_postings_cache_evicts{cache="test",reason="full"} %v
160-
`, numberOfKeys-c.expectedFinalItems)), "cortex_ingester_expanded_postings_cache_evicts")
157+
# HELP cortex_ingester_expanded_postings_cache_evicts_total Total number of evictions in the cache, excluding items that got evicted due to TTL.
158+
# TYPE cortex_ingester_expanded_postings_cache_evicts_total counter
159+
cortex_ingester_expanded_postings_cache_evicts_total{cache="test",reason="full"} %v
160+
`, numberOfKeys-c.expectedFinalItems)), "cortex_ingester_expanded_postings_cache_evicts_total")
161161
require.NoError(t, err)
162162

163163
}
@@ -181,11 +181,11 @@ func TestFifoCacheExpire(t *testing.T) {
181181
}
182182

183183
err := testutil.GatherAndCompare(r, bytes.NewBufferString(fmt.Sprintf(`
184-
# HELP cortex_ingester_expanded_postings_cache_miss Total number of miss requests to the cache.
185-
# TYPE cortex_ingester_expanded_postings_cache_miss counter
186-
cortex_ingester_expanded_postings_cache_miss{cache="test",reason="expired"} %v
187-
cortex_ingester_expanded_postings_cache_miss{cache="test",reason="miss"} %v
188-
`, numberOfKeys, numberOfKeys)), "cortex_ingester_expanded_postings_cache_miss")
184+
# HELP cortex_ingester_expanded_postings_cache_miss_total Total number of miss requests to the cache.
185+
# TYPE cortex_ingester_expanded_postings_cache_miss_total counter
186+
cortex_ingester_expanded_postings_cache_miss_total{cache="test",reason="expired"} %v
187+
cortex_ingester_expanded_postings_cache_miss_total{cache="test",reason="miss"} %v
188+
`, numberOfKeys, numberOfKeys)), "cortex_ingester_expanded_postings_cache_miss_total")
189189
require.NoError(t, err)
190190

191191
cache.timeNow = func() time.Time {
@@ -198,10 +198,10 @@ func TestFifoCacheExpire(t *testing.T) {
198198

199199
// Should expire all keys expired keys
200200
err = testutil.GatherAndCompare(r, bytes.NewBufferString(fmt.Sprintf(`
201-
# HELP cortex_ingester_expanded_postings_cache_evicts Total number of evictions in the cache, excluding items that got evicted due to TTL.
202-
# TYPE cortex_ingester_expanded_postings_cache_evicts counter
203-
cortex_ingester_expanded_postings_cache_evicts{cache="test",reason="expired"} %v
204-
`, numberOfKeys)), "cortex_ingester_expanded_postings_cache_evicts")
201+
# HELP cortex_ingester_expanded_postings_cache_evicts_total Total number of evictions in the cache, excluding items that got evicted due to TTL.
202+
# TYPE cortex_ingester_expanded_postings_cache_evicts_total counter
203+
cortex_ingester_expanded_postings_cache_evicts_total{cache="test",reason="expired"} %v
204+
`, numberOfKeys)), "cortex_ingester_expanded_postings_cache_evicts_total")
205205
require.NoError(t, err)
206206
}
207207
})

0 commit comments

Comments
 (0)