2017-06-16 82 views
0

嗨,我有使用logstash更新彈性的多個記錄的問題。 我logstash配置波紋管使用logstash更新彈性的多個記錄

output { 
    elasticsearch { 
     hosts => "******" 
     user => "xxxxx" 
     password => "yyyyyy" 
     index => "index_name" 
     document_type => "doc_type" 
     action => "update"   
     script_lang => "painless" 
     script_type => "inline" 
     document_id => "%{Id}" 
     script => 'ctx._source.Tags = params.event.get("Tags");' 
    } 

}

我輸出到logstash轉儲文件夾的樣子: {"index_name":"feed_name","doc_type":"doc_type","Id":["b504d808-f82d-4eaa-b192-446ec0ba487f", "1bcbc54f-fa7a-4079-90e7-71da527f56a5"],"es_action":"update","Tags": ["tag1","tag2"]}

我最大這裏的問題是,我不能夠同時更新這兩個recods但我需要創建兩個不同ID的記錄。

是否有爲什麼通過在我的輸出配置中編寫查詢來解決此問題? 在SQL中看起來成才這樣的:

Update Table 
SET Tags 
WHERE ID in (guid1, guid2) 

我知道,在這種情況下,我可以在logstash和問題就解決了添加兩個記錄,但我需要解決的第二個問題,我需要更換有一個所有記錄tag1並給它newTag。

回答

0

您是否考慮過使用split filter來克隆事件中的一個事件:id each?看起來過濾器可以幫助你。