forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
47 lines (37 loc) · 960 Bytes
/
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
package core
import (
"strings"
"github.com/pkg/errors"
"github.com/elastic/beats/libbeat/common/cfgwarn"
)
// Core metric types.
const (
percentages = "percentages"
ticks = "ticks"
)
// Config for the system core metricset.
type Config struct {
Metrics []string `config:"core.metrics"`
CPUTicks *bool `config:"cpu_ticks"` // Deprecated.
}
// Validate validates the core config.
func (c Config) Validate() error {
if c.CPUTicks != nil {
cfgwarn.Deprecate("6.1", "cpu_ticks is deprecated. Add 'ticks' to the core.metrics list.")
}
if len(c.Metrics) == 0 {
return errors.New("core.metrics cannot be empty")
}
for _, metric := range c.Metrics {
switch strings.ToLower(metric) {
case percentages, ticks:
default:
return errors.Errorf("invalid core.metrics value '%v' (valid "+
"options are %v and %v)", metric, percentages, ticks)
}
}
return nil
}
var defaultConfig = Config{
Metrics: []string{percentages},
}