Graylog之告警

官方文档:https://docs.graylog.org/en/3.0/index.html

前面我们已经了解了Graylog的搭建,以及日志的接入方法。我们知道graylog可以将收集的的日志通过web界面展示出来,但随着日志量的增加,我们可能不能及时的发现一些异常日志。为了避免这种情况出现,告警通知可以说很有必要了。

1.先在graylog server 的配置文件中添加Email配置,并重启服务。默认graylog的配置文件在/etc/graylog/server/server.conf

1vim /etc/graylog/server/server.conf
 2
 3#Email transport
 4transport_email_enabled = true
 5transport_email_hostname = smtp.exmail.qq.com
 6transport_email_port = 465
 7transport_email_use_auth = true
 8transport_email_auth_username = you@example.com  #修改成自己的名字
 9transport_email_auth_password = secret  #设置密码
10transport_email_subject_prefix = [graylog]
11transport_email_from_email = graylog@example.com  #修改example
12
13# systemctl restart graylog-server

2. Graylog  web界面配置

1)新建告警条件:点击“Alerts”--“Mange condition”--“Add new condition”

 

2) 选择想要添加告警的stream和条件类型

Condition type:

  • Field Content Alert Condition

Field表示字段,Value是字段的值,Grace Period是指当一个告警恢复时下一个告警的等待时间,Message Backlog是指包含在告警通知中的信息数量,Search Query(optional)查询搜索(可选的),可以匹配查询内容,默认是全部。例如下图告警条件是nginx日志中出现字段ERROR的内容。

  • Field Aggregation Alert Condition

Threshold Type阈值类型,Aggregation Type聚合类型。可以根据自己的需求设置对应的参数。

  • Message Count Alert Condition

选择阈值类型,统计消息数量是否超过或者低于设定阈值,否则触发告警。

 Condition配置完成

 3) 配置告警通知:点击“Notifications”--“Add new Notification ”

 4) 选择告警stream和通知类型

Notification type:

  • HTTP Alarm Callback

添加一条url到告警平台,告警平台可以通过配置发送到钉钉

  • Email Alert Callback

E-Mail Receivers选择接收邮件人的邮箱,Sender发生告警的发送方

 5) 测试邮件:点击Test查看收到邮件内容,配置完成

原文地址:https://www.cnblogs.com/xingxia/p/graylog_alert.html