Logstash詳解之——output模塊
Logstash的output模塊,相比於input模塊來說是一個輸出模塊,output模塊集成了大量的輸出插件,可以輸出到指定文件,也可輸出到指定的網絡端口,當然也可以輸出數據到ES.
在這裏我隻介紹如何輸出到ES,至於如何輸出到端口和指定文件,有很多的文檔資料可查找.
elasticsearch{
hosts=>["172.132.12.3:9200"]
action=>"index"
index=>"indextemplate-logstash"
#document_type=>"%{@type}"
document_id=>"ignore"
template=>"/opt/logstash-conf/es-template.json"
template_name=>"es-template.json"
template_overwrite=>true
}
action=>”index” #es要執行的動作 index, delete, create, update
l index:將logstash.時間索引到一個文檔
l delete:根據id刪除一個document(這個動作需要一個id)
l create:建立一個索引document,如果id存在 動作失敗.
l update:根據id更新一個document,有一種特殊情況可以upsert--如果document不是已經存在的情況更新document 。參見upsert選項。
l A sprintf style string to change the action based on the content of the event. The value %{[foo]} would use the foo field for the action
document_id=>” ” 為索引提供document id ,對重寫elasticsearch中相同id詞目很有用
document_type=>” ”事件要被寫入的document type,一般要將相似事件寫入同一type,可用%{}引用事件type,默認type=log
index=>”logstash-%{+YYYY,MM.dd}” 事件要被寫進的索引,可是動態的用%{foo}語句
hosts=>[“127.0.0.0”] ["127.0.0.1:9200","127.0.0.2:9200"] ["https://127.0.0.1:9200"]["https://127.0.0.1:9200/mypath"]
manage_template=>true 一個默認的es mapping 模板將啟用(除非設置為false 用自己的template)
template=>”” 有效的filepath 設置自己的template文件路徑,不設置就用已有的
template_name=>”logstash” 在es內部模板的名字
這裏需要十分注意的一個問題是,document_id盡量保證值得唯一,這樣會解決你麵即將麵臨的ES數據重複問題,切記切記!
最後更新:2017-09-06 16:32:40