diff --git a/CHANGELOG.md b/CHANGELOG.md index a4c13c5d97b7..3253b1909844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/component/prometheus/exporter/windows/config.go b/component/prometheus/exporter/windows/config.go index cc4cb20e4b17..44568833c1cd 100644 --- a/component/prometheus/exporter/windows/config.go +++ b/component/prometheus/exporter/windows/config.go @@ -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"` @@ -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(), @@ -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, + } +} diff --git a/component/prometheus/exporter/windows/config_default_windows_test.go b/component/prometheus/exporter/windows/config_default_windows_test.go index 9fddd1d635eb..7242ac42e525 100644 --- a/component/prometheus/exporter/windows/config_default_windows_test.go +++ b/component/prometheus/exporter/windows/config_default_windows_test.go @@ -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) diff --git a/component/prometheus/exporter/windows/config_windows.go b/component/prometheus/exporter/windows/config_windows.go index b634788eda8c..42270f9e241e 100644 --- a/component/prometheus/exporter/windows/config_windows.go +++ b/component/prometheus/exporter/windows/config_windows.go @@ -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 @@ -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, diff --git a/component/prometheus/exporter/windows/windows_test.go b/component/prometheus/exporter/windows/windows_test.go index 8b34164f5d7c..6f15ad6e7555 100644 --- a/component/prometheus/exporter/windows/windows_test.go +++ b/component/prometheus/exporter/windows/windows_test.go @@ -34,6 +34,11 @@ var ( service { where_clause = "where" } + + physical_disk { + include = ".+" + exclude = "" + } process { include = ".+" @@ -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) @@ -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) diff --git a/converter/internal/staticconvert/internal/build/windows_exporter.go b/converter/internal/staticconvert/internal/build/windows_exporter.go index 73aa706e8235..2f0b110a68f0 100644 --- a/converter/internal/staticconvert/internal/build/windows_exporter.go +++ b/converter/internal/staticconvert/internal/build/windows_exporter.go @@ -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, diff --git a/docs/sources/flow/reference/components/prometheus.exporter.windows.md b/docs/sources/flow/reference/components/prometheus.exporter.windows.md index 4ad33effdd4a..8042b5458d1c 100644 --- a/docs/sources/flow/reference/components/prometheus.exporter.windows.md +++ b/docs/sources/flow/reference/components/prometheus.exporter.windows.md @@ -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 | ✓ [os](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.os.md) | OS metrics (memory, processes, users) | ✓ +[physical_disk](https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.physical_disk.md) | Physical disks | ✓ [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 | diff --git a/docs/sources/static/configuration/integrations/windows-exporter-config.md b/docs/sources/static/configuration/integrations/windows-exporter-config.md index 53c58b60fe0b..7f12117ebfbc 100644 --- a/docs/sources/static/configuration/integrations/windows-exporter-config.md +++ b/docs/sources/static/configuration/integrations/windows-exporter-config.md @@ -114,6 +114,16 @@ Full reference of options: # Maps to collector.service.services-where in windows_exporter [where_clause: | 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: | 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: | default=".+"] + # Configuration for Windows Processes process: # Regexp of processes to include. Process name must both match whitelist and not match blacklist to be included. diff --git a/pkg/integrations/windows_exporter/config.go b/pkg/integrations/windows_exporter/config.go index 006bc5426d72..a8bdba73174c 100644 --- a/pkg/integrations/windows_exporter/config.go +++ b/pkg/integrations/windows_exporter/config.go @@ -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"` @@ -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"` +} diff --git a/pkg/integrations/windows_exporter/config_windows.go b/pkg/integrations/windows_exporter/config_windows.go index 17fd03d4f80c..657ff5861de4 100644 --- a/pkg/integrations/windows_exporter/config_windows.go +++ b/pkg/integrations/windows_exporter/config_windows.go @@ -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) @@ -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,