Add variable to filter by docker-compose projects/stacks
psychowood opened this issue · comments
Hi,
here's my simple use case:
- Local docker host
- Different docker-compose projects
- Filter container stats by compose project name
Basically, I added a variable on top of the dashboard, based on label_values(container_label_com_docker_compose_project)
and injected it in every query below, by adding ,container_label_com_docker_compose_project=~"$compose_projects"
everywhere except on the top row (CPU/Memory/Storage Load).
It would be nice to have the aggregated stat too (i.e. total memory used by a stack) but my grafana skills are more or less 1 hour old, I need more time :)
I could provide a PR for the provisioning file if you believe this could be useful.
I actually do something very similar with Docker Compose stacks myself this does actually take memory usage into account for the selected stack too.
Here's the configuration pane for the variable.
And the relevant configuration that needs to be added to each of the panels is the section bolded below (Used Memory panel as an example):
sum(container_memory_usage_bytes{image!="",container_label_com_docker_compose_project=~"$stack"})