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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...