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

Hello all,

Retrieving the properties via API for a container instance delivers:

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

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

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:

Thanks Christoph,

It even works with multiple value pairs:

type(CONTAINER_GROUP_INSTANCE), metadata(KUBERNETES_NAMESPACE:<VALUE>,KUBERNETES_NAMESPACE:<VALUE2>)

Hi 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 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 /api/v2/entities API

Thanks,
Alaor

Alaor,

seems this one is EQUALS comparison only, no contains.

Regards,

Henri

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