# Import xml file in to Elasticsearch through logstash

**URL:** <https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827>\
**Category:** Logstash\
**Created:** [December 2, 2016, 5:40am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827 "2016-12-02T05:40:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![amol\_sonawane1](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@amol\_sonawane1](https://discuss.elastic.co/u/amol_sonawane1)\
**Post date:** [December 2, 2016, 5:40am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827/1 "2016-12-02T05:40:39Z")

</div>

I want to import xml file in to Elasticsearch through logstash.  
I created config file as follows:  
input  
{  
file  
{  
path =\> "D:/logstash-5.0.0/logstash-5.0.0/bin/data.xml"  
start\_position =\> "beginning"  
sincedb\_path =\> "/dev/null"  
exclude =\> "\*.gz"  
}  
}  
filter  
{  
xml {  
source =\> "message"  
}  
}  
output  
{  
elasticsearch  
{  
codec =\> json  
hosts =\> "localhost"  
index =\> "xmldata"  
}  
stdout  
{  
codec =\> rubydebug  
}  
}

I have created small data.xml file and the xml record is in one line only.  
But I am getting following error.

D:\logstash-5.0.0\logstash-5.0.0\bin\>logstash -f D:\logstash-5.0.0\logstash-5.0.0\bin\logstash-xmlConfig.conf  
Sending Logstash logs to D:/logstash-5.0.0/logstash-5.0.0/logs which is now configured via log4j2.properties.  
[2016-12-01T19:59:21,474][INFO  
][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated  
{:changes=\>{:removed=\>[], :added=\>["[http://localhost:9200](http://localhost:9200)"]}}  
[2016-12-01T19:59:21,477][INFO][logstash.outputs.elasticsearch] Using mapping template from {:path=\>nil}  
[2016-12-01T19:59:21,631][INFO  
][logstash.outputs.elasticsearch] Attempting to install template  
{:manage\_template=\>{"template"=\>"logstash-", "version"=\>50001, "settings"=\>{"index.refresh\_interval"=\>"5s"}, "mappings"=\>{"default"=\>{"all"=\>{"enabled"=\>true, "norms"=\>false}, "dynamictemplates"=\>[{"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"}}}}}],  
"properties"=\>{"@timestamp"=\>{"type"=\>"date", "include\_in\_all"=\>false}, "@version"=\>{"type"=\>"keyword",  
"include\_in\_all"=\>false}, "geoip"=\>{"dynamic"=\>true,  
"properties"=\>{"ip"=\>{"type"=\>"ip"},  
"location"=\>{"type"=\>"geo\_point"},  
"latitude"=\>{"type"=\>"half\_float"},  
"longitude"=\>{"type"=\>"half\_float"}}}}}}}}  
[2016-12-01T19:59:21,638][INFO  
][logstash.outputs.elasticsearch] New Elasticsearch output  
{:class=\>"LogStash::Outputs::ElasticSearch",  
:hosts=\>["localhost"]}  
[2016-12-01T19:59:23,329][ERROR][logstash.agent  
] Pipeline aborted due to error {:exception=\>#,  
:backtrace=\>["D:/logstash-5.0.0/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/logstash-filter-xml-4.0.1/lib/logstash/filters/xml.rb:106:in  
register'", "D:/logstash-5.0.0/logstash-5.0.0/logstash-core/lib/logstash/pipeline.rb:197:instart\_workers'", "org/jruby/RubyArray.java:1613:in each'", "D:/logstash-5.0.0/logstash-5.0.0/logstash-core/lib/logstash/pipeline.rb:197:instart\_workers'", "D:/logstash-5.0.0/logstash-5.0.0/logstash-core/lib/logstash/pipeline.rb:153:in run'", "D:/logstash-5.0.0/logstash-5.0.0/logstash-core/lib/logstash/agent.rb:250:instart\_pipeline'"]}  
[2016-12-01T19:59:23,455][INFO][logstash.agent] Successfully started Logstash API endpoint {:port=\>9600}  
[2016-12-01T19:59:26,354][WARN][logstash.agent] stopping pipeline {:id=\>"main"}

I am using 5.x version

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 2, 2016, 7:01am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827/2 "2016-12-02T07:01:47Z")

</div>

This part of the log:

```plaintext
Pipeline aborted due to error {:exception=>#, 
:backtrace=>["D:/logstash-5.0.0/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/logstash-filter-xml-4.0.1/lib/logstash/filters/xml.rb:106:in

```

Doesn't it actually include an error message too? Something like

```plaintext
Pipeline aborted due to error {:exception=>#<When the 'store_xml' configuration option is true, 'target' must also be set>, 
:backtrace=>["D:/logstash-5.0.0/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/logstash-filter-xml-4.0.1/lib/logstash/filters/xml.rb:106:in

```

? Either way, the interesting error message is:

> When the 'store\_xml' configuration option is true, 'target' must also be set

---

<div class="post-metadata">

**Author:** ![amol\_sonawane1](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@amol\_sonawane1](https://discuss.elastic.co/u/amol_sonawane1)\
**Post date:** [December 2, 2016, 9:10am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827/3 "2016-12-02T09:10:35Z")

</div>

actual error log was:-

LogStash::ConfigurationError: translation missing: en.logstash.agent.configuration.invalid\_plugin\_register

The above error with logstash 5.0.0  
As per logstash 5.0.1 release note above error was resolved in 5.0.1 version  
[https://www.elastic.co/guide/en/logstash/current/logstash-5-0-1.html](https://www.elastic.co/guide/en/logstash/current/logstash-5-0-1.html)

Now I am using 5.0.2 version and getting below error with same conf and data file

ipeline aborted due to error {:exception=\>#LogStash::ConfigurationError: Cannot register filter xml plugin. The error reported is: When the 'store\_xml' configuration option is true, 'target' must also be set\>,

Please correct me If I doing anything wrong

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 2, 2016, 9:43am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827/4 "2016-12-02T09:43:28Z")

</div>

The xml filter is complaining about you not setting the `target` option.

---

<div class="post-metadata">

**Author:** ![amol\_sonawane1](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@amol\_sonawane1](https://discuss.elastic.co/u/amol_sonawane1)\
**Post date:** [December 6, 2016, 8:40am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827/5 "2016-12-06T08:40:58Z")

</div>

Thanks Magnus,  
After setting target option it is working fine

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 3, 2017, 8:41am UTC](https://discuss.elastic.co/t/import-xml-file-in-to-elasticsearch-through-logstash/67827/6 "2017-01-03T08:41:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
