2016-09-26 61 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

没有日志被转储 –