cadvisor_taskdef
Configure a cAdvisor task definition for container monitoring. This JSON task definition specifies image, ports, volumes, and essential settings for cAdvisor.
cAdvisor Task Definition
Understanding the cAdvisor Task Definition
This document provides a detailed look at a task definition for cAdvisor, a container monitoring tool. The configuration is designed for deployment within container orchestration platforms like AWS ECS. It outlines the necessary parameters to run cAdvisor effectively, enabling detailed performance metrics collection for your containers.
cAdvisor Configuration Breakdown
The core of the configuration is a JSON object defining the task. This includes the container definition, specifying the Docker image, resource allocation, port mappings, and essential runtime privileges. cAdvisor requires elevated permissions and specific volume mounts to access host system information, which are crucial for its monitoring capabilities.
Key Container Definition Parameters
- Name: Identifies the container as 'cadvisor'.
- Image: Uses the official 'google/cadvisor' Docker image.
- Memory Reservation: Sets a baseline memory allocation of 256 MiB.
- Port Mappings: Exposes the container's port 8080 to the host's port 8080 for accessing the cAdvisor UI and API.
- Essential: Marks the container as essential for the task to run.
- Privileged: Grants the container elevated privileges, necessary for accessing host system resources.
Required Volume Mounts for cAdvisor
To gather comprehensive system and container metrics, cAdvisor needs access to various host directories. The task definition includes mounts for:
/rootfs
(read-only): The host's root filesystem./var/run
: For runtime information, writable./sys
(read-only): System information and kernel parameters./var/lib/docker
(read-only): Docker daemon's data directory./dev/disk
(read-only): Host disk devices./sys/fs/cgroup
(read-only): Control group information.
Volume Definitions
The task definition also specifies the corresponding host volumes that map to the container paths. These volumes ensure cAdvisor can correctly access the required host system directories.
External Resources for Container Monitoring
- cAdvisor GitHub Repository: Official source for cAdvisor.
- AWS ECS Task Definitions Documentation: Learn more about configuring tasks on AWS.
- Kubernetes Logging and Monitoring Concepts: Broader context on container monitoring.
{
"family": "cadvisor",
"containerDefinitions": [
{
"name": "cadvisor",
"image": "google/cadvisor",
"memoryReservation": 256,
"portMappings":[
{
"protocol":"tcp",
"containerPort":8080,
"hostPort":8080
}
],
"essential": true,
"privileged": true,
"mountPoints": [
{
"sourceVolume": "root",
"containerPath": "/rootfs",
"readOnly": true
},
{
"sourceVolume": "var_run",
"containerPath": "/var/run",
"readOnly": false
},
{
"sourceVolume": "sys",
"containerPath": "/sys",
"readOnly": true
},
{
"sourceVolume": "var_lib_docker",
"containerPath": "/var/lib/docker",
"readOnly": true
},
{
"sourceVolume": "dev_disk",
"containerPath": "/dev/disk",
"readOnly": true
},
{
"sourceVolume": "cgroup",
"containerPath": "/sys/fs/cgroup",
"readOnly": true
}
]
}
],
"volumes": [
{
"host" : {
"sourcePath" : "/"
},
"name" : "root"
},
{
"host" : {
"sourcePath" : "/var/run"
},
"name" : "var_run"
},
{
"host" : {
"sourcePath" : "/sys"
},
"name" : "sys"
},
{
"host" : {
"sourcePath" : "/var/lib/docker"
},
"name" : "var_lib_docker"
},
{
"host" : {
"sourcePath" : "/dev_disk"
},
"name" : "dev_disk"
},
{
"host" : {
"sourcePath" : "/cgroup"
},
"name" : "cgroup"
}
]
}