diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c632eaf6..4de217e498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,9 @@ Main (unreleased) - Add a `otelcol.processor.groupbyattrs` component to reassociate collected metrics that match specified attributes from opentelemetry. (@kehindesalaam) +- Update windows_exporter to v0.27.2. (@jkroepke) + The `smb.enabled_list` and `smb_client.enabled_list` doesn't have any effect anymore. All sub-collectors are enabled by default. + - Live debugging of `loki.process` will now also print the timestamp of incoming and outgoing log lines. This is helpful for debugging `stage.timestamp`. (@ptodev) diff --git a/docs/sources/reference/components/prometheus/prometheus.exporter.windows.md b/docs/sources/reference/components/prometheus/prometheus.exporter.windows.md index 21aab6550e..9d4be3308e 100644 --- a/docs/sources/reference/components/prometheus/prometheus.exporter.windows.md +++ b/docs/sources/reference/components/prometheus/prometheus.exporter.windows.md @@ -198,9 +198,9 @@ The v2 collector can query service states much more efficiently, but can't provi ### smb block -Name | Type | Description | Default | Required ----------------|----------|--------------------------------------------|---------|--------- -`enabled_list` | `string` | Comma-separated list of collectors to use. | `""` | no +Name | Type | Description | Default | Required +---------------|----------|----------------------------------------------------------------|---------|--------- +`enabled_list` | `string` | Deprecated (no-op), Comma-separated list of collectors to use. | `""` | no The collectors specified by `enabled_list` can include the following: @@ -210,9 +210,9 @@ For example, `enabled_list` may be set to `"ServerShares"`. ### smb_client block -Name | Type | Description | Default | Required ----------------|----------|--------------------------------------------|---------|--------- -`enabled_list` | `string` | Comma-separated list of collectors to use. | `""` | no +Name | Type | Description | Default | Required +---------------|----------|----------------------------------------------------------------|---------|--------- +`enabled_list` | `string` | Deprecated (no-op), Comma-separated list of collectors to use. | `""` | no The collectors specified by `enabled_list` can include the following: diff --git a/go.mod b/go.mod index 4acfe13a0f..2d234aa803 100644 --- a/go.mod +++ b/go.mod @@ -146,7 +146,7 @@ require ( github.com/prometheus-community/elasticsearch_exporter v1.5.0 github.com/prometheus-community/postgres_exporter v0.11.1 github.com/prometheus-community/stackdriver_exporter v0.15.1 - github.com/prometheus-community/windows_exporter v0.26.2-0.20240731160221-8f2a45d83276 + github.com/prometheus-community/windows_exporter v0.27.2 github.com/prometheus-operator/prometheus-operator v0.66.0 github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.66.0 github.com/prometheus-operator/prometheus-operator/pkg/client v0.66.0 @@ -235,7 +235,7 @@ require ( golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 golang.org/x/net v0.27.0 golang.org/x/oauth2 v0.21.0 - golang.org/x/sys v0.22.0 + golang.org/x/sys v0.24.0 golang.org/x/text v0.16.0 golang.org/x/time v0.5.0 golang.org/x/tools v0.22.0 diff --git a/go.sum b/go.sum index ddbc0fdf92..96732b60c8 100644 --- a/go.sum +++ b/go.sum @@ -2116,6 +2116,8 @@ github.com/prometheus-community/stackdriver_exporter v0.15.1 h1:+k26zeBy8BlG+eDK github.com/prometheus-community/stackdriver_exporter v0.15.1/go.mod h1:UmmIgnrVQqDAeM8pSeYntBcUxPhp8oqb8W3nvRYzsSg= github.com/prometheus-community/windows_exporter v0.26.2-0.20240731160221-8f2a45d83276 h1:hyWyr4JekYnFneEiqamv6CXQBA2ymSnS+VZgiWla++s= github.com/prometheus-community/windows_exporter v0.26.2-0.20240731160221-8f2a45d83276/go.mod h1:5r9EMDZEMh+6a7fuTOoO/aik6R33NdSj5y19TFcfvDU= +github.com/prometheus-community/windows_exporter v0.27.2 h1:/tdRTouPMVsC4qt8+s9NOPEm7L/9qdDxmasiETlx+Wk= +github.com/prometheus-community/windows_exporter v0.27.2/go.mod h1:8+T6hfv71nvgVIzguouXkIGoa15ni+uXHHULBOA2bZo= github.com/prometheus-operator/prometheus-operator v0.66.0 h1:Jj4mbGAkfBbTih6ait03f2vUjEHB7Kb4gnlAmWu7AJ0= github.com/prometheus-operator/prometheus-operator v0.66.0/go.mod h1:U7S3+u6YTxwCTMNIQxZWttEq70qBA4Qps7/c5mUZOpQ= github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.66.0 h1:PPW01FLVjJHMNcbAL1DDD9EZceSQKMOU/VpK0irrxrI= @@ -3023,6 +3025,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/internal/component/prometheus/exporter/windows/config_windows.go b/internal/component/prometheus/exporter/windows/config_windows.go index b83209690d..21ef692a7c 100644 --- a/internal/component/prometheus/exporter/windows/config_windows.go +++ b/internal/component/prometheus/exporter/windows/config_windows.go @@ -13,56 +13,56 @@ func (a *Arguments) SetToDefault() { *a = Arguments{ EnabledCollectors: strings.Split(windows_integration.DefaultConfig.EnabledCollectors, ","), Dfsr: DfsrConfig{ - SourcesEnabled: strings.Split(col.ConfigDefaults.Dfsr.DfsrEnabledCollectors, ","), + SourcesEnabled: col.ConfigDefaults.DFSR.CollectorsEnabled, }, Exchange: ExchangeConfig{ - EnabledList: strings.Split(col.ConfigDefaults.Exchange.CollectorsEnabled, ","), + EnabledList: col.ConfigDefaults.Exchange.CollectorsEnabled, }, IIS: IISConfig{ - AppBlackList: col.ConfigDefaults.Iis.AppExclude, - AppWhiteList: col.ConfigDefaults.Iis.AppInclude, - SiteBlackList: col.ConfigDefaults.Iis.SiteExclude, - SiteWhiteList: col.ConfigDefaults.Iis.SiteInclude, - AppInclude: col.ConfigDefaults.Iis.AppInclude, - AppExclude: col.ConfigDefaults.Iis.AppExclude, - SiteInclude: col.ConfigDefaults.Iis.SiteInclude, - SiteExclude: col.ConfigDefaults.Iis.SiteExclude, + AppBlackList: col.ConfigDefaults.IIS.AppExclude.String(), + AppWhiteList: col.ConfigDefaults.IIS.AppInclude.String(), + SiteBlackList: col.ConfigDefaults.IIS.SiteExclude.String(), + SiteWhiteList: col.ConfigDefaults.IIS.SiteInclude.String(), + AppInclude: col.ConfigDefaults.IIS.AppInclude.String(), + AppExclude: col.ConfigDefaults.IIS.AppExclude.String(), + SiteInclude: col.ConfigDefaults.IIS.SiteInclude.String(), + SiteExclude: col.ConfigDefaults.IIS.SiteExclude.String(), }, LogicalDisk: LogicalDiskConfig{ - BlackList: col.ConfigDefaults.LogicalDisk.VolumeExclude, - WhiteList: col.ConfigDefaults.LogicalDisk.VolumeInclude, - Include: col.ConfigDefaults.LogicalDisk.VolumeInclude, - Exclude: col.ConfigDefaults.LogicalDisk.VolumeExclude, + BlackList: col.ConfigDefaults.LogicalDisk.VolumeExclude.String(), + WhiteList: col.ConfigDefaults.LogicalDisk.VolumeInclude.String(), + Include: col.ConfigDefaults.LogicalDisk.VolumeInclude.String(), + Exclude: col.ConfigDefaults.LogicalDisk.VolumeExclude.String(), }, MSMQ: MSMQConfig{ - Where: col.ConfigDefaults.Msmq.QueryWhereClause, + Where: *col.ConfigDefaults.Msmq.QueryWhereClause, }, MSSQL: MSSQLConfig{ - EnabledClasses: strings.Split(col.ConfigDefaults.Mssql.EnabledCollectors, ","), + EnabledClasses: col.ConfigDefaults.Mssql.CollectorsEnabled, }, Network: NetworkConfig{ - BlackList: col.ConfigDefaults.Net.NicExclude, - WhiteList: col.ConfigDefaults.Net.NicInclude, - Include: col.ConfigDefaults.Net.NicInclude, - Exclude: col.ConfigDefaults.Net.NicExclude, + BlackList: col.ConfigDefaults.Net.NicExclude.String(), + WhiteList: col.ConfigDefaults.Net.NicInclude.String(), + Include: col.ConfigDefaults.Net.NicInclude.String(), + Exclude: col.ConfigDefaults.Net.NicExclude.String(), }, PhysicalDisk: PhysicalDiskConfig{ - Exclude: col.ConfigDefaults.PhysicalDisk.DiskExclude, - Include: col.ConfigDefaults.PhysicalDisk.DiskInclude, + Exclude: col.ConfigDefaults.PhysicalDisk.DiskExclude.String(), + Include: col.ConfigDefaults.PhysicalDisk.DiskInclude.String(), }, Printer: PrinterConfig{ - Include: col.ConfigDefaults.Printer.Include, - Exclude: col.ConfigDefaults.Printer.Exclude, + Include: col.ConfigDefaults.Printer.PrinterInclude.String(), + Exclude: col.ConfigDefaults.Printer.PrinterExclude.String(), }, Process: ProcessConfig{ - BlackList: col.ConfigDefaults.Process.ProcessExclude, - WhiteList: col.ConfigDefaults.Process.ProcessInclude, - Include: col.ConfigDefaults.Process.ProcessInclude, - Exclude: col.ConfigDefaults.Process.ProcessExclude, + BlackList: col.ConfigDefaults.Process.ProcessExclude.String(), + WhiteList: col.ConfigDefaults.Process.ProcessInclude.String(), + Include: col.ConfigDefaults.Process.ProcessInclude.String(), + Exclude: col.ConfigDefaults.Process.ProcessExclude.String(), }, ScheduledTask: ScheduledTaskConfig{ - Include: col.ConfigDefaults.ScheduledTask.TaskInclude, - Exclude: col.ConfigDefaults.ScheduledTask.TaskExclude, + Include: col.ConfigDefaults.ScheduledTask.TaskInclude.String(), + Exclude: col.ConfigDefaults.ScheduledTask.TaskExclude.String(), }, Service: ServiceConfig{ UseApi: strconv.FormatBool(col.ConfigDefaults.Service.UseAPI), @@ -70,19 +70,19 @@ func (a *Arguments) SetToDefault() { V2: strconv.FormatBool(col.ConfigDefaults.Service.V2), }, SMB: SMBConfig{ - EnabledList: strings.Split(col.ConfigDefaults.Smb.CollectorsEnabled, ","), + EnabledList: []string{}, }, SMBClient: SMBClientConfig{ - EnabledList: strings.Split(col.ConfigDefaults.SmbClient.CollectorsEnabled, ","), + EnabledList: []string{}, }, SMTP: SMTPConfig{ - BlackList: col.ConfigDefaults.Smtp.ServerExclude, - WhiteList: col.ConfigDefaults.Smtp.ServerInclude, - Include: col.ConfigDefaults.Smtp.ServerInclude, - Exclude: col.ConfigDefaults.Smtp.ServerExclude, + BlackList: col.ConfigDefaults.SMTP.ServerExclude.String(), + WhiteList: col.ConfigDefaults.SMTP.ServerInclude.String(), + Include: col.ConfigDefaults.SMTP.ServerInclude.String(), + Exclude: col.ConfigDefaults.SMTP.ServerExclude.String(), }, TextFile: TextFileConfig{ - TextFileDirectory: col.ConfigDefaults.Textfile.TextFileDirectories, + TextFileDirectory: strings.Join(col.ConfigDefaults.Textfile.TextFileDirectories, ","), }, } } diff --git a/internal/static/integrations/windows_exporter/config.go b/internal/static/integrations/windows_exporter/config.go index c472c308b5..e68e54f989 100644 --- a/internal/static/integrations/windows_exporter/config.go +++ b/internal/static/integrations/windows_exporter/config.go @@ -145,11 +145,13 @@ type PrinterConfig struct { } // SMBConfig handles settings for the windows_exporter smb collector +// Deprecated: This is not used by the windows_exporter type SMBConfig struct { EnabledList string `yaml:"enabled_list,omitempty"` } // SMBClientConfig handles settings for the windows_exporter smb client collector +// Deprecated: This is not used by the windows_exporter type SMBClientConfig struct { EnabledList string `yaml:"enabled_list,omitempty"` } diff --git a/internal/static/integrations/windows_exporter/config_windows.go b/internal/static/integrations/windows_exporter/config_windows.go index 904889bdd5..eca469337e 100644 --- a/internal/static/integrations/windows_exporter/config_windows.go +++ b/internal/static/integrations/windows_exporter/config_windows.go @@ -1,56 +1,78 @@ package windows_exporter import ( + "errors" + "regexp" "strconv" + "strings" "github.com/prometheus-community/windows_exporter/pkg/collector" ) -func (c *Config) ToWindowsExporterConfig() collector.Config { - cfg := collector.ConfigDefaults - cfg.Dfsr.DfsrEnabledCollectors = c.Dfsr.SourcesEnabled - cfg.Exchange.CollectorsEnabled = c.Exchange.EnabledList +func (c *Config) ToWindowsExporterConfig() (collector.Config, error) { + var err error + + errs := make([]error, 0, 18) - cfg.Iis.SiteInclude = coalesceString(c.IIS.SiteInclude, c.IIS.SiteWhiteList) - cfg.Iis.SiteExclude = coalesceString(c.IIS.SiteExclude, c.IIS.SiteBlackList) - cfg.Iis.AppInclude = coalesceString(c.IIS.AppInclude, c.IIS.AppWhiteList) - cfg.Iis.AppExclude = coalesceString(c.IIS.AppExclude, c.IIS.AppBlackList) + cfg := collector.ConfigDefaults + cfg.DFSR.CollectorsEnabled = strings.Split(c.Dfsr.SourcesEnabled, ",") + cfg.Exchange.CollectorsEnabled = strings.Split(c.Exchange.EnabledList, ",") + + cfg.IIS.SiteInclude, err = regexp.Compile(coalesceString(c.IIS.SiteInclude, c.IIS.SiteWhiteList)) + errs = append(errs, err) + cfg.IIS.SiteExclude, err = regexp.Compile(coalesceString(c.IIS.SiteExclude, c.IIS.SiteBlackList)) + errs = append(errs, err) + cfg.IIS.AppInclude, err = regexp.Compile(coalesceString(c.IIS.AppInclude, c.IIS.AppWhiteList)) + errs = append(errs, err) + cfg.IIS.AppExclude, err = regexp.Compile(coalesceString(c.IIS.AppExclude, c.IIS.AppBlackList)) + errs = append(errs, err) cfg.Service.ServiceWhereClause = c.Service.Where cfg.Service.UseAPI = c.Service.UseApi == "true" cfg.Service.V2 = c.Service.V2 == "true" - cfg.Smtp.ServerInclude = coalesceString(c.SMTP.Include, c.SMTP.WhiteList) - cfg.Smtp.ServerExclude = coalesceString(c.SMTP.Exclude, c.SMTP.BlackList) - - cfg.Textfile.TextFileDirectories = c.TextFile.TextFileDirectory + cfg.SMTP.ServerInclude, err = regexp.Compile(coalesceString(c.SMTP.Include, c.SMTP.WhiteList)) + errs = append(errs, err) + cfg.SMTP.ServerExclude, err = regexp.Compile(coalesceString(c.SMTP.Exclude, c.SMTP.BlackList)) + errs = append(errs, err) - cfg.PhysicalDisk.DiskInclude = c.PhysicalDisk.Include - cfg.PhysicalDisk.DiskExclude = c.PhysicalDisk.Exclude + cfg.Textfile.TextFileDirectories = strings.Split(c.TextFile.TextFileDirectory, ",") - cfg.Printer.Include = c.Printer.Include - cfg.Printer.Exclude = c.Printer.Exclude + cfg.PhysicalDisk.DiskInclude, err = regexp.Compile(c.PhysicalDisk.Include) + errs = append(errs, err) + cfg.PhysicalDisk.DiskExclude, err = regexp.Compile(c.PhysicalDisk.Exclude) + errs = append(errs, err) - cfg.Process.ProcessExclude = coalesceString(c.Process.Exclude, c.Process.BlackList) - cfg.Process.ProcessInclude = coalesceString(c.Process.Include, c.Process.WhiteList) + cfg.Printer.PrinterInclude, err = regexp.Compile(c.Printer.Include) + errs = append(errs, err) + cfg.Printer.PrinterExclude, err = regexp.Compile(c.Printer.Exclude) + errs = append(errs, err) - cfg.Net.NicExclude = coalesceString(c.Network.Exclude, c.Network.BlackList) - cfg.Net.NicInclude = coalesceString(c.Network.Include, c.Network.WhiteList) + cfg.Process.ProcessExclude, err = regexp.Compile(coalesceString(c.Process.Exclude, c.Process.BlackList)) + errs = append(errs, err) + cfg.Process.ProcessInclude, err = regexp.Compile(coalesceString(c.Process.Include, c.Process.WhiteList)) + errs = append(errs, err) - cfg.Mssql.EnabledCollectors = c.MSSQL.EnabledClasses + cfg.Net.NicExclude, err = regexp.Compile(coalesceString(c.Network.Exclude, c.Network.BlackList)) + errs = append(errs, err) + cfg.Net.NicInclude, err = regexp.Compile(coalesceString(c.Network.Include, c.Network.WhiteList)) + errs = append(errs, err) - cfg.Msmq.QueryWhereClause = c.MSMQ.Where + cfg.Mssql.CollectorsEnabled = strings.Split(c.MSSQL.EnabledClasses, ",") - cfg.LogicalDisk.VolumeInclude = coalesceString(c.LogicalDisk.Include, c.LogicalDisk.WhiteList) - cfg.LogicalDisk.VolumeExclude = coalesceString(c.LogicalDisk.Exclude, c.LogicalDisk.BlackList) + cfg.Msmq.QueryWhereClause = &c.MSMQ.Where - cfg.ScheduledTask.TaskInclude = c.ScheduledTask.Include - cfg.ScheduledTask.TaskExclude = c.ScheduledTask.Exclude + cfg.LogicalDisk.VolumeInclude, err = regexp.Compile(coalesceString(c.LogicalDisk.Include, c.LogicalDisk.WhiteList)) + errs = append(errs, err) + cfg.LogicalDisk.VolumeExclude, err = regexp.Compile(coalesceString(c.LogicalDisk.Exclude, c.LogicalDisk.BlackList)) + errs = append(errs, err) - cfg.Smb.CollectorsEnabled = c.SMB.EnabledList - cfg.SmbClient.CollectorsEnabled = c.SMBClient.EnabledList + cfg.ScheduledTask.TaskInclude, err = regexp.Compile(c.ScheduledTask.Include) + errs = append(errs, err) + cfg.ScheduledTask.TaskExclude, err = regexp.Compile(c.ScheduledTask.Exclude) + errs = append(errs, err) - return cfg + return cfg, errors.Join(errs...) } func coalesceString(v ...string) string { @@ -66,56 +88,56 @@ func coalesceString(v ...string) string { var DefaultConfig = Config{ EnabledCollectors: "cpu,cs,logical_disk,net,os,service,system", Dfsr: DfsrConfig{ - SourcesEnabled: collector.ConfigDefaults.Dfsr.DfsrEnabledCollectors, + SourcesEnabled: strings.Join(collector.ConfigDefaults.DFSR.CollectorsEnabled, ","), }, Exchange: ExchangeConfig{ - EnabledList: collector.ConfigDefaults.Exchange.CollectorsEnabled, + EnabledList: strings.Join(collector.ConfigDefaults.Exchange.CollectorsEnabled, ","), }, IIS: IISConfig{ - AppBlackList: collector.ConfigDefaults.Iis.AppExclude, - AppWhiteList: collector.ConfigDefaults.Iis.AppInclude, - SiteBlackList: collector.ConfigDefaults.Iis.SiteExclude, - SiteWhiteList: collector.ConfigDefaults.Iis.SiteInclude, - AppInclude: collector.ConfigDefaults.Iis.AppInclude, - AppExclude: collector.ConfigDefaults.Iis.AppExclude, - SiteInclude: collector.ConfigDefaults.Iis.SiteInclude, - SiteExclude: collector.ConfigDefaults.Iis.SiteExclude, + AppBlackList: collector.ConfigDefaults.IIS.AppExclude.String(), + AppWhiteList: collector.ConfigDefaults.IIS.AppInclude.String(), + SiteBlackList: collector.ConfigDefaults.IIS.SiteExclude.String(), + SiteWhiteList: collector.ConfigDefaults.IIS.SiteInclude.String(), + AppInclude: collector.ConfigDefaults.IIS.AppInclude.String(), + AppExclude: collector.ConfigDefaults.IIS.AppExclude.String(), + SiteInclude: collector.ConfigDefaults.IIS.SiteInclude.String(), + SiteExclude: collector.ConfigDefaults.IIS.SiteExclude.String(), }, LogicalDisk: LogicalDiskConfig{ - BlackList: collector.ConfigDefaults.LogicalDisk.VolumeExclude, - WhiteList: collector.ConfigDefaults.LogicalDisk.VolumeInclude, - Include: collector.ConfigDefaults.LogicalDisk.VolumeInclude, - Exclude: collector.ConfigDefaults.LogicalDisk.VolumeExclude, + BlackList: collector.ConfigDefaults.LogicalDisk.VolumeExclude.String(), + WhiteList: collector.ConfigDefaults.LogicalDisk.VolumeInclude.String(), + Include: collector.ConfigDefaults.LogicalDisk.VolumeInclude.String(), + Exclude: collector.ConfigDefaults.LogicalDisk.VolumeExclude.String(), }, MSMQ: MSMQConfig{ - Where: collector.ConfigDefaults.Msmq.QueryWhereClause, + Where: *collector.ConfigDefaults.Msmq.QueryWhereClause, }, MSSQL: MSSQLConfig{ - EnabledClasses: collector.ConfigDefaults.Mssql.EnabledCollectors, + EnabledClasses: strings.Join(collector.ConfigDefaults.Mssql.CollectorsEnabled, ","), }, Network: NetworkConfig{ - BlackList: collector.ConfigDefaults.Net.NicExclude, - WhiteList: collector.ConfigDefaults.Net.NicInclude, - Include: collector.ConfigDefaults.Net.NicInclude, - Exclude: collector.ConfigDefaults.Net.NicExclude, + BlackList: collector.ConfigDefaults.Net.NicExclude.String(), + WhiteList: collector.ConfigDefaults.Net.NicInclude.String(), + Include: collector.ConfigDefaults.Net.NicInclude.String(), + Exclude: collector.ConfigDefaults.Net.NicExclude.String(), }, PhysicalDisk: PhysicalDiskConfig{ - Include: collector.ConfigDefaults.PhysicalDisk.DiskInclude, - Exclude: collector.ConfigDefaults.PhysicalDisk.DiskExclude, + Include: collector.ConfigDefaults.PhysicalDisk.DiskInclude.String(), + Exclude: collector.ConfigDefaults.PhysicalDisk.DiskExclude.String(), }, Printer: PrinterConfig{ - Include: collector.ConfigDefaults.Printer.Include, - Exclude: collector.ConfigDefaults.Printer.Exclude, + Include: collector.ConfigDefaults.Printer.PrinterInclude.String(), + Exclude: collector.ConfigDefaults.Printer.PrinterExclude.String(), }, Process: ProcessConfig{ - BlackList: collector.ConfigDefaults.Process.ProcessExclude, - WhiteList: collector.ConfigDefaults.Process.ProcessInclude, - Include: collector.ConfigDefaults.Process.ProcessInclude, - Exclude: collector.ConfigDefaults.Process.ProcessExclude, + BlackList: collector.ConfigDefaults.Process.ProcessExclude.String(), + WhiteList: collector.ConfigDefaults.Process.ProcessInclude.String(), + Include: collector.ConfigDefaults.Process.ProcessInclude.String(), + Exclude: collector.ConfigDefaults.Process.ProcessExclude.String(), }, ScheduledTask: ScheduledTaskConfig{ - Include: collector.ConfigDefaults.ScheduledTask.TaskInclude, - Exclude: collector.ConfigDefaults.ScheduledTask.TaskExclude, + Include: collector.ConfigDefaults.ScheduledTask.TaskInclude.String(), + Exclude: collector.ConfigDefaults.ScheduledTask.TaskExclude.String(), }, Service: ServiceConfig{ UseApi: strconv.FormatBool(collector.ConfigDefaults.Service.UseAPI), @@ -123,19 +145,19 @@ var DefaultConfig = Config{ V2: strconv.FormatBool(collector.ConfigDefaults.Service.V2), }, SMTP: SMTPConfig{ - BlackList: collector.ConfigDefaults.Smtp.ServerExclude, - WhiteList: collector.ConfigDefaults.Smtp.ServerInclude, - Include: collector.ConfigDefaults.Smtp.ServerInclude, - Exclude: collector.ConfigDefaults.Smtp.ServerExclude, + BlackList: collector.ConfigDefaults.SMTP.ServerExclude.String(), + WhiteList: collector.ConfigDefaults.SMTP.ServerInclude.String(), + Include: collector.ConfigDefaults.SMTP.ServerInclude.String(), + Exclude: collector.ConfigDefaults.SMTP.ServerExclude.String(), }, SMB: SMBConfig{ - EnabledList: collector.ConfigDefaults.Smb.CollectorsEnabled, + EnabledList: "", }, SMBClient: SMBClientConfig{ - EnabledList: collector.ConfigDefaults.SmbClient.CollectorsEnabled, + EnabledList: "", }, TextFile: TextFileConfig{ - TextFileDirectory: collector.ConfigDefaults.Textfile.TextFileDirectories, + TextFileDirectory: strings.Join(collector.ConfigDefaults.Textfile.TextFileDirectories, ","), }, } diff --git a/internal/static/integrations/windows_exporter/windows_exporter_windows.go b/internal/static/integrations/windows_exporter/windows_exporter_windows.go index 5ca468cf85..1a84b8ceaf 100644 --- a/internal/static/integrations/windows_exporter/windows_exporter_windows.go +++ b/internal/static/integrations/windows_exporter/windows_exporter_windows.go @@ -1,6 +1,8 @@ package windows_exporter //nolint:golint import ( + "context" + "errors" "sort" "strings" "time" @@ -15,12 +17,17 @@ import ( func New(logger log.Logger, c *Config) (integrations.Integration, error) { // Filter down to the enabled collectors enabledCollectorNames := enabledCollectors(c.EnabledCollectors) - winCol := collector.NewWithConfig(logger, c.ToWindowsExporterConfig()) + winExporterConfig, err := c.ToWindowsExporterConfig() + if err != nil { + return nil, err + } + + winCol := collector.NewWithConfig(logger, winExporterConfig) winCol.Enable(enabledCollectorNames) sort.Strings(enabledCollectorNames) level.Info(logger).Log("msg", "enabled windows_exporter collectors", "collectors", strings.Join(enabledCollectorNames, ",")) - err := winCol.Build() + err = winCol.Build() if err != nil { return nil, err } @@ -29,11 +36,22 @@ func New(logger log.Logger, c *Config) (integrations.Integration, error) { return nil, err } - return integrations.NewCollectorIntegration(c.Name(), integrations.WithCollectors( - // Hard-coded 4m timeout to represent the time a series goes stale. - // TODO: Make configurable if useful. - collector.NewPrometheus(4*time.Minute, &winCol, logger), - )), nil + return integrations.NewCollectorIntegration( + c.Name(), + integrations.WithCollectors( + // Hard-coded 4m timeout to represent the time a series goes stale. + // TODO: Make configurable if useful. + collector.NewPrometheus(4*time.Minute, &winCol, logger), + ), + integrations.WithRunner(func(ctx context.Context) error { + <-ctx.Done() + + // Stop the collector + err := winCol.Close() + + return errors.Join(ctx.Err(), err) + }), + ), nil } func enabledCollectors(input string) []string {