diff --git a/storage/remote/otlptranslator/prometheusremotewrite/helper.go b/storage/remote/otlptranslator/prometheusremotewrite/helper.go index 4c50099e06..b8c7817a84 100644 --- a/storage/remote/otlptranslator/prometheusremotewrite/helper.go +++ b/storage/remote/otlptranslator/prometheusremotewrite/helper.go @@ -88,7 +88,11 @@ func (c *PrometheusConverter) createAttributes(resource pcommon.Resource, attrib c.scratchBuilder.Sort() sortedLabels := c.scratchBuilder.Labels() - labelNamer := otlptranslator.LabelNamer{UTF8Allowed: settings.AllowUTF8} + labelNamer := otlptranslator.LabelNamer{ + UTF8Allowed: settings.AllowUTF8, + UnderscoreLabelSanitization: settings.LabelNameUnderscoreLabelSanitization, + PreserveMultipleUnderscores: settings.LabelNamePreserveMultipleUnderscores, + } if settings.AllowUTF8 { // UTF8 is allowed, so conflicts aren't possible. diff --git a/storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go b/storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go index 3dfd54cc9f..7083ce0885 100644 --- a/storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go +++ b/storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go @@ -54,6 +54,12 @@ type Settings struct { // PromoteScopeMetadata controls whether to promote OTel scope metadata to metric labels. PromoteScopeMetadata bool EnableTypeAndUnitLabels bool + // LabelNameUnderscoreLabelSanitization controls whether to enable prepending of 'key' to labels + // starting with '_'. Reserved labels starting with `__` are not modified. + LabelNameUnderscoreLabelSanitization bool + // LabelNamePreserveMultipleUnderscores enables preserving of multiple + // consecutive underscores in label names when AllowUTF8 is false. + LabelNamePreserveMultipleUnderscores bool } // PrometheusConverter converts from OTel write format to Prometheus remote write format.