2016-07-12 11 views
1

Ich versuche, eine Datenpipeline zu erstellen, wo Logstash jdbc plugin einige Daten mit SQL-Abfrage alle 5 Minuten erhalten und ElasticSearch-Ausgabe-Plugin setzt Daten aus dem Eingabe-Plugin in ElasticSearch-Server. Mit anderen Worten, ich möchte, dass dieses Ausgabe-Plugin ein vorhandenes Dokument im ElasticSearch-Server teilweise aktualisiert. meine Logstash Konfigurationsdatei wie folgt aussieht:Logstash-Konfiguration: Wie ruft man die Partial-Update-API aus dem ElasciSearch-Ausgabe-Plugin auf?

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

das Problem, dass Elasticsearch Ausgabe-Plugin ist nicht erscheint Teil Update API wie/{index}/{type}/{id}/_ Update aufzurufen. Das Handbuch listet nur Aktionen wie index, delete, create, update, aber es erwähnt nicht jede Aktion ruft, welche REST API URL, dh ob update Aktion ruft/{Index}/{Typ}/{ID}/_ Update oder/{index}/{typ}/{id} api (upsert). Ich möchte Teilupi-API vom Elastic Search Output Plugin aufrufen? Ist es möglich?

Antwort

6

gesetzt sowohl doc_as_upsert => true und action => "update" funktioniert in meinem Produktionsskript.

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" 
    } 
} 
3
+0

Dieses Handbuch verwirrte mich immer noch. Ich möchte einige JSON-Schlüssel zum exiting-Dokument in einem ElasticSearch-Server nach Dokument-ID hinzufügen. Welche Option verwende ich in diesem Fall? – inherithandle

+0

Ich denke, es sollte reichen, um 'doc_as_upsert => true' hinzuzufügen. –