# Defining Segments based on Tags

**URL:** <https://community.dynatrace.com/t/defining-segments-based-on-tags/55155>\
**Category:** Open Q&A\
**Tags:** tagging, segments\
**Created:** [March 2, 2026, 2:20pm UTC](https://community.dynatrace.com/t/defining-segments-based-on-tags/55155 "2026-03-02T14:20:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![makrem\_bargaoui](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@makrem\_bargaoui](https://community.dynatrace.com/u/makrem_bargaoui)\
**Post date:** [March 2, 2026, 2:20pm UTC](https://community.dynatrace.com/t/defining-segments-based-on-tags/55155/1 "2026-03-02T14:20:51Z")

</div>

Hello Team

Im trying to define a segment in order to group all entities based on the tagName called app

the app tagname includes the application name,  please see screenshot below

 ![Screenshot 2026-03-02 at 15.18.41.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/a/aa85643ac0b074541be7455f73598ae20d9c49f6.png)

as you can see when I click on preview the result is always 0,

is there anyway we can achieve that ? or this should be done in different way ?

bestregards,

Makrem

---

<div class="post-metadata">

**Author:** ![firmanprasetyo](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/firmanprasetyo/32/9412_2.png) [@firmanprasetyo](https://community.dynatrace.com/u/firmanprasetyo)\
**Post date:** [April 15, 2026, 10:38am UTC](https://community.dynatrace.com/t/defining-segments-based-on-tags/55155/2 "2026-04-15T10:38:24Z")

</div>

Hi Makrem,

1. **For Classic Entities**

For classic entities, you can use the following approach to extract and filter tags:

Variable:

```markup
fetch dt.entity.host
| expand tags
| fields tags
| dedup tags

```

Filter:

```markup
tags = "$tags"

```

 ![firmanprasetyo_0-1776246139340.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/a/6a814e56ac78147720976bbf0e42457090a0d4d4.png)

2.&nbsp;**For Grail-based Data (Logs, Metrics, and Events)**

When tags are applied directly to a server (e.g., using oneagentctl), they appear on the entity in the format [Environment]Owner:\<Value\>.

In Grail-based data, this tag is automatically ingested as a dedicated attribute named **“Owner”**. This allows you to apply a direct filter within your segment as follows:

```markup
Owner = "$owner"

```

 ![firmanprasetyo_2-1776249376420.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/a/6acbd0397486a1a40b05f11f98fd7f95bf58439c.png)

Note:

Please note that the two methods above do not work properly for **Grail-based entities**. This is because Grail-based entities have a different data structure for tag values compared to classic entities and record-level data (logs/metrics).

I’m still figuring out how to apply the segment using tags to grail-based entities.

Regards,

Firman
