Skip to content

Commit af97eeb

Browse files
committed
Changing tracking metric type to histogram from counter
Signed-off-by: Paurush Garg <paurushg@amazon.com>
1 parent 93424f0 commit af97eeb

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* [ENHANCEMENT] Distributor: Validate metric name before removing empty labels. #7253
4747
* [ENHANCEMENT] Make cortex_ingester_tsdb_sample_ooo_delta metric per-tenant #7278
4848
* [ENHANCEMENT] Distributor: Add dimension `nhcb` to keep track of nhcb samples in `cortex_distributor_received_samples_total` and `cortex_distributor_samples_in_total` metrics.
49+
* [ENHANCEMENT] Ingester: Added `cortex_ingester_ingested_histogram_buckets` metric to track number of histogram buckets ingested per user. #7297
4950
* [BUGFIX] Distributor: If remote write v2 is disabled, explicitly return HTTP 415 (Unsupported Media Type) for Remote Write V2 requests instead of attempting to parse them as V1. #7238
5051
* [BUGFIX] Ring: Change DynamoDB KV to retry indefinitely for WatchKey. #7088
5152
* [BUGFIX] Ruler: Add XFunctions validation support. #7111

pkg/ingester/ingester.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,6 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte
13421342
succeededExemplarsCount = 0
13431343
failedExemplarsCount = 0
13441344
startAppend = time.Now()
1345-
succeededHistogramBucketsCount = 0
13461345
sampleOutOfBoundsCount = 0
13471346
sampleOutOfOrderCount = 0
13481347
sampleTooOldCount = 0
@@ -1508,7 +1507,7 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte
15081507
if ref != 0 {
15091508
if _, err = app.AppendHistogram(ref, copiedLabels, hp.TimestampMs, h, fh); err == nil {
15101509
succeededHistogramsCount++
1511-
succeededHistogramBucketsCount += hp.BucketCount()
1510+
i.metrics.ingestedHistogramBuckets.WithLabelValues(userID).Observe(float64(hp.BucketCount()))
15121511
continue
15131512
}
15141513
} else {
@@ -1520,7 +1519,7 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte
15201519
newSeries = append(newSeries, copiedLabels)
15211520
}
15221521
succeededHistogramsCount++
1523-
succeededHistogramBucketsCount += hp.BucketCount()
1522+
i.metrics.ingestedHistogramBuckets.WithLabelValues(userID).Observe(float64(hp.BucketCount()))
15241523
continue
15251524
}
15261525
}
@@ -1615,7 +1614,6 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte
16151614
i.metrics.ingestedSamplesFail.Add(float64(failedSamplesCount))
16161615
i.metrics.ingestedHistograms.Add(float64(succeededHistogramsCount))
16171616
i.metrics.ingestedHistogramsFail.Add(float64(failedHistogramsCount))
1618-
i.metrics.ingestedHistogramBuckets.WithLabelValues(userID).Add(float64(succeededHistogramBucketsCount))
16191617
i.metrics.ingestedExemplars.Add(float64(succeededExemplarsCount))
16201618
i.metrics.ingestedExemplarsFail.Add(float64(failedExemplarsCount))
16211619

pkg/ingester/metrics.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type ingesterMetrics struct {
3838
ingestedHistogramsFail prometheus.Counter
3939
ingestedExemplarsFail prometheus.Counter
4040
ingestedMetadataFail prometheus.Counter
41-
ingestedHistogramBuckets *prometheus.CounterVec
41+
ingestedHistogramBuckets *prometheus.HistogramVec
4242
oooLabelsTotal *prometheus.CounterVec
4343
queries prometheus.Counter
4444
queriedSamples prometheus.Histogram
@@ -131,9 +131,13 @@ func newIngesterMetrics(r prometheus.Registerer,
131131
Name: "cortex_ingester_ingested_metadata_failures_total",
132132
Help: "The total number of metadata that errored on ingestion.",
133133
}),
134-
ingestedHistogramBuckets: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
135-
Name: "cortex_ingester_ingested_histogram_buckets_total",
136-
Help: "The total number of histogram buckets ingested per user.",
134+
ingestedHistogramBuckets: promauto.With(r).NewHistogramVec(prometheus.HistogramOpts{
135+
Name: "cortex_ingester_ingested_histogram_buckets",
136+
Help: "The number of ingested native histogram buckets per user.",
137+
NativeHistogramBucketFactor: 1.1,
138+
NativeHistogramMaxBucketNumber: 100,
139+
NativeHistogramMinResetDuration: 1,
140+
Buckets: prometheus.ExponentialBuckets(1, 2, 10), // 1 to 512 buckets
137141
}, []string{"user"}),
138142
oooLabelsTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
139143
Name: "cortex_ingester_out_of_order_labels_total",

pkg/ingester/metrics_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ func TestIngesterMetrics(t *testing.T) {
157157
# HELP cortex_ingester_ingested_native_histograms_failures_total The total number of native histograms that errored on ingestion.
158158
# TYPE cortex_ingester_ingested_native_histograms_failures_total counter
159159
cortex_ingester_ingested_native_histograms_failures_total 0
160+
# HELP cortex_ingester_ingested_histogram_buckets The number of ingested native histogram buckets per user.
161+
# TYPE cortex_ingester_ingested_histogram_buckets histogram
160162
# HELP cortex_ingester_ingestion_rate_samples_per_second Current ingestion rate in samples/sec that ingester is using to limit access.
161163
# TYPE cortex_ingester_ingestion_rate_samples_per_second gauge
162164
cortex_ingester_ingestion_rate_samples_per_second 0

0 commit comments

Comments
 (0)