Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/prometheus/exporter/windows/config.go
4096 views
1
package windows
2
3
import (
4
"strings"
5
6
windows_integration "github.com/grafana/agent/pkg/integrations/windows_exporter"
7
)
8
9
// DefaultArguments holds non-zero default options for Arguments when it is
10
// unmarshaled from YAML.
11
//
12
// Some defaults are populated from init functions in the github.com/grafana/agent/pkg/integrations/windows_exporter package.
13
14
var DefaultArguments = Arguments{
15
EnabledCollectors: strings.Split(windows_integration.DefaultConfig.EnabledCollectors, ","),
16
Dfsr: DfsrConfig{
17
SourcesEnabled: strings.Split(windows_integration.DefaultConfig.Dfsr.SourcesEnabled, ","),
18
},
19
Exchange: ExchangeConfig{
20
EnabledList: strings.Split(windows_integration.DefaultConfig.Exchange.EnabledList, ","),
21
},
22
IIS: IISConfig{
23
AppBlackList: windows_integration.DefaultConfig.IIS.AppBlackList,
24
AppWhiteList: windows_integration.DefaultConfig.IIS.AppWhiteList,
25
SiteBlackList: windows_integration.DefaultConfig.IIS.SiteBlackList,
26
SiteWhiteList: windows_integration.DefaultConfig.IIS.SiteWhiteList,
27
AppInclude: windows_integration.DefaultConfig.IIS.AppInclude,
28
AppExclude: windows_integration.DefaultConfig.IIS.AppExclude,
29
SiteInclude: windows_integration.DefaultConfig.IIS.SiteInclude,
30
SiteExclude: windows_integration.DefaultConfig.IIS.SiteExclude,
31
},
32
LogicalDisk: LogicalDiskConfig{
33
BlackList: windows_integration.DefaultConfig.LogicalDisk.BlackList,
34
WhiteList: windows_integration.DefaultConfig.LogicalDisk.WhiteList,
35
Include: windows_integration.DefaultConfig.LogicalDisk.Include,
36
Exclude: windows_integration.DefaultConfig.LogicalDisk.Exclude,
37
},
38
MSMQ: MSMQConfig{
39
Where: windows_integration.DefaultConfig.MSMQ.Where,
40
},
41
MSSQL: MSSQLConfig{
42
EnabledClasses: strings.Split(windows_integration.DefaultConfig.MSSQL.EnabledClasses, ","),
43
},
44
Network: NetworkConfig{
45
BlackList: windows_integration.DefaultConfig.Network.BlackList,
46
WhiteList: windows_integration.DefaultConfig.Network.WhiteList,
47
Include: windows_integration.DefaultConfig.Network.Include,
48
Exclude: windows_integration.DefaultConfig.Network.Exclude,
49
},
50
Process: ProcessConfig{
51
BlackList: windows_integration.DefaultConfig.Process.BlackList,
52
WhiteList: windows_integration.DefaultConfig.Process.WhiteList,
53
Include: windows_integration.DefaultConfig.Process.Include,
54
Exclude: windows_integration.DefaultConfig.Process.Exclude,
55
},
56
ScheduledTask: ScheduledTaskConfig{
57
Include: windows_integration.DefaultConfig.ScheduledTask.Include,
58
Exclude: windows_integration.DefaultConfig.ScheduledTask.Exclude,
59
},
60
Service: ServiceConfig{
61
UseApi: windows_integration.DefaultConfig.Service.UseApi,
62
Where: windows_integration.DefaultConfig.Service.Where,
63
},
64
SMTP: SMTPConfig{
65
BlackList: windows_integration.DefaultConfig.SMTP.BlackList,
66
WhiteList: windows_integration.DefaultConfig.SMTP.WhiteList,
67
Include: windows_integration.DefaultConfig.SMTP.Include,
68
Exclude: windows_integration.DefaultConfig.SMTP.Exclude,
69
},
70
TextFile: TextFileConfig{
71
TextFileDirectory: windows_integration.DefaultConfig.TextFile.TextFileDirectory,
72
},
73
}
74
75
// Arguments is used for controlling for this exporter.
76
type Arguments struct {
77
// Collectors to mark as enabled
78
EnabledCollectors []string `river:"enabled_collectors,attr,optional"`
79
80
// Collector-specific config options
81
Dfsr DfsrConfig `river:"dfsr,block,optional"`
82
Exchange ExchangeConfig `river:"exchange,block,optional"`
83
IIS IISConfig `river:"iis,block,optional"`
84
LogicalDisk LogicalDiskConfig `river:"logical_disk,block,optional"`
85
MSMQ MSMQConfig `river:"msmq,block,optional"`
86
MSSQL MSSQLConfig `river:"mssql,block,optional"`
87
Network NetworkConfig `river:"network,block,optional"`
88
Process ProcessConfig `river:"process,block,optional"`
89
ScheduledTask ScheduledTaskConfig `river:"scheduled_task,block,optional"`
90
Service ServiceConfig `river:"service,block,optional"`
91
SMTP SMTPConfig `river:"smtp,block,optional"`
92
TextFile TextFileConfig `river:"text_file,block,optional"`
93
}
94
95
// UnmarshalRiver implements River unmarshalling for Config.
96
func (a *Arguments) UnmarshalRiver(f func(interface{}) error) error {
97
*a = DefaultArguments
98
99
type args Arguments
100
return f((*args)(a))
101
}
102
103
// Convert converts the component's Arguments to the integration's Config.
104
func (a *Arguments) Convert() *windows_integration.Config {
105
return &windows_integration.Config{
106
EnabledCollectors: strings.Join(a.EnabledCollectors, ","),
107
Dfsr: a.Dfsr.Convert(),
108
Exchange: a.Exchange.Convert(),
109
IIS: a.IIS.Convert(),
110
LogicalDisk: a.LogicalDisk.Convert(),
111
MSMQ: a.MSMQ.Convert(),
112
MSSQL: a.MSSQL.Convert(),
113
Network: a.Network.Convert(),
114
Process: a.Process.Convert(),
115
ScheduledTask: a.ScheduledTask.Convert(),
116
Service: a.Service.Convert(),
117
SMTP: a.SMTP.Convert(),
118
TextFile: a.TextFile.Convert(),
119
}
120
}
121
122
// DfsrConfig handles settings for the windows_exporter Exchange collector
123
type DfsrConfig struct {
124
SourcesEnabled []string `river:"sources_enabled,attr,optional"`
125
}
126
127
// Convert converts the component's DfsrConfig to the integration's ExchangeConfig.
128
func (t DfsrConfig) Convert() windows_integration.DfsrConfig {
129
return windows_integration.DfsrConfig{
130
SourcesEnabled: strings.Join(t.SourcesEnabled, ","),
131
}
132
}
133
134
// ExchangeConfig handles settings for the windows_exporter Exchange collector
135
type ExchangeConfig struct {
136
EnabledList []string `river:"enabled_list,attr,optional"`
137
}
138
139
// Convert converts the component's ExchangeConfig to the integration's ExchangeConfig.
140
func (t ExchangeConfig) Convert() windows_integration.ExchangeConfig {
141
return windows_integration.ExchangeConfig{
142
EnabledList: strings.Join(t.EnabledList, ","),
143
}
144
}
145
146
// IISConfig handles settings for the windows_exporter IIS collector
147
type IISConfig struct {
148
AppBlackList string `river:"app_blacklist,attr,optional"`
149
AppWhiteList string `river:"app_whitelist,attr,optional"`
150
SiteBlackList string `river:"site_blacklist,attr,optional"`
151
SiteWhiteList string `river:"site_whitelist,attr,optional"`
152
AppExclude string `river:"app_exclude,attr,optional"`
153
AppInclude string `river:"app_include,attr,optional"`
154
SiteExclude string `river:"site_exclude,attr,optional"`
155
SiteInclude string `river:"site_include,attr,optional"`
156
}
157
158
// Convert converts the component's IISConfig to the integration's IISConfig.
159
func (t IISConfig) Convert() windows_integration.IISConfig {
160
return windows_integration.IISConfig{
161
AppBlackList: t.AppBlackList,
162
AppWhiteList: t.AppWhiteList,
163
SiteBlackList: t.SiteBlackList,
164
SiteWhiteList: t.SiteWhiteList,
165
AppExclude: t.AppExclude,
166
AppInclude: t.AppInclude,
167
SiteExclude: t.SiteExclude,
168
SiteInclude: t.SiteInclude,
169
}
170
}
171
172
// TextFileConfig handles settings for the windows_exporter Text File collector
173
type TextFileConfig struct {
174
TextFileDirectory string `river:"text_file_directory,attr,optional"`
175
}
176
177
// Convert converts the component's TextFileConfig to the integration's TextFileConfig.
178
func (t TextFileConfig) Convert() windows_integration.TextFileConfig {
179
return windows_integration.TextFileConfig{
180
TextFileDirectory: t.TextFileDirectory,
181
}
182
}
183
184
// SMTPConfig handles settings for the windows_exporter SMTP collector
185
type SMTPConfig struct {
186
BlackList string `river:"blacklist,attr,optional"`
187
WhiteList string `river:"whitelist,attr,optional"`
188
Exclude string `river:"exclude,attr,optional"`
189
Include string `river:"include,attr,optional"`
190
}
191
192
// Convert converts the component's SMTPConfig to the integration's SMTPConfig.
193
func (t SMTPConfig) Convert() windows_integration.SMTPConfig {
194
return windows_integration.SMTPConfig{
195
BlackList: t.BlackList,
196
WhiteList: t.WhiteList,
197
Exclude: t.Exclude,
198
Include: t.Include,
199
}
200
}
201
202
// ServiceConfig handles settings for the windows_exporter service collector
203
type ServiceConfig struct {
204
UseApi string `river:"use_api,attr,optional"`
205
Where string `river:"where_clause,attr,optional"`
206
}
207
208
// Convert converts the component's ServiceConfig to the integration's ServiceConfig.
209
func (t ServiceConfig) Convert() windows_integration.ServiceConfig {
210
return windows_integration.ServiceConfig{
211
UseApi: t.UseApi,
212
Where: t.Where,
213
}
214
}
215
216
// ProcessConfig handles settings for the windows_exporter process collector
217
type ProcessConfig struct {
218
BlackList string `river:"blacklist,attr,optional"`
219
WhiteList string `river:"whitelist,attr,optional"`
220
Exclude string `river:"exclude,attr,optional"`
221
Include string `river:"include,attr,optional"`
222
}
223
224
// Convert converts the component's ProcessConfig to the integration's ProcessConfig.
225
func (t ProcessConfig) Convert() windows_integration.ProcessConfig {
226
return windows_integration.ProcessConfig{
227
BlackList: t.BlackList,
228
WhiteList: t.WhiteList,
229
Exclude: t.Exclude,
230
Include: t.Include,
231
}
232
}
233
234
// ScheduledTaskConfig handles settings for the windows_exporter process collector
235
type ScheduledTaskConfig struct {
236
Exclude string `river:"exclude,attr,optional"`
237
Include string `river:"include,attr,optional"`
238
}
239
240
// Convert converts the component's ScheduledTaskConfig to the integration's ScheduledTaskConfig.
241
func (t ScheduledTaskConfig) Convert() windows_integration.ScheduledTaskConfig {
242
return windows_integration.ScheduledTaskConfig{
243
Exclude: t.Exclude,
244
Include: t.Include,
245
}
246
}
247
248
// NetworkConfig handles settings for the windows_exporter network collector
249
type NetworkConfig struct {
250
BlackList string `river:"blacklist,attr,optional"`
251
WhiteList string `river:"whitelist,attr,optional"`
252
Exclude string `river:"exclude,attr,optional"`
253
Include string `river:"include,attr,optional"`
254
}
255
256
// Convert converts the component's NetworkConfig to the integration's NetworkConfig.
257
func (t NetworkConfig) Convert() windows_integration.NetworkConfig {
258
return windows_integration.NetworkConfig{
259
BlackList: t.BlackList,
260
WhiteList: t.WhiteList,
261
Exclude: t.Exclude,
262
Include: t.Include,
263
}
264
}
265
266
// MSSQLConfig handles settings for the windows_exporter SQL server collector
267
type MSSQLConfig struct {
268
EnabledClasses []string `river:"enabled_classes,attr,optional"`
269
}
270
271
// Convert converts the component's MSSQLConfig to the integration's MSSQLConfig.
272
func (t MSSQLConfig) Convert() windows_integration.MSSQLConfig {
273
return windows_integration.MSSQLConfig{
274
EnabledClasses: strings.Join(t.EnabledClasses, ","),
275
}
276
}
277
278
// MSMQConfig handles settings for the windows_exporter MSMQ collector
279
type MSMQConfig struct {
280
Where string `river:"where_clause,attr,optional"`
281
}
282
283
// Convert converts the component's MSMQConfig to the integration's MSMQConfig.
284
func (t MSMQConfig) Convert() windows_integration.MSMQConfig {
285
return windows_integration.MSMQConfig{
286
Where: t.Where,
287
}
288
}
289
290
// LogicalDiskConfig handles settings for the windows_exporter logical disk collector
291
type LogicalDiskConfig struct {
292
BlackList string `river:"blacklist,attr,optional"`
293
WhiteList string `river:"whitelist,attr,optional"`
294
Include string `river:"include,attr,optional"`
295
Exclude string `river:"exclude,attr,optional"`
296
}
297
298
// Convert converts the component's LogicalDiskConfig to the integration's LogicalDiskConfig.
299
func (t LogicalDiskConfig) Convert() windows_integration.LogicalDiskConfig {
300
return windows_integration.LogicalDiskConfig{
301
BlackList: t.BlackList,
302
WhiteList: t.WhiteList,
303
Include: t.Include,
304
Exclude: t.Exclude,
305
}
306
}
307
308