【问题标题】:ELK - Duplicate logELK - 重复日志
【发布时间】:2021-02-23 07:49:33
【问题描述】:

我对 Logstash (v7.11) 和 Elasticsearch 有一个奇怪的问题。

我目前有两个配置文件:

  • 01-beats-syslog.conf(带有由 winlogbeat 发送的日志)

     input {
      beats {
        port => 5044
        ssl => false
       }
     }
    
     filter {
     if [type] == "syslog" {
         grok {
           match => { "message" => "%{SYSLOGLINE}" }
         }
    
         date {
     match => [ "timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
     }
       }
    
     }
    
     output {
      elasticsearch {
       hosts => localhost
         index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
            }
     stdout {
         codec => rubydebug
            }
     }
    
  • 02-network-syslog.conf(带有无代理设备(例如交换机、防火墙等)的日志)

     input {
       tcp {
         port => 514
         type => syslog
       }
       udp {
         port => 514
         type => syslog
       }
     }
    
     filter {
       if [type] == "syslog" {
         grok {
           match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
           add_field => [ "received_at", "%{@timestamp}" ]
           add_field => [ "received_from", "%{host}" ]
         }
         date {
           match => [ "syslog_timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
         }
       }
     }
    
     output {
      elasticsearch {
         hosts => ["localhost:9200"]
         index => "syslog-%{+YYYY.MM}"
            }
     stdout {
         codec => rubydebug
            }
     }
    

由于某种原因,“winlogbeat”日志的副本最终位于“network-syslog”索引中(除了真正的 syslog 流量)。每个配置文件都在侦听不同的端口,这有什么问题配置?

我还检查了我没有将流量转发到 514 的防火墙规则,实际上使用 tcpdump 我看不到来自该端口上的 winlogbeat 的流量。

【问题讨论】:

    标签: elasticsearch logstash elastic-stack


    【解决方案1】:

    如果您将 path.config 指向一个目录,则 logstash 将连接该目录中的所有文件,从所有输入读取事件,通过所有过滤器运行它们,并将所有它们发送到所有输出。要么配置 pipelines.yml 以在单独的管道中运行每个配置文件,要么在输出周围使用条件

     output {
       if [type] == "syslog" {
          elasticsearch {
            hosts => ["localhost:9200"] ...
    

    【讨论】:

    • 谢谢你的课,现在我清楚多了。我通过将标签应用于输入并根据here 描述的标签过滤输出来解决。这似乎不是最有效的方法。 Elastic 建议使用管道,但我还不清楚如何正确设置。
    猜你喜欢
    • 2018-07-02
    • 2020-03-19
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 2015-07-03
    • 2017-05-13
    • 1970-01-01
    相关资源
    最近更新 更多