-
Notifications
You must be signed in to change notification settings - Fork 938
Add sentinel_peer_info metric for Sentinel peer discovery #1097
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
Merged
+245
−17
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b17465
add sentinel_peer_info
tomatopunk 9500fe5
add sentinel_peer_info unit
tomatopunk b22b114
add sentinel_peer_info flag
tomatopunk 70e9972
fix ut
tomatopunk 5a30ebc
fix debug level log
tomatopunk 7c83dcc
always export metric desc
tomatopunk e69d576
if no master info, no register sentinel
tomatopunk 0d1b9b4
sentinels, flag no duplicate
tomatopunk f710954
Merge branch 'master' into master
oliver006 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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 := "" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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...) | ||
| } | ||
| } | ||
|
|
||
| /* | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.