---
title: "prometheus.exporter.process | Grafana Agent documentation"
description: "Learn about prometheus.exporter.process"
---

# prometheus.exporter.process

The `prometheus.exporter.process` component embeds [process\_exporter](https://github.com/ncabatoff/process-exporter) for collecting process stats from `/proc`.

## Usage

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.process "LABEL" {
}
```

## Arguments

The following arguments can be used to configure the exporter’s behavior. All arguments are optional. Omitted fields take their default values.

Expand table

| Name                | Type     | Description                                       | Default | Required |
|---------------------|----------|---------------------------------------------------|---------|----------|
| `procfs_path`       | `string` | procfs mountpoint.                                | `/proc` | no       |
| `track_children`    | `bool`   | Whether to track a process’ children.             | `true`  | no       |
| `track_threads`     | `bool`   | Report metrics for a process’ individual threads. | `true`  | no       |
| `gather_smaps`      | `bool`   | Gather metrics from the smaps file for a process. | `true`  | no       |
| `recheck_on_scrape` | `bool`   | Recheck process names on each scrape.             | `true`  | no       |

## Blocks

The following blocks are supported inside the definition of `prometheus.exporter.process`:

Expand table

| Hierarchy | Block                     | Description                                                                    | Required |
|-----------|---------------------------|--------------------------------------------------------------------------------|----------|
| matcher   | [matcher](#matcher-block) | A collection of matching rules to use for deciding which processes to monitor. | no       |

### matcher block

Each `matcher` block config can match multiple processes, which will be tracked as a single process “group.”

Expand table

| Name      | Type           | Description                                                                                      | Default          | Required |
|-----------|----------------|--------------------------------------------------------------------------------------------------|------------------|----------|
| `name`    | `string`       | The name to use for identifying the process group name in the metric.                            | `"{{.ExeBase}}"` | no       |
| `comm`    | `list(string)` | A list of strings that match the base executable name for a process, truncated to 15 characters. |                  | no       |
| `exe`     | `list(string)` | A list of strings that match `argv[0]` for a process.                                            |                  | no       |
| `cmdline` | `list(string)` | A list of regular expressions applied to the `argv` of the process.                              |                  | no       |

The `name` argument can use the following template variables. By default it uses the base path of the executable:

- `{{.Comm}}`: Basename of the original executable from /proc/&lt;pid&gt;/stat.
- `{{.ExeBase}}`: Basename of the executable from argv\[0].
- `{{.ExeFull}}`: Fully qualified path of the executable.
- `{{.Username}}`: Username of the effective user.
- `{{.Matches}}`: Map containing all regex capture groups resulting from matching a process with the cmdline rule group.
- `{{.PID}}`: PID of the process. Note that the PID is copied from the first executable found.
- `{{.StartTime}}`: The start time of the process. This is useful when combined with PID as PIDS get reused over time.
- `{{.Cgroups}}`: The cgroups, if supported, of the process (`/proc/self/cgroup`). This is particularly useful for identifying to which container a process belongs.

**NOTE**: Using `PID` or `StartTime` is discouraged, as it is almost never what you want, and is likely to result in high cardinality metrics.

The value that is used for matching `comm` list elements is derived from reading the second field of `/proc/<pid>/stat`, stripped of parens.

For values in `exe`, if there are no slashes, only the basename of `argv[0]` needs to match. Otherwise, the name must be an exact match. For example, “postgres” may match any postgres binary, but `/usr/local/bin/postgres` will only match a postgres process with that exact path. If any of the strings match, the process will be tracked.

Each regex in `cmdline` must match the corresponding argv for the process to be tracked. The first element that is matched is `argv[1]`. Regex captures are added to the .Matches map for use in the name.

## Exported fields

The following fields are exported and can be referenced by other components.

Expand table

| Name      | Type                | Description                                               |
|-----------|---------------------|-----------------------------------------------------------|
| `targets` | `list(map(string))` | The targets that can be used to collect exporter metrics. |

For example, the `targets` can either be passed to a `discovery.relabel` component to rewrite the targets’ label sets or to a `prometheus.scrape` component that collects the exposed metrics.

The exported targets use the configured [in-memory traffic](/docs/agent/v0.43/flow/concepts/component_controller/#in-memory-traffic) address specified by the [run command](/docs/agent/v0.43/flow/reference/cli/run/).

## Component health

`prometheus.exporter.process` is only reported as unhealthy if given an invalid configuration. In those cases, exported fields retain their last healthy values.

## Debug information

`prometheus.exporter.process` does not expose any component-specific debug information.

## Debug metrics

`prometheus.exporter.process` does not expose any component-specific debug metrics.

## Example

This example uses a [`prometheus.scrape` component](../prometheus.scrape/) to collect metrics from `prometheus.exporter.process`:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.process "example" {
  track_children = false

  matcher {
    comm = ["grafana-agent"]
  }
}

// Configure a prometheus.scrape component to collect process_exporter metrics.
prometheus.scrape "demo" {
  targets    = prometheus.exporter.process.example.targets
  forward_to = [prometheus.remote_write.demo.receiver]
}

prometheus.remote_write "demo" {
  endpoint {
    url = PROMETHEUS_REMOTE_WRITE_URL

    basic_auth {
      username = USERNAME
      password = PASSWORD
    }
  }
}
```

Replace the following:

- `PROMETHEUS_REMOTE_WRITE_URL`: The URL of the Prometheus remote\_write-compatible server to send metrics to.
- `USERNAME`: The username to use for authentication to the remote\_write API.
- `PASSWORD`: The password to use for authentication to the remote\_write API.

## Compatible components

`prometheus.exporter.process` has exports that can be consumed by the following components:

- Components that consume [Targets](../../compatibility/#targets-consumers)

> Note
> 
> Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.
