Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exporter/windows): expose physical_disk collector #5927

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ v0.39.0-rc.0 (2024-01-05)
- `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)

### 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)
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 | ✓
[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 |
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
mattdurham marked this conversation as resolved.
Show resolved Hide resolved
Exclude: collector.ConfigDefaults.PhysicalDisk.DiskExclude,
},
Process: ProcessConfig{
BlackList: collector.ConfigDefaults.Process.ProcessExclude,
WhiteList: collector.ConfigDefaults.Process.ProcessInclude,
Expand Down