-
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
Add systemd uptime metric collection #952
Conversation
41d45c1
to
8ae6035
Compare
@langesven Thanks for the PR! |
8ae6035
to
1c2a5a7
Compare
Hi @discordianfish - fair enough, I changed it to a CounterValue that is either 0 or the unix timestamp of when the job was started. Or would a Gauge be better suited but still keep track of just the timestamp? |
Note that there is also this PR #709 |
@langesven After some back and forth we decided to use gauges for timestamps in general, so yeah please change this to a gauge. |
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.
Looking good in general, but we should also have some tests if possible.
collector/systemd_linux.go
Outdated
@@ -55,6 +56,10 @@ func NewSystemdCollector() (Collector, error) { | |||
prometheus.BuildFQName(namespace, subsystem, "unit_state"), | |||
"Systemd unit", []string{"name", "state"}, nil, | |||
) | |||
unitStartedAtDesc := prometheus.NewDesc( | |||
prometheus.BuildFQName(namespace, subsystem, "unit_started_at_seconds"), |
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.
Let's call this unit_start_time_seconds to be consistent with already existing process_start_time_seconds
.
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.
@discordianfish That won't work, because process_start_time_seconds
metric family has no labels, so the collector will fail.
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 for consistency, we could name it unit_start_time_seconds
.
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.
@SuperQ That's what I suggested! Should have put it in ```` though :)
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.
Sorry! I didn't read what you said closely enough. 🦆
@langesven Can you change the metric name? Beside this LGTM |
1c2a5a7
to
867690e
Compare
Thanks for your feedback. |
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
Oh, would you mind adding a |
77fdded
to
388b97b
Compare
Added a feature changelog entry and rebased against master |
@langesven Looks like this still (again?) needs rebasing |
Signed-off-by: Sven Lange <tdl@hadiko.de>
Signed-off-by: Sven Lange <tdl@hadiko.de>
388b97b
to
7f505fb
Compare
@discordianfish it was indeed again 😄 rebased |
* Add systemd uptime metric collection Signed-off-by: Sven Lange <tdl@hadiko.de>
The no longer available
systemd_exporter
provided uptime metrics for systemd services, as such I figured I'd propose this as an extension tonode_epxorter
.This is somewhat relevant to #562 in that it exposes how long a service has been running for, not quite the timestamp of its start.
Exporting the duration makes it easier to define alerts on this metric in my opinion and would retain the functionality as provided by the previous project.