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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...