2016-09-26 24 views
1

你好問候我一直在試圖從CouchDB的數據推送到這裏elasticsearch是代碼無法發送CouchDB的數據使用logstash

input { 
couchdb_changes { 
    db => "users" 
    host => "localhost" 
    port => "5984" 
    } 
} 
output { 
elasticsearch { 
    hosts => ["127.0.0.1:9200"] 
    index => "playtym"   
    } 
} 
+1

會發生什麼?請更詳細地描述你的問題。 – Val

+0

我已將上述代碼放在「/opt/logstash/couch.conf」中,並運行命令「$ bin/logstash -f couch.conf」。在運行命令時,管道正在創建,但是當couchdb中發生更改時,它不會將數據推送到elasticsearch –

回答

1

到elasticsearch你可以粘貼logstash日誌?所以我們可以幫助你更好。

無論如何,我粘貼我的配置,我正在使用複製我的沙發彈性。

我在nginx背後使用沙發。 logstash位於彈性相同的服務器上。

input { 
    couchdb_changes { 
    type => "foo" 
    db => "database" 
    host => "couch.example.com" 
    username => "user" 
    password => "pass" 
    initial_sequence => 0 
    secure => true 
    port => 443 
    } 
} 

filter { 
    if [type] == "foo" { 

    if "delete" in [@metadata][action] { 
     mutate { add_field => { "[@metadata][my_action]" => "delete" } } 
    } 
    else { 
     mutate { add_field => { "[@metadata][my_action]" => "index" } } 
    } 

    if [doc] { 
     ruby { 
     code => ' 
       event["doc"].each{ |k,v| event["#{k}"] = v } 
       ' 
     } 
    } 
    # 6) 
    if [doc] { 
     mutate { remove_field => [ "[doc]" ] } 
    } 
    if [doc_as_upsert] { 
     mutate { remove_field => [ "[doc_as_upsert]" ] } 
    } 
    if [@version] { 
     mutate { remove_field => [ "[@version]" ] } 
    } 
    } 
} 

output { 

    if [type] == "foo" { 
    elasticsearch { 
     index => "%{[ClassName]}" #ClassName is a doc field that I am using to organize the index and document_type 
     document_type => "%{[ClassName]}" 
     document_id => "%{[@metadata][_id]}" 
     action => "%{[@metadata][my_action]}" 
     doc_as_upsert => "true" 
    } 
    } 
} 

我的配置是基於這樣的: https://github.com/gammaliu/couchdb-logstash-elasticsearch

+0

上面的代碼在我的問題中是logstash配置文件。我使用Apache作爲畝服務器。 –

+0

沒有日誌被轉儲 –