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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...