Splunk Search

Can you help me with the following value extraction of XML data?

moorvogi
Path Finder

I want to say there's a "simple" way to sets of data from XML. For example: in the XML below, i want two records/events.. such as.

identity_id        transaction_code            sname      dogname
3017669              SEL                        BARC                  abc123
1037669              SEL                        TARC                  pookybear

from the data set like below.

<AllRecords>
   <DataSet xmlns="">
        <arg token="dogname" value="abc123" />
        <identity_id>3017669</identity_id>
        <instrument_id>912383KM1</instrument_id>
        <transaction_code>SEL</transaction_code>
        <sname>BARC</sname>
        <currency_code>USA</currency_code>
   </DataSet> 

   <DataSet xmlns="">
        <arg token="dogname" value="pookybear" />
        <identity_id>1037669</identity_id>
        <instrument_id>219383KM1</instrument_id>
        <transaction_code>SEL</transaction_code>
        <sname>TARC</sname>
        <currency_code>USA</currency_code>
   </DataSet>
</AllRecords>
1 Solution

493669
Super Champion

Try this:

|spath|rename AllRecords.DataSet.* as *|rex max_match=0 "arg token=\"(?<token>\w+)\"\s*value=\"(?<value>\w+)"

View solution in original post

0 Karma

493669
Super Champion

Try this:

|spath|rename AllRecords.DataSet.* as *|rex max_match=0 "arg token=\"(?<token>\w+)\"\s*value=\"(?<value>\w+)"
0 Karma

moorvogi
Path Finder

sorry i forgot a field in my dataset. i also need to get "dogname" with the associated record for the row. i've updated the example above.

0 Karma

493669
Super Champion

give this a try:

|spath|rename AllRecords.DataSet.* as *|rex max_match=0 "arg token=\"(?<token>\w+)\"\s*value=\"(?<value>\w+)"
0 Karma

moorvogi
Path Finder

PERFECT! The winner is "rex". That's where i need to spend more time reading apparently. Thanks for the help!

0 Karma

moorvogi
Path Finder

how do i accept the updated answer? or should i just accept your first one? repost as another commet and i'll accept that one.. if you want.

0 Karma

493669
Super Champion

i have updated the answer ..please accept the answer and upvote the comment which helped

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...