简体   繁体   中英

Copy index data from one ES index to ES another using logstash

could you please help to write a script, m getting the following error while running this script

input {
  # We read from the "old" cluster
  elasticsearch {
    hosts => [ "localhost" ]
    port => "9200"
    index => "products"
    size => 500
    scroll => "5m"
    docinfo => true
  }
}

output {
  # We write to the "new" cluster
  elasticsearch {
    host => "localhost"
    port => "9200"
    protocol => "http"
    index => "%{[@metadata][_index1]}"
    index_type => "%{[@metadata][_type1]}"
    document_id => "%{[@metadata][_id]}"
  }
  # We print dots to see it in action
  stdout {
    codec => "dots"
  }
}

This is my logstash.conf file when I run this m getting the following error

Unknown setting 'port' for elasticsearch

{:level=>:error}
fetched an invalid config {:config=>"input {\n  # We read from the \"old\" cluster\n  elasticsearch {\n    hosts => [ \"localhost\" ]\n    port => \"9200\"\n    index => \"products\"\n    size => 500\n    scroll => \"5m\"\n    docinfo => true\n  }\n}\n\noutput {\n  # We write to the \"new\" cluster\n  elasticsearch {\n    host => \"localhost\"\n    port => \"9200\"\n    protocol => \"http\"\n    index => \"%{[@metadata][_index1]}\"\n    index_type => \"%{[@metadata][_type1]}\"\n    document_id => \"%{[@metadata][_id]}\"\n  }\n  # We print dots to see it in action\n  stdout {\n    codec => \"dots\"\n  }\

I've modified the configuration, with the options of the 2+ version.

input {
  # We read from the "old" cluster
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "products"
    size => 500
    scroll => "5m"
    docinfo => true
  }
}

output {
  # We write to the "new" cluster
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "%{[@metadata][_index1]}"
    document_type => "%{[@metadata][_type1]}"
    document_id => "%{[@metadata][_id]}"
  }
  # We print dots to see it in action
  stdout {
    codec => "dots"
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM