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):

按 Ctrl+C 复制代码
按 Ctrl+C 复制代码

节点内存使用率监控报警参考配置(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实现邮件报警的更多相关文章

  1. Prometheus(四):Prometheus+Alertmanager 配置邮件报警

    此处默认已安装Prometheus服务,服务地址:192.168.56.200  一.安装Alertmanager 此处采用源码编译的方式安装.首先下载alertmanager的软件包,下载地址:ht ...

  2. 【集群监控】Prometheus+AlertManager实现邮件报警

    AlertManager下载 https://prometheus.io/download/ 解压 添加配置文件test.yml,配置收发邮件邮箱 Prometheus下载配置参考我的另一篇: htt ...

  3. prometheus + grafana + node_exporter + alertmanager 的安装部署与邮件报警 (一)

    大家一定要先看详细的理论教程,再开始搭建,这样报错后才容易找到突破口 参考文档 https://www.cnblogs.com/afterdawn/p/9020129.html https://www ...

  4. Prometheus + AlertManager 邮件报警

    安装 wget https://github.com/prometheus/alertmanager/releases/download/v0.13.0/alertmanager-0.13.0.lin ...

  5. [k8s]prometheus+alertmanager二进制安装实现简单邮件告警

    本次任务是用alertmanaer发一个报警邮件 本次环境采用二进制普罗组件 本次准备监控一个节点的内存,当使用率大于2%时候(测试),发邮件报警. k8s集群使用普罗官方文档 环境准备 下载二进制h ...

  6. 2.Prometheus邮件报警配置

    1.安装配置 Alertmanager wget https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertm ...

  7. Prometheus 监控报警系统 AlertManager 之邮件告警

    转载自:https://cloud.tencent.com/developer/article/1486483 文章目录1.Prometheus & AlertManager 介绍2.环境.软 ...

  8. Prometheus(五):Prometheus+Alertmanager 配置企业微信报警

    此处默认已安装Prometheus服务,服务地址:192.168.56.200  一.设置企业微信 1.1.企业微信注册(已有企业微信账号请跳过) 企业微信注册地址:https://work.weix ...

  9. 验证Prometheus alertmanager邮件发送

    新环境上配置alertmanager时出现了“Client was not authenticated to send anonymous mail during MAIL FROM”错误,但老环境上 ...

随机推荐

  1. NC部门考勤月报定制sql

    SELECT t_1.pk_psndoc pk_psndoc, t_1.pk_group pk_group, t_1.pyear pyear, t_1.month month, t_1.code ps ...

  2. 转载 大话pcie

    原文https://blog.csdn.net/abcamus/article/details/76167747 一.PCIe DMA机制 PCIe控制器也提供DMA(Direct Memory ac ...

  3. 前端动态属性页面的 要用id做name 因为这样方便在提交表单时候取到值

    前端动态属性页面的 要用id做name 因为这样方便在提交表单时候取到值

  4. Nginx 对上游使用SSL链接

    L96 双向认证SSL指令示列 对下游使用证书指令 Syntax: ssl_certificate file; Default: — Context: http, server Syntax: ssl ...

  5. 洛谷P2084 进制转换

    题目背景 无 题目描述 今天小明学会了进制转换,比如(10101)2 ,那么它的十进制表示的式子就是 : 1*2^4+0*2^3+1*2^2+0*2^1+1*2^0, 那么请你编程实现,将一个M进制的 ...

  6. Codeforces 719A 月亮

    参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6395221.html A. Vitya in the Countryside time limit ...

  7. Codeforces519 E. A and B and Lecture Rooms

    传送门:>Here< 题意:询问给出一棵无根树上任意两点$a,b$,求关于所有点$i$,$dist(a,i) = dist(b,i)$的点的数量.要求每一次询问在$O(log n)$的时间 ...

  8. Python代码编写规范

    Python代码编写规范 编码: a)     如无特殊情况,文件一律使用UTF-8编码 b)     如无需特殊情况,文件头部必须加入#-*-coding:utf-8-*- 缩进 a)     统一 ...

  9. linux命令:查看系统版本

    debian系统 (1)  lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debia ...

  10. Nagios 使用 NSClient++ 监控Windows Server

    在被监控的Windows server 主机上安装NSClinet++下载地址:https://www.nsclient.org/download/32bit:http://files.nsclien ...