gen2brain / keepalived_exporter

Keepalived Prometheus Exporter
Apache License 2.0
44 stars 13 forks source link

The exporter requires to run as "root" to work #14

Closed kodachimaru closed 1 year ago

kodachimaru commented 2 years ago

If I run it as a non root user, I get this error

prometheus-keepalived-exporter[14775]: time="2022-05-31T10:21:39Z" level=error msg="Could not get ipvs family information from the kernel. It is possible that ipvs is not enabled in your kernel. Native loadbalancing will not work until this is fixed."
prometheus-keepalived-exporter[14775]: time="2022-05-31T10:21:39Z" level=warning msg="Running modprobe ip_vs failed with message: `modprobe: ERROR: could not insert 'ip_vs': Operation not permitted\ninsmod /lib/modules/4.19.0-16-amd64/kernel/lib/libcrc32c.ko`, error: exit status 1"

And the only metric returned is

keepalived_up 0

If I run it as "root" instead, the exporter works just fine. But obviously I don't wanna run it as root...

I think that the exporter should not try to use "insmod", maybe just log the missing module and exit. Whoever is installing the exporter will ensure that the required module is present before running it.

gen2brain commented 2 years ago

You can see here how to enable CAP capabilities https://github.com/gen2brain/keepalived_exporter/issues/5#issuecomment-579293035 instead of running as root. The exporter is not doing insmod, KA is doing it.

gen2brain commented 2 years ago

The perfect combination is to not run Keepalived as root, that is first, run as some user as in that comment, and run exporter as the same user.

kodachimaru commented 2 years ago

Will do that. Thx for the quick answer.