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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...