Splunk Search

regular expression for XML Log

jangid
Builder

I have following log in xml format

<tec><items><item><name>Status</name><value>Online</value></item><item><name>Company Name</name><value>EBS</value></item><item><name>Release</name><value>R12</value></item><item><name>System Date</name></item><item><name>OS Release</name><value>Red Hat Enterprise Linux Server release 5.8</value></item><item><name>Machine Time</name><value>Mon Oct 22 16:21:23 2012</value></item><item><name>release</name><value>Major 201000.0 , Minor 0.0</value></item></items></tec>

and tabular view of this log is

Name        Value
Status      Online
Company Name    XYZ
Release     R21
System Date     13:20 30/10/2012
OS Release      Red Hat
Machine Time    Mon Oct 22 16:21:23 2012
release     Major 201000.0 , Minor 0.0 

I want to create a regular expression for this to get the field in my dashboard
e.g.

Status=Online
CompanyName=XYZ
Release=R21
SystemDate=13:20 30/10/2012
OS Release=Red Hat
Machine Time=Mon Oct 22 16:21:23 2012
release=Major 201000.0 , Minor 0.0

I don't want to create multiple regex
what is regex for above or any other alternate for this?

Tags (1)

sdaniels
Splunk Employee
Splunk Employee

If you have the XML coming into Splunk and the events are broken properly you can use the spath command to get the values you are looking for.

http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/Spath

Or you can use the KV_MODE = XML in props.conf

http://docs.splunk.com/Documentation/Splunk/5.0/admin/Propsconf

Previous answer:
http://splunk-base.splunk.com/answers/54957/how-to-extract-data-from-xml

Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...