Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 6 additions & 1 deletion plugins/parsers/prometheus/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProtoCompact is no longer a valid type to decode from as of prometheus/common#808, so I changed this default to TextPlain since this is what it would fall back to before

if len(p.Header) > 0 {
format = expfmt.ResponseFormat(p.Header)
switch format.FormatType() {
Expand All @@ -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"))
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/serializers/prometheus/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading