Splunk Search

Extract and addition of values from an XML log file

a523504
Engager

Hi, I have been trying to extract valuesd from an XMl log file but failing so far.

2
3
4

This is the string I was using:
Source = 'Sheep' | xmlkv count NumberOfSheep

Could anyone please offer me some help,
thanks for your help.

Tags (1)
0 Karma
1 Solution

emechler_splunk
Splunk Employee
Splunk Employee

Your XML is malformed; the closing tags should be </numberofsheep> as such:

<numberofsheep>2</numberofsheep>
<numberofsheep>3</numberofsheep>
<numberofsheep>4</numberofsheep>

Once you have that, you can use the xmlkv command (or the new spath command) to extract the field:

source = 'Sheep' | xmlkv

...and then use stats to sum up the values:

source = 'Sheep' | xmlkv | stats sum(numberofsheep)

View solution in original post

0 Karma

emechler_splunk
Splunk Employee
Splunk Employee

Your XML is malformed; the closing tags should be </numberofsheep> as such:

<numberofsheep>2</numberofsheep>
<numberofsheep>3</numberofsheep>
<numberofsheep>4</numberofsheep>

Once you have that, you can use the xmlkv command (or the new spath command) to extract the field:

source = 'Sheep' | xmlkv

...and then use stats to sum up the values:

source = 'Sheep' | xmlkv | stats sum(numberofsheep)

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...