Prometheus部署+邮箱告警+企业微信告警+钉钉告警
1 部署Prometheus server
1.1 下载二进制包
1 | $ wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz |
1.2 解压并move至/work/admin目录下
1 | $ tar zcvf prometheus-2.7.1.linux-amd64.tar.gz |
1.3 配置并启动
1 | $ cat prometheus.yml |
2 部署node_exporter
2.1 下载二进制包
1 | $ wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz |
2.2 解压并move至/usr/local/prometheus目录下
1 | $ tar zcvf node_exporter-0.17.0.linux-amd64.tar.gz |
2.3 启动
1 | $ /usr/local/prometheus/node_exporter/node_exporter --web.listen-address=:9100 |
3 部署mysqld_exporter
3.1 下载二进制包
1 | $ wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz |
3.2 解压并move至/usr/local/prometheus目录下
1 | $ tar zcvf mysqld_exporter-0.11.0.linux-amd64.tar.gz |
3.3 为mysqld_exporter配置MySQL用户并授权,启动
1 | $ cat .my.cnf |
4 部署alertmanager
4.1 下载二进制包
1 | $ wget https://github.com/prometheus/alertmanager/releases/download/v0.16.1/alertmanager-0.16.1.linux-amd64.tar.gz |
4.2 解压并move至/usr/local/prometheus目录下
1 | $ tar zcvf alertmanager-0.16.1.linux-amd64.tar.gz |
4.3 修改配置文件并启动
1 | $ cat alertmanager.yml |
5 prometheus通过webhook推送告警至钉钉
5.1 添加钉钉机器人,获取webhook
参考 https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1
5.2 下载插件(二进制文件)
1 | $ wget https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v0.3.0/prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz |
5.3 解压并move至/usr/local/prometheus目录下
1 | $ tar zxvf prometheus-webhook-dingtalk-0.3.0.linux-amd64.tar.gz |
5.4 编辑启动脚本(请替换为自己的webhook URL 及 ding.profile)
1 | $ cat dingding_start.sh |
5.5 编辑alertmanager.yml,增加web_hook配置并重启alertmanager
1 | - name: 'ops_dingding' |