Skip to content
Closed
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
7 changes: 7 additions & 0 deletions pkg/ingester/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ type tsdbMetrics struct {
tsdbHeadTruncateFail *prometheus.Desc
tsdbHeadTruncateTotal *prometheus.Desc
tsdbHeadGcDuration *prometheus.Desc
tsdbHeadSeries *prometheus.Desc
tsdbActiveAppenders *prometheus.Desc
tsdbSeriesNotFound *prometheus.Desc
tsdbChunks *prometheus.Desc
Expand Down Expand Up @@ -454,6 +455,10 @@ func newTSDBMetrics(r prometheus.Registerer) *tsdbMetrics {
"cortex_ingester_tsdb_head_gc_duration_seconds",
"Runtime of garbage collection in the TSDB head.",
nil, nil),
tsdbHeadSeries: prometheus.NewDesc(
"cortex_ingester_tsdb_head_series",
"Total number of series in the TSDB head block.",
[]string{"user"}, nil),
tsdbActiveAppenders: prometheus.NewDesc(
"cortex_ingester_tsdb_head_active_appenders",
"Number of currently active TSDB appender transactions.",
Expand Down Expand Up @@ -573,6 +578,7 @@ func (sm *tsdbMetrics) Describe(out chan<- *prometheus.Desc) {
out <- sm.tsdbHeadTruncateFail
out <- sm.tsdbHeadTruncateTotal
out <- sm.tsdbHeadGcDuration
out <- sm.tsdbHeadSeries
out <- sm.tsdbActiveAppenders
out <- sm.tsdbSeriesNotFound
out <- sm.tsdbChunks
Expand Down Expand Up @@ -622,6 +628,7 @@ func (sm *tsdbMetrics) Collect(out chan<- prometheus.Metric) {
data.SendSumOfCounters(out, sm.tsdbHeadTruncateFail, "prometheus_tsdb_head_truncations_failed_total")
data.SendSumOfCounters(out, sm.tsdbHeadTruncateTotal, "prometheus_tsdb_head_truncations_total")
data.SendSumOfSummaries(out, sm.tsdbHeadGcDuration, "prometheus_tsdb_head_gc_duration_seconds")
data.SendSumOfGaugesPerUser(out, sm.tsdbHeadSeries, "prometheus_tsdb_head_series")
data.SendSumOfGauges(out, sm.tsdbActiveAppenders, "prometheus_tsdb_head_active_appenders")
data.SendSumOfCounters(out, sm.tsdbSeriesNotFound, "prometheus_tsdb_head_series_not_found_total")
data.SendSumOfGauges(out, sm.tsdbChunks, "prometheus_tsdb_head_chunks")
Expand Down
19 changes: 19 additions & 0 deletions pkg/ingester/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ func TestTSDBMetrics(t *testing.T) {
# TYPE cortex_ingester_tsdb_head_active_appenders gauge
cortex_ingester_tsdb_head_active_appenders 1982620

# HELP cortex_ingester_tsdb_head_series Total number of series in the TSDB head block.
# TYPE cortex_ingester_tsdb_head_series gauge
# 20 * (12345 and 85787 and 999 respectively)
cortex_ingester_tsdb_head_series{user="user1"} 246900
cortex_ingester_tsdb_head_series{user="user2"} 1715740
cortex_ingester_tsdb_head_series{user="user3"} 19980

# HELP cortex_ingester_tsdb_head_series_not_found_total Total number of TSDB requests for series that were not found.
# TYPE cortex_ingester_tsdb_head_series_not_found_total counter
cortex_ingester_tsdb_head_series_not_found_total 2081751
Expand Down Expand Up @@ -351,6 +358,12 @@ func TestTSDBMetricsWithRemoval(t *testing.T) {
# TYPE cortex_ingester_tsdb_head_active_appenders gauge
cortex_ingester_tsdb_head_active_appenders 1962640

# HELP cortex_ingester_tsdb_head_series Total number of series in the TSDB head block.
# TYPE cortex_ingester_tsdb_head_series gauge
# 20 * (12345 and 85787 and 999 respectively)
cortex_ingester_tsdb_head_series{user="user1"} 246900
cortex_ingester_tsdb_head_series{user="user2"} 1715740

# HELP cortex_ingester_tsdb_head_series_not_found_total Total number of TSDB requests for series that were not found.
# TYPE cortex_ingester_tsdb_head_series_not_found_total counter
cortex_ingester_tsdb_head_series_not_found_total 2081751
Expand Down Expand Up @@ -542,6 +555,12 @@ func populateTSDBMetrics(base float64) *prometheus.Registry {
})
checkpointCreationTotal.Add(19 * base)

series := promauto.With(r).NewGauge(prometheus.GaugeOpts{
Name: "prometheus_tsdb_head_series",
Help: "Total number of series in the head block.",
})
series.Set(20 * base)

activeAppenders := promauto.With(r).NewGauge(prometheus.GaugeOpts{
Name: "prometheus_tsdb_head_active_appenders",
Help: "Number of currently active appender transactions",
Expand Down