cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Metrics API to get container groups

stephenje
Newcomer

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?

8 REPLIES 8

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

stephenje
Newcomer

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

builtin:containers.cpu.usageMilliCores:filter(eq(Container,vehicle-ohs)):names:parents
this gives me multiple results....
But I only want to use the container returned with this query
builtin:kubernetes.containers:filter(eq("k8s.deploymentconfig.name","vehicle-ohs"),eq("k8s.namespace.name","vrm-e2e"),eq("container_state","running")):names:parents
But I cannot find out which container group this is in?

Hi@stephenje you can tag the container on creation to be able to identify it.

The true delight is in the finding out rather than in the knowing.

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

 

Awesome thanks @paolo_fumanelli that has worked...... mucg appreciated

 

 

stephenje
Newcomer

Thanks @DanielS can those tags be used in a filter?

 

Yes, you can reference it by using, type("CONTAINER_GROUP_INSTANCE~"),tag("[context]key1:value-1","key2:value-2","value-3")

The true delight is in the finding out rather than in the knowing.

Thanks @DanielS 

Featured Posts