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

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...