Automatically parse xml tags into fields in logstash

  Kiến thức lập trình

Let’s say I have a XML of this structure:

<root>
  <person>
    <name>John Doe</name>
    <age>30</age>
    <address>
      <city>New York</city>
      <zip>10001</zip>
    </address>
  </person>
</root>

Is it possible to have the tags be automatically parsed into fields such as name, age, address etc.?

Right now I have the following logstash.conf file:

input {
   file {
     path => "/home/support/simplexml.xml"
     start_position => "beginning"
   }
}

filter {
  xml { source => "message" target => "theXML" }
}

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "simple_xml"
  }
}

and see the following in Kibana:
Kibana

When I parse the same file in JSON, I’m able to get the separate fields like name, and age show up as fields in Kibana.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT