add mon.plugins.redis descriptions (#529)

* add mon.plugins.redis descriptions

* bugfix: add region field for instances/heartbeat
This commit is contained in:
yubo 2021-01-21 16:35:31 +08:00 committed by GitHub
parent 6a70bed30f
commit d640d86160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 6 deletions

View File

@ -1,8 +1,14 @@
region: default
workerProcesses: 5 workerProcesses: 5
logger: logger:
dir: logs/prober dir: logs/prober
level: DEBUG level: INFO
keepHours: 24 keepHours: 24
pluginsConfig: etc/plugins pluginsConfig: etc/plugins
ignoreConfig: false
report:
enabled: true
region: default
interval: 4000
timeout: 3000
api: api/hbs/heartbeat

View File

@ -21,6 +21,7 @@ type ReportSection struct {
HTTPPort string `yaml:"http_port"` HTTPPort string `yaml:"http_port"`
RPCPort string `yaml:"rpc_port"` RPCPort string `yaml:"rpc_port"`
Remark string `yaml:"remark"` Remark string `yaml:"remark"`
Region string `yaml:"region"`
} }
var Config ReportSection var Config ReportSection
@ -55,6 +56,7 @@ func report(addrs []string) {
"rpc_port": Config.RPCPort, "rpc_port": Config.RPCPort,
"http_port": Config.HTTPPort, "http_port": Config.HTTPPort,
"remark": Config.Remark, "remark": Config.Remark,
"region": Config.Region,
} }
var body reportRes var body reportRes

View File

@ -20,7 +20,7 @@ func (i *Instance) Add() error {
} }
func (i *Instance) Update() 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 return err
} }

View File

@ -2,6 +2,7 @@ package redis
import ( import (
"fmt" "fmt"
"strings"
"github.com/didi/nightingale/src/modules/monapi/collector" "github.com/didi/nightingale/src/modules/monapi/collector"
"github.com/didi/nightingale/src/modules/monapi/plugins" "github.com/didi/nightingale/src/modules/monapi/plugins"
@ -38,13 +39,15 @@ var (
"Optional. Specify redis commands to retrieve values": "设置服务器命令,采集数据名称", "Optional. Specify redis commands to retrieve values": "设置服务器命令,采集数据名称",
"Password": "密码", "Password": "密码",
"specify server password": "服务密码", "specify server password": "服务密码",
"redis-cli command": "redis-cli命令如果参数中带有空格请以数组方式设置参数",
"metric name": "变量名称,采集时会加上前缀 redis_commands_",
}, },
} }
) )
type RedisCommand struct { type RedisCommand struct {
Command []string `label:"Command" json:"command,required" description:"" ` Command []string `label:"Command" json:"command,required" example:"get sample_key" description:"redis-cli command"`
Field string `label:"Field" json:"field,required" description:"metric name"` 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"` 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 { if len(cmd.Command) == 0 {
return fmt.Errorf("redis.rule.commands[%d].command must be set", i) 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 == "" { if cmd.Field == "" {
return fmt.Errorf("redis.rule.commands[%d].field must be set", i) return fmt.Errorf("redis.rule.commands[%d].field must be set", i)
} }