{"id":37200116,"url":"https://github.com/aledbf/process-exporter","last_synced_at":"2026-01-14T23:01:46.298Z","repository":{"id":57504366,"uuid":"102975578","full_name":"aledbf/process-exporter","owner":"aledbf","description":"Prometheus exporter that mines /proc to report on selected processes ","archived":false,"fork":true,"pushed_at":"2017-09-09T18:34:02.000Z","size":837,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T08:14:16.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ncabatoff/process-exporter","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aledbf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-09T18:13:55.000Z","updated_at":"2017-09-09T18:13:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aledbf/process-exporter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/aledbf/process-exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fprocess-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fprocess-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fprocess-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fprocess-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aledbf","download_url":"https://codeload.github.com/aledbf/process-exporter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aledbf%2Fprocess-exporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28437916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T23:01:45.356Z","updated_at":"2026-01-14T23:01:46.189Z","avatar_url":"https://github.com/aledbf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# process-exporter\nPrometheus exporter that mines /proc to report on selected processes.\n\nThe premise for this exporter is that sometimes you have apps that are\nimpractical to instrument directly, either because you don't control the code\nor they're written in a language that isn't easy to instrument with Prometheus.\nA fair bit of information can be gleaned from /proc, especially for\nlong-running programs.\n\nFor most systems it won't be beneficial to create metrics for every process by\nname: there are just too many of them and most don't do enough to merit it.\nVarious command-line options are provided to control how processes are grouped\nand the groups are named.  Run \"process-exporter -man\" to see a help page\ngiving details.\n\nMetrics available currently include CPU usage, bytes written and read, and\nnumber of processes in each group.  \n\nBytes read and written come from /proc/[pid]/io in recent enough kernels.\nThese correspond to the fields `read_bytes` and `write_bytes` respectively.\nThese IO stats come with plenty of caveats, see either the Linux kernel \ndocumentation or man 5 proc.\n\nCPU usage comes from /proc/[pid]/stat fields utime (user time) and stime (system\ntime.)  It has been translated into fractional seconds of CPU consumed.  Since\nit is a counter, using rate() will tell you how many fractional cores were running\ncode from this process during the interval given.\n\nAn example Grafana dashboard to view the metrics is available at https://grafana.net/dashboards/249\n\n## Instrumentation cost\n\nprocess-exporter will consume CPU in proportion to the number of processes in\nthe system and the rate at which new ones are created.  The most expensive\nparts - applying regexps and executing templates - are only applied once per\nprocess seen.  If you have mostly long-running processes process-exporter\nshould be lightweight: each time a scrape occurs, parsing of /proc/$pid/stat\nand /proc/$pid/cmdline for every process being monitored and adding a few\nnumbers.\n\n## Config\n\nTo select and group the processes to monitor, either provide command-line\narguments or use a YAML configuration file. \n\nTo avoid confusion with the cmdline YAML element, we'll refer to the\nnull-delimited contents of `/proc/\u003cpid\u003e/cmdline` as the array `argv[]`.\n\nEach item in `process_names` gives a recipe for identifying and naming\nprocesses.  The optional `name` tag defines a template to use to name\nmatching processes; if not specified, `name` defaults to `{{.ExeBase}}`.\n\nTemplate variables available:\n- `{{.ExeBase}}` contains the basename of the executable\n- `{{.ExeFull}}` contains the fully qualified path of the executable\n- `{{.Matches}}` map contains all the matches resulting from applying cmdline regexps\n\nEach item in `process_names` must contain one or more selectors (`comm`, `exe`\nor `cmdline`); if more than one selector is present, they must all match.  Each\nselector is a list of strings to match against a process's `comm`, `argv[0]`,\nor in the case of `cmdline`, a regexp to apply to the command line.  \n\nFor `comm` and `exe`, the list of strings is an OR, meaning any process\nmatching any of the strings will be added to the item's group.  \n\nFor `cmdline`, the list of regexes is an AND, meaning they all must match.  Any\ncapturing groups in a regexp must use the `?P\u003cname\u003e` option to assign a name to\nthe capture, which is used to populate `.Matches`.\n\nA process may only belong to one group: even if multiple items would match, the\nfirst one listed in the file wins.\n\nOther performance tips: give an exe or comm clause in addition to any cmdline\nclause, so you avoid executing the regexp when the executable name doesn't\nmatch.\n\n```\n\nprocess_names:\n  # comm is the second field of /proc/\u003cpid\u003e/stat minus parens.\n  # It is the base executable name, truncated at 15 chars.  \n  # It cannot be modified by the program, unlike exe.\n  - comm:\n    - bash\n    \n  # exe is argv[0]. If no slashes, only basename of argv[0] need match.\n  # If exe contains slashes, argv[0] must match exactly.\n  - exe: \n    - postgres\n    - /usr/local/bin/prometheus\n\n  # cmdline is a list of regexps applied to argv.\n  # Each must match, and any captures are added to the .Matches map.\n  - name: \"{{.ExeFull}}:{{.Matches.Cfgfile}}\"\n    exe: \n    - /usr/local/bin/process-exporter\n    cmdline: \n    - -config.path\\\\s+(?P\u003cCfgfile\u003e\\\\S+)\n    \n\n```\n\nHere's the config I use on my home machine:\n\n```\n\nprocess_names:\n  - comm: \n    - chromium-browse\n    - bash\n    - prometheus\n    - gvim\n  - exe: \n    - /sbin/upstart\n    cmdline: \n    - --user\n    name: upstart:-user\n\n```\n\n## Docker\n\nA docker image can be created with\n\n```\nmake docker\n```\n\nThen run the docker, e.g.\n\n```\ndocker run --privileged --name pexporter -d -v /proc:/host/proc -p 127.0.0.1:9256:9256 process-exporter:master -procfs /host/proc -procnames chromium-browse,bash,prometheus,gvim,upstart:-user -namemapping \"upstart,(-user)\"\n```\n\nThis will expose metrics on http://localhost:9256/metrics.  Leave off the\n`127.0.0.1:` to publish on all interfaces.  Leave off the --priviliged and\nadd the --user docker run argument if you only need to monitor processes\nbelonging to a single user.\n\n## History\n\nAn earlier version of this exporter had options to enable auto-discovery of\nwhich processes were consuming resources.  This functionality has been removed.\nThese options were based on a percentage of resource usage, e.g. if an\nuntracked process consumed X% of CPU during a scrape, start tracking processes\nwith that name.  However during any given scrape it's likely that most\nprocesses are idle, so we could add a process that consumes minimal resources\nbut which happened to be active during the interval preceding the current\nscrape.  Over time this means that a great many processes wind up being\nscraped, which becomes unmanageable to visualize.  This could be mitigated by\nlooking at resource usage over longer intervals, but ultimately I didn't feel\nthis feature was important enough to invest more time in at this point.  It may\nre-appear at some point in the future, but no promises.\n\nAnother lost feature: the \"other\" group was used to count usage by non-tracked\nprocs.  This was useful to get an idea of what wasn't being monitored.  But it\ncomes at a high cost: if you know what processes you care about, you're wasting\na lot of CPU to compute the usage of everything else that you don't care about.\nThe new approach is to minimize resources expended on non-tracked processes and\nto require the user to whitelist the processes to track.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faledbf%2Fprocess-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faledbf%2Fprocess-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faledbf%2Fprocess-exporter/lists"}