Skip to content

Commit

Permalink
OTLP: Add metrics to track otlp request samples per batch
Browse files Browse the repository at this point in the history
  • Loading branch information
ying-jeanne committed Jun 4, 2024
1 parent 011c02f commit a63fb85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* [FEATURE] Query-frontend, querier: new experimental `/cardinality/active_native_histogram_metrics` API to get active native histogram metric names with statistics about active native histogram buckets. #7982 #7986 #8008
* [FEATURE] Alertmanager: Added `-alertmanager.max-silences-count` and `-alertmanager.max-silence-size-bytes` to set limits on per tenant silences. Disabled by default. #6898
* [FEATURE] Ingester: add experimental support for the server-side circuit breakers when writing to ingesters. This can be enabled using `-ingester.circuit-breaker.enabled` option. Further `-ingester.circuit-breaker.*` options for configuring circuit-breaker are available. Added metrics `cortex_ingester_circuit_breaker_results_total`, `cortex_ingester_circuit_breaker_transitions_total` and `cortex_ingester_circuit_breaker_current_state`. #8180
* [ENHANCEMENT] Distributor: add metrics `cortex_distributor_otlp_samples_per_batch` to track samples per batch in otlp request. #8265
* [ENHANCEMENT] Reduced memory allocations in functions used to propagate contextual information between gRPC calls. #7529
* [ENHANCEMENT] Distributor: add experimental limit for exemplars per series per request, enabled with `-distributor.max-exemplars-per-series-per-request`, the number of discarded exemplars are tracked with `cortex_discarded_exemplars_total{reason="too_many_exemplars_per_series_per_request"}` #7989 #8010
* [ENHANCEMENT] Store-gateway: merge series from different blocks concurrently. #7456
Expand Down
19 changes: 17 additions & 2 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ const (
)

type PushMetrics struct {
otlpRequestCounter *prometheus.CounterVec
uncompressedBodySize *prometheus.HistogramVec
otlpRequestCounter *prometheus.CounterVec
uncompressedBodySize *prometheus.HistogramVec
otlpIncomingSamplesPerBatch *prometheus.HistogramVec
}

func newPushMetrics(reg prometheus.Registerer) *PushMetrics {
Expand All @@ -281,6 +282,13 @@ func newPushMetrics(reg prometheus.Registerer) *PushMetrics {
NativeHistogramMinResetDuration: 1 * time.Hour,
NativeHistogramMaxBucketNumber: 100,
}, []string{"user"}),
otlpIncomingSamplesPerBatch: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
Name: "cortex_distributor_otlp_samples_per_batch",
Help: "Number of samples per batch in otlp request.",
NativeHistogramBucketFactor: 2,
NativeHistogramMinResetDuration: 1 * time.Hour,
NativeHistogramMaxBucketNumber: 100,
}, []string{"user"}),
}
}

Expand All @@ -296,9 +304,16 @@ func (m *PushMetrics) ObserveUncompressedBodySize(user string, size float64) {
}
}

func (m *PushMetrics) ObserveOtlpIncomingSamplesPerBatch(user string, count float64) {
if m != nil {
m.otlpIncomingSamplesPerBatch.WithLabelValues(user).Observe(count)
}
}

func (m *PushMetrics) deleteUserMetrics(user string) {
m.otlpRequestCounter.DeleteLabelValues(user)
m.uncompressedBodySize.DeleteLabelValues(user)
m.otlpIncomingSamplesPerBatch.DeleteLabelValues(user)
}

// New constructs a new Distributor
Expand Down
2 changes: 2 additions & 0 deletions pkg/distributor/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ func OTLPHandler(
"exemplar_count", exemplarCount,
)

pushMetrics.ObserveOtlpIncomingSamplesPerBatch(tenantID, float64(sampleCount))

req.Timeseries = metrics

if enableOtelMetadataStorage {
Expand Down

0 comments on commit a63fb85

Please sign in to comment.