Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 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 @@ -568,6 +569,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 Expand Up @@ -614,6 +616,10 @@ func NewRedisExporter(uri string, opts Options) (*Exporter, error) {
e.metricDescriptions[k] = newMetricDescr(opts.Namespace, k, desc.txt, desc.lbls)
}

if !opts.InclSentinelPeerInfo {
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.

I don't think we need to delete the description (and we don't do it for any other flags), just not emitting the metric should be enough?

delete(e.metricDescriptions, "sentinel_peer_info")
}

if e.options.MetricsPath == "" {
e.options.MetricsPath = "/metrics"
}
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
30 changes: 30 additions & 0 deletions exporter/sentinels.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ func (e *Exporter) processSentinelSentinels(ch chan<- prometheus.Metric, sentine

// If we are here then this master is in ok state
masterOkSentinels := 1
masterName := ""
masterAddr := ""
if len(labels) >= 2 {
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.

Do we still want to emit the metric if labels is empty?
(plus we outright use labels down in 197 for the other metric)
would be good to be consistent here and maybe just return if labels is empty?

masterName = labels[0]
masterAddr = labels[1]
}

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

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

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

sentinelFlags, ok := sentinelDetailMap["flags"]
if !ok {
continue
Expand Down
Loading
Loading