Prometheus+AlertManager实现邮件报警
AlertManager下载
https://prometheus.io/download/
解压
添加配置文件test.yml,配置收发邮件邮箱
参考配置:

global:
smtp_smarthost: 'smtp.163.com:25' #163服务器
smtp_from: 'XXX@163.com' #发邮件的邮箱
smtp_auth_username: 'XXX@163.com' #发邮件的邮箱用户名,也就是你的邮箱
smtp_auth_password: 'XXX' #发邮件的邮箱密码 route:
group_by: ['alertname'] repeat_interval: 1h receiver: live-monitoring receivers:
- name: 'live-monitoring'
email_configs:
- to: 'czh1226@qq.com' #收邮件的邮箱

更多配置参考alertmanager包中的simple.yml
添加报警规则
prometheus targets 监控报警参考配置(node_down.yml):
节点内存使用率监控报警参考配置(memory_over.yml)

groups:
- name: example
rules:
- alert: NodeMemoryUsage
expr: (node_memory_MemTotal_bytes - (node_memory_MemFree_bytes+node_memory_Buffers_bytes+node_memory_Cached_bytes )) / node_memory_MemTotal_bytes * 100 > 80
for: 1m
labels:
user: caizh
annotations:
summary: "{{$labels.instance}}: High Memory usage detected"
description: "{{$labels.instance}}: Memory usage is above 80% (current value is:{{ $value }})"

当然,想要监控节点内存需要提前配置好node_exporter
修改prometheus配置文件prometheus.yml,开启报警功能,添加报警规则配置文件

# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: ["localhost:9093"]
# - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "node_down.yml"
- "memory_over.yml"

配置完成!
启动alertmanager
./alertmanager --config.file test.yml
启动prometheus(默认会调用prometheus.yml)
./prometheus
http://localhost:9090/alerts
看配置与报警规则是否添加成功
成功则如下图:

我的Prometheus Targets如下:

尝试kill一个测试是否可以用邮件报警
例如在slave1节点上:
hadoop-daemon.sh stop datanode
InstanceDown会变成(1 active),并处在PENDING状态

1min后变FIRING状态

耐心等待几分钟,会收到报警邮件:

邮件可能会有延时,耐心等一会~
想测试内存使用率可以多开点占内存的服务,或者把报警规则中内存占用超过80%报警调小一些
Over~
Prometheus+AlertManager实现邮件报警的更多相关文章
- Prometheus(四):Prometheus+Alertmanager 配置邮件报警
此处默认已安装Prometheus服务,服务地址:192.168.56.200 一.安装Alertmanager 此处采用源码编译的方式安装.首先下载alertmanager的软件包,下载地址:ht ...
- 【集群监控】Prometheus+AlertManager实现邮件报警
AlertManager下载 https://prometheus.io/download/ 解压 添加配置文件test.yml,配置收发邮件邮箱 Prometheus下载配置参考我的另一篇: htt ...
- prometheus + grafana + node_exporter + alertmanager 的安装部署与邮件报警 (一)
大家一定要先看详细的理论教程,再开始搭建,这样报错后才容易找到突破口 参考文档 https://www.cnblogs.com/afterdawn/p/9020129.html https://www ...
- Prometheus + AlertManager 邮件报警
安装 wget https://github.com/prometheus/alertmanager/releases/download/v0.13.0/alertmanager-0.13.0.lin ...
- [k8s]prometheus+alertmanager二进制安装实现简单邮件告警
本次任务是用alertmanaer发一个报警邮件 本次环境采用二进制普罗组件 本次准备监控一个节点的内存,当使用率大于2%时候(测试),发邮件报警. k8s集群使用普罗官方文档 环境准备 下载二进制h ...
- 2.Prometheus邮件报警配置
1.安装配置 Alertmanager wget https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertm ...
- Prometheus 监控报警系统 AlertManager 之邮件告警
转载自:https://cloud.tencent.com/developer/article/1486483 文章目录1.Prometheus & AlertManager 介绍2.环境.软 ...
- Prometheus(五):Prometheus+Alertmanager 配置企业微信报警
此处默认已安装Prometheus服务,服务地址:192.168.56.200 一.设置企业微信 1.1.企业微信注册(已有企业微信账号请跳过) 企业微信注册地址:https://work.weix ...
- 验证Prometheus alertmanager邮件发送
新环境上配置alertmanager时出现了“Client was not authenticated to send anonymous mail during MAIL FROM”错误,但老环境上 ...
随机推荐
- Introduction to Dynamic SQL
The idea of using dynamic SQL is to execute SQL that will potentially generate and execute another S ...
- 51nod1016
1016 水仙花数 V2 1 秒 131,072 KB 160 分 6 级题 水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 ...
- bzoj 2429: [HAOI2006]聪明的猴子 (最小生成树)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2429 思路:就是找最小生成树最大的一条边,最小生成树的性质,最后加入的那条边就是最大的 实现 ...
- Eclipse中项目Project Explorer视图与Package Explorer视图
Package Explorer视图: Project Explorer视图 两种视图的切换:
- python3 函数function
def function(arg): pass 变量: 由字母.数字和下划线构成,不能以数字开头,不能任意特殊字符 变量定义规范,使用驼峰式或者下划线式格式 变量定义尽量简明,易懂,方便使用者应用 作 ...
- linux中文件的时间戳
touch命令 touch用来创建新文件,或者修改时间戳. linux中的文件有三个时间点,利用stat命令查看: 1.atime:最后访问时间:文件最后一次被存取或执行的时间. 2.mtime:最后 ...
- 【BZOJ5339】[TJOI2018]教科书般的亵渎(斯特林数)
[BZOJ5339][TJOI2018]教科书般的亵渎(斯特林数) 题面 BZOJ 洛谷 题解 显然交亵渎的次数是\(m+1\). 那么这题的本质就是让你求\(\sum_{i=1}^n i^{m+1} ...
- luogu1196 银河英雄传说 (并查集)
并查集,不仅记fa,还记与fa的距离,还记根对应的尾节点 路径压缩的时候更新那个距离就行了 #include<bits/stdc++.h> #define pa pair<int,i ...
- VCC、VDD和VSS
在电子电路中,常可以看到VCC.VDD和VSS三种不同的符号,它们有什么区别呢? 一.解释 VCC:C=circuit 表示电路的意思, 即接入电路的电压: VDD:D=device 表示器件的意思 ...
- mysql5.6做单向主从复制Replication
原理场景:MySQL从3.23版本开始提供复制功能.指的是将主数据库的DDL和DML操作通过二进制日志传到从服务器(也叫从库),然后在从库上对这些日志重新执行, 从而使得从库和主库的数据保持同步. 优 ...