Back to Blog
tutorialIntermediate5 min read

Monitoring Your Docker Resources and Containers Part 3

Part 3 of the Docker monitoring series. Covers importing pre-built Grafana dashboards for Node Exporter and cAdvisor, including fixes for memory usage queries.

Ubuntu Docker - Metrics with Grafana, cAdvisor, and Node Exporter

Overview

This tutorial builds on previous articles that covered Docker, Grafana, Node Exporter, and cAdvisor installation. The focus here is creating dashboards within Grafana to visualize both host-level and container-level metrics.

Setting Up the Node Exporter Dashboard

Navigate to the Dashboards section by clicking the hamburger menu, then select "Dashboards." Choose "New" followed by "Import."

In the import field labeled "Import via grafana.com," enter 1860 and click Load. This loads a pre-built Node Exporter dashboard. Most settings can remain at their defaults, but ensure you select the correct Prometheus data source before importing.

Once imported, you'll have access to a complete Node Exporter dashboard displaying host metrics.

Setting Up the cAdvisor Dashboard

Follow the same import process, but use dashboard ID 14282 for cAdvisor. This dashboard requires two corrections.

First Fix: Memory Usage Chart

Locate the "Memory Usage" panel and click the three-dot menu (visible on hover). Select "Edit."

Replace the existing query with:

sum(container_memory_working_set_bytes{instance=~"$host",name=~"$container",name=~".+"}) by (name)

Click "Run Queries," then save and apply the changes.

Second Fix: Memory Cached Chart

For the "Memory Cached" panel, click the three-dot menu and select "Edit."

Replace the query with:

sum(container_memory_usage_bytes{instance=~"$host",name=~"$container",name=~".+"}) by (name)

Again, run the queries and save.

Result

After completing these steps, you'll have both host-level metrics from Node Exporter and container-level metrics from cAdvisor displayed in Grafana, providing comprehensive Docker monitoring visibility.