From 21d8f705cbda107761dfa417dcbb7824f0501ff0 Mon Sep 17 00:00:00 2001 From: hainenber Date: Wed, 6 Dec 2023 23:38:10 +0700 Subject: [PATCH 1/7] feat(exporter/windows): expose physical_disk collector Signed-off-by: hainenber --- CHANGELOG.md | 3 +++ component/prometheus/exporter/windows/config.go | 16 ++++++++++++++++ .../internal/build/windows_exporter.go | 4 ++++ .../components/prometheus.exporter.windows.md | 1 + pkg/integrations/windows_exporter/config.go | 7 +++++++ .../windows_exporter/config_windows.go | 7 +++++++ 6 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e532812bb40c..9a57c5c5010d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,9 @@ Main (unreleased) - Added links between compatible components in the documentation to make it easier to discover them. (@thampiotr) +- Expose `physical_disk` collector from `windows_exporter` v0.24.0 to + Flow configuration. (@hainenber) + ### Bugfixes - Update `pyroscope.ebpf` to fix a logical bug causing to profile to many kthreads instead of regular processes https://github.com/grafana/pyroscope/pull/2778 (@korniltsev) diff --git a/component/prometheus/exporter/windows/config.go b/component/prometheus/exporter/windows/config.go index cc4cb20e4b17..fda9d16b9f3e 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:"network,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/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/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..9d7cbd40f397 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, From c5ffd5d7f1af8c6d61d6ffbf5998365e37221c39 Mon Sep 17 00:00:00 2001 From: hainenber Date: Wed, 6 Dec 2023 23:57:25 +0700 Subject: [PATCH 2/7] fix(exporter/windows): correct river attr name for physical_disk Signed-off-by: hainenber --- component/prometheus/exporter/windows/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/prometheus/exporter/windows/config.go b/component/prometheus/exporter/windows/config.go index fda9d16b9f3e..44568833c1cd 100644 --- a/component/prometheus/exporter/windows/config.go +++ b/component/prometheus/exporter/windows/config.go @@ -19,7 +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:"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"` From 9565147c5d6a9f29448d89a0bee34f7c6066a9a7 Mon Sep 17 00:00:00 2001 From: hainenber Date: Thu, 7 Dec 2023 00:04:19 +0700 Subject: [PATCH 3/7] feat(exporter/windows): set default args for physical_disk attr Signed-off-by: hainenber --- component/prometheus/exporter/windows/config_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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, From 24fd918a63a6c983eccd476bafcf6429876a99dc Mon Sep 17 00:00:00 2001 From: hainenber Date: Thu, 7 Dec 2023 00:04:40 +0700 Subject: [PATCH 4/7] feat(exporter/windows): update unit test + integration doc Signed-off-by: hainenber --- .../exporter/windows/config_default_windows_test.go | 2 ++ component/prometheus/exporter/windows/windows_test.go | 9 +++++++++ .../integrations/windows-exporter-config.md | 10 ++++++++++ 3 files changed, 21 insertions(+) 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/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/docs/sources/static/configuration/integrations/windows-exporter-config.md b/docs/sources/static/configuration/integrations/windows-exporter-config.md index 53c58b60fe0b..4d45e30acafe 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. From a29e1ae96d57f14f089efe24ab1c3ccceab184f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20Tr=E1=BB=8Dng=20H=E1=BA=A3i?= <41283691+hainenber@users.noreply.github.com> Date: Wed, 20 Dec 2023 22:34:16 +0700 Subject: [PATCH 5/7] Update docs/sources/static/configuration/integrations/windows-exporter-config.md Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com> --- .../configuration/integrations/windows-exporter-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/static/configuration/integrations/windows-exporter-config.md b/docs/sources/static/configuration/integrations/windows-exporter-config.md index 4d45e30acafe..feafa84d6229 100644 --- a/docs/sources/static/configuration/integrations/windows-exporter-config.md +++ b/docs/sources/static/configuration/integrations/windows-exporter-config.md @@ -117,7 +117,7 @@ Full reference of options: # 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 + # 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. From e0299be72b34243b5bf964e853ed3beef5f7c620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20Tr=E1=BB=8Dng=20H=E1=BA=A3i?= <41283691+hainenber@users.noreply.github.com> Date: Wed, 20 Dec 2023 22:34:21 +0700 Subject: [PATCH 6/7] Update docs/sources/static/configuration/integrations/windows-exporter-config.md Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com> --- .../configuration/integrations/windows-exporter-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/static/configuration/integrations/windows-exporter-config.md b/docs/sources/static/configuration/integrations/windows-exporter-config.md index feafa84d6229..7f12117ebfbc 100644 --- a/docs/sources/static/configuration/integrations/windows-exporter-config.md +++ b/docs/sources/static/configuration/integrations/windows-exporter-config.md @@ -121,7 +121,7 @@ Full reference of options: [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 + # Maps to collector.logical_disk.disk-exclude in windows_exporter. [exclude: | default=".+"] # Configuration for Windows Processes From 4515d6fb75d16fae9bf9e6664207230dcfd712a8 Mon Sep 17 00:00:00 2001 From: mattdurham Date: Thu, 11 Jan 2024 09:48:47 -0500 Subject: [PATCH 7/7] Update config_windows.go adding a comma --- pkg/integrations/windows_exporter/config_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/integrations/windows_exporter/config_windows.go b/pkg/integrations/windows_exporter/config_windows.go index 9d7cbd40f397..657ff5861de4 100644 --- a/pkg/integrations/windows_exporter/config_windows.go +++ b/pkg/integrations/windows_exporter/config_windows.go @@ -91,7 +91,7 @@ var DefaultConfig = Config{ Exclude: collector.ConfigDefaults.Net.NicExclude, }, PhysicalDisk: PhysicalDiskConfig{ - Include: collector.ConfigDefaults.PhysicalDisk.DiskInclude + Include: collector.ConfigDefaults.PhysicalDisk.DiskInclude, Exclude: collector.ConfigDefaults.PhysicalDisk.DiskExclude, }, Process: ProcessConfig{