【问题标题】:Logstash is skipping records while inserting records in elastic searchLogstash 在弹性搜索中插入记录时跳过记录
【发布时间】:2018-01-05 06:28:57
【问题描述】:

我是弹性搜索的新手。我正在使用 Logstash 将数据从我的 PostgreSQL 数据库推送到弹性索引。我通常在配置文件中设置jdbc_page_size => 100000 以加快摄取速度。但是,即使 logstash 日志显示所有数据都已推送,数据也不会完全推送。所以,我设置了jdbc_page_size => 25000,解决了我的问题

我在使用 PostgesSQL(不是 MySQL 或 MS SQL Server)时遇到了这个问题。如果有人有任何见解,请说明为什么会发生这种情况。

编辑: 按要求配置文件:

input {
jdbc {
jdbc_connection_string => "jdbc:postgresql://ip:5432/dbname"
jdbc_user => "postgres"
jdbc_password => "postgres"
jdbc_driver_library => "/postgresql.jar"
jdbc_driver_class => "org.postgresql.Driver"
jdbc_paging_enabled => true
jdbc_page_size => 25000
statement => "select * from source_table"
}
}
output {
elasticsearch {
hosts => "localhost:9200"
index => "sample"
document_type => "docs"
document_id => "%{id}"
}
}

【问题讨论】:

  • 当您运行curl -XGET localhost:9200/_cat/thread_pool/bulk,index?v&h=id,name,active,rejected,completed 时会得到什么,您是否在 ES 日志中看到任何错误?
  • 我没有收到任何错误。 Active 和 Rejected 值为 0。
  • 完成了呢?
  • name active denied completed\ bulk 0 0 1725905 index 0 0 1 bulk 0 0 2044705 index 0 0 12 S1VEM5x-RAG7FHlsZ2hrvA bulk 0 0 1980739 S1VEM5x-RAG7FHlsZ2hrvA index 0 0 17
  • 已完成的非零值

标签: elasticsearch logstash


【解决方案1】:

PostgreSQL 不会以相同的顺序给出记录,所以请在查询中添加 order by 子句,它将解决您的问题。 您可以尝试以下配置,它正在工作。

input {
jdbc {
jdbc_connection_string => "jdbc:postgresql://ip:5432/dbname"
jdbc_user => "postgres"
jdbc_password => "postgres"
jdbc_driver_library => "/postgresql.jar"
jdbc_driver_class => "org.postgresql.Driver"
jdbc_paging_enabled => true
jdbc_page_size => 25000
statement => "select * from source_table order by id desc"
}
}
output {
elasticsearch {
hosts => "localhost:9200"
index => "sample"
document_type => "docs"
document_id => "%{id}"
}
}

【讨论】:

    猜你喜欢
    • 2016-11-05
    • 2012-11-29
    • 2020-06-04
    • 2017-05-12
    • 1970-01-01
    • 2015-11-01
    • 1970-01-01
    • 2015-11-16
    • 1970-01-01
    相关资源
    最近更新 更多