Skip to content

Update process exporter to v0.8.7 #4065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Main (unreleased)

- Switch to the community maintained fork of `go-jmespath` that has more features. (@dehaansa)

- Update the `prometheus.exporter.process` component to get the `remove_empty_groups` option. (@dehaansa)

### Bugfixes

- Fix issues with propagating cluster peers change notifications to components configured with remotecfg. (@dehaansa)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@ prometheus.exporter.process "<LABEL>" {

You can use the following arguments with `prometheus.exporter.process`:

| Name | Type | Description | Default | Required |
| ------------------- | -------- | ------------------------------------------------- | --------- | -------- |
| `gather_smaps` | `bool` | Gather metrics from the smaps file for a process. | `true` | no |
| `procfs_path` | `string` | The procfs mount point. | `"/proc"` | no |
| `recheck_on_scrape` | `bool` | Recheck process names on each scrape. | `true` | no |
| `track_children` | `bool` | Whether to track a process' children. | `true` | no |
| `track_threads` | `bool` | Report metrics for a process' individual threads. | `true` | no |
| Name | Type | Description | Default | Required |
| --------------------- | -------- | ------------------------------------------------- | --------- | -------- |
| `gather_smaps` | `bool` | Gather metrics from the smaps file for a process. | `true` | no |
| `procfs_path` | `string` | The procfs mount point. | `"/proc"` | no |
| `recheck_on_scrape` | `bool` | Recheck process names on each scrape. | `false` | no |
| `remove_empty_groups` | `bool` | Forget process groups with no processes. | `false` | no |
| `track_children` | `bool` | Whether to track a process' children. | `true` | no |
| `track_threads` | `bool` | Report metrics for a process' individual threads. | `true` | no |

If `remove_empty_groups` is `true`, the process "groups" created by the `matcher` blocks continue to report metrics until {{< param "PRODUCT_NAME" >}} is restarted.
This can cause unbounded growth in metrics being reported and resources consumed by {{< param "PRODUCT_NAME" >}} if the `matcher` blocks' `name` arguments define group names that
may be different for new process instances.
This is the default behavior for backwards compatibility, but we recommend that you set `remove_empty_groups` to `false`.

For example, when `remove_empty_groups` is `true` and the `name` argument for a `matcher` block utilizes the `.PID` of
a process, the `matcher` creates a new process group when a new instance of a process in that `matcher` block is identified.
The previous group continues to report metrics even though no running processes are associated with that group.

## Blocks

Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ require (
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
github.com/natefinch/atomic v1.0.1
github.com/ncabatoff/process-exporter v0.7.10
github.com/ncabatoff/process-exporter v0.8.7
github.com/oklog/run v1.2.0
github.com/olekukonko/tablewriter v0.0.5
github.com/oliver006/redis_exporter v1.54.0
Expand Down Expand Up @@ -1096,7 +1096,7 @@ replace (

// TODO(marctc, mattdurham): Replace node_export with custom fork for multi usage. https://github.com/prometheus/node_exporter/pull/2812
// this commit is on the refactor_collectors branch in the grafana fork.
github.com/prometheus/node_exporter => github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20250218170810-6300fab82195 //refactor_collectors
github.com/prometheus/node_exporter => github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20250806062222-612bdf9540ec //refactor_collectors
)

replace github.com/github/smimesign => github.com/grafana/smimesign v0.2.1-0.20220408144937-2a5adf3481d3
Expand All @@ -1111,8 +1111,6 @@ exclude (
k8s.io/client-go v12.0.0+incompatible
)

replace github.com/prometheus/procfs => github.com/prometheus/procfs v0.12.0

replace go.opentelemetry.io/ebpf-profiler => github.com/grafana/opentelemetry-ebpf-profiler v0.0.0-20250624035245-5fc775dac6dc

// TODO - remove this once otel updates to go 1.24 & k8s client 0.33.x
Expand Down
25 changes: 17 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,8 @@ github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe h1:yIXAAbLswn
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd h1:FW1Km8Z1mE8r/WLBAbX3LYv14DEZehdZTWOfF4qsqOY=
github.com/grafana/mysqld_exporter v0.17.2-0.20250226152553-be612e3fdedd/go.mod h1:iEFA+REkm+0WRvVxy0cA1bBhJlFcQB998yymb45TqMU=
github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20250218170810-6300fab82195 h1:K7uSltwt72o1IkGGCDFkj/d87uXB4pk3BRfpJZgZX3E=
github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20250218170810-6300fab82195/go.mod h1:onpUlSx7BWY8aO+tr3DChzBJB06pZfZ4gltVtsRXLFA=
github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20250806062222-612bdf9540ec h1:0IKKoe10XCjjHNajIjMfZR3LMJvzbltZmBmSD9EAP/0=
github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20250806062222-612bdf9540ec/go.mod h1:1qoZ74W1muNrTyeP2fUzUbg2UKD8AeX435xSCJNub7Y=
github.com/grafana/opentelemetry-collector/featuregate v0.0.0-20240325174506-2fd1623b2ca0 h1:i/Ne0XwoRokYj52ZcSmnvuyID3h/uA91n0Ycg/grHU8=
github.com/grafana/opentelemetry-collector/featuregate v0.0.0-20240325174506-2fd1623b2ca0/go.mod h1:mm8+xyQfgDmqhyegZRNIQmoKsNnDTwWKFLsdMoXAb7A=
github.com/grafana/opentelemetry-ebpf-profiler v0.0.0-20250624035245-5fc775dac6dc h1:Qv8+wIvDB5c1liVKAcTNxgKTf/gEQSyPEAiVZXrSLR8=
Expand Down Expand Up @@ -1938,11 +1938,10 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/ncabatoff/fakescraper v0.0.0-20201102132415-4b37ba603d65/go.mod h1:Tx6UMSMyIsjLG/VU/F6xA1+0XI+/f9o1dGJnf1l+bPg=
github.com/ncabatoff/go-seq v0.0.0-20180805175032-b08ef85ed833 h1:t4WWQ9I797y7QUgeEjeXnVb+oYuEDQc6gLvrZJTYo94=
github.com/ncabatoff/go-seq v0.0.0-20180805175032-b08ef85ed833/go.mod h1:0CznHmXSjMEqs5Tezj/w2emQoM41wzYM9KpDKUHPYag=
github.com/ncabatoff/process-exporter v0.7.10 h1:+Ere7+3se6QqP54gg7aBRagWcL8bq3u5zNi/GRSWeKQ=
github.com/ncabatoff/process-exporter v0.7.10/go.mod h1:DHZRZjqxw9LCOpLlX0DjBuyn6d5plh41Jv6Tmttj7Ek=
github.com/ncabatoff/process-exporter v0.8.7 h1:V+Xtlq7Q9ticzNtkIR9fUlyNxD+rQLs1P8qzumsCWQI=
github.com/ncabatoff/process-exporter v0.8.7/go.mod h1:tzUO/+OadS/ynh8xu2lO66zb72a8x0VrIWLPddKGilU=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down Expand Up @@ -2388,8 +2387,18 @@ github.com/prometheus/memcached_exporter v0.13.0 h1:d246RYODFCXy39XA8S2PBrqp5jLC
github.com/prometheus/memcached_exporter v0.13.0/go.mod h1:fp7Wk6v0RFijeP3Syvd1TShBSJoCG5iFfvPdi5dCMEU=
github.com/prometheus/otlptranslator v0.0.0-20250414121140-35db323fe9fb h1:wuS7VydG/rDWTbYMp07paPv3R1hiPC9WgingWs+xgi0=
github.com/prometheus/otlptranslator v0.0.0-20250414121140-35db323fe9fb/go.mod h1:M7gjuJF83qnpgElJIPfhiK+YAHlvot5epcAV+Rie7eo=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/prometheus/sigv4 v0.2.0 h1:qDFKnHYFswJxdzGeRP63c4HlH3Vbn1Yf/Ao2zabtVXk=
github.com/prometheus/sigv4 v0.2.0/go.mod h1:D04rqmAaPPEUkjRQxGqjoxdyJuyCh6E0M18fZr0zBiE=
github.com/prometheus/snmp_exporter v0.29.0 h1:COShgBj1tmWvA5pAkWQgO/lB3+bL/MFqUIqOELSZaBw=
Expand Down Expand Up @@ -2427,7 +2436,6 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
Expand Down Expand Up @@ -3330,6 +3338,7 @@ golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
22 changes: 12 additions & 10 deletions internal/component/prometheus/exporter/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ func createIntegration(opts component.Options, args component.Arguments, default
// DefaultArguments holds the default arguments for the prometheus.exporter.process
// component.
var DefaultArguments = Arguments{
ProcFSPath: "/proc",
Children: true,
Threads: true,
SMaps: true,
Recheck: false,
ProcFSPath: "/proc",
Children: true,
Threads: true,
SMaps: true,
Recheck: false,
RemoveEmptyGroups: false,
}

// Arguments configures the prometheus.exporter.process component
type Arguments struct {
ProcessExporter []MatcherGroup `alloy:"matcher,block,optional"`

ProcFSPath string `alloy:"procfs_path,attr,optional"`
Children bool `alloy:"track_children,attr,optional"`
Threads bool `alloy:"track_threads,attr,optional"`
SMaps bool `alloy:"gather_smaps,attr,optional"`
Recheck bool `alloy:"recheck_on_scrape,attr,optional"`
ProcFSPath string `alloy:"procfs_path,attr,optional"`
Children bool `alloy:"track_children,attr,optional"`
Threads bool `alloy:"track_threads,attr,optional"`
SMaps bool `alloy:"gather_smaps,attr,optional"`
Recheck bool `alloy:"recheck_on_scrape,attr,optional"`
RemoveEmptyGroups bool `alloy:"remove_empty_groups,attr,optional"`
}

// MatcherGroup taken and converted to Alloy from github.com/ncabatoff/process-exporter/config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestAlloyConfigUnmarshal(t *testing.T) {
track_threads = false
gather_smaps = true
recheck_on_scrape = true
remove_empty_groups = true
`

var args Arguments
Expand All @@ -29,6 +30,7 @@ func TestAlloyConfigUnmarshal(t *testing.T) {
require.False(t, args.Threads)
require.True(t, args.SMaps)
require.True(t, args.Recheck)
require.True(t, args.RemoveEmptyGroups)

expected := []MatcherGroup{
{
Expand Down Expand Up @@ -76,6 +78,7 @@ func TestAlloyConfigConvert(t *testing.T) {
require.True(t, c.Threads)
require.False(t, c.SMaps)
require.False(t, c.Recheck)
require.False(t, c.RemoveEmptyGroups)

e := config.MatcherRules{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ func toProcessExporter(config *process_exporter.Config) *process.Arguments {
}

return &process.Arguments{
ProcessExporter: matcherGroups,
ProcFSPath: config.ProcFSPath,
Children: config.Children,
Threads: config.Threads,
SMaps: config.SMaps,
Recheck: config.Recheck,
ProcessExporter: matcherGroups,
ProcFSPath: config.ProcFSPath,
Children: config.Children,
Threads: config.Threads,
SMaps: config.SMaps,
Recheck: config.Recheck,
RemoveEmptyGroups: config.RemoveEmptyGroups,
}
}
22 changes: 12 additions & 10 deletions internal/static/integrations/process_exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ import (

// DefaultConfig holds the default settings for the process_exporter integration.
var DefaultConfig = Config{
ProcFSPath: "/proc",
Children: true,
Threads: true,
SMaps: true,
Recheck: false,
ProcFSPath: "/proc",
Children: true,
Threads: true,
SMaps: true,
Recheck: false,
RemoveEmptyGroups: false,
}

// Config controls the process_exporter integration.
type Config struct {
ProcessExporter exporter_config.MatcherRules `yaml:"process_names,omitempty"`

ProcFSPath string `yaml:"procfs_path,omitempty"`
Children bool `yaml:"track_children,omitempty"`
Threads bool `yaml:"track_threads,omitempty"`
SMaps bool `yaml:"gather_smaps,omitempty"`
Recheck bool `yaml:"recheck_on_scrape,omitempty"`
ProcFSPath string `yaml:"procfs_path,omitempty"`
Children bool `yaml:"track_children,omitempty"`
Threads bool `yaml:"track_threads,omitempty"`
SMaps bool `yaml:"gather_smaps,omitempty"`
Recheck bool `yaml:"recheck_on_scrape,omitempty"`
RemoveEmptyGroups bool `yaml:"remove_empty_groups,omitempty"`
}

// UnmarshalYAML implements yaml.Unmarshaler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ func New(logger log.Logger, c *Config) (*Integration, error) {
}

pc, err := collector.NewProcessCollector(collector.ProcessCollectorOption{
ProcFSPath: c.ProcFSPath,
Children: c.Children,
Threads: c.Threads,
GatherSMaps: c.SMaps,
Namer: cfg.MatchNamers,
Recheck: c.Recheck,
Debug: false,
ProcFSPath: c.ProcFSPath,
Children: c.Children,
Threads: c.Threads,
GatherSMaps: c.SMaps,
Namer: cfg.MatchNamers,
Recheck: c.Recheck,
RemoveEmptyGroups: c.RemoveEmptyGroups,
Debug: false,
})
if err != nil {
return nil, err
Expand Down
Loading