我正在尝试在Cisco路由器的接口吞吐量超过特定值时生成警报。请看一下我的代码。
我正在使用电报收集数据。我的测量“监视器使用情况”包含多个字段键和值。如何将它们分开并对其发出警报?我是否正确使用“衍生”节点?是我应该在“衍生”节点中使用的字段键吗?
是否可以记录每个节点的输出以帮助进行故障排除?就我而言,如何查看“警报”节点计算出的“ bytes_recv_per_sec”值?
“ log”节点的作用是什么?日志文件在哪里?我在“ /var/log/kapacitor/kapacitor.log”中看不到很多有价值的信息
我尝试用不同的参数方法处理不同的节点,但没有成功。感谢您的帮助。
dbrp "telegraf"."autogen"
stream
|from()
.measurement('monitor usage')
.where(lambda: "agent_host" == '10.92.192.15')
|window()
.period(1m)
.every(1m)
|httpOut('dump')
|stats(1m)
|httpOut('stats')
|derivative('Envision_Po1.891_ifHCInOctets')
.unit(1s).nonNegative()
.as('bytes_recv_per_sec')
|alert()
.warn(lambda: "bytes_recv_per_sec" > 40.0)
.crit(lambda: "bytes_recv_per_sec" > 80.0)
// post to logfile
.log('/tmp/alerts.log')
在此阶段,我希望看到“ /tmp/alerts.log”在达到警报阈值时生成一些警报消息。最终,我想发送警报电子邮件。
根据请求,这是有关“监控器使用情况”度量的我的数据库的信息
> show series from "monitor usage";
key
---
monitor\ usage,agent_host=10.85.1.5,host=dzhao-trex,sw_name=it-na-wan-pro-01-11p.int.pason.com
monitor\ usage,agent_host=10.85.1.6,host=dzhao-trex,sw_name=it-na-wan-pro-02-11p.int.pason.com
monitor\ usage,agent_host=10.92.192.15,host=dzhao-trex,rtr_name=irt01-00rm255r2r1.int.pason.com
monitor\ usage,agent_host=10.92.192.17,host=dzhao-trex,sw_name=wsw01-00rm255r2r1.pason.com
monitor\ usage,agent_host=172.19.254.200,host=dzhao-trex,sw_name=ssw01-04rm120r7.int.pason.com
monitor\ usage,agent_host=192.168.195.1,host=dzhao-trex,sw_name=wrt01-06.int.pason.com
> show field keys from "monitor usage";
name: monitor usage
fieldKey fieldType
-------- ---------
Envision_Po1.891_ifHCInOctets integer
Envision_Po1.891_ifHCOutOctets integer
Gi0/0/0_ifHCInOctets integer
Gi0/0/0_ifHCOutOctets integer
GigabitEthernet0/0/0_ifHCInOctets integer
GigabitEthernet0/0/0_ifHCOutOctets integer
GigabitEthernet0/0/2_ifHCInOctets integer
GigabitEthernet0/0/2_ifHCOutOctets integer
HE_Po1.892_ifHCInOctets integer
HE_Po1.892_ifHCOutOctets integer
Po1003_ifHCInOctets integer
Po1003_ifHCOutOctets integer
Rogers_Po1.894_ifHCInOctets integer
Rogers_Po1.894_ifHCOutOctets integer
Shaw_Po1.893_ifHCInOctets integer
Shaw_Po1.893_ifHCOutOctets integer
Te2/5/6_ifHCInOctets integer
Te2/5/6_ifHCOutOctets integer
Tunnel100_ifHCInOctets integer
Tunnel100_ifHCOutOctets integer
Tunnel1_ifHCInOctets integer
Tunnel1_ifHCOutOctets integer
Tunnel2_ifHCInOctets integer
Tunnel2_ifHCOutOctets integer
YYCIX_Gi0/0/1_ifHCInOctets integer
YYCIX_Gi0/0/1_ifHCOutOctets integer
> show tag keys from "monitor usage";
name: monitor usage
tagKey
------
agent_host
host
rtr_name
sw_name