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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agentic SOC Triage: Investigating Splunk ES Notables with MCP Server and a Local LLM

The Problem: Too Many Alerts, Too Little Context Security operations teams running Splunk Enterprise Security ...

All Work and No Play? Not at .conf26! Unwind at These Evening Events

Between hands-on technical sessions, keynote reveals, and diving into live architectures, .conf26 is packed ...

Join the Hackathon at .conf26 and build a No-Code AI agent

Join us for the AI Agent Buildathon, an in-person, three-hour hands-on Hackathon where you’ll use Splunk Agent ...