-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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/systemd summary #765
Feat/systemd summary #765
Conversation
collector/systemd_linux.go
Outdated
func summarizeUnits(units []dbus.UnitStatus) map[string]float64 { | ||
summarized := make(map[string]float64) | ||
|
||
summarized["total"] = float64(len(units)) |
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.
Total should not be included, as totals are a function of sum()
in PromQL.
collector/systemd_linux.go
Outdated
@@ -57,23 +60,36 @@ func NewSystemdCollector() (Collector, error) { | |||
"Whether the system is operational (see 'systemctl is-system-running')", | |||
nil, nil, | |||
) | |||
summaryDesc := prometheus.NewDesc( | |||
prometheus.BuildFQName(namespace, subsystem, "unit_state_summary"), |
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 would suggest simply calling this units
. So the metric name would be node_systemd_units
I like the idea, but I'm conflicted about the control flag. I need to think about this. |
I had a talk with @brian-brazil. What do you think of doing the flags like this. Instead of having a bool for summary, we always collect the summary when the collector is enabled. And use the whitelist to disable collection of the per-unit metrics.
This would be a little unintuitive, but allow for a bit more flexibility where you might want the unit state summary and also a very small whitelist of units. |
Sounds OK to me. I'll get those changes in. It should simplify the code also. |
A little bit of the code logic had to change to only call |
Squashed my commits. |
collector/systemd_linux.go
Outdated
} | ||
|
||
summary := summarizeUnits(allUnits) | ||
if err != nil { |
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.
This looks like leftover, summarizeUnits()
doesn't return an err
.
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.
Yep, there's another one for filterUnits
as well a few lines after. Will clean both.
Looks great! One minor comment. |
Did I break something? |
No, it looks like our freebsd build slave ran out of disk again. You can ignore that. |
Alright then, thanks for the feedback. Looks OK now? |
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.
LGTM
We fixed the broken test server, now all checks pass. |
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.
LGTM
Here's the topic in the Google Groups to discuss this: https://groups.google.com/forum/?fromgroups#!topic/prometheus-developers/uhpXqdS0r8A
By using
./node_exporter --collector.systemd --collector.systemd.summary
, you can get simplified/summarized systemd stats: