prometheus.exporter.process
The prometheus.exporter.process
component embeds the process_exporter
for collecting process stats from /proc
.
Usage
prometheus.exporter.process "<LABEL>" {
}
Arguments
You can use the following arguments with prometheus.exporter.process
:
Blocks
You can use the following block with prometheus.exporter.process
:
matcher
Each matcher
block configuration can match multiple processes, which are tracked as a single process “group.”
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/<pid>/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 regular explression 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
orStartTime
is discouraged, as it’s almost never what you want, and is likely to result in high cardinality metrics.
The value that’s 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 PostgreSQL binary, but /usr/local/bin/postgres
only matches a PostgreSQL process with that exact path.
If any of the strings match, the process is tracked.
Each regular expression in cmdline
must match the corresponding argv
for the process to be tracked.
The first element that is matched is argv[1]
.
Regular expression 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.
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 address specified by the run command.
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
doesn’t expose any component-specific debug information.
Debug metrics
prometheus.exporter.process
doesn’t expose any component-specific debug metrics.
Example
This example uses a prometheus.scrape
component to collect metrics from prometheus.exporter.process
:
prometheus.exporter.process "example" {
track_children = false
matcher {
comm = ["alloy"]
}
}
// 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 Prometheusremote_write
compatible server to send metrics to.<USERNAME>
: The username to use for authentication to theremote_write
API.<PASSWORD>
: The password to use for authentication to theremote_write
API.
Compatible components
prometheus.exporter.process
has exports that can be consumed by the following components:
- Components that consume Targets
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.