Skip to content

Commit

Permalink
Merge pull request #52 from oliver006/oh_fix_check_keys
Browse files Browse the repository at this point in the history
add "addr" to check key metrics
  • Loading branch information
oliver006 authored Feb 10, 2017
2 parents 478bfcd + fd68622 commit 776f426
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ var (
"used_cpu_user_children": "used_cpu_user_children",

// # Cluster
"cluster_stats_messages_sent": "cluster_messages_sent_total",
"cluster_stats_messages_received": "cluster_messages_received_total",
"cluster_stats_messages_sent": "cluster_messages_sent_total",
"cluster_stats_messages_received": "cluster_messages_received_total",
}
)

Expand Down Expand Up @@ -145,12 +145,12 @@ func NewRedisExporter(host RedisHost, namespace, checkKeys string) (*Exporter, e
Namespace: namespace,
Name: "key_value",
Help: "The value of \"key\"",
}, []string{"db", "key"}),
}, []string{"addr", "db", "key"}),
keySizes: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "key_size",
Help: "The length or size of \"key\"",
}, []string{"db", "key"}),
}, []string{"addr", "db", "key"}),
duration: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "exporter_last_scrape_duration_seconds",
Expand Down Expand Up @@ -472,7 +472,7 @@ func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
}
if tempVal, err := c.Do("GET", k.key); err == nil && tempVal != nil {
if val, err := strconv.ParseFloat(fmt.Sprintf("%s", tempVal), 64); err == nil {
e.keyValues.WithLabelValues("db"+k.db, k.key).Set(val)
e.keyValues.WithLabelValues(addr, "db"+k.db, k.key).Set(val)
}
}

Expand All @@ -485,7 +485,7 @@ func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
"STRLEN",
} {
if tempVal, err := c.Do(op, k.key); err == nil && tempVal != nil {
e.keySizes.WithLabelValues("db"+k.db, k.key).Set(float64(tempVal.(int64)))
e.keySizes.WithLabelValues(addr, "db"+k.db, k.key).Set(float64(tempVal.(int64)))
break
}
}
Expand Down

0 comments on commit 776f426

Please sign in to comment.