Я попытался создать процесс загрузки с Logstash из XML-файла в Elasticsearch.
На основании учебных пособий я создал следующий файл конфигурации:
input {
file {
path => [ "D:\data\test\test_invoice.xml" ]
start_position => "beginning"
sincedb_path => "nul"
}
}
filter {
xml {
store_xml => "false"
source => "message"
#remove_namespaces => "true"
target => "invoice"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "ofr_invoice"
}
stdout { codec => rubydebug }
}
Это исходный XML:
<?xml version="1.0" encoding="UTF-8" ?>
<invoice>
<invoice_no>125</invoice_no>
<vendor>abc</vendor>
<custormer>asdf</custormer>
<invoice_items>
<item>
<item_name>asdf</item_name>
<item_price>23</item_price>
</item>
<item>
<item_name>qwer</item_name>
<item_price>45</item_price>
</item>
</invoice_items>
</invoice>
Когда я выполнил его с помощью Logstash, я получил следующий результат:
Sending Logstash logs to D:/app/elastic/logstash-6.4.0/logs which is now configured via log4j2.properties
[2018-09-14T13:05:38,402][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2018-09-14T13:05:38,889][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"6.4.0"}
[2018-09-14T13:05:41,796][INFO ][logstash.pipeline ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>8, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2018-09-14T13:05:42,136][INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}}
[2018-09-14T13:05:42,146][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://localhost:9200/, :path=>"/"}
[2018-09-14T13:05:42,280][WARN ][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"http://localhost:9200/"}
[2018-09-14T13:05:42,323][INFO ][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>6}
[2018-09-14T13:05:42,327][WARN ][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>6}
[2018-09-14T13:05:42,354][INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost:9200"]}
[2018-09-14T13:05:42,371][INFO ][logstash.outputs.elasticsearch] Using mapping template from {:path=>nil}
[2018-09-14T13:05:42,389][INFO ][logstash.outputs.elasticsearch] Attempting to install template {:manage_template=>{"template"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s"}, "mappings"=>{"_default_"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}}
[2018-09-14T13:05:43,811][INFO ][logstash.pipeline ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x50a295f7 run>"}
[2018-09-14T13:05:43,856][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2018-09-14T13:05:43,874][INFO ][filewatch.observingtail ] START, creating Discoverer, Watch with file and sincedb collections
[2018-09-14T13:05:44,098][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
Выглядит нормально, но не добавил запись (документ) в Elasticsearch. Кто-нибудь может сказать мне, почему?