Path: blob/main/component/prometheus/exporter/windows/config.go
4096 views
package windows12import (3"strings"45windows_integration "github.com/grafana/agent/pkg/integrations/windows_exporter"6)78// DefaultArguments holds non-zero default options for Arguments when it is9// unmarshaled from YAML.10//11// Some defaults are populated from init functions in the github.com/grafana/agent/pkg/integrations/windows_exporter package.1213var DefaultArguments = Arguments{14EnabledCollectors: strings.Split(windows_integration.DefaultConfig.EnabledCollectors, ","),15Dfsr: DfsrConfig{16SourcesEnabled: strings.Split(windows_integration.DefaultConfig.Dfsr.SourcesEnabled, ","),17},18Exchange: ExchangeConfig{19EnabledList: strings.Split(windows_integration.DefaultConfig.Exchange.EnabledList, ","),20},21IIS: IISConfig{22AppBlackList: windows_integration.DefaultConfig.IIS.AppBlackList,23AppWhiteList: windows_integration.DefaultConfig.IIS.AppWhiteList,24SiteBlackList: windows_integration.DefaultConfig.IIS.SiteBlackList,25SiteWhiteList: windows_integration.DefaultConfig.IIS.SiteWhiteList,26AppInclude: windows_integration.DefaultConfig.IIS.AppInclude,27AppExclude: windows_integration.DefaultConfig.IIS.AppExclude,28SiteInclude: windows_integration.DefaultConfig.IIS.SiteInclude,29SiteExclude: windows_integration.DefaultConfig.IIS.SiteExclude,30},31LogicalDisk: LogicalDiskConfig{32BlackList: windows_integration.DefaultConfig.LogicalDisk.BlackList,33WhiteList: windows_integration.DefaultConfig.LogicalDisk.WhiteList,34Include: windows_integration.DefaultConfig.LogicalDisk.Include,35Exclude: windows_integration.DefaultConfig.LogicalDisk.Exclude,36},37MSMQ: MSMQConfig{38Where: windows_integration.DefaultConfig.MSMQ.Where,39},40MSSQL: MSSQLConfig{41EnabledClasses: strings.Split(windows_integration.DefaultConfig.MSSQL.EnabledClasses, ","),42},43Network: NetworkConfig{44BlackList: windows_integration.DefaultConfig.Network.BlackList,45WhiteList: windows_integration.DefaultConfig.Network.WhiteList,46Include: windows_integration.DefaultConfig.Network.Include,47Exclude: windows_integration.DefaultConfig.Network.Exclude,48},49Process: ProcessConfig{50BlackList: windows_integration.DefaultConfig.Process.BlackList,51WhiteList: windows_integration.DefaultConfig.Process.WhiteList,52Include: windows_integration.DefaultConfig.Process.Include,53Exclude: windows_integration.DefaultConfig.Process.Exclude,54},55ScheduledTask: ScheduledTaskConfig{56Include: windows_integration.DefaultConfig.ScheduledTask.Include,57Exclude: windows_integration.DefaultConfig.ScheduledTask.Exclude,58},59Service: ServiceConfig{60UseApi: windows_integration.DefaultConfig.Service.UseApi,61Where: windows_integration.DefaultConfig.Service.Where,62},63SMTP: SMTPConfig{64BlackList: windows_integration.DefaultConfig.SMTP.BlackList,65WhiteList: windows_integration.DefaultConfig.SMTP.WhiteList,66Include: windows_integration.DefaultConfig.SMTP.Include,67Exclude: windows_integration.DefaultConfig.SMTP.Exclude,68},69TextFile: TextFileConfig{70TextFileDirectory: windows_integration.DefaultConfig.TextFile.TextFileDirectory,71},72}7374// Arguments is used for controlling for this exporter.75type Arguments struct {76// Collectors to mark as enabled77EnabledCollectors []string `river:"enabled_collectors,attr,optional"`7879// Collector-specific config options80Dfsr DfsrConfig `river:"dfsr,block,optional"`81Exchange ExchangeConfig `river:"exchange,block,optional"`82IIS IISConfig `river:"iis,block,optional"`83LogicalDisk LogicalDiskConfig `river:"logical_disk,block,optional"`84MSMQ MSMQConfig `river:"msmq,block,optional"`85MSSQL MSSQLConfig `river:"mssql,block,optional"`86Network NetworkConfig `river:"network,block,optional"`87Process ProcessConfig `river:"process,block,optional"`88ScheduledTask ScheduledTaskConfig `river:"scheduled_task,block,optional"`89Service ServiceConfig `river:"service,block,optional"`90SMTP SMTPConfig `river:"smtp,block,optional"`91TextFile TextFileConfig `river:"text_file,block,optional"`92}9394// UnmarshalRiver implements River unmarshalling for Config.95func (a *Arguments) UnmarshalRiver(f func(interface{}) error) error {96*a = DefaultArguments9798type args Arguments99return f((*args)(a))100}101102// Convert converts the component's Arguments to the integration's Config.103func (a *Arguments) Convert() *windows_integration.Config {104return &windows_integration.Config{105EnabledCollectors: strings.Join(a.EnabledCollectors, ","),106Dfsr: a.Dfsr.Convert(),107Exchange: a.Exchange.Convert(),108IIS: a.IIS.Convert(),109LogicalDisk: a.LogicalDisk.Convert(),110MSMQ: a.MSMQ.Convert(),111MSSQL: a.MSSQL.Convert(),112Network: a.Network.Convert(),113Process: a.Process.Convert(),114ScheduledTask: a.ScheduledTask.Convert(),115Service: a.Service.Convert(),116SMTP: a.SMTP.Convert(),117TextFile: a.TextFile.Convert(),118}119}120121// DfsrConfig handles settings for the windows_exporter Exchange collector122type DfsrConfig struct {123SourcesEnabled []string `river:"sources_enabled,attr,optional"`124}125126// Convert converts the component's DfsrConfig to the integration's ExchangeConfig.127func (t DfsrConfig) Convert() windows_integration.DfsrConfig {128return windows_integration.DfsrConfig{129SourcesEnabled: strings.Join(t.SourcesEnabled, ","),130}131}132133// ExchangeConfig handles settings for the windows_exporter Exchange collector134type ExchangeConfig struct {135EnabledList []string `river:"enabled_list,attr,optional"`136}137138// Convert converts the component's ExchangeConfig to the integration's ExchangeConfig.139func (t ExchangeConfig) Convert() windows_integration.ExchangeConfig {140return windows_integration.ExchangeConfig{141EnabledList: strings.Join(t.EnabledList, ","),142}143}144145// IISConfig handles settings for the windows_exporter IIS collector146type IISConfig struct {147AppBlackList string `river:"app_blacklist,attr,optional"`148AppWhiteList string `river:"app_whitelist,attr,optional"`149SiteBlackList string `river:"site_blacklist,attr,optional"`150SiteWhiteList string `river:"site_whitelist,attr,optional"`151AppExclude string `river:"app_exclude,attr,optional"`152AppInclude string `river:"app_include,attr,optional"`153SiteExclude string `river:"site_exclude,attr,optional"`154SiteInclude string `river:"site_include,attr,optional"`155}156157// Convert converts the component's IISConfig to the integration's IISConfig.158func (t IISConfig) Convert() windows_integration.IISConfig {159return windows_integration.IISConfig{160AppBlackList: t.AppBlackList,161AppWhiteList: t.AppWhiteList,162SiteBlackList: t.SiteBlackList,163SiteWhiteList: t.SiteWhiteList,164AppExclude: t.AppExclude,165AppInclude: t.AppInclude,166SiteExclude: t.SiteExclude,167SiteInclude: t.SiteInclude,168}169}170171// TextFileConfig handles settings for the windows_exporter Text File collector172type TextFileConfig struct {173TextFileDirectory string `river:"text_file_directory,attr,optional"`174}175176// Convert converts the component's TextFileConfig to the integration's TextFileConfig.177func (t TextFileConfig) Convert() windows_integration.TextFileConfig {178return windows_integration.TextFileConfig{179TextFileDirectory: t.TextFileDirectory,180}181}182183// SMTPConfig handles settings for the windows_exporter SMTP collector184type SMTPConfig struct {185BlackList string `river:"blacklist,attr,optional"`186WhiteList string `river:"whitelist,attr,optional"`187Exclude string `river:"exclude,attr,optional"`188Include string `river:"include,attr,optional"`189}190191// Convert converts the component's SMTPConfig to the integration's SMTPConfig.192func (t SMTPConfig) Convert() windows_integration.SMTPConfig {193return windows_integration.SMTPConfig{194BlackList: t.BlackList,195WhiteList: t.WhiteList,196Exclude: t.Exclude,197Include: t.Include,198}199}200201// ServiceConfig handles settings for the windows_exporter service collector202type ServiceConfig struct {203UseApi string `river:"use_api,attr,optional"`204Where string `river:"where_clause,attr,optional"`205}206207// Convert converts the component's ServiceConfig to the integration's ServiceConfig.208func (t ServiceConfig) Convert() windows_integration.ServiceConfig {209return windows_integration.ServiceConfig{210UseApi: t.UseApi,211Where: t.Where,212}213}214215// ProcessConfig handles settings for the windows_exporter process collector216type ProcessConfig struct {217BlackList string `river:"blacklist,attr,optional"`218WhiteList string `river:"whitelist,attr,optional"`219Exclude string `river:"exclude,attr,optional"`220Include string `river:"include,attr,optional"`221}222223// Convert converts the component's ProcessConfig to the integration's ProcessConfig.224func (t ProcessConfig) Convert() windows_integration.ProcessConfig {225return windows_integration.ProcessConfig{226BlackList: t.BlackList,227WhiteList: t.WhiteList,228Exclude: t.Exclude,229Include: t.Include,230}231}232233// ScheduledTaskConfig handles settings for the windows_exporter process collector234type ScheduledTaskConfig struct {235Exclude string `river:"exclude,attr,optional"`236Include string `river:"include,attr,optional"`237}238239// Convert converts the component's ScheduledTaskConfig to the integration's ScheduledTaskConfig.240func (t ScheduledTaskConfig) Convert() windows_integration.ScheduledTaskConfig {241return windows_integration.ScheduledTaskConfig{242Exclude: t.Exclude,243Include: t.Include,244}245}246247// NetworkConfig handles settings for the windows_exporter network collector248type NetworkConfig struct {249BlackList string `river:"blacklist,attr,optional"`250WhiteList string `river:"whitelist,attr,optional"`251Exclude string `river:"exclude,attr,optional"`252Include string `river:"include,attr,optional"`253}254255// Convert converts the component's NetworkConfig to the integration's NetworkConfig.256func (t NetworkConfig) Convert() windows_integration.NetworkConfig {257return windows_integration.NetworkConfig{258BlackList: t.BlackList,259WhiteList: t.WhiteList,260Exclude: t.Exclude,261Include: t.Include,262}263}264265// MSSQLConfig handles settings for the windows_exporter SQL server collector266type MSSQLConfig struct {267EnabledClasses []string `river:"enabled_classes,attr,optional"`268}269270// Convert converts the component's MSSQLConfig to the integration's MSSQLConfig.271func (t MSSQLConfig) Convert() windows_integration.MSSQLConfig {272return windows_integration.MSSQLConfig{273EnabledClasses: strings.Join(t.EnabledClasses, ","),274}275}276277// MSMQConfig handles settings for the windows_exporter MSMQ collector278type MSMQConfig struct {279Where string `river:"where_clause,attr,optional"`280}281282// Convert converts the component's MSMQConfig to the integration's MSMQConfig.283func (t MSMQConfig) Convert() windows_integration.MSMQConfig {284return windows_integration.MSMQConfig{285Where: t.Where,286}287}288289// LogicalDiskConfig handles settings for the windows_exporter logical disk collector290type LogicalDiskConfig struct {291BlackList string `river:"blacklist,attr,optional"`292WhiteList string `river:"whitelist,attr,optional"`293Include string `river:"include,attr,optional"`294Exclude string `river:"exclude,attr,optional"`295}296297// Convert converts the component's LogicalDiskConfig to the integration's LogicalDiskConfig.298func (t LogicalDiskConfig) Convert() windows_integration.LogicalDiskConfig {299return windows_integration.LogicalDiskConfig{300BlackList: t.BlackList,301WhiteList: t.WhiteList,302Include: t.Include,303Exclude: t.Exclude,304}305}306307308