cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Filter / DQL query to fetch host based on Tag

ushag
Newcomer

I have around 100 hosts in my management zone. But they are for different instance, some for QA1, QA2,  etc..

I added a tag, to each of the hosts. However, I probably missed 2 of the hosts. Now I am unable to find the host where I missed this custom tag.  

How can I query to find which host is not having my instance tag. 

Filter I can search using this tag. but how to find host which do not have this tag

2 REPLIES 2

ChadTurner
DynaMight Legend
DynaMight Legend

First and foremost, this is why Automatic Tags are preferred.

If DQL is a curve ball, One of the easy ways to do this would be to create an opposing tag. So you made a tag that says "environment" you can create an Auto Tag rule that tags hosts as "Missed" if they dont have a Host tag of Environment.

In terms of your host, is the environment in your naming convention? Do you have a CMDB? Ideally you should leverage an auto tag rule that read the host name of the metadata then provides the applicable value as an environment tag. 

If you want to go the DQL route you can do the following: 

fetch dt.entity.host
| fieldsAdd tags
| filter NOT contains(tags, "[Environment]")

-Chad

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

You have more than one way to do it. I will tell you without DQL because it will work in Managed as well:

 

 

builtin:host.cpu.usage:filter(and(or(in("dt.entity.host",entitySelector("type(host),not(tag(~"XXXXX~"))"))))):splitBy("dt.entity.host"):sort(value(auto,descending))

 

 


It is just pick it up a metric always available in every host, splitting it by host and filtering negating tag value. Replace "XXXXX" for your tag.

If you change to table view, it will be better maybe:

AntonPineiro_0-1735910188021.png

And if they are manual tags, you can do it visually from UI, selecting your tag, and untagged:

AntonPineiro_0-1735910446712.png

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Featured Posts