Use same timestamp for fields in system input (#4078)
This commit is contained in:
parent
06671777e9
commit
ec47cab950
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/host"
|
"github.com/shirou/gopsutil/host"
|
||||||
"github.com/shirou/gopsutil/load"
|
"github.com/shirou/gopsutil/load"
|
||||||
|
@ -43,7 +44,8 @@ func (_ *SystemStats) Gather(acc telegraf.Accumulator) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.AddGauge("system", fields, nil)
|
now := time.Now()
|
||||||
|
acc.AddGauge("system", fields, nil, now)
|
||||||
|
|
||||||
hostinfo, err := host.Info()
|
hostinfo, err := host.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -52,10 +54,10 @@ func (_ *SystemStats) Gather(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
acc.AddCounter("system", map[string]interface{}{
|
acc.AddCounter("system", map[string]interface{}{
|
||||||
"uptime": hostinfo.Uptime,
|
"uptime": hostinfo.Uptime,
|
||||||
}, nil)
|
}, nil, now)
|
||||||
acc.AddFields("system", map[string]interface{}{
|
acc.AddFields("system", map[string]interface{}{
|
||||||
"uptime_format": format_uptime(hostinfo.Uptime),
|
"uptime_format": format_uptime(hostinfo.Uptime),
|
||||||
}, nil)
|
}, nil, now)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue