2016-03-28 45 views
2

我試圖使用http_poller從ElasticSearch中提取數據並將它們寫入另一個ES。在執行此操作時,ES查詢需要作爲POST請求完成。 在提供的示例中,我找不到用於發佈主體的參數,它從ruby引用manticore客戶端。基於這一點,我已經使用params參數來發布主體。Logstash http_poller發佈名稱可能未找到錯誤

的http_poller組件看起來像這樣

input { 


http_poller { 
    urls => { 
     some_other_service => { 
     method => "POST" 
     url => "http://localhost:9200/index-2016-03-26/_search" 
     params => '"query": { "filtered": { "filter": { "bool": { "must": [ { "term": { "SERVERNAME": "SERVER1" }}, {"range": { "eventtime": { "gte": "26/Mar/2016:13:00:00" }}} ]}}} }"' 
     } 
    } 
    # Maximum amount of time to wait for a request to complete 
    request_timeout => 300 
    # How far apart requests should be 
    interval => 300 
    # Decode the results as JSON 
    codec => "json" 
    # Store metadata about the request in this key 
    metadata_target => "http_poller_metadata" 
    } 
} 
output { 
    stdout { 
    codec => json 
    } 
} 

當我執行這一點,Logstash給出了一個錯誤, 錯誤:名稱不能爲空{:水平=>:錯誤}

任何幫助非常感謝。

我的猜測是參數需要是真正的關鍵值對,但問題是如何使用logstash發佈查詢。

我提到了這個鏈接以獲得可用選項的HTTP客戶端 https://github.com/cheald/manticore/blob/master/lib/manticore/client.rb

回答

1

因爲我得到了答案時,我嘗試了不同的選擇,以爲我會分享解決方案,以及。

在上述有效負載中用身體替換參數。

正確有效載荷做使用HTTP輪詢後是

input { 


http_poller { 
    urls => { 
     some_other_service => { 
     method => "POST" 
     url => "http://localhost:9200/index-2016-03-26/_search" 
     body=> '"query": { "filtered": { "filter": { "bool": { "must": [ { "term": { "SERVERNAME": "SERVER1" }}, {"range": { "eventtime": { "gte": "26/Mar/2016:13:00:00" }}} ]}}} }"' 
     } 
    } 
    # Maximum amount of time to wait for a request to complete 
    request_timeout => 300 
    # How far apart requests should be 
    interval => 300 
    # Decode the results as JSON 
    codec => "json" 
    # Store metadata about the request in this key 
    metadata_target => "http_poller_metadata" 
    } 
} 
output { 
    stdout { 
    codec => json 
    } 
}