Skip to content

Commit

Permalink
[integrations] Add udev data path arg to node_exporter (#4481)
Browse files Browse the repository at this point in the history
  • Loading branch information
sduranc authored and clayton-cornell committed Aug 14, 2023
1 parent c4878d5 commit c11f101
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Main (unreleased)
### Enhancements

- Add [godeltaprof](https://github.com/grafana/godeltaprof) profiling types (`godeltaprof_memory`, `godeltaprof_mutex`, `godeltaprof_block`) to `pyroscope.scrape` component

- Integrations: make `udev` data path configurable in the `node_exporter` integration. (@sduranc)

### Bugfixes

Expand Down
9 changes: 6 additions & 3 deletions component/prometheus/exporter/unix/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
//
// Some defaults are populated from init functions in the github.com/grafana/agent/pkg/integrations/node_exporter package.
var DefaultArguments = Arguments{
ProcFSPath: node_integration.DefaultConfig.ProcFSPath,
RootFSPath: node_integration.DefaultConfig.RootFSPath,
SysFSPath: node_integration.DefaultConfig.SysFSPath,
ProcFSPath: node_integration.DefaultConfig.ProcFSPath,
RootFSPath: node_integration.DefaultConfig.RootFSPath,
SysFSPath: node_integration.DefaultConfig.SysFSPath,
UdevDataPath: node_integration.DefaultConfig.UdevDataPath,
Disk: DiskStatsConfig{
DeviceExclude: node_integration.DefaultConfig.DiskStatsDeviceExclude,
},
Expand Down Expand Up @@ -66,6 +67,7 @@ type Arguments struct {
ProcFSPath string `river:"procfs_path,attr,optional"`
SysFSPath string `river:"sysfs_path,attr,optional"`
RootFSPath string `river:"rootfs_path,attr,optional"`
UdevDataPath string `river:"udev_data_path,attr,optional"`

// Collectors to mark as enabled
EnableCollectors flagext.StringSlice `river:"enable_collectors,attr,optional"`
Expand Down Expand Up @@ -106,6 +108,7 @@ func (a *Arguments) Convert() *node_integration.Config {
ProcFSPath: a.ProcFSPath,
SysFSPath: a.SysFSPath,
RootFSPath: a.RootFSPath,
UdevDataPath: a.UdevDataPath,
EnableCollectors: a.EnableCollectors,
DisableCollectors: a.DisableCollectors,
SetCollectors: a.SetCollectors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Name | Type | Description | Default | Required
`procfs_path` | `string` | The procfs mountpoint. | `/proc` | no
`sysfs_path` | `string` | The sysfs mountpoint. | `/sys` | no
`rootfs_path` | `string` | Specify a prefix for accessing the host filesystem. | `/` | no
`udev_data_path` | `string` | The udev data path. | `/run/udev/data` | no

`set_collectors` defines a hand-picked list of enabled-by-default
collectors. If set, anything not provided in that list is disabled by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ integrations:
rootfs_path: /host/root
sysfs_path: /host/sys
procfs_path: /host/proc
udev_data_path: /host/root/run/udev/data
```

For running on Kubernetes, ensure to set the equivalent mounts and capabilities
Expand Down Expand Up @@ -266,6 +267,10 @@ the Agent is running on is a no-op.
# directory.
[rootfs_path: <string> | default = "/"]

# udev data path needed for diskstats from Node exporter. When running
# in Kubernetes it should be set to /host/root/run/udev/data.
[udev_data_path: <string> | default = "/run/udev/data"]

# Expose expensive bcache priority stats.
[enable_bcache_priority_stats: <boolean>]

Expand Down
13 changes: 8 additions & 5 deletions pkg/integrations/node_exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ var (
// DefaultConfig's defaults are populated from init functions in this package.
// See the init function here and in node_exporter_linux.go.
DefaultConfig = Config{
ProcFSPath: procfs.DefaultMountPoint,
RootFSPath: "/",
ProcFSPath: procfs.DefaultMountPoint,
RootFSPath: "/",
UdevDataPath: "/run/udev/data",

DiskStatsDeviceExclude: "^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$",

Expand Down Expand Up @@ -82,9 +83,10 @@ func init() {
type Config struct {
IncludeExporterMetrics bool `yaml:"include_exporter_metrics,omitempty"`

ProcFSPath string `yaml:"procfs_path,omitempty"`
SysFSPath string `yaml:"sysfs_path,omitempty"`
RootFSPath string `yaml:"rootfs_path,omitempty"`
ProcFSPath string `yaml:"procfs_path,omitempty"`
SysFSPath string `yaml:"sysfs_path,omitempty"`
RootFSPath string `yaml:"rootfs_path,omitempty"`
UdevDataPath string `yaml:"udev_data_path,omitempty"`

// Collectors to mark as enabled
EnableCollectors flagext.StringSlice `yaml:"enable_collectors,omitempty"`
Expand Down Expand Up @@ -307,6 +309,7 @@ func MapConfigToNodeExporterFlags(c *Config) (accepted []string, ignored []strin
"--path.procfs", c.ProcFSPath,
"--path.sysfs", c.SysFSPath,
"--path.rootfs", c.RootFSPath,
"--path.udev.data", c.UdevDataPath,
)

if collectors[CollectorBCache] {
Expand Down

0 comments on commit c11f101

Please sign in to comment.