Skip to content

Commit

Permalink
Merge pull request #168 from xginn8/start_time_uptime
Browse files Browse the repository at this point in the history
Add start_time_seconds
  • Loading branch information
oliver006 authored Jun 23, 2018
2 parents ce489e3 + 4ce20da commit 23970fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ func (e *Exporter) initGauges() {
Name: "slave_info",
Help: "Information about the Redis slave",
}, []string{"addr", "alias", "master_host", "master_port", "read_only"})
e.metrics["start_time_seconds"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: e.namespace,
Name: "start_time_seconds",
Help: "Start time of the Redis instance since unix epoch in seconds.",
}, []string{"addr", "alias"})
e.metrics["master_link_up"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: e.namespace,
Name: "master_link_up",
Expand Down Expand Up @@ -465,6 +470,13 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
e.metricsMtx.RUnlock()
continue
}
if fieldKey == "uptime_in_seconds" {
if uptime, err := extractVal(fieldValue); err != nil {
e.metricsMtx.RLock()
e.metrics["start_time_seconds"].WithLabelValues(addr, alias).Set(float64(time.Now().Unix()) - uptime)
e.metricsMtx.RUnlock()
}
}

if slaveOffset, slaveIp, slaveState, ok := parseConnectedSlaveString(fieldKey, fieldValue); ok {
e.metricsMtx.RLock()
Expand Down

0 comments on commit 23970fd

Please sign in to comment.