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: Initialise and correctly register all index cache metrics. #1069

Merged
merged 1 commit into from
Apr 23, 2019
Merged
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
20 changes: 15 additions & 5 deletions pkg/store/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,50 @@ func newIndexCache(reg prometheus.Registerer, maxBytes uint64) (*indexCache, err
Name: "thanos_store_index_cache_items_evicted_total",
Help: "Total number of items that were evicted from the index cache.",
}, []string{"item_type"})
evicted.WithLabelValues(cacheTypePostings)
evicted.WithLabelValues(cacheTypeSeries)

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

c.requests = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "thanos_store_index_cache_requests_total",
Help: "Total number of requests to the cache.",
}, []string{"item_type"})
c.requests.WithLabelValues(cacheTypePostings)
c.requests.WithLabelValues(cacheTypeSeries)

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

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

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

c.currentSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "thanos_store_index_cache_items_size_bytes",
Help: "Current byte size of items in the index cache.",
}, []string{"item_type"})

// Initialize eviction metric with 0.
evicted.WithLabelValues(cacheTypePostings)
evicted.WithLabelValues(cacheTypeSeries)
c.currentSize.WithLabelValues(cacheTypePostings)
c.currentSize.WithLabelValues(cacheTypeSeries)

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