Dashboards & Visualizations

Extract key-value pairs from xml file

rxdeleon
Explorer

Here's a snippet of a long XML file. I would like to extract the keys such as id, status, error_sequence_number, etc. then assign the value as indicated by the string "value=".
























































Tags (1)
0 Karma

araitz
Splunk Employee
Splunk Employee
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

When defining field extractions for this sourcetype in transforms.conf you can use a regex like so:

[some_stanza]
...
REGEX  = name="(?<_KEY_1>[^"]+)"\s+value="(?<_VAL_1>[^"]+)"
...

Note, you may want to define two of those if the order of name and value can be reversed in your data.

0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...