diff --git a/go.mod b/go.mod index c7f82c28c1b56..fa1ac6d5af3df 100644 --- a/go.mod +++ b/go.mod @@ -174,7 +174,7 @@ require ( github.com/prometheus-community/pro-bing v0.7.0 github.com/prometheus/client_golang v1.23.0 github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.65.0 + github.com/prometheus/common v0.66.1 github.com/prometheus/procfs v0.17.0 github.com/prometheus/prometheus v0.54.1 github.com/rabbitmq/amqp091-go v1.10.0 diff --git a/go.sum b/go.sum index 9e6cfdb189ac5..f10cfb9317450 100644 --- a/go.sum +++ b/go.sum @@ -2169,8 +2169,8 @@ github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7q github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE= -github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= +github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= +github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/plugins/parsers/prometheus/parser.go b/plugins/parsers/prometheus/parser.go index e2d5a937c675f..e378db644e858 100644 --- a/plugins/parsers/prometheus/parser.go +++ b/plugins/parsers/prometheus/parser.go @@ -33,7 +33,7 @@ func (p *Parser) SetDefaultTags(tags map[string]string) { func (p *Parser) Parse(data []byte) ([]telegraf.Metric, error) { // Determine the metric transport-type derived from the response header and // create a matching decoder. - format := expfmt.NewFormat(expfmt.TypeProtoCompact) + format := expfmt.NewFormat(expfmt.TypeTextPlain) if len(p.Header) > 0 { format = expfmt.ResponseFormat(p.Header) switch format.FormatType() { @@ -43,6 +43,11 @@ func (p *Parser) Parse(data []byte) ([]telegraf.Metric, error) { if !bytes.HasSuffix(data, []byte("\n")) { data = append(data, []byte("\n")...) } + fallthrough + case expfmt.TypeProtoCompact: + // As of prometheus common 0.66.0, ProtoText and ProtoCompact are disallowed from the decoder. Before this + // version, it used to fall back to TextPlain, so we do that here instead to mimic the old behavior. + format = expfmt.NewFormat(expfmt.TypeTextPlain) case expfmt.TypeUnknown: p.Log.Debugf("Unknown format %q... Trying to continue...", p.Header.Get("Content-Type")) } diff --git a/plugins/serializers/prometheus/convert.go b/plugins/serializers/prometheus/convert.go index a1d7fc4d97de9..62019f5dbf30d 100644 --- a/plugins/serializers/prometheus/convert.go +++ b/plugins/serializers/prometheus/convert.go @@ -86,7 +86,7 @@ func sanitize(name string, table table) (string, bool) { // SanitizeMetricName checks if the name is a valid Prometheus metric name. // If not, it attempts to replace invalid runes with an underscore to create a valid name. func SanitizeMetricName(name string) (string, bool) { - if model.IsValidLegacyMetricName(name) { + if model.LegacyValidation.IsValidMetricName(name) { return name, true } return sanitize(name, metricNameTable) @@ -95,7 +95,7 @@ func SanitizeMetricName(name string) (string, bool) { // SanitizeLabelName checks if the name is a valid Prometheus label name. // If not, it attempts to replace invalid runes with an underscore to create a valid name. func SanitizeLabelName(name string) (string, bool) { - if model.LabelName(name).IsValidLegacy() { + if model.LegacyValidation.IsValidLabelName(name) { return name, true } return sanitize(name, labelNameTable)