Splunk Search

Calculations on 2 different fields from 2 separate logs, newbie here

606866581
Path Finder

Hi, I've got 2 log lines which look similar to this:

Thu Aug 08 16:45:01 2013 | Field1 : 25
Thu Aug 08 16:45:01 2013 | Field2 : 30

Does anyone know how to find Field3 which is (Field2-Field1)

I've tried:
| eval Field3=Field2-Field1 |

But because they're not from the same log line, Field3 is always null.
Any advice is appreciated!

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Assuming the two events have the same timestamp and no other events with that timestamp exist, you can do this:

... | eventstats first(Field1) as f1 first(Field2) as f2 by _time | eval f3 = f2 - f1

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Assuming the two events have the same timestamp and no other events with that timestamp exist, you can do this:

... | eventstats first(Field1) as f1 first(Field2) as f2 by _time | eval f3 = f2 - f1
0 Karma

606866581
Path Finder

Worked perfectly, Thanks!

0 Karma

606866581
Path Finder

Actually yes, the timestamp is guaranteed to be exactly the same

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Are they reliably group-able by timestamp? If not, how should Splunk guess which two lines to match up?

0 Karma

606866581
Path Finder

unfortunately these logs are pretty bare, they're not much longer than the example above ^

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Is there some kind of grouping field that Splunk can use to match two lines together?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...