Splunk Search

Lookup within time range

stephenmeyers
Explorer

I have data being fed to splunk in real time that I would like to tie to project IDs and budgets in a lookup table based on two criteria:

  1. time falls between start_time and end_time in  the lookup table
  2. owner equals the owner in the lookup table

Here's the example data:

timeownerSpentNotes
2020-10-26 10:06:00Bill$30Supplies
2020-10-26 12:16:41Bill$10Food
2020-10-27 06:30:51Jeff$10Food
2020-11-04 07:06:03Bill$15Fuel
2020-11-04 08:01:19Frank$20Fuel
2020-11-05 08:10:00Bill$20Supplies
2020-11-05 08:12:21Jeff$10Fuel

 

Here's the example lookup table:

project_idownerbudgetstart_timeend_time
1eBill$2002020-10-26 08:00:002020-11-04 12:00:00
2bJeff$2002020-10-21 08:00:002020-11-06 12:00:00
4aFrank$1002020-11-04 08:00:002020-11-22 17:00:00
2aBill$2002020-11-05 08:00:002020-11-10 12:00:00

 

This is the output I am looking for:

timeproject_idbudgetownerSpentNotes
2020-10-26 10:06:001e$200Bill$30Supplies
2020-10-26 12:16:411e$200Bill$10Food
2020-10-27 06:30:512b$200Jeff$10Food
2020-11-04 07:06:031e$200Bill$15Fuel
2020-11-04 08:01:194a$100Frank$20Fuel
2020-11-05 08:10:002a$200Bill$20Supplies
2020-11-05 08:12:212b$200Jeff$10Fuel

 

I'm not really sure how to use the lookup command on a range, or if it's possible. Any suggestions/solutions are welcome. Thanks in advance!

Labels (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @stephenmeyers, sorry, I edited my reply, the time field name was wrong. This way lookup will also check the _time of event to be bigger then start_time field in the lookup. Although it will not use the end_time field, it should show your desired result. 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @stephenmeyers, you should use time

 

transforms.conf

[project_lookup]
filename = project_lookup.csv
time_field = start_time
time_format = %Y-%m-%d %H:%M:%S

props.conf

[project_lookup]
LOOKUP-project = project_lookup owner OUTPUT project_id budget

 

https://docs.splunk.com/Documentation/Splunk/8.1.1/Knowledge/Configureatime-boundedlookup#Defining_t...

 

If this reply helps you an upvote is appreciated.

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

stephenmeyers
Explorer

It doesn't look like this solution would match by the time within start_time and end_time, but only by the owner field. In the example, owner Bill is on 2 different projects, but the time ranges are different.

The time range bit is the real hurdle I'm dealing with. 

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 ...