1 Star 0 Fork 0

sqos/beats

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
config.go 1.05 KB
Copy Edit Raw Blame History
package cpu
import (
"strings"
"github.com/pkg/errors"
"github.com/elastic/beats/libbeat/common/cfgwarn"
)
// CPU metric types.
const (
percentages = "percentages"
normalizedPercentages = "normalized_percentages"
ticks = "ticks"
)
// Config for the system cpu metricset.
type Config struct {
Metrics []string `config:"cpu.metrics"`
CPUTicks *bool `config:"cpu_ticks"` // Deprecated.
}
// Validate validates the cpu config.
func (c Config) Validate() error {
if c.CPUTicks != nil {
cfgwarn.Deprecate("6.1", "cpu_ticks is deprecated. Add 'ticks' to the cpu.metrics list.")
}
if len(c.Metrics) == 0 {
return errors.New("cpu.metrics cannot be empty")
}
for _, metric := range c.Metrics {
switch strings.ToLower(metric) {
case percentages, normalizedPercentages, ticks:
default:
return errors.Errorf("invalid cpu.metrics value '%v' (valid "+
"options are %v, %v, and %v)", metric, percentages,
normalizedPercentages, ticks)
}
}
return nil
}
var defaultConfig = Config{
Metrics: []string{percentages},
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.1.4

Search