Read metrics¶
Source · io.systemd.Metrics · systemd v260+ · Unprivileged
systemd v260 introduced io.systemd.Metrics: services publish metric
families on sockets under /run/systemd/report/. This example discovers those
sockets and streams every metric from each, which is the building block for
exporters such as report2otel.
Run it¶
Output (illustrative)
# io.systemd.Manager
io.systemd.Manager.unitsByTypeTotal 12
io.systemd.Manager.unitsByTypeTotal 41
io.systemd.Manager.unitActiveState{dev-hvc0.device} "active"
io.systemd.Manager.unitActiveState{ssh.service} "active"
The code¶
How it works¶
- No default socket. Many daemons implement
io.systemd.Metrics, each on its own socket, so the package hasDialPathbut noDial. - Requires-more.
Liststreams one reply per metric; it takes no parameters, so the method is justList(ctx). - Untyped values.
Valueis IDL typeany, so it's ajson.RawMessage;Fields(?object) distinguishes metrics within a family (e.g. by unit type). UseDescribeto learn each family's type (counter,gauge,string).
See also¶
- Streaming
- Publish metrics: the server side