Using Grafana to plot Docker container metrics Source
Markdown source
1---2title: 'Using Grafana to plot Docker container metrics'3date: '2020-09-18'4published_at: '2020-09-18T11:23:00.001+10:00'5tags: ['cadvisor', 'containers', 'docker', 'grafana', 'prometheus']6author: 'Gavin Jackson'7excerpt: 'At work, we have been busy playing around with Docker (initially for development environments, with a view to bump these into higher environments further down the track. I wanted to get some performan...'8updated_at: '2020-09-18T11:23:58.899+10:00'9legacy_url: 'http://www.gavinj.net/2020/09/using-grafana-to-plot-docker-container.html'10---1112At work, we have been busy playing around with Docker (initially for development environments, with a view to bump these into higher environments further down the track.1314I wanted to get some performance metrics for my running docker containers. Below is a recipe that I ended up using (which may be of interest to others).1516## The Code1718[https://github.com/gavinjackson/docker-metrics](https://github.com/gavinjackson/docker-metrics)1920## How it Works2122It consists of the following four containers (defined in the docker-compose.yml file):23241. **cadvisor **collects container stats252. **node-exporter** collects physical hardware stats.263. **prometheus **harvests this data.274. **grafana **is configured to consume data from the prometheus server and present some pre-made dashboards to visualise the data.2829Once running, this is what the dashboards look like:3031[](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjObNNCOoiHAlEOal0vVsszuiVtGFPci5lGeS2EiAI-xXb6doEmRpGH-w2bcLndirThzDPr5uDIFYjup3-KIZdOQrU6Tx3VDcfStEA8V2KjEvIY9oS8ITXY7SAoWCrgl63877gR_aAKhhg/)3233[](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8fFPmQuvLNaPNJdsJGnLKM7ryredDMtbXnd2tYxcQ1poarZMWz4oKMerLAuTDYR8H7NFMIW2rYb0vHu3tZ56_WM8R3QYZ4_RjdeY8vYdg9zdio3rZ0i4DEIYzl-wGqXVjPh7lApv8Ngg/)3435The cool thing about this is that you can copy this into your existing docker project and you will get instant metrics for all of your running containers (and host system).3637## Interesting links:3839**cadvisor **- the magical container that extracts the docker container metrics [https://github.com/google/cadvisor](https://github.com/google/cadvisor)4041**node-exporter** - the container that harvests the host metrics [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter)4243**prometheus **- the tool that collects this data [https://prometheus.io/](https://prometheus.io/)4445**grafana **- the time based visualisation layer that draws it's data from prometheus [https://grafana.com/](https://grafana.com/)4647The following grafana dashboards were provisioned:48491. [https://grafana.com/grafana/dashboards/1860](https://grafana.com/grafana/dashboards/1860) Node Exporter Full, and502. [https://grafana.com/grafana/dashboards/893](https://grafana.com/grafana/dashboards/893) Docker and system Monitoring513. [https://grafana.com/grafana/dashboards/8321](https://grafana.com/grafana/dashboards/8321) Docker monitoring with node selection525354