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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...