prometheus pushgateway
pushgateway是prometheus的一个组件,prometheus server默认是通过exporter主动获取数据(默认采取pull拉取数据),pushgateway则是通过被动方式推送数据到prometheus server,用户可以写一些自定义的监控脚本把需要监控的数据发送给pushgateway, 然后pushgateway再把数据发送给prometheus server
prometheus 默认采用定时pull 模式拉取targets数据,但是如果不在一个子网或者防火墙,prometheus就拉取不到targets数据,所以可以采用各个target往pushgateway上push数据,然后prometheus去pushgateway上定时pull数据
在监控业务数据的时候,需要将不同数据汇总, 汇总之后的数据可以由pushgateway统一收集,然后由 prometheus 统一拉取。
1)prometheus拉取状态只针对 pushgateway, 不能对每个节点都有效;
2)pushgateway出现问题,整个采集到的数据都会出现问题
3)监控下线,prometheus还会拉取到旧的监控数据,需要手动清理 pushgateway不要的数据。
1)安装pushgateway
此时pushgateway上还没有数据
2)修改prometheus-alertmanager-cfg.yaml文件,添加job
3)测试发送数据
把数据上报到pushgateway,在被监控服务所在的机器配置数据上报,想要把192.168.40.181这个机器的内存数据上报到pushgateway
1)编写shell脚本
2)打开pushgateway web ui界面,可看到如下
3)打开prometheus ui界面,可看到如下node_memory_usages的metrics指标
4)设置计划任务,定时上报数据
作者:lawrence
-------------------------------------------
个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!
扫描上面二维码关注我
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.