29 Mar 2023 01:14 PM
I am looking to get the CPU and memory from a particular container instance...
I can find the container details using
builtin:kubernetes.containers
and filter for the one I need
I ideally want to run
builtin:containers.cpu.usageMilliCores but in order to get the right container I need the container_group_instance value
I am not sure how to find out this information, can anyone assist?
Solved! Go to Solution.
29 Mar 2023 02:25 PM
Not sure what you want to get, builtin:containers.cpu.usageMilliCores also accepts container as filter condition. Can you please further explain your need?
BR
29 Mar 2023 03:44 PM
Hey thanks for the response...... we have multiple containers with the same name as they are in different environments.....
So I am using this query
29 Mar 2023 05:45 PM
Hi@stephenje you can tag the container on creation to be able to identify it.
30 Mar 2023 07:41 AM
Hi, if you want to filter only a single container of a specific namespace you can leverage on relationships like this:
builtin:containers.cpu.usageMilliCores
:filter(in("dt.entity.container_group_instance", entitySelector("type(~"CONTAINER_GROUP_INSTANCE~"),fromRelationships.isCgiOfNamespace(type(CLOUD_APPLICATION_NAMESPACE),entityName.equals(<NAMESPACE_NAME>))")))
:splitBy():sort(value(auto,descending)):limit(20)
or by referencing the namespace by id
builtin:containers.cpu.usageMilliCores
:filter(in("dt.entity.container_group_instance", entitySelector("type(~"CONTAINER_GROUP_INSTANCE~"),fromRelationships.isCgiOfNamespace(type(CLOUD_APPLICATION_NAMESPACE),entityId(<NAMESPACE_entityId>))")))
:splitBy():sort(value(auto,descending)):limit(20)
In general usage of relationships when dealing with k8s entities is very useful.
See:
Monitored entities API - GET all entity types | Dynatrace Docs
Environment API v2 - Entity selector | Dynatrace Docs
Hope this helps
Paolo
30 Mar 2023 07:06 AM
Thanks @DanielS can those tags be used in a filter?
30 Mar 2023 12:48 PM
Yes, you can reference it by using, type("CONTAINER_GROUP_INSTANCE~"),tag("[context]key1:value-1","key2:value-2","value-3")