我尝试使用sensu将指标发送到UDP中的Influxdb。
我设置了我的Influxdb数据库:
# echo "cpu value=1" | nc -C -w 1 -u localhost 8089
# echo "select * from cpu" | influx -database sensu
name: cpu
time value
1490898218118704438 1
我从存储库(https://github.com/sensu-plugins/sensu-plugins-influxdb)安装了插件:
# sensu-install -p influxdb
# cp /opt/sensu/embedded/bin/mutator-influxdb-line-protocol.rb /etc/sensu/extensions/
根据doc:
配置处理程序{
"handlers": {
"influxdb": {
"type": "udp",
"socket": {
"host": "localhost",
"port": 8089
},
"mutator": "influxdb_line_protocol"
}
}
并配置了一个检查以使用此处理程序:
{
"checks": {
"cpu-metrics": {
"command": "/opt/sensu/embedded/bin/metrics-cpu-pcnt-usage.rb",
"handlers": [
"influxdb"
],
"interval": 60,
"subscribers": [
"production"
],
"type": "metric",
"standalone": false
}
}
}
现在,当我重新启动sensu-server
时,我可以看到已加载扩展程序:
{"时间戳":" 2017-03-30T19:53:05.083622 + 0000""电平":"警告&#34 ;, "消息":"加载的扩展","输入":" mutator"," name":" Influxdb_line_protocol","说明":"返回格式为InfluxDB线路协议的检查输出"}
我可以看到客户端收集的指标:
{"时间戳":" 2017-03-30T20:08:49.940732 + 0000""电平":"信息&#34 ;, "消息":"收到检查请求","检查":{"命令":" / opt / sensu / embedded /箱/指标-CPU-PCNT-usage.rb""处理":[" influxdb&#34],"类型":"度量&# 34;,"独立":假,"名称":" CPU-度量""发出":1490904529}} {"时间戳":" 2017-03-30T20:08:51.150984 + 0000""电平":"信息"&#34 ;消息":"发布检查结果","有效负载":{"客户":" nott","检查& #34; {"命令":" /opt/sensu/embedded/bin/metrics-cpu-pcnt-usage.rb","处理":[ "度量&#34],"类型":"度量""独立":假,"名称":&# 34; CPU-度量""发出":1490904529,"间隔" 60"订户":["生产"] ,"执行":1490904529,"期限":1.21,"输出":" nott.cpu.user 0.25 1490904531 \ nnott.cpu.nice 0.00 1490904531 \ nnott.cpu.system 0.00 1490904531 \ nnott.cpu.idle 99.25 1490904531 \ nnott.cpu.iowait 0.00 1490904531 \ nnott.cpu.irq 0.00 1490904531 \ nnott.cpu.softirq 0.00 1490904531 \ nnott.cpu.steal 0.50 1490904531 \ nnott.cpu.guest 0.00 1490904531 \ n"," status":0}}}
但我的trendxdb数据库中还没有更多内容。
influx -database sensu
Connected to http://localhost:8086 version 1.2.1
InfluxDB shell version: 1.2.1
> show measurements;
name: measurements
name
----
cpu
任何见解?
更新:根据评论中的要求,这是我的Influxdb UDP配置:
[[udp]]
enabled = true
bind-address = "127.0.0.1:8089"
database = "sensu"
retention-policy = ""
batch-size = 5000
batch-pending = 10
batch-timeout = "1s"
read-buffer = 0
更新2:如果我添加调试处理程序,我可以在服务器日志中看到指标检查的结果:
{"时间戳":" 2017-04-15T13:05:46.047354 + 0000""电平":"信息&#34 ;, " message":" handler extension"," extension":{" type":" extension",&# 34;名称":"调试"}"事件" {" ID":" 1303c9d3-096c-4744-9fdc-9566c831270c&# 34;}"输出":" {\"客户\":{\"名称\":\"诺特\ " \"地址\":\" 127.0.0.1 \" \"环境\":\"生产\ " \"订阅\":[\"证书\" \"生产\" \"客户端:诺特\&#34],\"插座\":{\"绑定\":\" 127.0.0.1 \" \&#34 ;端口\":3030},\"版本\":\" 0.28.2 \" \"时间戳\":1492261543 },\"检查\":{\"命令\":\" /opt/sensu/embedded/bin/metrics-cpu-pcnt-usage.rb \" \"处理程序\":[\"度量\&#34],\"间隔\":60,\&#34 ;订户\":[\"生产\&#34],\"类型\":\"度量\" \&#34 ;独立\ ":真,\"名称\":\" CPU-度量\" \"发出\":1492261544,\&# 34;执行\":1492261544,\"持续时间\":1.205,\"输出\":\" nott.cpu.user 0.75 1492261546 \ nnott.cpu.nice 0.00 1492261546 \ nnott.cpu.system 0.00 1492261546 \ nnott.cpu.idle 99.00 1492261546 \ nnott.cpu.iowait 0.00 1492261546 \ nnott.cpu.irq 0.00 1492261546 \ nnott.cpu.softirq 0.00 1492261546 \ nnott。 cpu.steal 0.25 1492261546 \ nnott.cpu.guest 0.00 1492261546 \ n \",\" status \":0,\" history \":[\& #34; 0 \" \" 0 \" \" 0 \" \" 0 \" \&#34 ; 0 \" \" 0 \" \" 0 \" \" 0 \" \" 0 \" \" 0 \" \" 0 \" \" 0 \" \" 0 \& #34; \" 0 \" \" 0 \" \" 0 \" \" 0 \&#34 ; \" 0 \" \" 0 \" \" 0 \" \" 0 \"] ,\" total_state_change \":0},\"发生\":1,\" occurrences_watermark \":1,\"动作\":\"创建\" \"时间戳\":1492261546,\" ID为\":\" 1303c9d3 -096c- 4744-9fdc-9566c831270c \" \" last_ok \":1492261546,\"沉默\":假,\" silenced_by \" :[]}""状态":0}
但我在环回上看到没有任何关于porr 8089的交换。
答案 0 :(得分:0)
我有同样的问题。
将precision = "s"
行添加到influxdb.conf
文件中的UDP块后,此问题得以解决。