Filebeat未将数据发送到Logstash

时间:2019-02-02 00:06:11

标签: elasticsearch logstash filebeat snort

我正试图将警报从Snort IDS发送到Elasticsearch,因此我正在使用3种技术:

我的filebeat配置文件中包含以下代码:

input {
beats {
    port => 5044
}

} 过滤器{

if [type] == "snort" {

    # parse the message into individual fields
    grok {
        match => { "message" => "(?<ts>.*\d{2}:\d{2}:\d{2})\s(?<host>.*?)\s.*?\s\[(?<generator_id>.*?)::(?<signature_id>.*?):.*?\]\s(?<signature>.*?)\s\[Classification:\s(?<classification>.*?)\]\s\[Priority:\s(?<priority>.*?)\].*?{(?<protocol>.*?)\}\s(?<source_ip>.*?):(?<source_port>.*?)\s-\>\s(?<destination_ip>.*?):(?<destination_port>.*)" }
    }

    # remove the original message if parsing was successful
    if !("_grokparsefailure" in [tags]) {
        mutate {
            remove_field => [ "message" ]
        }
    }

    # parse the timestamp and save in a new datetime field
    if [ts] {
        date {
            match => [ "ts", "MMM dd HH:mm:ss" ]
            target => "sys_timestamp"
        }

        # remove the original timestamp if date parsing was successful
        if !("_dateparsefailure" in [tags]) {
            mutate {
                remove_field => [ "ts" ]
            }
        }
    }
}

} 输出{

# save events to Elasticsearch with the uuid as the document id
elasticsearch {
    hosts => ["localhost:9200"]
manage_template => false
    index => "teste-%{+YYYY-MM-dd}"
}

}

当我检查“ http://localhost:9200/ola- * / _ search?pretty”时,我希望看到snort的警报日志,但是未检索到警报。我正在努力解决此问题...我不知道出了什么问题。

谢谢!

1 个答案:

答案 0 :(得分:1)

您的堆栈是什么版本?您的filebeat配置文件同时具有filebeat.prospectorsfilebeat.inputs,从6.3版开始,您应该使用filebeat.inputs而不是filebeat.prospectors

自6.0版以来,document_type配置也已删除,您的消息可能没有名为type的字段,其值为snort,这是logstash管道中的主要过滤器。最好使用标签过滤邮件。

在您的filebeat.yml中使用它。

filebeat.inputs:
- type: log
  paths:
    - /var/log/snort/*.log
  tags: ["snort"]

并更改您的logstash过滤器,只需使用if "snort" in [tags]而不是if [type] == "snort"

您的输出正在将收到的任何消息发送到名为teste-%{+YYYY-MM-dd}的索引,为什么要对名为ola-*的索引进行搜索?您应该针对teste-*索引进行搜索。

我建议您使用stdout输出运行管道,以查看发生了什么情况。

只需将其放在您的管道中,以查看是否收到任何消息以及这些消息如何。

output {
  stdout { }
}