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!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...