Skip to content

Commit

Permalink
improvement: Expose hwmon collector config options in prometheus.expo…
Browse files Browse the repository at this point in the history
…rter.unix component. (#1369)

* improvement: Expose hwmon collector config options in prometheus.exporter.unix component.

* Cleanup docs. Add changelog. Consitent naming hwmon.

* Cleanup changelog.

* Add to convert command. Fix docstrings suggestions from PR review

* PR review doc recommendations

---------

Co-authored-by: William Dumont <william.dumont@grafana.com>
  • Loading branch information
dtrejod and wildum authored Aug 1, 2024
1 parent 69d1a38 commit c711385
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Main (unreleased)

- `mimir.rules.kubernetes` is now able to add extra labels to the Prometheus rules. (@psychomantys)

- `prometheus.exporter.unix` component now exposes hwmon collector config. (@dtrejod)

- Upgrade from OpenTelemetry v0.102.1 to v0.105.0.
- [`otelcol.receiver.*`] A new `compression_algorithms` attribute to configure which
compression algorithms are allowed by the HTTP server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The following blocks are supported inside the definition of `prometheus.exporter
| disk | [disk][] | Configures the diskstats collector. | no |
| ethtool | [ethtool][] | Configures the ethtool collector. | no |
| filesystem | [filesystem][] | Configures the filesystem collector. | no |
| hwmon | [hwmon][] | Configures the hwmon collector. | no |
| ipvs | [ipvs][] | Configures the ipvs collector. | no |
| ntp | [ntp][] | Configures the ntp collector. | no |
| netclass | [netclass][] | Configures the netclass collector. | no |
Expand All @@ -80,6 +81,7 @@ The following blocks are supported inside the definition of `prometheus.exporter
[disk]: #disk-block
[ethtool]: #ethtool-block
[filesystem]: #filesystem-block
[hwmon]: #hwmon-block
[ipvs]: #ipvs-block
[ntp]: #ntp-block
[netclass]: #netclass-block
Expand Down Expand Up @@ -163,6 +165,13 @@ The default values vary by the operating system {{< param "PRODUCT_NAME" >}} run
```
{{< /code >}}

### hwmon block

| Name | Type | Description | Default | Required |
|--------------------|------------|------------------------------------------------------------------------------------|----------|----------|
| `chip_include` | `string` | Regular expression of hwmon chip to include. Mutually exclusive to `chip-exclude`. | | no |
| `chip_exclude` | `string` | Regular expression of hwmon chip to exclude. Mutually exclusive to `chip-include`. | | no |

### ipvs block

| Name | Type | Description | Default | Required |
Expand Down
9 changes: 9 additions & 0 deletions internal/component/prometheus/exporter/unix/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type Arguments struct {
Disk DiskStatsConfig `alloy:"disk,block,optional"`
EthTool EthToolConfig `alloy:"ethtool,block,optional"`
Filesystem FilesystemConfig `alloy:"filesystem,block,optional"`
HwMon HwMonConfig `alloy:"hwmon,block,optional"`
IPVS IPVSConfig `alloy:"ipvs,block,optional"`
NTP NTPConfig `alloy:"ntp,block,optional"`
Netclass NetclassConfig `alloy:"netclass,block,optional"`
Expand Down Expand Up @@ -125,6 +126,8 @@ func (a *Arguments) Convert() *node_integration.Config {
FilesystemFSTypesExclude: a.Filesystem.FSTypesExclude,
FilesystemMountPointsExclude: a.Filesystem.MountPointsExclude,
FilesystemMountTimeout: a.Filesystem.MountTimeout,
HwMonChipInclude: a.HwMon.ChipInclude,
HwMonChipExclude: a.HwMon.ChipExclude,
IPVSBackendLabels: a.IPVS.BackendLabels,
NTPIPTTL: a.NTP.IPTTL,
NTPLocalOffsetTolerance: a.NTP.LocalOffsetTolerance,
Expand Down Expand Up @@ -236,6 +239,12 @@ type EthToolConfig struct {
MetricsInclude string `alloy:"metrics_include,attr,optional"`
}

// HwMonConfig contains config specific to the hwmon collector.
type HwMonConfig struct {
ChipExclude string `alloy:"chip_exclude,attr,optional"`
ChipInclude string `alloy:"chip_include,attr,optional"`
}

// FilesystemConfig contains config specific to the filesystem collector.
type FilesystemConfig struct {
FSTypesExclude string `alloy:"fs_types_exclude,attr,optional"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func toNodeExporter(config *node_exporter.Config) *unix.Arguments {
MountPointsExclude: config.FilesystemMountPointsExclude,
MountTimeout: config.FilesystemMountTimeout,
},
HwMon: unix.HwMonConfig{
ChipExclude: config.HwMonChipExclude,
ChipInclude: config.HwMonChipInclude,
},
IPVS: unix.IPVSConfig{
BackendLabels: config.IPVSBackendLabels,
},
Expand Down
7 changes: 7 additions & 0 deletions internal/static/integrations/node_exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ type Config struct {
FilesystemFSTypesExclude string `yaml:"filesystem_fs_types_exclude,omitempty"`
FilesystemMountPointsExclude string `yaml:"filesystem_mount_points_exclude,omitempty"`
FilesystemMountTimeout time.Duration `yaml:"filesystem_mount_timeout,omitempty"`
HwMonChipInclude string `yaml:"hwmon_chip_include,omitempty"`
HwMonChipExclude string `yaml:"hwmon_chip_exclude,omitempty"`
IPVSBackendLabels []string `yaml:"ipvs_backend_labels,omitempty"`
NTPIPTTL int `yaml:"ntp_ip_ttl,omitempty"`
NTPLocalOffsetTolerance time.Duration `yaml:"ntp_local_offset_tolerance,omitempty"`
Expand Down Expand Up @@ -382,6 +384,11 @@ func (c *Config) mapConfigToNodeConfig() *collector.NodeCollectorConfig {
StatWorkerCount: &blankInt,
}

cfg.HwMon = collector.HwMonConfig{
ChipInclude: &c.HwMonChipInclude,
ChipExclude: &c.HwMonChipExclude,
}

var joinedLabels string
if len(c.IPVSBackendLabels) > 0 {
joinedLabels = strings.Join(c.IPVSBackendLabels, ",")
Expand Down

0 comments on commit c711385

Please sign in to comment.