Monitoring is now baked into Docker for Mac/Windows by default. How cool is that? No longer do we need to guess about the performance of our development machines or test environments.
Some may ask the Million Dollar $$ question as to why we would want to monitor our local installation. For starters, I am sort of monitoring mad and monitor everything. Second, in order to truly understand your environment, we need to dissect what is running and how it's running. Finally, it is a good practice to understand your environment and if it is impacting the performance of your workload or not.
Monitoring the Docker for Mac/Windows Daemon
Let's get started by configuring your installation. The following screenshots are from a Mac but the steps should work the same for Windows. We will now enable Daemon metrics on our Docker for Mac/Windows formatted for Prometheus
- Open Docker for Mac/Windows Preferences menu
Daemonmenu and click
metrics-addr" : "0.0.0.0:9323",
Àpply & Restartand wait for Docker to come back online.
- Test it out. Open a browser tab with the following URL:
Monitor with Prometheus
Our local Docker for Mac/Windows installation is now creating Prometheus formatted metrics. Next, let's start-up a Prometheus stack and consume these newly created metrics.
- Clone the Prometheus stack locally:
git clone https://github.com/vegasbrianc/prometheus.git .
- Edit the
prometheus/prometheus.ymlfile. Navigate to the end of the file and find the section name
- Edit the target string to the with the hostname or IP of the machine running Docker for Mac/Windows:
- targets: ['hostname-here:9323']
- Save the file and exit
- Start the Prometheus stack:
docker-compose up -d
- In a new browser tab open Grafana:
- Login to Grafana: username -
- After logging in you will be prompted with a green button to add a data source. Click
Add Data Source
- Input the following information into the Data Source:
Access: Leave default
HTTP Auth: Click
Click `Save & Test``
Click on the Grafana Logo in the upper right-hand corner, hover over Dashboards, and select
- Type the number
1229in the Grafana.com Dashboard input area and click
- Everything should now be populated except for the last field that requires the data source. Click the drop-down and select
We have set up the Docker Daemon log its metrics, configured and launched a Prometheus stack to consume these metrics, and finally imported a Grafana dashboard as a starting point. You should now be able to create some interesting graphs and reports based on your installation.