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
Get Updates on the Splunk Community!

Splunk APM & RUM | Upcoming Planned Maintenance

There will be planned maintenance of the streaming infrastructure for Splunk APM and Splunk RUM in the coming ...

Part 2: Diving Deeper With AIOps

Getting the Most Out of Event Correlation and Alert Storm Detection in Splunk IT Service Intelligence   Watch ...

User Groups | Upcoming Events!

If by chance you weren't already aware, the Splunk Community is host to numerous User Groups, organized ...