Splunk Search

Difference of fields with the same name in a transaction

RVDowning
Contributor

Given data of the form:
[OPEN PLAN START] Guid=358846c0a0e9, AvailRAM=4555
...
[OPEN PLAN END] Guid=358846c0a0e9, AvailRAM=3211

And if we filter and define transaction by Guid....

"OPEN PLAN" | transaction Guid

is there any way to find the difference between the AvailRam field of 4555 and the AvailRam field of 3211, namely 1344?

Tags (1)
1 Solution

wpreston
Motivator

Sure, this can be done. Us the mvlist option in your transaction command, then do some multivalue field manipulation. I'd also suggest adding startswith and endswith to your transaction to make it a little easier for Splunk to figure out. Try this:

"OPEN PLAN" | transaction Guid startswith="OPEN PLAN START" endswith="OPEN PLAN END" mvlist=AvailRam | eval StartingRam=mvindex(AvailRam, 0) | eval EndingRam=mvindex(AvailRam,-1) | eval RamDiff=StartingRam - EndingRam

RamDiff in the above search is the difference between the Starting and Ending ram amounts for each transaction. This search makes the assumption that you always want to subtract the Ending Ram from the Starting Ram. If this is not the case and you just want the difference between the numbers, you can modify the last eval to use abs()

View solution in original post

wpreston
Motivator

Sure, this can be done. Us the mvlist option in your transaction command, then do some multivalue field manipulation. I'd also suggest adding startswith and endswith to your transaction to make it a little easier for Splunk to figure out. Try this:

"OPEN PLAN" | transaction Guid startswith="OPEN PLAN START" endswith="OPEN PLAN END" mvlist=AvailRam | eval StartingRam=mvindex(AvailRam, 0) | eval EndingRam=mvindex(AvailRam,-1) | eval RamDiff=StartingRam - EndingRam

RamDiff in the above search is the difference between the Starting and Ending ram amounts for each transaction. This search makes the assumption that you always want to subtract the Ending Ram from the Starting Ram. If this is not the case and you just want the difference between the numbers, you can modify the last eval to use abs()

clete2
Path Finder

Fantastic answer. Exactly what I was looking for. Thank you.

0 Karma

RVDowning
Contributor

Ah brilliant, thanks much!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...