diff --git a/etc/prober.yml b/etc/prober.yml index 9ef20f1d..19518c0c 100644 --- a/etc/prober.yml +++ b/etc/prober.yml @@ -1,8 +1,14 @@ -region: default workerProcesses: 5 + logger: dir: logs/prober - level: DEBUG + level: INFO keepHours: 24 pluginsConfig: etc/plugins -ignoreConfig: false + +report: + enabled: true + region: default + interval: 4000 + timeout: 3000 + api: api/hbs/heartbeat diff --git a/src/common/report/report.go b/src/common/report/report.go index b9d2ed7c..81bbd843 100644 --- a/src/common/report/report.go +++ b/src/common/report/report.go @@ -21,6 +21,7 @@ type ReportSection struct { HTTPPort string `yaml:"http_port"` RPCPort string `yaml:"rpc_port"` Remark string `yaml:"remark"` + Region string `yaml:"region"` } var Config ReportSection @@ -55,6 +56,7 @@ func report(addrs []string) { "rpc_port": Config.RPCPort, "http_port": Config.HTTPPort, "remark": Config.Remark, + "region": Config.Region, } var body reportRes diff --git a/src/models/mon_hbs.go b/src/models/mon_hbs.go index c8b177a0..098f2dad 100644 --- a/src/models/mon_hbs.go +++ b/src/models/mon_hbs.go @@ -20,7 +20,7 @@ func (i *Instance) Add() error { } func (i *Instance) Update() error { - _, err := DB["hbs"].Where("id=?", i.Id).MustCols("ts", "http_port", "rpc_port").Update(i) + _, err := DB["hbs"].Where("id=?", i.Id).MustCols("ts", "http_port", "rpc_port", "region").Update(i) return err } diff --git a/src/modules/monapi/plugins/redis/redis.go b/src/modules/monapi/plugins/redis/redis.go index c9872b4e..b9fc6fea 100644 --- a/src/modules/monapi/plugins/redis/redis.go +++ b/src/modules/monapi/plugins/redis/redis.go @@ -2,6 +2,7 @@ package redis import ( "fmt" + "strings" "github.com/didi/nightingale/src/modules/monapi/collector" "github.com/didi/nightingale/src/modules/monapi/plugins" @@ -38,13 +39,15 @@ var ( "Optional. Specify redis commands to retrieve values": "设置服务器命令,采集数据名称", "Password": "密码", "specify server password": "服务密码", + "redis-cli command": "redis-cli命令,如果参数中带有空格,请以数组方式设置参数", + "metric name": "变量名称,采集时会加上前缀 redis_commands_", }, } ) type RedisCommand struct { - Command []string `label:"Command" json:"command,required" description:"" ` - Field string `label:"Field" json:"field,required" description:"metric name"` + Command []string `label:"Command" json:"command,required" example:"get sample_key" description:"redis-cli command"` + Field string `label:"Field" json:"field,required" example:"sample_key" description:"metric name"` Type string `label:"Type" json:"type" enum:"[\"float\", \"integer\"]" default:"float" description:"metric type"` } @@ -62,6 +65,20 @@ func (p *RedisRule) Validate() error { if len(cmd.Command) == 0 { return fmt.Errorf("redis.rule.commands[%d].command must be set", i) } + + var command []string + for i, cmd := range cmd.Command { + if i == 0 { + for _, v := range strings.Fields(cmd) { + command = append(command, v) + } + continue + } + + command = append(command, cmd) + } + cmd.Command = command + if cmd.Field == "" { return fmt.Errorf("redis.rule.commands[%d].field must be set", i) }