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. 使用电脑adb给Essential Phone刷机 —(官方篇)

    用ADB给Essential Phone线刷升级 重要:请确保在刷机前已经解锁,关于解锁教程群里有! 准备 原版boot Twrp boot Magisk卡刷包 到官网下载OTA包 准备好Essent ...

  2. Mybatis常见问题总结

    1.大于号.小于号在sql语句中的转换 使用mybatis 时sql语句是写在xml文件中,如果sql中有一些特殊的字符的话,比如< ,<=,>,>=等符号,会引起xml格式的 ...

  3. Git——Git的简单介绍【一】

    官方网站 Git官网 https://git-scm.com/ GitHub https://github.com GitLab https://about.gitlab.com/ SVN https ...

  4. 初略 异步IO

    import asyncio asyncio.coroutine() from concurrent.futures import ThreadPoolExecutor def task(): pri ...

  5. Machine Schedule POJ - 1325(水归类建边)

    Machine Schedule Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17457   Accepted: 7328 ...

  6. WC2019 划水记

    写在前面: 本篇是擅长咕咕咕的\(\text{BLUESKY007}\)同学难得不咕写的游记,将会记录\(WC2019(2019.1.24(Day\ 0)\sim2019.1.30(Day\ 6))\ ...

  7. Asp.Net Output.Write()

    string name="张三" <div> <label>@Output.Write(name)</label> </div> 在 ...

  8. 构建DHCP服务

    --------------------DHCP 配置-------------------# yum install dhcp -y# vim /etc/dhcp/dhcpd.conf# cp /u ...

  9. luogu5024 [NOIp2018]保卫王国 (动态dp)

    可以直接套动态dp,但因为它询问之间相互独立,所以可以直接倍增记x转移到fa[x]的矩阵 #include<bits/stdc++.h> #define CLR(a,x) memset(a ...

  10. 【php】php目录路径函数系列

    在写框架和项目时候我们经常要获取绝对路径,php有内置函数realpath(),  也可以写个函数来实现这个功能 function getAbsolutePath($path) { $path = s ...