Create separate documents from xml file

Hi, I have an xml file , and want to parse it to logstash . is it possible to create a separate documents for each tag ? here is my xml file:

       <key2> Value2 </key2>
       <id> 00001 </id>
       <date> 01-01-2016 09:00:00 </date>
            <Name>XSS </Name>

Here is my logstash config file :

input {
  file {
       path => "/home/user/test.xml"
       start_position => "beginning"
       sincedb_path => "/dev/null"

       codec => multiline  {

               pattern => "^<xmldata>"
               negate => "true"
               what => "previous"


      target => "xml_content"
       store_xml => false
       source => "message"
       xpath =>
       "/xmldata/head1/key1/text()", "key1",
       "/xmldata/head1/key2/text()", "key2",
       "/xmldata/ReportItems/ReportItem/Name/text()", "Name"

      mutate {
         remove_field => ["message"]

     date {
       match => [ "date", "dd-MM-yyyy HH:mm:ss" ]
       timezone => "Europe/Amsterdam"

      elasticsearch {
      hosts => ["localhost:9200"]



The split filter can split the elements of an array into one document per item, so if you use the xml filter and possibly others filters to craft such an array the split filter will take care of the rest.

Thank you so much, it works :smiley:

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