最近使用ELK收集日志,利用Logstash收集syslog到Elasticsearch并且收到特定消息发出微信报警。

ELK的版本是7.12 ,客户端的日志通过udp 端口514 发送到logstash,再由logstash分析后存储到Elasticsearch并且通过特定条件发出微信警报。Logstash需要安装exec插件来实现调用微信发送程序。

下面记录一下自己的logstash配置文件,同时收集syslog和filebeat的配置方法。

input {
  syslog{
    type => "system-syslog"
    port => 514
  }

  beats{
    type => "beats"
    port => 5044
  }
}

filter{
此内容查看价格为1.99智能币立即购买
你的支持是我更新原创的动力,如果有疑问详询qq:16900693
output { if [type] == "system-syslog" { #stdout { codec => rubydebug } elasticsearch { hosts => ["http://xxx.xxx.xxx.xxx:9200"] index => "syslog-%{+YYYY.MM.dd}" template_overwrite => true } if [message] =~ "Security" { exec { command => "/root/weixin %{msg}" } } } if [type] == "beats" { #stdout { codec => rubydebug } elasticsearch { hosts => ["http://xxx.xxx.xxx:9200"] index => "beats-%{+YYYY.MM.dd}" template_overwrite => true } if [host][hostname] == "XXXXXX" { exec{ command => "/root/weixin ${msg}" } } } #stdout { codec => rubydebug } }

发表回复