From d45b64d7a0c890d2c945e2929bd6fa5f90f6f22e Mon Sep 17 00:00:00 2001 From: Vincent Caron Date: Fri, 27 Apr 2018 23:55:10 +0200 Subject: [PATCH] Use same timestamp for fields in system input (#4078) (cherry picked from commit ec47cab950cb733cb56b10ba50313f0d167fff01) --- plugins/inputs/system/system.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/inputs/system/system.go b/plugins/inputs/system/system.go index fd204d6af..ad17c56ed 100644 --- a/plugins/inputs/system/system.go +++ b/plugins/inputs/system/system.go @@ -7,6 +7,7 @@ import ( "os" "runtime" "strings" + "time" "github.com/shirou/gopsutil/host" "github.com/shirou/gopsutil/load" @@ -43,7 +44,8 @@ func (_ *SystemStats) Gather(acc telegraf.Accumulator) error { return err } - acc.AddGauge("system", fields, nil) + now := time.Now() + acc.AddGauge("system", fields, nil, now) hostinfo, err := host.Info() if err != nil { @@ -52,10 +54,10 @@ func (_ *SystemStats) Gather(acc telegraf.Accumulator) error { acc.AddCounter("system", map[string]interface{}{ "uptime": hostinfo.Uptime, - }, nil) + }, nil, now) acc.AddFields("system", map[string]interface{}{ "uptime_format": format_uptime(hostinfo.Uptime), - }, nil) + }, nil, now) return nil }