Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup some metrics #203

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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