Grafana 配置 Prometheus 告警
Email configuration
我们这里选择 email 告警,首先修改 grafana 的配置文件 /etc/grafana/grafana.ini
,找到 SMTP 部分,修改为如下:
修改完成后,重启 grafana。
Notification channels
登陆到 grafana 中,创建一个通知渠道,测试一下,看看是否收到邮件。
- Name - Enter a name for this channel. It will be displayed when users add notifications to alert rules.
- Type - Select the channel type. Refer to the List of supported notifiers for details.
- Default (send on all alerts) - When selected, this option sends a notification on this channel for all alert rules.
- Include Image - See Enable images in notifications for details.
- Disable Resolve Message - When selected, this option disables the resolve message [OK] that is sent when the alerting state returns to false.
- Send reminders - When this option is checked additional notifications (reminders) will be sent for triggered alerts. You can specify how often reminders should be sent using number of seconds (s), minutes (m) or hours (h), for example
30s
,3m
,5m
or1h
.
Create alerts
grafana 不支持带有变量的模板报警,所以我们需要创建一个不带有变量的模板,这个我们可以去官方的 dashboard 中找一个,我这里找到编号为5984
,大家可以安装这个模板。
我在里面简单修改了一下格式,以及数据源,主要是针对 CPU 的负载修改了一下,其他资源默认可以使用。
我这边已经测试过了,没有什么问题,报警都可以正常运行,我把 promSQL 贴出来
CPU:
legend 设置为{{instance}}
内存:
legend 设置为{{instance}}
存储:
legend 设置为 {{instance}} - {{mountpoint}}
案例
以下拿 CPU 的配置截图给大家看下:
Queries:
Visualization:
Alert:
分类:
Prometheus
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?