-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
receive: Hash-ring metrics #1363
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,11 @@ type ConfigWatcher struct { | |
logger log.Logger | ||
watcher *fsnotify.Watcher | ||
|
||
changesCounter prometheus.Counter | ||
errorCounter prometheus.Counter | ||
refreshCounter prometheus.Counter | ||
changesCounter prometheus.Counter | ||
errorCounter prometheus.Counter | ||
refreshCounter prometheus.Counter | ||
hashringNodesGauge *prometheus.GaugeVec | ||
hashringTenantsGauge *prometheus.GaugeVec | ||
|
||
// last is the last known configuration. | ||
last []HashringConfig | ||
|
@@ -75,13 +77,27 @@ func NewConfigWatcher(logger log.Logger, r prometheus.Registerer, path string, i | |
Name: "thanos_receive_hashrings_file_refreshes_total", | ||
Help: "The number of refreshes of the hashrings configuration file.", | ||
}), | ||
hashringNodesGauge: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Name: "thanos_receive_hashring_nodes", | ||
Help: "The number of nodes per hashring.", | ||
}, | ||
[]string{"name"}), | ||
hashringTenantsGauge: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Name: "thanos_receive_hashring_tenants", | ||
Help: "The number of tenants per hashring.", | ||
}, | ||
[]string{"name"}), | ||
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. Just curious on cardinality of this - this change on restart time or is fairly consistent across restarts? 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. This is consistent across restarts. |
||
} | ||
|
||
if r != nil { | ||
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. I think those metrics will work bit better if we would register them below ^^ 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. 🤦♂ Thanks for pointing that out. |
||
r.MustRegister( | ||
c.changesCounter, | ||
c.errorCounter, | ||
c.refreshCounter, | ||
c.hashringNodesGauge, | ||
c.hashringTenantsGauge, | ||
) | ||
} | ||
|
||
|
@@ -172,6 +188,11 @@ func (cw *ConfigWatcher) refresh(ctx context.Context) { | |
// Save the last known configuration. | ||
cw.last = config | ||
|
||
for _, c := range config { | ||
cw.hashringNodesGauge.WithLabelValues(c.Hashring).Set(float64(len(c.Endpoints))) | ||
cw.hashringTenantsGauge.WithLabelValues(c.Hashring).Set(float64(len(c.Tenants))) | ||
} | ||
|
||
select { | ||
case <-ctx.Done(): | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nodes or endpoints? (: Don't have strong opinion.