Logstash-Logstash 配置(五)实战举例:将错误日志写入es


 

Logstash 配置(五)实战举例:将错误日志写入es

配置:

input {

    file {

        path => ["/usr/local/logstash-6.6.2/data_test/run_error.log"]

        type => "error"

        start_position => "beginning"

}

}

output {

    elasticsearch {

        hosts => ["192.168.109.133:9200"]

        index => "logstash-%{type}-%{+YYYY.MM.dd}"

        document_type => "%{type}"

        sniffing => true

        template_overwrite => true

    }

}

-----------------------------------------------------------------------------

执行结果:

 

问题:一个错误被分成了多个document。如何解决?

解决方法-加codec配置:

input {

    file {

        path => ["/usr/local/logstash-6.6.2/data_test/run_error.log"]

        type => "error"

        start_position => "beginning"

            codec=>multiline{

                pattern=”^\[”

                nagate=>true

                what=>"orevious"

            }           

    }

}

output {

    elasticsearch {

        hosts => ["192.168.109.133:9200"]

        index => "logstash-%{type}-%{+YYYY.MM.dd}"

        document_type => "%{type}"

        sniffing => true

        template_overwrite => true

    }

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM