未验证 提交 d640d861 编写于 作者: Y yubo 提交者: GitHub

add mon.plugins.redis descriptions (#529)

* add mon.plugins.redis descriptions

* bugfix: add region field for instances/heartbeat
上级 6a70bed3
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
......@@ -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
......
......@@ -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
}
......
......@@ -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)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册