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

feat: add Redis Sentinel metrics ckquorum #691

Merged
merged 8 commits into from
Aug 25, 2022
1 change: 1 addition & 0 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func NewRedisExporter(redisURI string, opts Options) (*Exporter, error) {
"sentinel_master_sentinels": {txt: "The number of sentinels monitoring this master", lbls: []string{"master_name", "master_address"}},
"sentinel_master_slaves": {txt: "The number of slaves of the master", lbls: []string{"master_name", "master_address"}},
"sentinel_master_status": {txt: "Master status on Sentinel", lbls: []string{"master_name", "master_address", "master_status"}},
"sentinel_master_ckquorum_status": {txt: "Master ckquorum status", lbls: []string{"master_name", "message"}},
"sentinel_masters": {txt: "The number of masters this sentinel is watching"},
"sentinel_running_scripts": {txt: "Number of scripts in execution right now"},
"sentinel_scripts_queue_length": {txt: "Queue of user scripts to execute"},
Expand Down
10 changes: 10 additions & 0 deletions exporter/sentinels.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ func (e *Exporter) extractSentinelMetrics(ch chan<- prometheus.Metric, c redis.C
}
masterAddr := masterIp + ":" + masterPort

masterCkquorum, err := redis.String(doRedisCmd(c, "SENTINEL", "CKQUORUM", masterName))
oliver006 marked this conversation as resolved.
Show resolved Hide resolved
log.Debugf("Sentinel ckquorum status for master %s", masterName)
oliver006 marked this conversation as resolved.
Show resolved Hide resolved
masterCkquorumStatus := 0
masterCkquorumMsg := masterCkquorum
if err != nil {
masterCkquorumStatus = 1
oliver006 marked this conversation as resolved.
Show resolved Hide resolved
masterCkquorumMsg = err.Error()
}
e.registerConstMetricGauge(ch, "sentinel_master_ckquorum_status", float64(masterCkquorumStatus), masterName, masterCkquorumMsg)

sentinelDetails, _ := redis.Values(doRedisCmd(c, "SENTINEL", "SENTINELS", masterName))
log.Debugf("Sentinel details for master %s: %s", masterName, sentinelDetails)
e.processSentinelSentinels(ch, sentinelDetails, masterName, masterAddr)
Expand Down
5 changes: 3 additions & 2 deletions exporter/sentinels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ func TestExtractSentinelMetricsForSentinel(t *testing.T) {
}

want := map[string]bool{
"sentinel_master_ok_sentinels": false,
"sentinel_master_ok_slaves": false,
"sentinel_master_ok_sentinels": false,
"sentinel_master_ok_slaves": false,
"sentinel_master_ckquorum_status": false,
}

for m := range chM {
Expand Down