Debugging process_exporter group naming configuration

Technical howto article


This article provides debugging methods to print out detailed process information collected by process_exporter to help with troubleshooting and developing process group naming configuration.


Using ps

You can use this ps command to print relevant process details.

ps -eo pid,comm=Name,exe=EXE,args=Comm

It lists all processes with their PID, command name (comm), executable path (exe) and command line (cmdline) that process_exporter configs can use for all the currently running processes.

Using process_exporter

Follow this example to print out detailed process information exactly as collected by process_exporter.

Write this content in a file named process_exporter.yaml:

    # This process group name template concatenates several process properties,
    # separated by a tab character.
  - name: "{{.PID}}\t{{.Comm}}\t{{.ExeBase}}\t{{.ExeFull}}\t{{.Matches.cmdline}}"
      - '(?P<cmdline>.+)'

Then, start process_exporter like as follows. I installed process_exporter from the apt repository, so the binary is called prometheus-process-exporter. You can also download and run the process-exporter standalone binary from GitHub.

prometheus-process-exporter \
  -web.listen-address :9257 \
  -config.path process_exporter.yaml

The following shell pipeline scrapes the process_exporter metrics and formats the groupname label value for each process.

The columns are coming from the group name template in process_exporter.yaml:
PID, Comm, ExeBase, ExeFull, cmdline.

curl -s http://localhost:9257/metrics \
| grep "^namedprocess_namegroup_num_procs" \
| sed -E 's/.*groupname="(.*)"}.*/\\1/' \
| sort -n \
| less

Understanding the process_exporter source code

process_exporter uses the prometheus/procfs library to get process information from /proc.

Specifically, it uses the Proc object class in the proc.go module.

From there, you can check exactly how process_exporter collects process information from the /proc filesystem.

Alexandre de Verteuil
Alexandre de Verteuil
Senior Solutions Architect

I teach people how to see the matrix metrics.
Monkeys and sunsets make me happy.