# How to retrieve a key value of metadata item in properties of an entity (openshift container)?

**URL:** <https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408>\
**Category:** Container platforms\
**Tags:** openshift, tagging\
**Created:** [September 1, 2022, 2:00pm UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408 "2022-09-01T14:00:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![henridb](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@henridb](https://community.dynatrace.com/u/henridb)\
**Post date:** [September 1, 2022, 2:00pm UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408/1 "2022-09-01T14:00:29Z")

</div>

Hello all,

Retrieving the properties via API for a container instance delivers:

```auto
{
  "entityId": "CONTAINER_GROUP_INSTANCE-08E89EB939BF5F49",
  "type": "CONTAINER_GROUP_INSTANCE",
  "displayName": "pega-web-55959b478c-dx8qw",
  "properties": {
    "metadata": [
      {
        "key": "KUBERNETES_NAMESPACE",
        "value": "pega-cm02-dev01"
      },
      {
        "key": "KUBERNETES_FULL_POD_NAME",
        "value": "pega-web-55959b478c-dx8qw"
      },
      {
        "key": "KUBERNETES_BASE_POD_NAME",
        "value": "pega-web-*"
      }
    ]
  }
}

```

Now I need to check for a text in the KUBERNETES\_NAMESPACE value from the metadata in properties to do some auto tagging. What is the syntax for that?

This is as far as we got now: type(CONTAINER\_GROUP\_INSTANCE),…

Regards,

Henri

---

<div class="post-metadata">

**Author:** ![christoph\_wilts](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@christoph\_wilts](https://community.dynatrace.com/u/christoph_wilts)\
**Post date:** [September 6, 2022, 2:11pm UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408/2 "2022-09-06T14:11:07Z")

</div>

Hi Henri,

If you like to filter for metadata from the properties section in the auto-tagging rules, you can use the following entity selector:

type(CONTAINER\_GROUP\_INSTANCE), metadata(KUBERNETES\_NAMESPACE:\<VALUE\>)

You can exchange the \<VALUE\> with the namespace you want to filter for. I have attached an example for the kube-system namespace:

 ![Screenshot 2022-09-06 at 15.51.34.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/e/9e75d753959244b4fe63cfa26caadd3487d44d0e.png)

---

<div class="post-metadata">

**Author:** ![henridb](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@henridb](https://community.dynatrace.com/u/henridb)\
**Post date:** [September 8, 2022, 7:05am UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408/3 "2022-09-08T07:05:52Z")

</div>

Thanks Christoph,

It even works with multiple value pairs:

type(CONTAINER\_GROUP\_INSTANCE), metadata(KUBERNETES\_NAMESPACE:\<VALUE\>,KUBERNETES\_NAMESPACE:\<VALUE2\>)

---

<div class="post-metadata">

**Author:** ![aporcher](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@aporcher](https://community.dynatrace.com/u/aporcher)\
**Post date:** [September 9, 2022, 2:42am UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408/4 "2022-09-09T02:42:18Z")

</div>

Hi&nbsp;Christoph,  
Any clue about which is the syntax if I want all entities where a metadata field has any value instead of a specific value? I’m looking for something like&nbsp;type(CONTAINER\_GROUP\_INSTANCE), metadata(CLOUD\_FOUNDRY\_APP\_NAME) which works for the majority of key:value fields but does not work for metadata.  
In this case, I’m using the&nbsp;/api/v2/entities API

Thanks,  
Alaor

---

<div class="post-metadata">

**Author:** ![henridb](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@henridb](https://community.dynatrace.com/u/henridb)\
**Post date:** [September 9, 2022, 11:23am UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408/5 "2022-09-09T11:23:37Z")

</div>

Alaor,

seems this one is EQUALS comparison only, no contains.

Regards,

Henri

---

<div class="post-metadata">

**Author:** ![christoph\_wilts](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@christoph\_wilts](https://community.dynatrace.com/u/christoph_wilts)\
**Post date:** [September 9, 2022, 11:59am UTC](https://community.dynatrace.com/t/how-to-retrieve-a-key-value-of-metadata-item-in-properties-of-an-entity-openshift-container/36408/6 "2022-09-09T11:59:13Z")

</div>

Yes Henri is right - it only allows EQUALS at the moment.

The filter is following the Entity Attribute selector: [Environment API v2 - Entity selector — Dynatrace Docs](https://www.dynatrace.com/support/help/shortlink/api-entities-v2-selector#attribute)
