Splunk Search

Storing spl in lookup

hoytn
Explorer

Is it possible to store a search string in a lookup column, retrieve the content and run it as a search?
For example:
index=some_index
| lookup test.csv lookup_key_field as event_code OUTPUT spl_field as search_string
| ... some command to actually run the search_string ...

0 Karma

woodcock
Esteemed Legend

Like this:

index=some_index
| lookup test.csv lookup_key_field AS event_code OUTPUT spl_field AS search_string
| map search="search [|makeresults | eval search=$search_string$ | return $search_string]"

gaurav_maniar
Builder

Hi Hoytn,

please try the below working example,

| makeresults | eval query="sourcetype=splunkd* | head 1" | outputlookup query_lookup.csv

Now get the result from lookup via sub-search,

index=_internal | search [| inputlookup query_lookup.csv | return $query]

Accept the answer if it helps.

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...