05 Nov 2024 08:30 AM
Hello,
We have an on-prem cluster of Linux VM Docker hosts. The environment also contains other ecosystems each with its own set of hosts (i.e. Windows, JBoss, etc), here I am interested in our container hosts. Each node has about 70 containerized microservices, depending on post deployment rebalancing of these containers across the cluster.
I can go to each host and scroll down to Container Analysis and see the count there.
However, I would like to build a dashboard that would fetch hosts with containers and display number of containers per host. Image names would be nice as well. I'm sure if I get a boost, I can play around to get other details and such. I am having hard time getting to this data outside of individual host view. Grant it I'm a novice to Dynatrace, so perhaps I am missing in my attempts to get this on a dashboard or similar. It'd be nice to know if it's possible.
Thank you,
AK
Solved! Go to Solution.
07 Nov 2024 12:57 PM - edited 07 Nov 2024 12:58 PM
Hey Aleksey,
You could try running a DQL query on a dashboard that looks something like this:
fetch dt.entity.docker_container_group_instance
// Get host name
| fieldsAdd hosted_by
| fieldsFlatten hosted_by
| fieldsRemove hosted_by
| fieldsAdd entityName(hosted_by.dt.entity.host, type:"dt.entity.host")
| fieldsRemove hosted_by.dt.entity.host
//Renaming Fields
| fieldsRename container_instance = entity.name, host_name = dt.entity.host.name
// Get the count per server and add a list of the containers
| summarize {number_of_containers= count(), containers = collectArray(container_instance)} , by:host_name
Let me know if that works for what you need
11 Nov 2024 08:44 PM
Hi David.
Thank you for your help. Here is what I am facing..
fetch dt.entity.docker_container_group_instance
does not return any records for me . Seems that our containers are not registered as part of docker_container_group_instance entity. Not sure if it is due to some detection rules or what not.
We are currently migrating from one APM to Dynatrace. Currently container instance images are coded for the other APM tool. The good thing about DT OneAgent is that we deployed it on the host Linux node(s) and it picked up all containers. All we had to do is restart the containers to allow for deep monitoring. We also verified that the other APM service got automatically shutdown after restart of the container. This is all groovy as we want to avoid making changes to container images and configs to get deep monitoring in DT until after we are fully in DT and begin clean up / decoupling for previous APM from out containerized microservices in subsequent PSIs.
That being said, it seems that the side affect here is that out containers belong to "dt.entity.container_group" instead of "dt.entity.docker_container_group" and their instances.
The DQL you provided is not working for me because of that. I tried the quick dummy approach and replaced "fetch dt.entity.docker_container_group_instance" with "fetch dt.entity.container_group_instance" but i got errors "The field hosted_by does't exist" . I am not DQL expert. With little that I do know I was not able to figure out how to mod this query to get me result I want.
fetch dt.entity.container_group_instance
does give me a list of 515 records which is a total number of containers across 7 nodes and image name is something like this "repo.xxxxxx.com/<microservice-name-api>:<version_tag>"
Can I achieve my original request with what I have without having to inject anything DT related manually into container images?
Thank you!
11 Nov 2024 10:59 PM
you can try this one it's fetch hosts has processes of technology `DOCKER` then summarizes by count of docker pgi per each host
fetch dt.entity.host
| expand pgi=contains[dt.entity.process_group_instance]
| filter pgi in [
fetch dt.entity.process_group_instance
| filter matchesValue(softwareTechnologies, "*DOCKER*")
| fields id
]
| summarize pgiDockerCount=count(), by:{id, hostName = entity.name}
I've added id field without renaming to be able to inspect it with app host.
BR,
Mostafa Hussein.
12 Nov 2024 05:09 AM
Thank you Mostafa! That worked really well for my edge case.