簡體   English   中英

Logstash 配置:如何從 ElasticSearch 輸出插件調用部分更新 API?

[英]Logstash configuration: how to call the partial-update API from ElasticSearch output plugin?

我正在嘗試創建一個數據管道,其中 Logstash jdbc 插件每 5 分鍾通過 SQL 查詢獲取一些數據,ElasticSearch 輸出插件將數據從輸入插件放入 ElasticSearch 服務器。 我希望這個輸出插件可以部分更新 ElasticSearch 服務器中的現有文檔。 我的 Logstash 配置文件如下所示:

input {
    jdbc {
        jdbc_driver_library => "/Users/hello/logstash-2.3.2/lib/mysql-connector-java-5.1.34.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        jdbc_connection_string => "jdbc:mysql://localhost:13306/mysqlDB”
        jdbc_user => “root”
        jdbc_password => “1234”
        last_run_metadata_path => "/Users/hello/.logstash_last_run_display"
        statement => "SELECT * FROM checkout WHERE checkout_no between :sql_last_value + 1 and :sql_last_value + 5 ORDER BY checkout_no ASC"
        schedule => “*/5 * * * *"
        use_column_value => true
        tracking_column => “checkout_no”
    }
}

output {
    stdout { codec => json_lines }

    elasticsearch {
        action => "update"
        index => "ecs"
        document_type => “checkout”
        document_id => “%{checkout_no}"
        hosts => ["localhost:9200"]
    }
}

問題是 ElasticSearch 輸出插件似乎沒有調用部分更新 API,例如 /{index}/{type}/{id}/_update。 手冊只列出了indexdeletecreateupdate ,但沒有提到每個操作調用哪個 REST API URL,即) update操作是否調用 /{index}/{type}/{id}/_update 或/{index}/{type}/{id} api(更新插入)。 我想從彈性搜索輸出插件調用部分更新 api? 有可能嗎?

設置doc_as_upsert => trueaction => "update"在我的生產腳本中工作。

output {

  elasticsearch {
    hosts => ["es_host"]
    document_id => "%{id}" # !!! the id here MUST be the same
    index => "logstash-my-index"
    timeout => 30
    workers => 1
    doc_as_upsert => true
    action => "update"
  }
}

這是可能的。 Elasticsearch 輸出插件有一系列upsert選項,對應於 Elasticsearch 更新 API 中的選項:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM