0
0
Dockerdevops~30 mins

Grafana dashboards for containers in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Grafana Dashboards for Containers
📖 Scenario: You work in a small team managing containerized applications. You want to monitor your containers' performance using Grafana dashboards. This project will guide you to set up a simple Docker Compose file that runs Prometheus and Grafana containers, and configure Grafana to display container metrics.
🎯 Goal: Build a Docker Compose setup that runs Prometheus and Grafana containers. Configure Grafana to connect to Prometheus as a data source and prepare a basic dashboard to monitor container metrics.
📋 What You'll Learn
Create a Docker Compose file with Prometheus and Grafana services
Add a Prometheus configuration file to scrape container metrics
Configure Grafana to use Prometheus as a data source
Verify Grafana dashboard is accessible and shows container metrics
💡 Why This Matters
🌍 Real World
Monitoring container performance is essential in real-world DevOps to ensure applications run smoothly and issues are detected early.
💼 Career
This project teaches skills used by DevOps engineers and site reliability engineers to set up monitoring and observability for containerized environments.
Progress0 / 4 steps
1
Create Docker Compose file with Prometheus and Grafana
Create a file named docker-compose.yml with two services: prometheus and grafana. Use the images prom/prometheus:latest and grafana/grafana:latest. Map port 9090 for Prometheus and port 3000 for Grafana. Mount a local directory ./prometheus to /etc/prometheus/ in the Prometheus container.
Docker
Need a hint?

Use version: '3.8' at the top. Define two services with correct images, ports, and volume for Prometheus.

2
Add Prometheus scrape configuration
Create a file named prometheus/prometheus.yml with a scrape config to monitor Docker containers. Use job_name: 'docker' and scrape targets at 'host.docker.internal:9323'. Set scrape interval to 15s.
Docker
Need a hint?

Define scrape_configs with job_name, scrape_interval, and static_configs with the target address.

3
Configure Grafana to use Prometheus data source
Add environment variables to the grafana service in docker-compose.yml to set up Prometheus as a data source automatically. Use GF_SECURITY_ADMIN_PASSWORD=admin and GF_DATASOURCES_PROMETHEUS_URL=http://prometheus:9090.
Docker
Need a hint?

Add an environment section under grafana with the two variables exactly as shown.

4
Start containers and verify Grafana dashboard
Run docker-compose up -d in your terminal to start Prometheus and Grafana containers. Then, open http://localhost:3000 in your browser. Log in with username admin and password admin. Verify you can add Prometheus as a data source and see container metrics.
Docker
Need a hint?

Use the terminal command docker-compose up -d to start containers. Open Grafana in your browser and log in with admin for both username and password.