Monitoring Containers with Prometheus and cAdviser

A Cloud Enthusiast
Search for a command to run...

A Cloud Enthusiast
No comments yet. Be the first to comment.
DNS changes are powerful and risky. A single incorrect Route 53 record can cause outages, security exposure, or compliance issues. A simple but effective governance control is to get alerted whenever

Description Terraform is an infrastructure-as-code tool that makes handling infrastructure more straightforward and manageable. A Terraform module is a collection of configuration files that encapsula
Introduction Amazon Elastic Kubernetes Service (Amazon EKS) is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS and on-premises. Kubernetes is an open-source system for automating deployment, scaling, and management of...

In this article, I will briefly define what is DevOps, then we will discuss the suggested strategy to manage and automate DevOps teamwork in the context of AWS Team. What is DevOps? DevOps is the combination of cultural philosophies, practices, and t...
Introduction In this blog, we will demonstrate how to proactively monitor a web server EC2 security group for any traffic rule changes using Lambda along with a few other services. If we detect any unauthorized changes, we will then undo them using L...

In this blog, we will walk through how to monitor containers using Prometheus and cAdviser.
cAdvisor (short for container Advisor) analyzes and exposes resource usage and performance data from running containers. cAdvisor exposes Prometheus metrics out of the box. The container metrics will be collected by cAdvisor and scraped by Prometheus.
sudo privilegesConfigure Prometheus to scrape metrics from cAdvisor. Create a prometheus.yml file and paste below code:
scrape_configs:
- job_name: cadvisor
scrape_interval: 5s
static_configs:
- targets:
- cadvisor:8080
Now, in the same directory where you have created prometheus.yml, create adocker-compose.yml file defining both prometheus and cAdviser services. Copy and paste below in the file:
version: '3'
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- 9090:9090
command:
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
depends_on:
- cadvisor
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
ports:
- 8080:8080
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
Run docker-compose up -d to deploy the services and make it running in the background.
To verify the running containers, run docker ps. you can also access prometheus web dashboard on [your-public-ip]:9090 and cAdviser on [your-public-ip]:8080