@@ -167,10 +167,11 @@ type Distributor struct {
167
167
RequestParserWrapper push.RequestParserWrapper
168
168
169
169
// metrics
170
- ingesterAppends * prometheus.CounterVec
171
- ingesterAppendTimeouts * prometheus.CounterVec
172
- replicationFactor prometheus.Gauge
173
- streamShardCount prometheus.Counter
170
+ ingesterAppends * prometheus.CounterVec
171
+ ingesterAppendTimeouts * prometheus.CounterVec
172
+ replicationFactor prometheus.Gauge
173
+ streamShardCount prometheus.Counter
174
+ tenantPushSanitizedStructuredMetadata * prometheus.CounterVec
174
175
175
176
usageTracker push.UsageTracker
176
177
ingesterTasks chan pushIngesterTask
@@ -284,6 +285,11 @@ func New(
284
285
Name : "stream_sharding_count" ,
285
286
Help : "Total number of times the distributor has sharded streams" ,
286
287
}),
288
+ tenantPushSanitizedStructuredMetadata : promauto .With (registerer ).NewCounterVec (prometheus.CounterOpts {
289
+ Namespace : constants .Loki ,
290
+ Name : "distributor_push_structured_metadata_sanitized_total" ,
291
+ Help : "The total number of times we've had to sanitize structured metadata (names or values) at ingestion time per tenant." ,
292
+ }, []string {"tenant" }),
287
293
kafkaAppends : promauto .With (registerer ).NewCounterVec (prometheus.CounterOpts {
288
294
Namespace : constants .Loki ,
289
295
Name : "distributor_kafka_appends_total" ,
@@ -527,11 +533,17 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
527
533
continue
528
534
}
529
535
536
+ var normalized string
530
537
structuredMetadata := logproto .FromLabelAdaptersToLabels (entry .StructuredMetadata )
531
538
for i := range entry .StructuredMetadata {
532
- structuredMetadata [i ].Name = otlptranslate .NormalizeLabel (structuredMetadata [i ].Name )
539
+ normalized = otlptranslate .NormalizeLabel (structuredMetadata [i ].Name )
540
+ if normalized != structuredMetadata [i ].Name {
541
+ structuredMetadata [i ].Name = normalized
542
+ d .tenantPushSanitizedStructuredMetadata .WithLabelValues (tenantID ).Inc ()
543
+ }
533
544
if strings .ContainsRune (structuredMetadata [i ].Value , utf8 .RuneError ) {
534
545
structuredMetadata [i ].Value = strings .Map (removeInvalidUtf , structuredMetadata [i ].Value )
546
+ d .tenantPushSanitizedStructuredMetadata .WithLabelValues (tenantID ).Inc ()
535
547
}
536
548
}
537
549
if shouldDiscoverLevels {
0 commit comments