使用logstash将索引数据从一个ES索引复制到另一个索引



您可以帮助写一个脚本,m在运行此脚本时遇到以下错误

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"
  }
}

当我运行此m时,这是我的logstash.conf文件,获取以下错误

eLasticsearch的未知设置'端口'

{:level=>:error}
fetched an invalid config {:config=>"input {n  # We read from the "old" clustern  elasticsearch {n    hosts => [ "localhost" ]n    port => "9200"n    index => "products"n    size => 500n    scroll => "5m"n    docinfo => truen  }n}nnoutput {n  # We write to the "new" clustern  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 actionn  stdout {n    codec => "dots"n  }

我已经修改了配置,并带有2 版本的选项。

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"
  }
}

最新更新