Skip to content
Snippets Groups Projects
Commit f6267058 authored by Christian Groschupp's avatar Christian Groschupp
Browse files

Add slowlog_last_id metric.

parent 824dc556
No related branches found
No related tags found
No related merge requests found
Loading
@@ -200,6 +200,11 @@ func (e *Exporter) initGauges() {
Loading
@@ -200,6 +200,11 @@ func (e *Exporter) initGauges() {
Name: "slowlog_length", Name: "slowlog_length",
Help: "Total slowlog", Help: "Total slowlog",
}, []string{"addr", "alias"}) }, []string{"addr", "alias"})
e.metrics["slowlog_last_id"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: e.namespace,
Name: "slowlog_last_id",
Help: "Last id of slowlog",
}, []string{"addr", "alias"})
} }
   
// splitKeyArgs splits a command-line supplied argument into a slice of dbKeyPairs. // splitKeyArgs splits a command-line supplied argument into a slice of dbKeyPairs.
Loading
@@ -874,6 +879,20 @@ func (e *Exporter) scrapeRedisHost(scrapes chan<- scrapeResult, addr string, idx
Loading
@@ -874,6 +879,20 @@ func (e *Exporter) scrapeRedisHost(scrapes chan<- scrapeResult, addr string, idx
e.metricsMtx.RUnlock() e.metricsMtx.RUnlock()
} }
   
if values, err := redis.Values(c.Do("SLOWLOG", "GET", "1")); err == nil {
var slowlogLastId int64 = 0
if len(values) > 0 {
if values, err = redis.Values(values[0], err); err == nil && len(values) > 0 {
slowlogLastId = values[0].(int64)
}
}
e.metricsMtx.RLock()
e.metrics["slowlog_last_id"].WithLabelValues(addr, e.redis.Aliases[idx]).Set(float64(slowlogLastId))
e.metricsMtx.RUnlock()
}
log.Debugf("scrapeRedisHost() done") log.Debugf("scrapeRedisHost() done")
return nil return nil
} }
Loading
Loading
Loading
@@ -345,6 +345,7 @@ func TestExporterMetrics(t *testing.T) {
Loading
@@ -345,6 +345,7 @@ func TestExporterMetrics(t *testing.T) {
"config_maxmemory", // testing config extraction "config_maxmemory", // testing config extraction
"config_maxclients", // testing config extraction "config_maxclients", // testing config extraction
"slowlog_length", "slowlog_length",
"slowlog_last_id",
"start_time_seconds", "start_time_seconds",
"uptime_in_seconds", "uptime_in_seconds",
} }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment