Splunk Search

metadata search for tagged and untagged servers

pil321
Communicator

I'm trying to do a search for servers that have reported to verify their status (server up or server down). I have something like this:

|metadata type=hosts | eval status=if((now()-lastTime < 60, "server up", "server down") | fields host,status | sort host

I also have servers that have been decommissioned and are tagged as such (tag::decommissioned).

How do I exclude the tagged servers from my search? Or, is there a better way to do this?

Tags (1)
0 Karma
1 Solution

jtrucks
Splunk Employee
Splunk Employee

You have to insert the tags into the results and then filter it out like:

|metadata type=hosts |tags | search NOT tag::decommissioned=* |  eval status=if(now()-lastTime < 60, "server up", "server down") | fields host,status | sort host

🙂

--
Jesse Trucks
Minister of Magic

View solution in original post

jtrucks
Splunk Employee
Splunk Employee

You have to insert the tags into the results and then filter it out like:

|metadata type=hosts |tags | search NOT tag::decommissioned=* |  eval status=if(now()-lastTime < 60, "server up", "server down") | fields host,status | sort host

🙂

--
Jesse Trucks
Minister of Magic

pil321
Communicator

Thanks jtrucks!

I had to modify it slightly, but it worked:
...| tags | search NOT tag::host="decommissioned" | ...

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...