From 3d979493adba1f58ce80e935b0b2f5b6b7cc6f16 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) --- 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 }