创建 contact point 时进行邮件告警测试,报错如下:
"status":"failed","error":"SMTP not configured, check your grafana.ini config file's [smtp] section"
根据报错信息可以判断,是由于 SMTP 服务没有配置导致,因此下一步先来配置 SMTP 服务。
配置文件位置:
# cd /usr/local/grafana-9.2.4/conf/
# vim defaults.ini
(配置文件内容较多,此处只截取 SMTP 相关配置)
[smtp]
enabled = false
host = localhost:25
user =
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password =
cert_file =
key_file =
skip_verify = false
from_address = admin@grafana.localhost
from_name = Grafana
ehlo_identity =
startTLS_policy =
[emails]
welcome_email_on_sign_up = false
templates_pattern = emails/*.html, emails/*.txt
content_types = text/html
*/=========================
对上面两部分内容进行修改。如下:(password是授权码并非密码)
[smtp]
enabled = true
host = smtp.qq.com:587
user = 10507***52@qq.com
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = pzqfhqpqbtslbbhb
# cert_file =
# key_file =
# skip_verify = true
from_address = 10507***52@qq.com
from_name = Grafana
ehlo_identity =
startTLS_policy =
[emails]
welcome_email_on_sign_up = true
templates_pattern = emails/*.html, emails/*.txt
content_types = text/html
修改完后,重新启动服务:
# nohup /usr/local/grafana-9.2.4/bin/grafana-server web > /usr/local/grafana-9.2.4/bin/grafana.log 2>&1 &
重新测试:
检查邮件: