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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...