无法使用logstash将couchdb数据发送到elasticsearch

时间:2016-09-26 12:46:30

标签: elasticsearch couchdb logstash-configuration

您好问候我一直在尝试将数据从couchdb推送到elasticsearch这里是代码

$value

1 个答案:

答案 0 :(得分:1)

您可以粘贴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