Skip to content

Conversation

bhouse
Copy link

@bhouse bhouse commented Apr 30, 2025

Add support for collecting ActiveEnterTimestampMonotonic from each systemd unit and exposing it as the systemd_unit_active_enter_monotonic_seconds metric.

I encountered a bug in dbus or systemd that is reporting the same values for systemd_boot_monotonic_seconds and systemd_boot_time_seconds, with both being the monotonic value. This prohibits the calculation of the difference with the existing systemd_unit_active_enter_time_seconds which is reported as the value from the realtime clock.

Example:

$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager UserspaceTimestamp UserspaceTimestampMonotonic
t 10938338
t 10938338

On other systems:

$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager UserspaceTimestamp UserspaceTimestampMonotonic
t 1746046198232969
t 42412983

This change is to only add monotonic seconds for active_enter to avoid a major amplification of metrics for each unit by adding the same for active_exit, inactive_enter, inactive_exit.

Add support for collecting `ActiveEnterTimestampMonotonic` from each systemd
unit and exposing it as the `systemd_unit_active_enter_monotonic_seconds`
metric.

I encountered a bug in dbus or systemd that is reporting the same values for
`systemd_boot_monotonic_seconds` and `systemd_boot_time_seconds`, with both
being the monotonic value. This prohibits the calculation of the difference
with the existing `systemd_unit_active_enter_time_seconds` which is reported as
the value from the realtime clock.

Example:

```
$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager UserspaceTimestamp UserspaceTimestampMonotonic
t 10938338
t 10938338
```

On other systems:

```
$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager UserspaceTimestamp UserspaceTimestampMonotonic
t 1746046198232969
t 42412983
```

This change is to only add monotonic seconds for `active_enter` to avoid a
major amplification of metrics for each unit by adding the same for
`active_exit`, `inactive_enter`, `inactive_exit`.

Signed-off-by: Ben House <[email protected]>
@bhouse bhouse force-pushed the bhouse/unit-active-enter-monotonic-seconds branch from 35fa3e9 to de75655 Compare May 2, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant