Graylog 日志关键字告警配置
2019-04-23 本文已影响0人
awker
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 先配置告警条件
![](https://img.haomeiwen.com/i12475671/1dcaac5723618463.png)
![](https://img.haomeiwen.com/i12475671/0ebbb87909b507f5.png)
![](https://img.haomeiwen.com/i12475671/fbb11eb7eb242efb.png)
![](https://img.haomeiwen.com/i12475671/37b849e43464b4a0.png)
![](https://img.haomeiwen.com/i12475671/9384272ea893765d.png)
2.2 再配置告警通知
![](https://img.haomeiwen.com/i12475671/b82408dff71fdcad.png)
![](https://img.haomeiwen.com/i12475671/4121999a56eb305b.png)
![](https://img.haomeiwen.com/i12475671/9930a6ef69ab1287.png)
![](https://img.haomeiwen.com/i12475671/f699cf153fc48c75.png)
配置完告警通知后,点击 Test 测试一下邮件发送是否正常
![](https://img.haomeiwen.com/i12475671/d0cb500d696b587f.png)
测试成功的结果如下
![](https://img.haomeiwen.com/i12475671/20d2eea4fafe99e7.png)
模拟测试
// app.log 是 graylog-server 已经监听收集的日志
echo "graylog alert test OutOfMemoryError" >> app.log
测试结果
![](https://img.haomeiwen.com/i12475671/ac0be70419a06818.png)