-
Notifications
You must be signed in to change notification settings - Fork 80
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
Thread specific summary counters #19
base: main
Are you sure you want to change the base?
Conversation
Fixes following staticcheck warning. $ staticcheck ./unbound_exporter.go unbound_exporter.go:279:22: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (S1007)
Per thread metrics can be unnecessarily detailed in environments where there are lots of unbound instances, and prometheus server memory is short in supply.
@@ -297,6 +304,15 @@ func CollectFromReader(file io.Reader, ch chan<- prometheus.Metric) error { | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if !threads && strings.HasPrefix(matches[0], "thread") { |
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.
Can you guarantee that matches actually has this length?
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.
I think I can. There is matches != nil
check before ParseFloat(), so there should always be at least first entry. Assuming the first entry tells thread
all of the expressions have three fields. That should make both the matches[1]
assignment and matches[1:]
reference safe.
Gotcha, here's the old (default) behavior:
and behavior with the new flag
|
This pull request has three minor changes that are so trivial they hopefully do not need much discussion.
Main purpose of the change set is to add
-threads=false
command-line option support, that will make the thread specific exports to be summary counters. Level of detail is just too much in cases such as a company I work for, where we have lots of threads and lots of installations. That leads to prometheus server to reserve a lot of memory to keep track of these metrics, that are always summarised when visualised. Notice that the default per thread counting is kept as-is, new summary output is only for people who really want to merge the metrics.