Skip to content

Commit

Permalink
exchange: enable all collectors as default (#1572)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored Aug 17, 2024
1 parent b5ceb27 commit 4e460bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
7 changes: 7 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
collectors:
enabled: cpu,cpu_info,cs,exchange,iis,logical_disk,logon,memory,net,os,process,remote_fx,service,system,tcp,time,terminal_services,textfile
collector:
service:
services-where: "Name='windows_exporter'"
log:
level: warn
47 changes: 20 additions & 27 deletions pkg/collector/exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ type Config struct {
}

var ConfigDefaults = Config{
CollectorsEnabled: []string{},
CollectorsEnabled: []string{
"ADAccessProcesses",
"TransportQueues",
"HttpProxy",
"ActiveSync",
"AvailabilityService",
"OutlookWebAccess",
"Autodiscover",
"WorkloadManagement",
"RpcClientAccess",
"MapiHttpEmsmdb",
},
}

type Collector struct {
Expand Down Expand Up @@ -72,20 +83,6 @@ type Collector struct {
enabledCollectors []string
}

// All available Collector functions.
var exchangeAllCollectorNames = []string{
"ADAccessProcesses",
"TransportQueues",
"HttpProxy",
"ActiveSync",
"AvailabilityService",
"OutlookWebAccess",
"Autodiscover",
"WorkloadManagement",
"RpcClientAccess",
"MapiHttpEmsmdb",
}

func New(logger log.Logger, config *Config) *Collector {
if config == nil {
config = &ConfigDefaults
Expand Down Expand Up @@ -141,7 +138,7 @@ func NewWithFlags(app *kingpin.Application) *Collector {
sb := strings.Builder{}
sb.WriteString(fmt.Sprintf("%-32s %-32s\n", "Collector Name", "[PerfID] Perflib Object"))

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

Expand Down Expand Up @@ -239,22 +236,18 @@ func (c *Collector) Build() error {
c.syncCommandsPerSec = desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder")
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")

if len(c.config.CollectorsEnabled) == 0 {
c.enabledCollectors = exchangeAllCollectorNames
} else {
c.enabledCollectors = make([]string, 0, len(exchangeAllCollectorNames))
c.enabledCollectors = make([]string, 0, len(ConfigDefaults.CollectorsEnabled))

for _, collectorName := range c.config.CollectorsEnabled {
if !slices.Contains(exchangeAllCollectorNames, collectorName) {
return fmt.Errorf("unknown exchange collector: %s", collectorName)
}

c.enabledCollectors = append(c.enabledCollectors, collectorName)
for _, collectorName := range c.config.CollectorsEnabled {
if !slices.Contains(ConfigDefaults.CollectorsEnabled, collectorName) {
return fmt.Errorf("unknown exchange collector: %s", collectorName)
}

c.enabledCollectors = slices.Clip(c.enabledCollectors)
c.enabledCollectors = append(c.enabledCollectors, collectorName)
}

c.enabledCollectors = slices.Clip(c.enabledCollectors)

return nil
}

Expand Down

0 comments on commit 4e460bc

Please sign in to comment.