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. codeforces509B

    Painting Pebbles CodeForces - 509B There are n piles of pebbles on the table, the i-th pile contains ...

  2. [离散时间信号处理学习笔记] 10. z变换与LTI系统

    我们前面讨论了z变换,其实也是为了利用z变换分析LTI系统. 利用z变换得到LTI系统的单位脉冲响应 对于用差分方程描述的LTI系统而言,z变换将十分有用.有如下形式的差分方程: $\displays ...

  3. git在Linux下的安装

    参考:https://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git Git 的工作需要调用 curl,zlib,op ...

  4. Matplotlib学习---matplotlib的一些基本用法

    Matplotlib有两种接口,一种是matlab风格接口,一种是面向对象接口.在这里,统一使用面向对象接口.因为面向对象接口可以适应更复杂的场景,在多图之间进行切换将变得非常容易. 首先导入matp ...

  5. ionic报错: Failed to load resource

    隔了一天,才发现是代码写错了 出错的原因是在ts 文件中使用这样的定义 data: [] = ['高新区', '经开区', '其他园区']; 错误在于这个定义的类型,不能是 [],修改成 any就没有 ...

  6. SuperSocket 案例

    SuperSocket 是一个轻量级, 跨平台而且可扩展的 .Net/Mono Socket 服务器程序框架.你无须了解如何使用 Socket, 如何维护 Socket 连接和 Socket 如何工作 ...

  7. 爬虫_腾讯招聘(xpath)

    和昨天一样的工作量,时间只用了一半,但还是效率有点低了,因为要把两个网页结合起来,所以在列表操作上用了好多时间 import requests from lxml import etree heade ...

  8. 栈长这里是生成了一个 Maven 示例项目。

    Spring Cloud 的注册中心可以由 Eureka.Consul.Zookeeper.ETCD 等来实现,这里推荐使用 Spring Cloud Eureka 来实现注册中心,它基于 Netfl ...

  9. Android自带Monkey测试

    Monkey是在模拟器上或设备上运行的一个小程序,它能够产生为随机的用户事件流,例如点击(click),触摸(touch),挥手(gestures),还有一系列的系统级事件.可以使用Monkey来给正 ...

  10. 【CF981D】Bookshelves(贪心,动态规划)

    [CF981D]Bookshelves(贪心,动态规划) 题面 洛谷 Codeforces 给定一个长度为\(n\)的数列,把他们划分成\(k\)段,使得每段的和的结构按位与起来最大. 题解 从高位往 ...