Skip to content

Commit 4e460bc

Browse files
authored
exchange: enable all collectors as default (#1572)
1 parent b5ceb27 commit 4e460bc

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
collectors:
2+
enabled: cpu,cpu_info,cs,exchange,iis,logical_disk,logon,memory,net,os,process,remote_fx,service,system,tcp,time,terminal_services,textfile
3+
collector:
4+
service:
5+
services-where: "Name='windows_exporter'"
6+
log:
7+
level: warn

pkg/collector/exchange/exchange.go

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ type Config struct {
2323
}
2424

2525
var ConfigDefaults = Config{
26-
CollectorsEnabled: []string{},
26+
CollectorsEnabled: []string{
27+
"ADAccessProcesses",
28+
"TransportQueues",
29+
"HttpProxy",
30+
"ActiveSync",
31+
"AvailabilityService",
32+
"OutlookWebAccess",
33+
"Autodiscover",
34+
"WorkloadManagement",
35+
"RpcClientAccess",
36+
"MapiHttpEmsmdb",
37+
},
2738
}
2839

2940
type Collector struct {
@@ -72,20 +83,6 @@ type Collector struct {
7283
enabledCollectors []string
7384
}
7485

75-
// All available Collector functions.
76-
var exchangeAllCollectorNames = []string{
77-
"ADAccessProcesses",
78-
"TransportQueues",
79-
"HttpProxy",
80-
"ActiveSync",
81-
"AvailabilityService",
82-
"OutlookWebAccess",
83-
"Autodiscover",
84-
"WorkloadManagement",
85-
"RpcClientAccess",
86-
"MapiHttpEmsmdb",
87-
}
88-
8986
func New(logger log.Logger, config *Config) *Collector {
9087
if config == nil {
9188
config = &ConfigDefaults
@@ -141,7 +138,7 @@ func NewWithFlags(app *kingpin.Application) *Collector {
141138
sb := strings.Builder{}
142139
sb.WriteString(fmt.Sprintf("%-32s %-32s\n", "Collector Name", "[PerfID] Perflib Object"))
143140

144-
for _, cname := range exchangeAllCollectorNames {
141+
for _, cname := range ConfigDefaults.CollectorsEnabled {
145142
sb.WriteString(fmt.Sprintf("%-32s %-32s\n", cname, collectorDesc[cname]))
146143
}
147144

@@ -239,22 +236,18 @@ func (c *Collector) Build() error {
239236
c.syncCommandsPerSec = desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder")
240237
c.activeUserCountMapiHttpEmsMDB = desc("mapihttp_emsmdb_active_user_count", "Number of unique outlook users that have shown some kind of activity in the last 2 minutes")
241238

242-
if len(c.config.CollectorsEnabled) == 0 {
243-
c.enabledCollectors = exchangeAllCollectorNames
244-
} else {
245-
c.enabledCollectors = make([]string, 0, len(exchangeAllCollectorNames))
239+
c.enabledCollectors = make([]string, 0, len(ConfigDefaults.CollectorsEnabled))
246240

247-
for _, collectorName := range c.config.CollectorsEnabled {
248-
if !slices.Contains(exchangeAllCollectorNames, collectorName) {
249-
return fmt.Errorf("unknown exchange collector: %s", collectorName)
250-
}
251-
252-
c.enabledCollectors = append(c.enabledCollectors, collectorName)
241+
for _, collectorName := range c.config.CollectorsEnabled {
242+
if !slices.Contains(ConfigDefaults.CollectorsEnabled, collectorName) {
243+
return fmt.Errorf("unknown exchange collector: %s", collectorName)
253244
}
254245

255-
c.enabledCollectors = slices.Clip(c.enabledCollectors)
246+
c.enabledCollectors = append(c.enabledCollectors, collectorName)
256247
}
257248

249+
c.enabledCollectors = slices.Clip(c.enabledCollectors)
250+
258251
return nil
259252
}
260253

0 commit comments

Comments
 (0)