Skip to content
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
2 changes: 2 additions & 0 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Options struct {
InclConfigMetrics bool
InclModulesMetrics bool
InclSearchIndexesMetrics bool
InclSentinelPeerInfo bool
CheckSearchIndexes string
DisableExportingKeyValues bool
ExcludeLatencyHistogramMetrics bool
Expand Down Expand Up @@ -569,6 +570,7 @@ func NewRedisExporter(uri string, opts Options) (*Exporter, error) {
"search_index_number_of_uses_total": {txt: "Number of times the index has been used", lbls: []string{"index_name"}},
"search_index_cleaning": {txt: "Index deletion flag. A value of 1 indicates index deletion is in progress", lbls: []string{"index_name"}},
"sentinel_master_ckquorum_status": {txt: "Master ckquorum status", lbls: []string{"master_name", "message"}},
"sentinel_peer_info": {txt: "Other Sentinel peers discovered via SENTINEL SENTINELS (one scrape from one Sentinel)", lbls: []string{"master_name", "master_address", "name", "ip", "port", "runid", "flags"}},
"sentinel_master_ok_sentinels": {txt: "The number of okay sentinels monitoring this master", lbls: []string{"master_name", "master_address"}},
"sentinel_master_ok_slaves": {txt: "The number of okay slaves of the master", lbls: []string{"master_name", "master_address"}},
"sentinel_master_sentinels": {txt: "The number of sentinels monitoring this master", lbls: []string{"master_name", "master_address"}},
Expand Down
1 change: 0 additions & 1 deletion exporter/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestKeyspaceStringParser(t *testing.T) {
},
}

log.SetLevel(log.DebugLevel)
for _, tst := range tsts {
if kt, kx, ttl, kc, ok := parseDBKeyspaceString(tst.db, tst.stats); true {

Expand Down
44 changes: 39 additions & 5 deletions exporter/sentinels.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ func (e *Exporter) processSentinelSentinels(ch chan<- prometheus.Metric, sentine

// If we are here then this master is in ok state
masterOkSentinels := 1
hasMasterLabels := len(labels) >= 2
masterName := ""
masterAddr := ""
if hasMasterLabels {
masterName = labels[0]
masterAddr = labels[1]
}

for _, sentinelDetail := range sentinelDetails {
sentinelDetailMap, err := redis.StringMap(sentinelDetail, nil)
Expand All @@ -152,14 +159,39 @@ func (e *Exporter) processSentinelSentinels(ch chan<- prometheus.Metric, sentine
continue
}

sentinelFlags, ok := sentinelDetailMap["flags"]
if !ok {
name := ""
if v, ok := sentinelDetailMap["name"]; ok {
name = v
}
ip := ""
if v, ok := sentinelDetailMap["ip"]; ok {
ip = v
}
port := ""
if v, ok := sentinelDetailMap["port"]; ok {
port = v
}
runid := ""
if v, ok := sentinelDetailMap["runid"]; ok {
runid = v
}
flags := ""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use this down in line 175 and onwards instead of extracting it again down there

flagsFound := false
if v, ok := sentinelDetailMap["flags"]; ok {
flags = v
flagsFound = true
}
if e.options.InclSentinelPeerInfo && hasMasterLabels {
e.registerConstMetricGauge(ch, "sentinel_peer_info", 1, masterName, masterAddr, name, ip, port, runid, flags)
}

if !flagsFound {
continue
}
if strings.Contains(sentinelFlags, "o_down") {
if strings.Contains(flags, "o_down") {
continue
}
if strings.Contains(sentinelFlags, "s_down") {
if strings.Contains(flags, "s_down") {
continue
}
masterOkSentinels = masterOkSentinels + 1
Expand Down Expand Up @@ -188,7 +220,9 @@ func (e *Exporter) processSentinelSlaves(ch chan<- prometheus.Metric, slaveDetai
}
masterOkSlaves = masterOkSlaves + 1
}
e.registerConstMetricGauge(ch, "sentinel_master_ok_slaves", float64(masterOkSlaves), labels...)
if len(labels) >= 2 {
e.registerConstMetricGauge(ch, "sentinel_master_ok_slaves", float64(masterOkSlaves), labels...)
}
}

/*
Expand Down
Loading
Loading