-
Notifications
You must be signed in to change notification settings - Fork 486
/
Copy pathconfig.go
201 lines (178 loc) · 6.08 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package windows_exporter //nolint:golint
import (
"github.com/go-kit/log"
"github.com/grafana/agent/pkg/integrations"
integrations_v2 "github.com/grafana/agent/pkg/integrations/v2"
"github.com/grafana/agent/pkg/integrations/v2/metricsutils"
)
// DefaultConfig holds the default settings for the windows_exporter integration.
var DefaultConfig = Config{
// NOTE(rfratto): there is an init function in config_windows.go that
// populates defaults for collectors based on the exporter defaults.
EnabledCollectors: "cpu,cs,logical_disk,net,os,service,system",
Dfsr: DfsrConfig{
SourcesEnabled: "",
},
Exchange: ExchangeConfig{
EnabledList: "",
},
IIS: IISConfig{
AppBlackList: "",
AppWhiteList: "",
SiteBlackList: "",
SiteWhiteList: "",
AppInclude: "",
AppExclude: "",
SiteInclude: "",
SiteExclude: "",
},
LogicalDisk: LogicalDiskConfig{
BlackList: "",
WhiteList: "",
Include: "",
Exclude: "",
},
MSMQ: MSMQConfig{
Where: "",
},
MSSQL: MSSQLConfig{
EnabledClasses: "",
},
Network: NetworkConfig{
BlackList: "",
WhiteList: "",
Include: "",
Exclude: "",
},
Process: ProcessConfig{
BlackList: "",
WhiteList: "",
Include: "",
Exclude: "",
},
ScheduledTask: ScheduledTaskConfig{
Include: "",
Exclude: "",
},
Service: ServiceConfig{
UseApi: "",
Where: "",
},
SMTP: SMTPConfig{
BlackList: "",
WhiteList: "",
Include: "",
Exclude: "",
},
TextFile: TextFileConfig{
TextFileDirectory: "",
},
}
func init() {
integrations.RegisterIntegration(&Config{})
integrations_v2.RegisterLegacy(&Config{}, integrations_v2.TypeSingleton, metricsutils.NewNamedShim("windows"))
}
// Config controls the windows_exporter integration.
// All of these and their child fields are pointers, so we can determine if the value was set or not.
type Config struct {
EnabledCollectors string `yaml:"enabled_collectors"`
Dfsr DfsrConfig `yaml:"dfsr,omitempty"`
Exchange ExchangeConfig `yaml:"exchange,omitempty"`
IIS IISConfig `yaml:"iis,omitempty"`
TextFile TextFileConfig `yaml:"text_file,omitempty"`
SMTP SMTPConfig `yaml:"smtp,omitempty"`
Service ServiceConfig `yaml:"service,omitempty"`
Process ProcessConfig `yaml:"process,omitempty"`
Network NetworkConfig `yaml:"network,omitempty"`
MSSQL MSSQLConfig `yaml:"mssql,omitempty"`
MSMQ MSMQConfig `yaml:"msmq,omitempty"`
LogicalDisk LogicalDiskConfig `yaml:"logical_disk,omitempty"`
ScheduledTask ScheduledTaskConfig `yaml:"scheduled_task,omitempty"`
}
// UnmarshalYAML implements yaml.Unmarshaler for Config.
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = DefaultConfig
type plain Config
return unmarshal((*plain)(c))
}
// Name returns the name used, "windows_explorer"
func (c *Config) Name() string {
return "windows_exporter"
}
// InstanceKey returns the hostname:port of the agent.
func (c *Config) InstanceKey(agentKey string) (string, error) {
return agentKey, nil
}
// NewIntegration creates an integration based on the given configuration
func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) {
return New(l, c)
}
// DfsrConfig handles settings for the windows_exporter dfsr collector
type DfsrConfig struct {
SourcesEnabled string `yaml:"sources_enabled,omitempty"`
}
// ExchangeConfig handles settings for the windows_exporter Exchange collector
type ExchangeConfig struct {
EnabledList string `yaml:"enabled_list,omitempty"`
}
// IISConfig handles settings for the windows_exporter IIS collector
type IISConfig struct {
SiteWhiteList string `yaml:"site_whitelist,omitempty"`
SiteBlackList string `yaml:"site_blacklist,omitempty"`
AppWhiteList string `yaml:"app_whitelist,omitempty"`
AppBlackList string `yaml:"app_blacklist,omitempty"`
SiteInclude string `yaml:"site_include,omitempty"`
SiteExclude string `yaml:"site_exclude,omitempty"`
AppInclude string `yaml:"app_include,omitempty"`
AppExclude string `yaml:"app_exclude,omitempty"`
}
// TextFileConfig handles settings for the windows_exporter Text File collector
type TextFileConfig struct {
TextFileDirectory string `yaml:"text_file_directory,omitempty"`
}
// SMTPConfig handles settings for the windows_exporter SMTP collector
type SMTPConfig struct {
BlackList string `yaml:"blacklist,omitempty"`
WhiteList string `yaml:"whitelist,omitempty"`
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}
// ServiceConfig handles settings for the windows_exporter service collector
type ServiceConfig struct {
UseApi string `yaml:"use_api,omitempty"`
Where string `yaml:"where_clause,omitempty"`
}
// ProcessConfig handles settings for the windows_exporter process collector
type ProcessConfig struct {
BlackList string `yaml:"blacklist,omitempty"`
WhiteList string `yaml:"whitelist,omitempty"`
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}
// NetworkConfig handles settings for the windows_exporter network collector
type NetworkConfig struct {
BlackList string `yaml:"blacklist,omitempty"`
WhiteList string `yaml:"whitelist,omitempty"`
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}
// MSSQLConfig handles settings for the windows_exporter SQL server collector
type MSSQLConfig struct {
EnabledClasses string `yaml:"enabled_classes,omitempty"`
}
// MSMQConfig handles settings for the windows_exporter MSMQ collector
type MSMQConfig struct {
Where string `yaml:"where_clause,omitempty"`
}
// LogicalDiskConfig handles settings for the windows_exporter logical disk collector
type LogicalDiskConfig struct {
BlackList string `yaml:"blacklist,omitempty"`
WhiteList string `yaml:"whitelist,omitempty"`
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}
// ScheduledTaskConfig handles settings for the windows_exporter scheduled_task collector
type ScheduledTaskConfig struct {
Include string `yaml:"include,omitempty"`
Exclude string `yaml:"exclude,omitempty"`
}