# Extension 2.0 Screens - How to add filtering

**URL:** <https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621>\
**Category:** Dynatrace Tips\
**Tags:** filter, extensions\
**Created:** [June 28, 2022, 8:28am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621 "2022-06-28T08:28:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Radu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radu/32/23351_2.png) [@Radu](https://community.dynatrace.com/u/Radu)\
**Post date:** [June 28, 2022, 8:28am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/1 "2022-06-28T08:28:34Z")

</div>

**Use case** : Enabling filtering and filter bars to [entity lists](https://www.dynatrace.com/support/help/shortlink/ua-pages#entities-list-card) of [screens](https://www.dynatrace.com/support/help/shortlink/ua-pages) created from an [Extension 2.0 YAML](https://www.dynatrace.com/support/help/extend-dynatrace/extensions20/extension-yaml).

 ![Radu_0-1656400972454.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/6/b64710fc6a29ba765b0b1fbc8ffaf38d2eaa874c.png)

**Example context** : I have an entity type “my:interface” that has a RUNS\_ON relationship to an entity type “my:device”. I have an [Entities List card](https://www.dynatrace.com/support/help/shortlink/ua-pages#entities-list-card) which already lists all “my:interface” entities I want to filter.

All definitions are given based on schema version 1.239 and may or may not change in the future.

**Example 1** : I want to filter my list by the interface names.  
YAML definition:

```auto
filtering:
  entityFilters:
    - displayName: Interface
      filters:
        - type: entityName
          displayName: Name
          freeText: true
          modifier: contains
          defaultSearch: true
          distinct: false
          entityTypes:
            - my:interface

```

**YAML explanation** :

- **filtering** - the block which defines the filtering capability
- **entityFilters** - the block which defines the groups of filters (these are displayed slightly greyed out in the filtering list)
- **filters** - the actual filters that are part of this group
  - **displayName** - how this filter is labelled within the UI

  - **type** - must reference an attribute of the entity you are filtering. Note: every entity has **entityName** as a default attribute.

  - **freeText** - if true, the user can freely type text; otherwise they must select from a list of suggestions. Note: only default attributes such as **entityName** are capable of offering list of suggestions.

  - **modifier** - when **freeText** is **true** , this defines how the text should be matched against the attribute. When **freeText** is **false** , this must be omitted. Note: all non-default attributes must match as “equals” regardless of this option.

  - **defaultSearch** - when true, if the user starts typing without selecting a filter first, this filter will be selected by default. Only one filter within the **filtering** block may have this enabled.

  - **distinct** - when true, only one instance of this filter can be applied

  - **entityTypes** - A mandatory list of entity types that this filter applies to. If you omit this, your filtering bar will just show a spinning wheel because of the incomplete definition.

**Example 2** : Given example 1, I also want to filter by the device these interfaces are running on

**YAML definition:**

```auto
filtering:
  relationships:
    - type(my:device),toRelationships.runsOn($(entityConditions))
  entityFilters:
    - displayName: Interface
      filters:
        - type: entityName
          displayName: Name
          freeText: true
          modifier: contains
          defaultSearch: true
          distinct: false
          entityTypes:
            - my:interface
    - displayName: Related entity
      filters:
        - type: entityName
          displayName: Device name
          freeText: false
          defaultSearch: false
          distinct: true
          entityTypes:
            - my:device

```

**YAML Explanation:**

Most of the definition is the same as above. Changes include:

- **filters**
  - **entityTypes** - For the second filter, this is now “my:device”. This is because despite filtering a list of interfaces, the filter attribute belongs to devices.

- **relationships**
  - any entity that is not directly part of the entity list must have a relationship defined to the listed entity for it to be considered. **$(entityConditions)** here resolves to each of the “my:interface” entities.

---

<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 9, 2023, 9:58pm UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/2 "2023-01-09T21:58:05Z")

</div>

Great Tip&nbsp;[@Radu](https://community.dynatrace.com/user/22272)

---

<div class="post-metadata">

**Author:** ![patrik\_steuer](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@patrik\_steuer](https://community.dynatrace.com/u/patrik_steuer)\
**Post date:** [May 16, 2023, 8:51am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/3 "2023-05-16T08:51:49Z")

</div>

Thanks&nbsp;[@Radu](https://community.dynatrace.com/user/22272)&nbsp; for the infos, especially about ommiting the freeText field for equals modifiers is valueable, since I couldn’t figure out the reason for the error message

```markup
dtcli.utils.ExtensionValidationError: {"error":{"code":400,"message":"Validation errors for asset node:host:\nGiven property 'modifier' with value: 'equals' should not be set as its precondition is not satisfied\n","constraintViolations":[]}}

```

However with Schema version 1.263 I now receive following error, indicating that freeText is mandory:

```markup
dtcli.utils.ExtensionValidationError: {"error":{"code":400,"message":"Extension validation error","constraintViolations":[{"path":"$.screens[1].entitiesListCards[0].filtering.entityFilters[0].filters[4]","message":"$.screens[1].entitiesListCards[0].filtering.entityFilters[0].filters[4].freeText: is missing but it is required","parameterLocation":"PAYLOAD_BODY","location":null}]}

```

So it seems that this is a chicken/egg problem do you have an idea how to solve this?

Something I also recognized is that the contains modifier is only suitable for entity names, other attributes can not make use of it.

---

<div class="post-metadata">

**Author:** ![patrik\_steuer](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@patrik\_steuer](https://community.dynatrace.com/u/patrik_steuer)\
**Post date:** [May 16, 2023, 9:07am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/4 "2023-05-16T09:07:22Z")

</div>

Another remark, it would be great to have the possibility to filter by health state, so that you can focus on not healthy entities.

---

<div class="post-metadata">

**Author:** ![patrik\_steuer](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@patrik\_steuer](https://community.dynatrace.com/u/patrik_steuer)\
**Post date:** [August 10, 2023, 1:35pm UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/5 "2023-08-10T13:35:06Z")

</div>

Do you know if it is possible to not only use attributes, but also tags for filtering?

---

<div class="post-metadata">

**Author:** ![Radu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radu/32/23351_2.png) [@Radu](https://community.dynatrace.com/u/Radu)\
**Post date:** [August 16, 2023, 7:58am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/6 "2023-08-16T07:58:08Z")

</div>

I believe freeText must always be present with either true or false value. It cannot be omitted. With relation to modifiers, this still is the case - if freeText = false, then you should not specify modifier.  
As for the attributes, it is only the special - entityName, ipAddress (a.k.a. dt.ip\_addresses), listenPort (a.k.a. dt.listen\_ports), and dnsName (dt.dns\_names) - that support suggestions in the UI.

---

<div class="post-metadata">

**Author:** ![Radu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radu/32/23351_2.png) [@Radu](https://community.dynatrace.com/u/Radu)\
**Post date:** [August 16, 2023, 7:58am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/7 "2023-08-16T07:58:50Z")

</div>

Please post it as a product idea in the dedicated forum [here](https://community.dynatrace.com/category/DynatraceProductIdeas)

---

<div class="post-metadata">

**Author:** ![Radu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radu/32/23351_2.png) [@Radu](https://community.dynatrace.com/u/Radu)\
**Post date:** [August 16, 2023, 7:59am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/8 "2023-08-16T07:59:30Z")

</div>

Only attributes are supported currently. Any other suggestions you can post as product ideas on the [dedicated forum](https://community.dynatrace.com/category/DynatraceProductIdeas).

---

<div class="post-metadata">

**Author:** ![patrik\_steuer](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@patrik\_steuer](https://community.dynatrace.com/u/patrik_steuer)\
**Post date:** [September 6, 2024, 9:24am UTC](https://community.dynatrace.com/t/extension-2-0-screens-how-to-add-filtering/35621/9 "2024-09-06T09:24:41Z")

</div>

Currently supported attributes for filtering on generic entities are the same as of other CUSTOM\_DEVICES:

```markup
- dt.security_context
- entityName
- healthState
- ipAddress
- mzId
- mzName
- softwareTechnologies
- softwareTechnologies.version
- tag

```

An endpoint is available under /rest/v2/entities/suggest, which can be used to query the available filters for an entity by providing an entity selector. Copy the request from your browser dev tools and adapt it as needed if you want to check it on your own.
