Splunk Search

How to use a column of data in a CSV lookup to initiate a search?

joea9
Explorer

I am using a CSV lookup that adds additional fields to my Splunk search results...

Search string:

date_month=october OR date_month=june | lookup mylookup month as date_month

CSV file:

month,shortname
july,jul
june,jun
october,oct

So it's matching the date_month field in my search results with the month column in my CSV file and returning the 'shortname' as a new field.

QUESTION

However, I want to use data in my CSV file to initiate the search instead. I want to do a lookup that will return all of the months in the month column of my CSV file, and then do a search on them, while including the additional 'shortname' field in the search results?

I got this far:

| inputlookup myiplookup | fields month

Which returns the list of values in my CSV 'month' column, but it doesn't actually search on them, and doesn't return the 'shortname' field.

Tags (4)
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Searching based on lookup fields and adding fields to results from a lookup are two separate things, so you will need to do two steps to achieve this.

First, configure your lookup as an automatic lookup on your data. That'll allow you to leave off the explicitly | lookup command from your first search.
Second, run a search like this:

index=foo sourcetype=bar [inputlookup mylookup | fields month | rename month as date_month] | ...

That'll build an OR'd list of date_month filters from your lookup.

As an alternative, having the automatic lookup also allows you to write this kind of search:

index=foo sourcetype=bar shortname=jun | ...

That will be translated to date_month=june under the hood.

Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

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