Skip to content

Commit

Permalink
feat(exporter/windows): expose physical_disk collector (#5927)
Browse files Browse the repository at this point in the history
* feat(exporter/windows): expose physical_disk collector

Signed-off-by: hainenber <[email protected]>

* fix(exporter/windows): correct river attr name for physical_disk

Signed-off-by: hainenber <[email protected]>

* feat(exporter/windows): set default args for physical_disk attr

Signed-off-by: hainenber <[email protected]>

* feat(exporter/windows): update unit test + integration doc

Signed-off-by: hainenber <[email protected]>

* Update docs/sources/static/configuration/integrations/windows-exporter-config.md

Co-authored-by: Clayton Cornell <[email protected]>

* Update docs/sources/static/configuration/integrations/windows-exporter-config.md

Co-authored-by: Clayton Cornell <[email protected]>

---------

Signed-off-by: hainenber <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
  • Loading branch information
hainenber and clayton-cornell authored Jan 11, 2024
1 parent 2ba4488 commit 19318b6
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ v0.39.0 (2024-01-09)
- `discovery.lightsail` now supports additional parameters for configuring HTTP client settings. (@ptodev)
- Add `sample_age_limit` to remote_write config to drop samples older than a specified duration. (@marctc)

- Expose `physical_disk` collector from `windows_exporter` v0.24.0 to
Flow configuration. (@hainenber)

- Handle paths in the Kubelet URL for `discovery.kubelet`. (@petewall)

- `loki.source.docker` now deduplicates targets which report the same container
Expand Down
16 changes: 16 additions & 0 deletions component/prometheus/exporter/windows/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Arguments struct {
MSMQ MSMQConfig `river:"msmq,block,optional"`
MSSQL MSSQLConfig `river:"mssql,block,optional"`
Network NetworkConfig `river:"network,block,optional"`
PhysicalDisk PhysicalDiskConfig `river:"physical_disk,block,optional"`
Process ProcessConfig `river:"process,block,optional"`
ScheduledTask ScheduledTaskConfig `river:"scheduled_task,block,optional"`
Service ServiceConfig `river:"service,block,optional"`
Expand All @@ -38,6 +39,7 @@ func (a *Arguments) Convert() *windows_integration.Config {
MSSQL: a.MSSQL.Convert(),
Network: a.Network.Convert(),
Process: a.Process.Convert(),
PhysicalDisk: a.PhysicalDisk.Convert(),
ScheduledTask: a.ScheduledTask.Convert(),
Service: a.Service.Convert(),
SMTP: a.SMTP.Convert(),
Expand Down Expand Up @@ -230,3 +232,17 @@ func (t LogicalDiskConfig) Convert() windows_integration.LogicalDiskConfig {
Exclude: t.Exclude,
}
}

// PhysicalDiskConfig handles settings for the windows_exporter physical disk collector
type PhysicalDiskConfig struct {
Include string `river:"include,attr,optional"`
Exclude string `river:"exclude,attr,optional"`
}

// Convert converts the component's PhysicalDiskConfig to the integration's PhysicalDiskConfig.
func (t PhysicalDiskConfig) Convert() windows_integration.PhysicalDiskConfig {
return windows_integration.PhysicalDiskConfig{
Include: t.Include,
Exclude: t.Exclude,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func TestRiverUnmarshalWithDefaultConfig(t *testing.T) {
require.Equal(t, DefaultArguments.MSSQL.EnabledClasses, args.MSSQL.EnabledClasses)
require.Equal(t, DefaultArguments.Network.Exclude, args.Network.Exclude)
require.Equal(t, DefaultArguments.Network.Include, args.Network.Include)
require.Equal(t, DefaultArguments.PhysicalDisk.Exclude, args.PhysicalDisk.Exclude)
require.Equal(t, DefaultArguments.PhysicalDisk.Include, args.PhysicalDisk.Include)
require.Equal(t, DefaultArguments.Process.Exclude, args.Process.Exclude)
require.Equal(t, DefaultArguments.Process.Include, args.Process.Include)
require.Equal(t, DefaultArguments.ScheduledTask.Exclude, args.ScheduledTask.Exclude)
Expand Down
7 changes: 6 additions & 1 deletion component/prometheus/exporter/windows/config_windows.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package windows

import (
"strings"

windows_integration "github.com/grafana/agent/pkg/integrations/windows_exporter"
col "github.com/prometheus-community/windows_exporter/pkg/collector"
"strings"
)

// DefaultArguments holds non-zero default options for Arguments when it is
Expand Down Expand Up @@ -44,6 +45,10 @@ var DefaultArguments = Arguments{
Include: col.ConfigDefaults.Net.NicInclude,
Exclude: col.ConfigDefaults.Net.NicExclude,
},
PhysicalDisk: PhysicalDiskConfig{
Exclude: col.ConfigDefaults.PhysicalDisk.DiskExclude,
Include: col.ConfigDefaults.PhysicalDisk.DiskInclude,
},
Process: ProcessConfig{
BlackList: col.ConfigDefaults.Process.ProcessExclude,
WhiteList: col.ConfigDefaults.Process.ProcessInclude,
Expand Down
9 changes: 9 additions & 0 deletions component/prometheus/exporter/windows/windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ var (
service {
where_clause = "where"
}
physical_disk {
include = ".+"
exclude = ""
}
process {
include = ".+"
Expand Down Expand Up @@ -75,6 +80,8 @@ func TestRiverUnmarshal(t *testing.T) {
require.Equal(t, "", args.SMTP.Exclude)
require.Equal(t, ".+", args.SMTP.Include)
require.Equal(t, "where", args.Service.Where)
require.Equal(t, "", args.PhysicalDisk.Exclude)
require.Equal(t, ".+", args.PhysicalDisk.Include)
require.Equal(t, "", args.Process.Exclude)
require.Equal(t, ".+", args.Process.Include)
require.Equal(t, "", args.Network.Exclude)
Expand Down Expand Up @@ -102,6 +109,8 @@ func TestConvert(t *testing.T) {
require.Equal(t, "", conf.SMTP.Exclude)
require.Equal(t, ".+", conf.SMTP.Include)
require.Equal(t, "where", conf.Service.Where)
require.Equal(t, "", conf.PhysicalDisk.Exclude)
require.Equal(t, ".+", conf.PhysicalDisk.Include)
require.Equal(t, "", conf.Process.Exclude)
require.Equal(t, ".+", conf.Process.Include)
require.Equal(t, "", conf.Network.Exclude)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func toWindowsExporter(config *windows_exporter.Config) *windows.Arguments {
Exclude: config.Network.Exclude,
Include: config.Network.Include,
},
PhysicalDisk: windows.PhysicalDiskConfig{
Exclude: config.PhysicalDisk.Exclude,
Include: config.PhysicalDisk.Include,
},
Process: windows.ProcessConfig{
BlackList: config.Process.BlackList,
WhiteList: config.Process.WhiteList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ Name | Description | Enabled by default
[netframework_clrsecurity](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.netframework_clrsecurity.md) | .NET Framework Security Check metrics |
[net](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.net.md) | Network interface I/O | &#10003;
[os](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.os.md) | OS metrics (memory, processes, users) | &#10003;
[physical_disk](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.physical_disk.md) | Physical disks | &#10003;
[process](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.process.md) | Per-process metrics |
[remote_fx](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.remote_fx.md) | RemoteFX protocol (RDP) metrics |
[scheduled_task](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.scheduled_task.md) | Scheduled Tasks metrics |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ Full reference of options:
# Maps to collector.service.services-where in windows_exporter
[where_clause: <string> | default=""]

# Configuration for physical disk on Windows
physical_disk:
# Regexp of volumes to include. Disk name must both match include and not match exclude to be included.
# Maps to collector.logical_disk.disk-include in windows_exporter.
[include: <string> | default=".+"]

# Regexp of volumes to exclude. Disk name must both match include and not match exclude to be included.
# Maps to collector.logical_disk.disk-exclude in windows_exporter.
[exclude: <string> | default=".+"]

# Configuration for Windows Processes
process:
# Regexp of processes to include. Process name must both match whitelist and not match blacklist to be included.
Expand Down
7 changes: 7 additions & 0 deletions pkg/integrations/windows_exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
TextFile TextFileConfig `yaml:"text_file,omitempty"`
SMTP SMTPConfig `yaml:"smtp,omitempty"`
Service ServiceConfig `yaml:"service,omitempty"`
PhysicalDisk PhysicalDiskConfig `yaml:"physical_disk,omitempty"`
Process ProcessConfig `yaml:"process,omitempty"`
Network NetworkConfig `yaml:"network,omitempty"`
MSSQL MSSQLConfig `yaml:"mssql,omitempty"`
Expand Down Expand Up @@ -126,3 +127,9 @@ type ScheduledTaskConfig struct {
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}

// PhysicalDiskConfig handles settings for the windows_exporter physical disk collector
type PhysicalDiskConfig struct {
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}
7 changes: 7 additions & 0 deletions pkg/integrations/windows_exporter/config_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func (c *Config) ToWindowsExporterConfig() collector.Config {

cfg.Textfile.TextFileDirectories = c.TextFile.TextFileDirectory

cfg.PhysicalDisk.DiskInclude = c.PhysicalDisk.Include
cfg.PhysicalDisk.DiskExclude = c.PhysicalDisk.Exclude

cfg.Process.ProcessExclude = coalesceString(c.Process.Exclude, c.Process.BlackList)
cfg.Process.ProcessInclude = coalesceString(c.Process.Include, c.Process.WhiteList)

Expand Down Expand Up @@ -87,6 +90,10 @@ var DefaultConfig = Config{
Include: collector.ConfigDefaults.Net.NicInclude,
Exclude: collector.ConfigDefaults.Net.NicExclude,
},
PhysicalDisk: PhysicalDiskConfig{
Include: collector.ConfigDefaults.PhysicalDisk.DiskInclude,
Exclude: collector.ConfigDefaults.PhysicalDisk.DiskExclude,
},
Process: ProcessConfig{
BlackList: collector.ConfigDefaults.Process.ProcessExclude,
WhiteList: collector.ConfigDefaults.Process.ProcessInclude,
Expand Down

0 comments on commit 19318b6

Please sign in to comment.