# Pro-tip: Exclude entities by tag (find the non-matching entities)

**URL:** <https://community.dynatrace.com/t/pro-tip-exclude-entities-by-tag-find-the-non-matching-entities/36665>\
**Category:** Dynatrace Tips\
**Tags:** tagging, filter, tips-and-tricks\
**Created:** [September 27, 2022, 12:32am UTC](https://community.dynatrace.com/t/pro-tip-exclude-entities-by-tag-find-the-non-matching-entities/36665 "2022-09-27T00:32:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_AM](https://avatars.discourse-cdn.com/v4/letter/t/ce7236/32.png) [@The\_AM](https://community.dynatrace.com/u/The_AM)\
**Post date:** [September 27, 2022, 12:32am UTC](https://community.dynatrace.com/t/pro-tip-exclude-entities-by-tag-find-the-non-matching-entities/36665/1 "2022-09-27T00:32:37Z")

</div>

## How do you exclude entities by tagging non-match?

### Also known as filter for “negate match” or “does not match”.

This question comes up from time-to-time, and I’d just responded to the same on [another thread.](https://community.dynatrace.com/post/195164) I thought it worthwhile to share as a **Dynatrace tip!**

#### Option 1)

You could have many tags, it is true. For all the different conditions you could think of.

eg: include or exclude Kubernetes nodes

 ![The_AM_0-1664238177434.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/e4ee09ad82e4f76d897d37139c8525d6c3d23b39.png)

Then say, if you want to exclude Linux-only OS, you would need another tag for ‘isLinuxOS’: yes/no

For Windows, ‘isWindowsOS’: yes/no

And so on…

This is cumbersome, I agree.

#### Option 2) [Recommended]

However, an easier way may be to make a tag called “exclude” and all the optional tag values point to the condition you’d like to exclude. You may add many different options here.

 ![The_AM_1-1664238177442.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/7/4752eea6c590f22de22f68d0493a28f1de910d91.png)

#### The Results!

You can see here, the results can be quite powerful.

I could exclude all my Kubernetes nodes, to find other types of hosts.

 ![The_AM_2-1664238263602.png](https://global.discourse-cdn.com/dynatrace/original/2X/7/7df2007d57b8fded50cc45dae8f0f242f10df1f4.png)

It is even possible to combine multiple conditions.

 ![The_AM_3-1664238317168.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/e/ae8fc0e5e44197000dbcb27e57f41cdfb53a82f6.png)

Technically, you could filter to the same entity by combining an inclusion and exclusion tag. It all depends on the problem you’d like to solve.

 ![The_AM_4-1664238387869.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0a1f783a850ecb69751291cf5401a17eb728268a.png)

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [January 10, 2023, 4:52pm UTC](https://community.dynatrace.com/t/pro-tip-exclude-entities-by-tag-find-the-non-matching-entities/36665/2 "2023-01-10T16:52:14Z")

</div>

very nice little trick to work around that negations of filtering 🙂 Kudos to you&nbsp;[@The\_AM](https://community.dynatrace.com/user/21137)

---

<div class="post-metadata">

**Author:** ![Vanguard](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/vanguard/32/29977_2.png) [@Vanguard](https://community.dynatrace.com/u/Vanguard)\
**Post date:** [September 13, 2024, 11:35am UTC](https://community.dynatrace.com/t/pro-tip-exclude-entities-by-tag-find-the-non-matching-entities/36665/3 "2024-09-13T11:35:19Z")

</div>

I do not understand how this work. In the example you use exclude:kubernetes-node, however it seems you set a tag value of non-k8-node in the Rules. Please show details of the configured rule conditions and what tag values have been used and why. I spent 1h trying to follow this tip and gotten nowhere.

---

<div class="post-metadata">

**Author:** ![The\_AM](https://avatars.discourse-cdn.com/v4/letter/t/ce7236/32.png) [@The\_AM](https://community.dynatrace.com/u/The_AM)\
**Post date:** [September 25, 2024, 3:02am UTC](https://community.dynatrace.com/t/pro-tip-exclude-entities-by-tag-find-the-non-matching-entities/36665/4 "2024-09-25T03:02:23Z")

</div>

**exclude:non-k8s-node** matches all Kubernetes nodes (include only K8s nodes). All other servers are excluded.  
**exclude:kubernetes-node** matches all nodes that do not have Kubernetes. All Kubernetes servers are excluded.

These rules do not necessarily cover every use-case and are non-exhaustive.

Edit: It’s also been about 2 years since this was made, it is possible metadata available has changed.
