ncabatoff / process-exporter

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

Use labels for things like pid #311

Open Roemer opened 1 month ago

Roemer commented 1 month ago

Currently, only the name can be configured with templates. Wouldn't it be a good idea to allow to add labels to metrics? So for example if I want to have a pid, this currently looks like:

namedprocess_namegroup_memory_bytes{groupname="node-301373",memtype="swapped"}

but with a config like:

process_names:
  - name: "{{.Comm}}"
    labels:
      - pid: "{{.PID}}"
    cmdline:
      - '.+'

the resulting entry would look like:

namedprocess_namegroup_memory_bytes{groupname="node",memtype="swapped", pid="301373"}

therefore making it simpler to group by names but still differentiate/filter via labels if wanted