1、graylog server 添加 email 配置,并重启服务
# vim /etc/graylog/server/server.conf
transport_email_enabled = true
transport_email_hostname = mail.xxx.cn
transport_email_port = 587
transport_email_use_auth = true
transport_email_use_tls = false
transport_email_use_ssl = false
transport_email_auth_username = it_monitor
transport_email_auth_password = 123456
transport_email_subject_prefix = [graylog]
transport_email_from_email = it_monitor@xxx.cn
transport_email_web_interface_url = http://graylog.xxx.cn
# systemctl restart graylog-server
2、在 graylog web 界面配置告警规则
示例:生产应用服务只要出现 OutOfMemoryError 关键字就告警
2.1 先配置告警条件





2.2 再配置告警通知




配置完告警通知后,点击 Test 测试一下邮件发送是否正常

测试成功的结果如下

模拟测试
// app.log 是 graylog-server 已经监听收集的日志
echo "graylog alert test OutOfMemoryError" >> app.log
测试结果

网友评论