Skip to content
Snippets Groups Projects
Commit e582e878 authored by Oliver's avatar Oliver
Browse files

if no CONFIG dbCount was found then default dbCount to one when cluster enabled, 16 otherwise

parent ed524c82
No related branches found
No related tags found
No related merge requests found
Loading
@@ -625,23 +625,32 @@ func (e *Exporter) scrapeRedisHost(scrapes chan<- scrapeResult, addr string, idx
Loading
@@ -625,23 +625,32 @@ func (e *Exporter) scrapeRedisHost(scrapes chan<- scrapeResult, addr string, idx
log.Debugf("Redis CONFIG err: %s", err) log.Debugf("Redis CONFIG err: %s", err)
} }
   
info, err := redis.String(doRedisCmd(c, "INFO", "ALL")) infoAll, err := redis.String(doRedisCmd(c, "INFO", "ALL"))
if err == nil { if err != nil {
e.extractInfoMetrics(info, addr, e.redis.Aliases[idx], scrapes, dbCount, true)
} else {
log.Errorf("Redis INFO err: %s", err) log.Errorf("Redis INFO err: %s", err)
return err return err
} }
isClusterEnabled := strings.Contains(infoAll, "cluster_enabled:1")
   
if strings.Contains(info, "cluster_enabled:1") { if isClusterEnabled {
info, err = redis.String(doRedisCmd(c, "CLUSTER", "INFO")) if clusterInfo, err := redis.String(doRedisCmd(c, "CLUSTER", "INFO")); err == nil {
if err != nil { e.extractInfoMetrics(clusterInfo, addr, e.redis.Aliases[idx], scrapes, dbCount, false)
log.Errorf("redis err: %s", err)
// in cluster mode Redis only supports one database so no extra padding beyond that needed
dbCount = 1
} else { } else {
e.extractInfoMetrics(info, addr, e.redis.Aliases[idx], scrapes, dbCount, false) log.Errorf("Redis CLUSTER INFO err: %s", err)
}
} else {
// in non-cluster mode, if dbCount is zero then "CONFIG" failed to retrieve a valid
// number of databases and we use the Redis config default which is 16
if dbCount == 0 {
dbCount = 16
} }
} }
   
e.extractInfoMetrics(infoAll, addr, e.redis.Aliases[idx], scrapes, dbCount, true)
if reply, err := doRedisCmd(c, "LATENCY", "LATEST"); err == nil { if reply, err := doRedisCmd(c, "LATENCY", "LATEST"); err == nil {
var eventName string var eventName string
var spikeLast, milliseconds, max int64 var spikeLast, milliseconds, max int64
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