01 Sep 2022 03:00 PM - last edited on 02 Sep 2022 08:55 AM by MaciejNeumann
Hello all,
Retrieving the properties via API for a container instance delivers:
{ "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
Solved! Go to Solution.
06 Sep 2022 03:11 PM - edited 07 Sep 2022 01:05 PM
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:
08 Sep 2022 08:05 AM
Thanks Christoph,
It even works with multiple value pairs:
type(CONTAINER_GROUP_INSTANCE), metadata(KUBERNETES_NAMESPACE:<VALUE>,KUBERNETES_NAMESPACE:<VALUE2>)
09 Sep 2022 03:42 AM
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
09 Sep 2022 12:23 PM
Alaor,
seems this one is EQUALS comparison only, no contains.
Regards,
Henri
09 Sep 2022 12:59 PM
Yes Henri is right - it only allows EQUALS at the moment.
The filter is following the Entity Attribute selector: https://www.dynatrace.com/support/help/shortlink/api-entities-v2-selector#attribute