Splunk Search

Eval Question

tmarlette
Motivator

I am trying to translate a user, to an external IP address and be accurate within 5 seconds. I have to do this using two different searches and two different sourcetypes.

I am specifically looking for the 5 second "time check" of one searches timestamps, to the other's for accuracy, and I was thinking that the "eval" command would be the best for it but i'm not sure. I would like Splunk to compare the two searches timestamps, and return only the results that are within a 5 second window of the first searches time stamps.

This is the current search

sourcetype=qds eventtype="myevent" host="machine" | join int_port[search sourcetype=net "connection"] | table _time,user,domain,user_ip,ext_ip

Is "eval" the best function to use here?

Tags (1)
0 Karma
1 Solution

tmarlette
Motivator

The answer to this question was to use the "transaction" function.

Here was the section that solved it:
transaction int_port startswith="some log part" endswith="some other log part" maxspan=10s

View solution in original post

0 Karma

tmarlette
Motivator

The answer to this question was to use the "transaction" function.

Here was the section that solved it:
transaction int_port startswith="some log part" endswith="some other log part" maxspan=10s

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

In general you can look for relationships between fields with the where command, such as this:

some search | where abs(a - b) < 5000

That would filter out any event where the difference between field a and b isn't less than 5000.

In order to do that in your case you need two _time fields, I fear in a simple join they might be muddled together in _time / one might get lost. Have you tried renaming the _time field in the second search before joining, say to time2? Doing a where on the difference between _time and time2 may yield your desired result.

martin_mueller
SplunkTrust
SplunkTrust

Additionally, don't forget to apply the abs() function in case time1 is larger than time2.

0 Karma

sowings
Splunk Employee
Splunk Employee

Try grouping the arithmetic with ( ) in your where command: where ((time2-time1) < 5).

When I've needed to do this before, I've used eval to create a "delta" field, representing the difference between two time values, then using a search / where to filter for delta over a certain threshold.

0 Karma

tmarlette
Motivator

i just tried this, and it didn't work. the "where" command seems to be using integers. for instance

some search | where time2-time1 < 5

I think splunk sees the 5 as an integer, not seconds, and adding the 's' confuses splunk.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...