ncabatoff / process-exporter

Prometheus exporter that mines /proc to report on selected processes
MIT License
1.72k stars 270 forks source link

Support Cgroups attribute for process #199

Closed azertyfun closed 3 years ago

azertyfun commented 3 years ago

Hi!

This exposes the procps method to get a process' cgroups.

If the cgroup is not available, we simply return an empty array as this can commonly happen on older kernels using the v1 cgroups (found at /proc/self/cgroups instead of /proc/self/cgroup).


I upgraded procfs to v0.7.1, because prometheus/procfs#399 is required for the tests to work.


Sample output with name: "{{.Comm}}-{{.PID}}-{{.Cgroups}}":

namedprocess_namegroup_context_switches_total{ctxswitchtype="nonvoluntary",groupname="(sd-pam)-1366-[/user.slice/user-1000.slice/user@1000.service/init.scope]"} 0
ncabatoff commented 3 years ago

This change seems fine, would you mind refreshing the PR and updating the README please?

ncabatoff commented 3 years ago

Thanks @azertyfun !