stefanprodan / dockprom

Docker hosts and containers monitoring with Prometheus, Grafana, cAdvisor, NodeExporter and AlertManager
MIT License
6.05k stars 1.73k forks source link

Add variable to filter by docker-compose projects/stacks #217

Closed psychowood closed 3 years ago

psychowood commented 3 years ago

Hi, here's my simple use case:

  1. Local docker host
  2. Different docker-compose projects
  3. 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 :)

image

I could provide a PR for the provisioning file if you believe this could be useful.

Seth1u commented 3 years ago

I don't find networks metrics dashboard image

Can you tell me how to prompt it? Thanks

nightah commented 3 years ago

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"})

Seth1u commented 3 years ago

image

image

I chabge it like u but same errors, no containers show up

image