Splunk Search

How To String Multiple Searches To Update KV Store

joemarty82
Explorer

Hello,

 

I have been banging my head on a problem. What I am trying to do is run a first query to get a list of assets, then with that list I want to update my kv store. I can do what I want in two separate searches but when I combine them it does not work. I have tried using append, join, and just stringing them together but nothing works yet. My latest attempt was with join.

 

sourcetype="asset-info" | eval nowfield=now() | eval diff = ( nowfield-1814400) |
convert timeformat="%Y-%m-%dT%H:%M:%S.%9NZ" mktime(last_found) as new_epoch | eval last_scanned=substr(new_epoch,1,10) | where last_scanned < diff | eval vuln_last_found=substr(last_found,1,10) | eval target_id = dns_name
 | join type=inner max=0 target_id
  [
   | inputlookup kvstore_db | where fqdn=target_id AND state!="closed" | eval key=_key | eval state="oct7" | outputlookup kvstore_db append=True
   ]

 

The first half is the first search that gets the list of assets (target_id), then I filter on that with the kvstore lookup (kvstore_db) , fallowed by the outputlookup to actually update the (state) field with the value "oct7". This basically works as is if I run the two searches independently, but when I put them together (which is what I need) is does work. I am hoping someone can help.

 

Thanks,

Joe 

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...