Skip to content

Commit

Permalink
feat: add Redis Sentinel metrics ckquorum (#691)
Browse files Browse the repository at this point in the history
Co-authored-by: opanmustopah <opan.mustopah@gojek.com>
  • Loading branch information
opan and om-goto authored Aug 25, 2022
1 parent 78f0431 commit 19f7b03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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
9 changes: 9 additions & 0 deletions exporter/sentinels.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ func (e *Exporter) extractSentinelMetrics(ch chan<- prometheus.Metric, c redis.C
}
masterAddr := masterIp + ":" + masterPort

masterCkquorumMsg, err := redis.String(doRedisCmd(c, "SENTINEL", "CKQUORUM", masterName))
log.Debugf("Sentinel ckquorum status for master %s: %s %s", masterName, masterCkquorumMsg, err)
masterCkquorumStatus := 1
if err != nil {
masterCkquorumStatus = 0
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

0 comments on commit 19f7b03

Please sign in to comment.