Skip to content

Commit

Permalink
Merge pull request #203 from SuperQ/cleanup
Browse files Browse the repository at this point in the history
Cleanup some metrics
  • Loading branch information
oliver006 authored Dec 3, 2018
2 parents 77c2c78 + e2a2611 commit 10045b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type Exporter struct {
scrapeErrors prometheus.Gauge
totalScrapes prometheus.Counter
metrics map[string]*prometheus.GaugeVec
metricsMtx sync.RWMutex

metricsMtx sync.RWMutex
sync.RWMutex
}

Expand All @@ -71,13 +72,14 @@ var (
"blocked_clients": "blocked_clients",

// # Memory
"used_memory": "memory_used_bytes",
"used_memory_rss": "memory_used_rss_bytes",
"used_memory_peak": "memory_used_peak_bytes",
"used_memory_lua": "memory_used_lua_bytes",
"total_system_memory": "total_system_memory_bytes",
"maxmemory": "memory_max_bytes",
"mem_fragmentation_ratio": "memory_fragmentation_ratio",
"allocator_active": "allocator_active_bytes",
"allocator_allocated": "allocator_allocated_bytes",
"allocator_resident": "allocator_resident_bytes",
"used_memory": "memory_used_bytes",
"used_memory_rss": "memory_used_rss_bytes",
"used_memory_peak": "memory_used_peak_bytes",
"used_memory_lua": "memory_used_lua_bytes",
"maxmemory": "memory_max_bytes",

// # Persistence
"rdb_changes_since_last_save": "rdb_changes_since_last_save",
Expand Down Expand Up @@ -192,15 +194,14 @@ func (e *Exporter) initGauges() {
Help: "Length of the last latency spike in milliseconds",
}, []string{"addr", "alias", "event_name"})

// Emulate a Summary.
e.metrics["command_call_duration_seconds_count"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
e.metrics["commands_total"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: e.namespace,
Name: "command_call_duration_seconds_count",
Name: "commands_total",
Help: "Total number of calls per command",
}, []string{"addr", "alias", "cmd"})
e.metrics["command_call_duration_seconds_sum"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
e.metrics["commands_duration_seconds_total"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: e.namespace,
Name: "command_call_duration_seconds_sum",
Name: "commands_duration_seconds_total",
Help: "Total amount of time in seconds spent per command",
}, []string{"addr", "alias", "cmd"})
e.metrics["slowlog_length"] = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Expand Down Expand Up @@ -566,8 +567,8 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
}

e.metricsMtx.RLock()
e.metrics["command_call_duration_seconds_count"].WithLabelValues(addr, alias, cmd).Set(calls)
e.metrics["command_call_duration_seconds_sum"].WithLabelValues(addr, alias, cmd).Set(usecTotal / 1e6)
e.metrics["commands_total"].WithLabelValues(addr, alias, cmd).Set(calls)
e.metrics["commands_duration_seconds_total"].WithLabelValues(addr, alias, cmd).Set(usecTotal / 1e6)
e.metricsMtx.RUnlock()
continue
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ func TestCommandStats(t *testing.T) {
close(chM)
}()

want := map[string]bool{"test_command_call_duration_seconds_count": false, "test_command_call_duration_seconds_sum": false}
want := map[string]bool{"test_commands_duration_seconds_total": false, "test_commands_total": false}

for m := range chM {
switch m.(type) {
Expand Down

0 comments on commit 10045b8

Please sign in to comment.