Grafana 邮件告警配置

记录一次使用Grafana 邮件告警触发并发送

系统版本

[root@VM-16-5-centos grafana]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

grafana版本

[root@VM-16-5-centos grafana]# grafana-server -v
Version 7.0.4 (commit: c4d8d0c2ae, branch: HEAD)

1、修改配置文件,告警配置
grafana只有graph支持告警通知。grafana的告警通知渠道有很多种,像Email、Teams、钉钉等都有支持。
在grafana.ini中开启告警:
配置文件太长了,我放一些关于设置邮件配置的内容吧

#################################### Alerting ############################
[alerting]
# Disable alerting engine & UI features
enabled = true  #开启
# Makes it possible to turn off alert rule execution but alerting UI is visible
execute_alerts = true  #开启

# Default setting for new alert rules. Defaults to categorize error and timeouts as alerting. (alerting, keep_state)
error_or_timeout = alerting  #开启

# Default setting for how Grafana handles nodata or null values in alerting. (alerting, no_data, keep_state, ok)
nodata_or_nullvalues = no_data  #开启

# Alert notifications can include images, but rendering many images at the same time can overload the server
# This limit will protect the server from render overloading and make sure notifications are sent out quickly
concurrent_render_limit = 5  #开启


# Default setting for alert calculation timeout. Default value is 30
;evaluation_timeout_seconds = 30

# Default setting for alert notification timeout. Default value is 30
;notification_timeout_seconds = 30

2、邮件通知
STMP服务器配置
要能发送邮件通知,首先需要在配置文件grafana.ini中配置邮件服务器等信息

#################################### SMTP / Emailing ##########################
[smtp]
enabled = true
host = smtp.163.com:25
user = xxxxxxx@163.com  #你的邮箱
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = xxxxxxxxxxxxxxxx  #是你163邮箱的授权码
;cert_file =
;key_file =
skip_verify = true
from_address = xxxxxxx@163.com  #你的邮箱
from_name = Grafana
# EHLO identity in SMTP dialog (defaults to instance_name)
;ehlo_identity = dashboard.example.com

[emails]
;welcome_email_on_sign_up = false
;templates_pattern = emails/*.html

3、重启Grafana服务
修改完配置,记得重启Grafana服务

# systemctl restart grafana-server

4.在grafana中配置邮件通知方式

保证同时发送告警图片。
发送告警图片需要安装插件:
参考:https://grafana.com/docs/grafana/latest/administration/image_rendering/
 
安装图形渲染插件
参考:https://grafana.com/grafana/plugins/grafana-image-renderer/installation
 
[root@xxx jalchu]# whereis grafana-cli
grafana-cli: /usr/sbin/grafana-cli
[root@xxx jalchu]# /usr/sbin/grafana-cli plugins install grafana-image-renderer
installing grafana-image-renderer @ 2.0.0
from: https://grafana.com/api/plugins/grafana-image-renderer/versions/2.0.0/download
into: /var/lib/grafana/plugins
 
Installed grafana-image-renderer successfully 
 
Restart grafana after installing plugins . <service grafana-server restart>

在这里插入图片描述
在这里插入图片描述
上面装grafana-image-renderer一直装不上,执行命令grafana-cli plugins install grafana-image-renderer后没反应,所以采用另一种方式:
https://github.com/grafana/grafana-image-renderer/releases/tag/v2.0.1

yum install freetype*
yum install libXcomposite libXdamage libXtst cups libXScrnSaver pango atk adwaita-cursor-theme adwaita-icon-theme at at-spi2-atk at-spi2-core cairo-gobject colord-libs dconf desktop-file-utils ed emacs-filesystem gdk-pixbuf2 glib-networking gnutls gsettings-desktop-schemas gtk-update-icon-cache gtk3 hicolor-icon-theme jasper-libs json-glib libappindicator-gtk3 libdbusmenu libdbusmenu-gtk3 libepoxy liberation-fonts liberation-narrow-fonts liberation-sans-fonts liberation-serif-fonts libgusb libindicator-gtk3 libmodman libproxy libsoup libwayland-cursor libwayland-egl libxkbcommon m4 mailx nettle patch psmisc redhat-lsb-core redhat-lsb-submod-security rest spax time trousers xdg-utils xkeyboard-config alsa-lib

下载zip包放在如下目录下解压

[root@VM-16-5-centos plugins]# ls
grafana-piechart-panel  plugin-linux-x64-glibc  plugin-linux-x64-glibc.zip
[root@VM-16-5-centos plugins]# systemctl restart grafana-server
[root@VM-16-5-centos plugins]# pwd
/var/lib/grafana/plugins

重启服务就能看到安装好了
在这里插入图片描述

保存并发送测试邮件,配置完成,点击Send Test 可测试是否成功
5、指标测试告警
在这里插入图片描述
在这里插入图片描述

配置好之后就可以看到
在这里插入图片描述
发送邮件也正常可以。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值