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

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...