# How to parse xml.log via logstash

**URL:** <https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940>\
**Category:** Logstash\
**Created:** [September 9, 2020, 3:23am UTC](https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940 "2020-09-09T03:23:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gavin-orange](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gavin-orange/32/75287_2.png) [@gavin-orange](https://discuss.elastic.co/u/gavin-orange)\
**Post date:** [September 9, 2020, 3:23am UTC](https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940/1 "2020-09-09T03:23:43Z")

</div>

Hello Guys ,  
I am totally new into ES and now I want to use logstash to parse the xml.log , hope could get any help .  
Here is part of xml.log which I have :

```auto
    <msg time='2019-10-25T01:50:15.913+08:00' org_id='oracle' comp_id='rdbms'
     client_id='' type='UNKNOWN' level='16'
     host_id='cnsh-ipccdb1' host_addr='10.7.1.11' module=''
     pid='20386'>
     <txt> Current log# 4 seq# 430140 mem# 0: +DG_ORA/ora11g/onlinelog/group_4.283.995416149
     </txt>
    </msg>

```

How do I edit the filter ?

---

<div class="post-metadata">

**Author:** ![gavin-orange](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gavin-orange/32/75287_2.png) [@gavin-orange](https://discuss.elastic.co/u/gavin-orange)\
**Post date:** [September 9, 2020, 4:05am UTC](https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940/2 "2020-09-09T04:05:07Z")

</div>

I want the results as below :

```auto
time : 2019-10-25T01:50:15.913+08:00 
log: Current log# 4 seq# 430140 mem# 0: +DG_ORA/ora11g/onlinelog/group_4.283.995416149

```

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 9, 2020, 4:29am UTC](https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940/3 "2020-09-09T04:29:44Z")

</div>

Hi @gavin-orange  
Welcome to the community.

Have you look the [XML](https://www.elastic.co/guide/en/logstash/current/plugins-filters-xml.html) filter.. should get you there / extract the fields

Then you might need to do some renaming , converting etc.

Pay attention to the date / time formats etc

---

<div class="post-metadata">

**Author:** ![gavin-orange](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gavin-orange/32/75287_2.png) [@gavin-orange](https://discuss.elastic.co/u/gavin-orange)\
**Post date:** [September 9, 2020, 6:10am UTC](https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940/4 "2020-09-09T06:10:11Z")

</div>

Hi Stephen ,  
I used the " multiline " in filebeat to format the xml logs .  
Then in logstash :

```auto
xml {
          source => "message"
          target => "parsed"
          store_xml => true
          force_array => false
          xpath => {
            "msg time" => "timestamp"
            "txt" => "contents" }

```

but the outcome is not as wished .

---

<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:** [October 7, 2020, 6:10am UTC](https://discuss.elastic.co/t/how-to-parse-xml-log-via-logstash/247940/5 "2020-10-07T06:10:13Z")

</div>

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