Splunk Search

How to create the Conditional search?

tcpcannon
Loves-to-Learn Lots

I have looked through the forums and can't find exactly what I am looking for.

Here is my search and what I think should work, but I don't think I completely understand multisearch.

 

 

| multisearch
[ search index=patch sourcetype=device host="bradley-lab" device_group=PRE*
| where match(host,"bradley-lab")]
[ search index=patch sourcetype=device host="bradley-lab" device_group=BFV*
| where NOT match(host,"bradley-lab")]

| dedup extracted_host
| eval my_time=_time
| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(my_time)
| rename extracted_host as device_Name, my_time as "Date Posted"
| table "Date Posted" device_group device_Name current_system_version latest_system_version status

 

 

 



host=bradley-lab will come from a token drilldown on a dashboard

if the host is bradley-lab I want it to show all devices with the device_group=PRE
and if the host is anything else, I want it to show all devices with device_group=BFV

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

index=patch sourcetype=device device_group=PRE* OR device_group=BFV*
| where (match(host,"bradley-lab") AND searchmatch(device_group=PRE*)) OR (NOT match(host,"bradley-lab") AND searchmatch(device_group=BFV*))

| dedup extracted_host
| eval my_time=_time
| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(my_time)
| rename extracted_host as device_Name, my_time as "Date Posted"
| table "Date Posted" device_group device_Name current_system_version latest_system_version status
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...