#通过 Email 接收告警
本章将通过一个简单的实验介绍如何通过Email接受告警。
相关信息说明:
- prometheus版本: prometheus-1.7.1.darwin-amd64
- alertmanager版本: alertmanager-0.8.0.darwin-amd64
- 发送告警邮件的邮箱: qq email
- 假设该实验运行在本地机器上。prometheus默认端口为9090,Alertmanager默认端口为 9093.
### step 1: 下载 alertmanager
下载链接:https://github.com/prometheus/prometheus/releases
### step 2: 配置AlertManager下的simple.yml
其中一些关键配置如下:
```
global:
smtp_smarthost: 'smtp.qq.com:587'
smtp_from: 'xxx@qq.com'
smtp_auth_username: 'xxx@qq.com'
smtp_auth_password: 'your_email_password'
route:
# If an alert has successfully been sent, wait 'repeat_interval' to resend them.
repeat_interval: 10s
# A default receiver
receiver: team-X-mails
receivers:
- name: 'team-X-mails'
email_configs:
- to: 'team-X+alerts@example.org'
```
### step 3: 在prometheus下添加 alert.rules 文件
文件中写入以下简单规则作为示例。
```
ALERT memory_high
IF prometheus_local_storage_memory_series >= 0
FOR 1s
ANNOTATIONS {
summary = "Prometheus using more memory than it should {{ $labels.instance }}",
description = "{{ $labels.instance }} has lots of memory man (current value: {{ $value }}s)",
}
```
### step 4: 修改prometheus.yml 文件
添加以下规则:
```
rule_files:
- "alert.rules"
```
### step 5: 启动AlertManager服务
```
./alertmanager -config.file=simple.yml
```
### step 6: 启动prometheus服务
```
./prometheus -alertmanager.url=http://localhost:9093
```
根据以上步骤设置,此时 “team-X+alerts@example.org” 应该就可以收到 “xxx@qq.com” 发送的告警邮件了。
- 前言
- 修订记录
- 如何贡献
- Prometheus 简介
- Prometheus 是什么?
- 为什么选择 Prometheus?
- Prometheus 安装
- 二进制包安装
- Docker 安装
- 基础概念
- 数据模型
- Metric types
- 作业与实例
- PromQL
- PromQL 基本使用
- 与 SQL 对比
- 数据可视化
- Web Console
- Grafana
- Prometheus 配置
- 全局配置
- 告警配置
- 规则配置
- 数据拉取配置
- 远程可写存储
- 远程可读存储
- 服务发现
- 配置样例
- Exporter
- 文本格式
- Golang Sample Exporter
- Python Sample Exporter
- Node Exporter 安装使用
- Node Exporter 常用查询
- 其他 Exporter 介绍
- Pushgateway
- Pushgateway 是什么?
- 如何使用 Pushgateway?
- 数据存储
- Memory Store
- Local Store
- Remote Store
- Rule
- 如何配置
- Rule 触发逻辑
- Aleretmanager
- Aleretmanager 是什么?
- 如何实现告警分组和去噪
- 通过 Email 接收告警
- 通过 OneAlert 管理告警
- 通过 Webhooks 接收告警
- 其他告警接收方案
- 使用 Prometheus 实现主机运行状态监控的完整演示
- Target 配置
- Rule 配置
- Alertmanager 配置
- 演示功能
- Prometheus Tool
- Promu 介绍和使用
- Client SDK
- Prometheus 性能调优
- 通过 Metrics 查看 Prometheus 运行状态
- 通过日志分析 Prometheus 运行状态
- 通过调整启动参数优化性能
- Prometheus 与 JVM 监控
- JVM Exporter 安装
- JVM 数据查询
- Prometheus 与容器监控
- Docker 监控
- Rocket 监控
- Prometheus 与容器编排
- Kubernetes
- Docker Swarm
- Prometheus 与 DevOps
- 如何从 0 开发一个 exporter
- 使用 Webhooks 开发一个 alert receiver
- 产品化
- 高可用方案探讨
- 集群方案
- 主从方案
- v2.0 功能洞见
- 新功能
- 新存储架构
- 常见问题收录
- 如何热加载新配置?
- 为什么重启 Prometheus 过后,数据无法查询?
- 如何删除 Pushgateway 的数据?
- 为什么内存使用这么高?
- 为什么有数据丢失?
- Prometheus 如何通过认证后拉取数据?
