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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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