记一次部署系列:prometheus通过pushgateway配置自定义监控项

数据库96

1、部署pushgateway并配置prometheus能够拿到pushgateway的数据,类似下图。部署过程参考:https://www.cnblogs.com/sunnytomorrow/p/16068405.html

记一次部署系列:prometheus通过pushgateway配置自定义监控项

2、创建脚本生成监控项数据并写入文件,然后将数据put或post到pushgateway中。注意:数据必须为数字格式。

我这里创建"存活容器数量"和"停止容器数量"的监控项

bash;gutter:true;
]# cat query.sh#!/bin/bash
Up_container=`docker ps -a |grep Up|wc -l`
Exit_container=`docker ps -a |grep Exit|wc -l`
echo -e "Up_container $Up_container\nExit_container $Exit_container" > result.txt]# ./query.sh]# cat result.txtUp_container 1   # Up_container类似于为变量名Exit_container 0]# curl -X PUT --data-binary @result.txt http://192.168.4.67:9091/metrics/job/test_job/instance/test_instance

3、访问prometheus界面,查看pushgateway中的数据

记一次部署系列:prometheus通过pushgateway配置自定义监控项

记一次部署系列:prometheus通过pushgateway配置自定义监控项

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长