Skip to content

Monitor user unit services #134

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

Open
Lusitaniae opened this issue Jul 19, 2024 · 3 comments
Open

Monitor user unit services #134

Lusitaniae opened this issue Jul 19, 2024 · 3 comments

Comments

@Lusitaniae
Copy link

In some cases I want to monitor systemd services setup as a user unit

sudo su -l user1

systemctl status --user app1

checking the systemd status from outside won't work

@newskooler
Copy link

I have the same issue and I struggle to get it working :( i am running systemd exporter as root and expect it to get all metric for root and all users.

@Lusitaniae
Copy link
Author

I end up making systemd-exporter run in the same user as the service being monitored

and adding

--systemd.collector.user

@gsaslis
Copy link
Contributor

gsaslis commented Mar 13, 2025

I was able to get systemd_exporter exporting metrics about user systemd services (which, in my case, are other podman quadlets) with the following podman quadlet (1001 is the id of the user these are all running under) :

$ cat ~/.config/containers/systemd/systemd_exporter.container

[Container]
ContainerName=systemd_exporter
Environment=XDG_RUNTIME_DIR=/run/user/1001
Exec=--log.level=info --systemd.collector.user --systemd.collector.enable-restart-count --systemd.collector.enable-ip-accounting --systemd.collector.unit-include=woodpecker-server.service|woodpecker-agent.service|grafana.service|minio.service|prometheus.service|gateway.service|alertmanager.service|loki.*.service|radicle.*.service
Group=1001
Image=quay.io/prometheuscommunity/systemd-exporter:main
LogDriver=journald
PublishPort=9668:9558
User=1001
UserNS=keep-id:uid=1001,gid=1001
Volume=/proc:/host/proc:ro
Volume=/run/systemd:/run/systemd:ro
Volume=/run/user/1001:/run/user/1001:ro
PodmanArgs=--restart on-failure
AutoUpdate=local
[Unit]
After=podman-user-wait-network-online.service

[Install]
WantedBy=default.target

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

No branches or pull requests

3 participants