Splunk Cloud Platform

Use of IN Clause to find out available host in splunk

mchoudhary
Explorer

Hi Team,

I am a newbie in Splunk. I am using a basic IN clause in a search command to pull out the 36 windows server integration available or not in splunk.

index=* NOT index=_* host IN ("host1", "host2", "host3", ...., "host36")
| stats count by host

It gives me the servers which are available in splunk. I want to find out the missing ones and the available ones in this format-

hoststatus
host1Available
host2Available
host3Missing

I am using the below query but it only gives 6 statistics.

| makeresults count=1
| eval all_hosts="host1,host2,host3....host36"
| makemv delim="," all_hosts
| mvexpand all_hosts
| rename all_hosts AS host
| append [ search index=* NOT index=_* host=*
    | stats count by host ]
| stats values(count) AS event_count by host
| where host IN ("host1", "host2",....,"host36")
| eval status=if(isnull(event_count), "Missing", "Available")
| table host status
| sort status, host

 Can anyone please help me out what I am doing wrong.

Thanks in Advance!!

Labels (1)
Tags (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

index=* NOT index=_* host=*
| stats count by host
| append
  [| makeresults
  | eval host=split("host1,host2,host3....host36",",")
  | mvexpand host
  | eval count=1]
| stats sum(count) AS event_count by host
| eval status=if(event_count = 1, "Missing", "Available")
| table host status
| sort status, host
0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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