Skip to content

Commit

Permalink
Fix #5831 and use the defaults from windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdurham committed Nov 21, 2023
1 parent f1871df commit be3890e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 57 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ internal API changes are not present.
Main (unreleased)
-----------------


### Bugfixes

- Fix issue with windows_exporter defaults not being set correctly. (@mattdurham)

v0.38.0 (2023-11-21)
--------------------

Expand Down
67 changes: 34 additions & 33 deletions component/prometheus/exporter/windows/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"

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

// DefaultArguments holds non-zero default options for Arguments when it is
Expand All @@ -14,61 +15,61 @@ import (
var DefaultArguments = Arguments{
EnabledCollectors: strings.Split(windows_integration.DefaultConfig.EnabledCollectors, ","),
Dfsr: DfsrConfig{
SourcesEnabled: strings.Split(windows_integration.DefaultConfig.Dfsr.SourcesEnabled, ","),
SourcesEnabled: strings.Split(col.ConfigDefaults.Dfsr.DfsrEnabledCollectors, ","),
},
Exchange: ExchangeConfig{
EnabledList: strings.Split(windows_integration.DefaultConfig.Exchange.EnabledList, ","),
EnabledList: strings.Split(col.ConfigDefaults.Exchange.CollectorsEnabled, ","),
},
IIS: IISConfig{
AppBlackList: windows_integration.DefaultConfig.IIS.AppBlackList,
AppWhiteList: windows_integration.DefaultConfig.IIS.AppWhiteList,
SiteBlackList: windows_integration.DefaultConfig.IIS.SiteBlackList,
SiteWhiteList: windows_integration.DefaultConfig.IIS.SiteWhiteList,
AppInclude: windows_integration.DefaultConfig.IIS.AppInclude,
AppExclude: windows_integration.DefaultConfig.IIS.AppExclude,
SiteInclude: windows_integration.DefaultConfig.IIS.SiteInclude,
SiteExclude: windows_integration.DefaultConfig.IIS.SiteExclude,
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,
},
LogicalDisk: LogicalDiskConfig{
BlackList: windows_integration.DefaultConfig.LogicalDisk.BlackList,
WhiteList: windows_integration.DefaultConfig.LogicalDisk.WhiteList,
Include: windows_integration.DefaultConfig.LogicalDisk.Include,
Exclude: windows_integration.DefaultConfig.LogicalDisk.Exclude,
BlackList: col.ConfigDefaults.LogicalDisk.VolumeExclude,
WhiteList: col.ConfigDefaults.LogicalDisk.VolumeInclude,
Include: col.ConfigDefaults.LogicalDisk.VolumeInclude,
Exclude: col.ConfigDefaults.LogicalDisk.VolumeExclude,
},
MSMQ: MSMQConfig{
Where: windows_integration.DefaultConfig.MSMQ.Where,
Where: col.ConfigDefaults.Msmq.QueryWhereClause,
},
MSSQL: MSSQLConfig{
EnabledClasses: strings.Split(windows_integration.DefaultConfig.MSSQL.EnabledClasses, ","),
EnabledClasses: strings.Split(col.ConfigDefaults.Mssql.EnabledCollectors, ","),
},
Network: NetworkConfig{
BlackList: windows_integration.DefaultConfig.Network.BlackList,
WhiteList: windows_integration.DefaultConfig.Network.WhiteList,
Include: windows_integration.DefaultConfig.Network.Include,
Exclude: windows_integration.DefaultConfig.Network.Exclude,
BlackList: col.ConfigDefaults.Net.NicExclude,
WhiteList: col.ConfigDefaults.Net.NicInclude,
Include: col.ConfigDefaults.Net.NicInclude,
Exclude: col.ConfigDefaults.Net.NicExclude,
},
Process: ProcessConfig{
BlackList: windows_integration.DefaultConfig.Process.BlackList,
WhiteList: windows_integration.DefaultConfig.Process.WhiteList,
Include: windows_integration.DefaultConfig.Process.Include,
Exclude: windows_integration.DefaultConfig.Process.Exclude,
BlackList: col.ConfigDefaults.Process.ProcessExclude,
WhiteList: col.ConfigDefaults.Process.ProcessInclude,
Include: col.ConfigDefaults.Process.ProcessInclude,
Exclude: col.ConfigDefaults.Process.ProcessExclude,
},
ScheduledTask: ScheduledTaskConfig{
Include: windows_integration.DefaultConfig.ScheduledTask.Include,
Exclude: windows_integration.DefaultConfig.ScheduledTask.Exclude,
Include: col.ConfigDefaults.ScheduledTask.TaskInclude,
Exclude: col.ConfigDefaults.ScheduledTask.TaskExclude,
},
Service: ServiceConfig{
UseApi: windows_integration.DefaultConfig.Service.UseApi,
Where: windows_integration.DefaultConfig.Service.Where,
UseApi: "false",
Where: col.ConfigDefaults.Service.ServiceWhereClause,
},
SMTP: SMTPConfig{
BlackList: windows_integration.DefaultConfig.SMTP.BlackList,
WhiteList: windows_integration.DefaultConfig.SMTP.WhiteList,
Include: windows_integration.DefaultConfig.SMTP.Include,
Exclude: windows_integration.DefaultConfig.SMTP.Exclude,
BlackList: col.ConfigDefaults.Smtp.ServerExclude,
WhiteList: col.ConfigDefaults.Smtp.ServerInclude,
Include: col.ConfigDefaults.Smtp.ServerInclude,
Exclude: col.ConfigDefaults.Smtp.ServerExclude,
},
TextFile: TextFileConfig{
TextFileDirectory: windows_integration.DefaultConfig.TextFile.TextFileDirectory,
TextFileDirectory: col.ConfigDefaults.Textfile.TextFileDirectories,
},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package windows

import (
"strings"
"testing"

windows_integration "github.com/grafana/agent/pkg/integrations/windows_exporter"
"github.com/grafana/river"
"github.com/stretchr/testify/require"
)
Expand All @@ -14,26 +12,26 @@ func TestRiverUnmarshalWithDefaultConfig(t *testing.T) {
err := river.Unmarshal([]byte(""), &args)
require.NoError(t, err)

require.Equal(t, strings.Split(windows_integration.DefaultConfig.EnabledCollectors, ","), args.EnabledCollectors)
require.Equal(t, strings.Split(windows_integration.DefaultConfig.Dfsr.SourcesEnabled, ","), args.Dfsr.SourcesEnabled)
require.Equal(t, strings.Split(windows_integration.DefaultConfig.Exchange.EnabledList, ","), args.Exchange.EnabledList)
require.Equal(t, windows_integration.DefaultConfig.IIS.AppExclude, args.IIS.AppExclude)
require.Equal(t, windows_integration.DefaultConfig.IIS.AppInclude, args.IIS.AppInclude)
require.Equal(t, windows_integration.DefaultConfig.IIS.SiteExclude, args.IIS.SiteExclude)
require.Equal(t, windows_integration.DefaultConfig.IIS.SiteInclude, args.IIS.SiteInclude)
require.Equal(t, windows_integration.DefaultConfig.LogicalDisk.Exclude, args.LogicalDisk.Exclude)
require.Equal(t, windows_integration.DefaultConfig.LogicalDisk.Include, args.LogicalDisk.Include)
require.Equal(t, windows_integration.DefaultConfig.MSMQ.Where, args.MSMQ.Where)
require.Equal(t, strings.Split(windows_integration.DefaultConfig.MSSQL.EnabledClasses, ","), args.MSSQL.EnabledClasses)
require.Equal(t, windows_integration.DefaultConfig.Network.Exclude, args.Network.Exclude)
require.Equal(t, windows_integration.DefaultConfig.Network.Include, args.Network.Include)
require.Equal(t, windows_integration.DefaultConfig.Process.Exclude, args.Process.Exclude)
require.Equal(t, windows_integration.DefaultConfig.Process.Include, args.Process.Include)
require.Equal(t, windows_integration.DefaultConfig.ScheduledTask.Exclude, args.ScheduledTask.Exclude)
require.Equal(t, windows_integration.DefaultConfig.ScheduledTask.Include, args.ScheduledTask.Include)
require.Equal(t, windows_integration.DefaultConfig.Service.UseApi, args.Service.UseApi)
require.Equal(t, windows_integration.DefaultConfig.Service.Where, args.Service.Where)
require.Equal(t, windows_integration.DefaultConfig.SMTP.Exclude, args.SMTP.Exclude)
require.Equal(t, windows_integration.DefaultConfig.SMTP.Include, args.SMTP.Include)
require.Equal(t, windows_integration.DefaultConfig.TextFile.TextFileDirectory, args.TextFile.TextFileDirectory)
require.Equal(t, DefaultArguments.EnabledCollectors, args.EnabledCollectors)
require.Equal(t, DefaultArguments.Dfsr.SourcesEnabled, args.Dfsr.SourcesEnabled)
require.Equal(t, DefaultArguments.Exchange.EnabledList, args.Exchange.EnabledList)
require.Equal(t, DefaultArguments.IIS.AppExclude, args.IIS.AppExclude)
require.Equal(t, DefaultArguments.IIS.AppInclude, args.IIS.AppInclude)
require.Equal(t, DefaultArguments.IIS.SiteExclude, args.IIS.SiteExclude)
require.Equal(t, DefaultArguments.IIS.SiteInclude, args.IIS.SiteInclude)
require.Equal(t, DefaultArguments.LogicalDisk.Exclude, args.LogicalDisk.Exclude)
require.Equal(t, DefaultArguments.LogicalDisk.Include, args.LogicalDisk.Include)
require.Equal(t, DefaultArguments.MSMQ.Where, args.MSMQ.Where)
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.Process.Exclude, args.Process.Exclude)
require.Equal(t, DefaultArguments.Process.Include, args.Process.Include)
require.Equal(t, DefaultArguments.ScheduledTask.Exclude, args.ScheduledTask.Exclude)
require.Equal(t, DefaultArguments.ScheduledTask.Include, args.ScheduledTask.Include)
require.Equal(t, DefaultArguments.Service.UseApi, args.Service.UseApi)
require.Equal(t, DefaultArguments.Service.Where, args.Service.Where)
require.Equal(t, DefaultArguments.SMTP.Exclude, args.SMTP.Exclude)
require.Equal(t, DefaultArguments.SMTP.Include, args.SMTP.Include)
require.Equal(t, DefaultArguments.TextFile.TextFileDirectory, args.TextFile.TextFileDirectory)
}

0 comments on commit be3890e

Please sign in to comment.