From ac40bdc52e8ced5afc9605cea33b4fe32d998797 Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Fri, 1 Oct 2021 15:10:25 -0600 Subject: [PATCH] fix: procstat missing tags in procstat_lookup metric (#9808) In #9488 the way that tags were built for procstat_lookup was changed and it was only including the pid_finder and result tags. This is not consistent with the documentation and is a regression from how they were previously constructed. Becuase of the large change to how procstat metrics are gathered, this will use one of the process metric's tags as a basis for the tags for procstat_lookup. Resolves: #9793 --- plugins/inputs/procstat/procstat.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/procstat/procstat.go b/plugins/inputs/procstat/procstat.go index ce29a0846..7b2ffba26 100644 --- a/plugins/inputs/procstat/procstat.go +++ b/plugins/inputs/procstat/procstat.go @@ -154,9 +154,10 @@ func (p *Procstat) Gather(acc telegraf.Accumulator) error { } } + tags := make(map[string]string) p.procs = newProcs - for _, proc := range p.procs { + tags = proc.Tags() p.addMetric(proc, acc, now) } @@ -165,7 +166,7 @@ func (p *Procstat) Gather(acc telegraf.Accumulator) error { "running": len(p.procs), "result_code": 0, } - tags := make(map[string]string) + tags["pid_finder"] = p.PidFinder tags["result"] = "success" acc.AddFields("procstat_lookup", fields, tags, now)