logstash向elasticsearch寫入數據,如何指定多個數據template


   之前在配置從logstash寫數據到elasticsearch時,指定單個數據模板沒有問題,但是在配置多個數據模板時候,總是不成功,后來找了很多資料,終於找到解決辦法,就是要多加一個配置項: template_name ,切該名字必須全部為小寫

  參考配置信息:

output {
        if [type] == "log_01" {
                elasticsearch {
                        cluster => 'elasticsearch'
                        host =>         'x.x.x.x'
                        index => 'log_01-%{+YYYY-MM-dd}'
                        port => '9300'
                        workers => 1
                        template => "/data/logstash/conf/template_01.json"
                        template_name => "template_01.json"
                        template_overwrite => true
                }
        }
        if [type] == "log_02" {
            elasticsearch {
                        cluster => 'elasticsearch'
                        host =>         'x.x.x.x'
                        index => 'log_02-%{+YYYY-MM-dd}'
                        port => '9300'
                        workers => 1
                        template => "/data/logstash/conf/template_02.json"
                        template_name => "template_01.json"
                      template_overwrite => true
                }
        }
}

模板的配置請參見:http://qindongliang.iteye.com/blog/2290384


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM