Skip to content

Commit

Permalink
Properly decode uptime from redis (#170)
Browse files Browse the repository at this point in the history
* Properly decode uptime from redis
* Add uptime_in_seconds & start_time_seconds to expected metrics
  • Loading branch information
xginn8 authored and oliver006 committed Jun 25, 2018
1 parent a8c01c5 commit 3150962
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
continue
}
if fieldKey == "uptime_in_seconds" {
if uptime, err := extractVal(fieldValue); err != nil {
if uptime, err := strconv.ParseFloat(fieldValue, 64); err == nil {
e.metricsMtx.RLock()
e.metrics["start_time_seconds"].WithLabelValues(addr, alias).Set(float64(time.Now().Unix()) - uptime)
e.metricsMtx.RUnlock()
Expand Down
2 changes: 2 additions & 0 deletions exporter/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ func TestExporterMetrics(t *testing.T) {
"config_maxmemory", // testing config extraction
"config_maxclients", // testing config extraction
"slowlog_length",
"start_time_seconds",
"uptime_in_seconds",
}

for _, k := range wantKeys {
Expand Down

0 comments on commit 3150962

Please sign in to comment.