Skip to content

Commit

Permalink
fix(serializers.template): Unwrap metrics if required (influxdata#15740)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianrothbucher authored Aug 14, 2024
1 parent fc19891 commit 371b988
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/serializers/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ func (s *Serializer) Init() error {
}

func (s *Serializer) Serialize(metric telegraf.Metric) ([]byte, error) {
m, ok := metric.(telegraf.TemplateMetric)
metricPlain := metric
if wm, ok := metric.(telegraf.UnwrappableMetric); ok {
metricPlain = wm.Unwrap()
}
m, ok := metricPlain.(telegraf.TemplateMetric)
if !ok {
s.Log.Errorf("metric of type %T is not a template metric", metric)
s.Log.Errorf("metric of type %T is not a template metric", metricPlain)
return nil, nil
}
var b bytes.Buffer
Expand Down

0 comments on commit 371b988

Please sign in to comment.