Skip to content

Commit 0f2fce5

Browse files
author
Xuewei Zhang
committed
Change host/uptime to GAUGE metrics
1 parent 42285cb commit 0f2fce5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pkg/systemstatsmonitor/host_collector.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
type hostCollector struct {
2929
tags map[string]string
3030
uptime *metrics.Int64Metric
31-
lastUptime int64
3231
}
3332

3433
func NewHostCollectorOrDie(hostConfig *ssmtypes.HostStatsConfig) *hostCollector {
@@ -52,7 +51,7 @@ func NewHostCollectorOrDie(hostConfig *ssmtypes.HostStatsConfig) *hostCollector
5251
hostConfig.MetricsConfigs["host/uptime"].DisplayName,
5352
"The uptime of the operating system",
5453
"second",
55-
metrics.Sum,
54+
metrics.LastValue,
5655
[]string{"kernel_version", "os_version"})
5756
if err != nil {
5857
glog.Fatalf("Error initializing metric for host/uptime: %v", err)
@@ -72,10 +71,8 @@ func (hc *hostCollector) collect() {
7271
glog.Errorf("Failed to retrieve uptime of the host: %v", err)
7372
return
7473
}
75-
uptimeSeconds := int64(uptime)
7674

7775
if hc.uptime != nil {
78-
hc.uptime.Record(hc.tags, uptimeSeconds-hc.lastUptime)
76+
hc.uptime.Record(hc.tags, int64(uptime))
7977
}
80-
hc.lastUptime = uptimeSeconds
81-
}
78+
}

0 commit comments

Comments
 (0)