监控层次:
┌─────────────────────────────────────────┐
│ Docker监控架构 │
├─────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────┐ │
│ │ 应用层监控 │ │
│ │ ├─ 应用性能(APM) │ │
│ │ ├─ 业务指标 │ │
│ │ └─ 错误追踪 │ │
│ └─────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ 容器层监控 │ │
│ │ ├─ 资源使用 │ │
│ │ ├─ 容器状态 │ │
│ │ ├─ 网络流量 │ │
│ │ └─ 存储IO │ │
│ └─────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ 主机层监控 │ │
│ │ ├─ 主机资源 │ │
│ │ ├─ 系统负载 │ │
│ │ ├─ 网络状态 │ │
│ │ └─ 存储状态 │ │
│ └─────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ 集群层监控 │ │
│ │ ├─ 集群状态 │ │
│ │ ├─ 服务健康 │ │
│ │ └─ 调度状态 │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
东巴文理解:
监控数据类型:
┌──────────────────┬──────────────┬──────────────┐
│ 数据类型 │ 采集频率 │ 保存周期 │
├──────────────────┼──────────────┼──────────────┤
│ 实时指标 │ 秒级 │ 短期(7天) │
│ 性能指标 │ 分钟级 │ 中期(30天) │
│ 业务指标 │ 分钟级 │ 长期(1年) │
│ 日志数据 │ 实时 │ 长期(1年) │
│ 事件数据 │ 实时 │ 长期(1年) │
└──────────────────┴──────────────┴──────────────┘
监控目标:
├─ 可用性: 服务是否正常
├─ 性能: 响应时间、吞吐量
├─ 资源: CPU、内存、磁盘、网络
├─ 错误: 错误率、异常
└─ 容量: 资源使用趋势
常用监控工具:
监控工具对比:
┌──────────────────┬──────────────┬──────────────┐
│ 工具 │ 特点 │ 适用场景 │
├──────────────────┼──────────────┼──────────────┤
│ Prometheus │ 时序数据库 │ 指标监控 │
│ Grafana │ 可视化 │ 数据展示 │
│ cAdvisor │ 容器监控 │ 资源监控 │
│ InfluxDB │ 时序数据库 │ 数据存储 │
│ ELK Stack │ 日志分析 │ 日志管理 │
│ Datadog │ SaaS平台 │ 全面监控 │
│ Sysdig │ 深度监控 │ 性能分析 │
└──────────────────┴──────────────┴──────────────┘
实时监控:
# 查看所有容器资源使用
docker stats
# 输出
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
a1b2c3d4e5f6 nginx 0.50% 5.234MiB / 7.777GiB 0.07% 1.2kB / 0B 0B / 0B 2
b2c3d4e5f6g7 mysql 1.23% 150.5MiB / 7.777GiB 1.89% 5.6kB / 2.3kB 12.3MB / 0B 35
c3d4e5f6g7h8 redis 0.12% 8.123MiB / 7.777GiB 0.10% 890B / 0B 0B / 0B 4
# 查看特定容器
docker stats nginx mysql
# 不刷新显示
docker stats --no-stream
# 自定义格式
docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
# 输出
CONTAINER CPU % MEM USAGE / LIMIT
nginx 0.50% 5.234MiB / 7.777GiB
mysql 1.23% 150.5MiB / 7.777GiB
redis 0.12% 8.123MiB / 7.777GiB
指标说明:
监控指标:
├─ CPU %: CPU使用率
├─ MEM USAGE / LIMIT: 内存使用/限制
├─ MEM %: 内存使用率
├─ NET I/O: 网络IO
├─ BLOCK I/O: 磁盘IO
└─ PIDS: 进程数
CPU使用率计算:
CPU % = (容器CPU时间 / 系统CPU时间) × 100%
内存使用率计算:
MEM % = (容器内存使用 / 内存限制) × 100%
查看容器进程:
# 查看容器进程
docker top nginx
# 输出
UID PID PPID C STIME TTY TIME CMD
root 12345 12340 0 10:00 ? 00:00:00 nginx: master process nginx -g daemon off;
systemd+ 12346 12345 0 10:00 ? 00:00:00 nginx: worker process
# 查看特定用户进程
docker top nginx -u root
# 查看完整命令
docker top nginx -eo pid,cmd
查看容器详情:
# 查看容器状态
docker inspect --format '{{.State.Status}}' nginx
# 输出
running
# 查看容器IP
docker inspect --format '{{.NetworkSettings.IPAddress}}' nginx
# 输出
172.17.0.2
# 查看容器资源限制
docker inspect --format 'CPU: {{.HostConfig.CpuQuota}}, Memory: {{.HostConfig.Memory}}' nginx
# 输出
CPU: 100000, Memory: 536870912
# 查看容器挂载点
docker inspect --format '{{.Mounts}}' nginx
# 查看容器健康检查
docker inspect --format '{{.State.Health.Status}}' nginx
启动cAdvisor:
# 启动cAdvisor容器
docker run -d \
--name=cadvisor \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:ro \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/dev/disk/:/dev/disk:ro \
--publish=8080:8080 \
--detach=true \
--privileged \
--device=/dev/kmsg \
google/cadvisor:latest
# 访问Web界面
http://localhost:8080
# 查看容器指标
curl http://localhost:8080/metrics
Docker Compose部署:
version: '3.8'
services:
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
restart: always
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
privileged: true
devices:
- /dev/kmsg
指标类型:
容器指标:
├─ CPU:
│ ├─ container_cpu_usage_seconds_total
│ ├─ container_cpu_system_seconds_total
│ └─ container_cpu_user_seconds_total
│
├─ Memory:
│ ├─ container_memory_usage_bytes
│ ├─ container_memory_max_usage_bytes
│ └─ container_memory_cache
│
├─ Network:
│ ├─ container_network_receive_bytes_total
│ ├─ container_network_transmit_bytes_total
│ └─ container_network_receive_errors_total
│
├─ Filesystem:
│ ├─ container_fs_usage_bytes
│ ├─ container_fs_limit_bytes
│ └─ container_fs_io_time_seconds_total
│
└─ Processes:
├─ container_processes
└─ container_threads
docker-compose.yml:
version: '3.8'
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: always
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
restart: always
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: always
ports:
- "9100:9100"
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
volumes:
prometheus_data:
prometheus.yml:
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'cadvisor'
static_configs:
- targets: ['cadvisor:8080']
- job_name: 'node-exporter'
static_configs:
- targets: ['node-exporter:9100']
添加Grafana服务:
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: always
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_INSTALL_PLUGINS=
depends_on:
- prometheus
volumes:
grafana_data:
配置数据源:
1. 访问Grafana: http://localhost:3000
2. 登录: admin/admin
3. 添加数据源:
- Name: Prometheus
- Type: Prometheus
- URL: http://prometheus:9090
- Access: Server (default)
4. 保存并测试
导入Dashboard:
1. 点击 "+" -> "Import"
2. 输入Dashboard ID:
- Docker监控: 179 (Docker and system monitoring)
- 容器监控: 11600 (Docker Container)
- 主机监控: 1860 (Node Exporter Full)
3. 点击 "Load"
4. 选择数据源: Prometheus
5. 点击 "Import"
告警规则配置:
# prometheus/alert.rules.yml
groups:
- name: docker_alerts
rules:
- alert: ContainerCpuUsage
expr: (sum(rate(container_cpu_usage_seconds_total{name!=""}[5m])) by (name)) * 100 > 80
for: 5m
labels:
severity: warning
annotations:
summary: "Container CPU usage is high"
description: "Container {{ $labels.name }} CPU usage is {{ $value }}%"
- alert: ContainerMemoryUsage
expr: (sum(container_memory_usage_bytes{name!=""}) by (name) / sum(container_spec_memory_limit_bytes{name!=""}) by (name)) * 100 > 80
for: 5m
labels:
severity: warning
annotations:
summary: "Container memory usage is high"
description: "Container {{ $labels.name }} memory usage is {{ $value }}%"
- alert: ContainerKilled
expr: time() - container_last_seen{name!=""} > 60
for: 1m
labels:
severity: critical
annotations:
summary: "Container has been killed"
description: "Container {{ $labels.name }} has been killed"
- alert: ContainerRestart
expr: increase(container_restart_count{name!=""}[1h]) > 3
for: 5m
labels:
severity: warning
annotations:
summary: "Container restart frequently"
description: "Container {{ $labels.name }} has restarted {{ $value }} times in the last hour"
Alertmanager配置:
# alertmanager.yml
global:
resolve_timeout: 5m
smtp_smarthost: 'smtp.example.com:587'
smtp_from: 'alertmanager@example.com'
smtp_auth_username: 'alertmanager@example.com'
smtp_auth_password: 'password'
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'team-email'
receivers:
- name: 'team-email'
email_configs:
- to: 'team@example.com'
send_resolved: true
查看容器日志:
# 查看容器日志
docker logs nginx
# 实时查看日志
docker logs -f nginx
# 查看最后100行
docker logs --tail 100 nginx
# 查看指定时间范围的日志
docker logs --since 2024-01-01T00:00:00 nginx
docker logs --until 2024-01-02T00:00:00 nginx
# 查看最近30分钟的日志
docker logs --since 30m nginx
# 添加时间戳
docker logs -t nginx
# 查看容器日志详情
docker inspect --format '{{.HostConfig.LogConfig.Type}}' nginx
日志格式:
日志格式:
┌──────────────────┬──────────────┬──────────────┐
│ 驱动 │ 特点 │ 适用场景 │
├──────────────────┼──────────────┼──────────────┤
│ json-file │ 默认驱动 │ 单机环境 │
│ syslog │ 系统日志 │ 集中管理 │
│ journald │ systemd日志 │ systemd系统 │
│ fluentd │ 日志收集 │ 大规模环境 │
│ awslogs │ AWS CloudWatch│ AWS环境 │
│ splunk │ Splunk平台 │ 企业环境 │
│ gelf │ Graylog │ Graylog环境 │
│ none │ 禁用日志 │ 临时容器 │
└──────────────────┴──────────────┴──────────────┘
配置日志驱动:
# 使用json-file驱动(默认)
docker run -d \
--name nginx \
--log-driver json-file \
--log-opt max-size=10m \
--log-opt max-file=3 \
nginx
# 使用syslog驱动
docker run -d \
--name nginx \
--log-driver syslog \
--log-opt syslog-address=tcp://192.168.1.100:514 \
--log-opt syslog-facility=daemon \
nginx
# 使用fluentd驱动
docker run -d \
--name nginx \
--log-driver fluentd \
--log-opt fluentd-address=localhost:24224 \
--log-opt tag=docker.{{.Name}} \
nginx
# 禁用日志
docker run -d \
--name nginx \
--log-driver none \
nginx
daemon.json配置:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3",
"labels": "production",
"env": "os,customer"
}
}
ELK Stack组成:
┌─────────────────────────────────────────┐
│ ELK Stack架构 │
├─────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────┐ │
│ │ Docker容器 │ │
│ │ (日志源) │ │
│ └──────────────┬──────────────────┘ │
│ │ │
│ ↓ │
│ ┌─────────────────────────────────┐ │
│ │ Filebeat/Fluentd │ │
│ │ (日志收集) │ │
│ └──────────────┬──────────────────┘ │
│ │ │
│ ↓ │
│ ┌─────────────────────────────────┐ │
│ │ Logstash │ │
│ │ (日志处理) │ │
│ └──────────────┬──────────────────┘ │
│ │ │
│ ↓ │
│ ┌─────────────────────────────────┐ │
│ │ Elasticsearch │ │
│ │ (日志存储) │ │
│ └──────────────┬──────────────────┘ │
│ │ │
│ ↓ │
│ ┌─────────────────────────────────┐ │
│ │ Kibana │ │
│ │ (日志展示) │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
docker-compose.yml:
version: '3.8'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0
container_name: elasticsearch
restart: always
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms512m -Xmx512m
- xpack.security.enabled=false
ports:
- "9200:9200"
- "9300:9300"
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
networks:
- elk
logstash:
image: docker.elastic.co/logstash/logstash:7.17.0
container_name: logstash
restart: always
ports:
- "5044:5044"
- "9600:9600"
volumes:
- ./logstash/pipeline:/usr/share/logstash/pipeline
networks:
- elk
depends_on:
- elasticsearch
kibana:
image: docker.elastic.co/kibana/kibana:7.17.0
container_name: kibana
restart: always
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
networks:
- elk
depends_on:
- elasticsearch
filebeat:
image: docker.elastic.co/beats/filebeat:7.17.0
container_name: filebeat
restart: always
user: root
volumes:
- ./filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- elk
depends_on:
- logstash
volumes:
elasticsearch_data:
networks:
elk:
Logstash配置:
# logstash/pipeline/logstash.conf
input {
beats {
port => 5044
}
}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
mutate {
remove_field => [ "host" ]
}
}
output {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "docker-logs-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
}
Filebeat配置:
# filebeat/filebeat.yml
filebeat.inputs:
- type: container
paths:
- '/var/lib/docker/containers/*/*.log'
processors:
- add_docker_metadata:
host: "unix:///var/run/docker.sock"
- decode_json_fields:
fields: ["message"]
target: "json"
overwrite_keys: true
output.logstash:
hosts: ["logstash:5044"]
logging.json: true
logging.metrics.enabled: false
访问Kibana:
1. 访问Kibana: http://localhost:5601
2. 创建索引模式:
- Management -> Stack Management -> Index Patterns
- 点击 "Create index pattern"
- 输入索引模式: docker-logs-*
- 选择时间字段: @timestamp
- 点击 "Create index pattern"
3. 查看日志:
- Discover -> 选择索引模式
- 设置时间范围
- 搜索日志
4. 创建仪表板:
- Dashboard -> Create new dashboard
- 添加可视化图表
- 保存仪表板
常用查询:
# 查询特定容器日志
container.name: "nginx"
# 查询错误日志
log.level: "ERROR"
# 查询特定时间范围
@timestamp: [2024-01-01 TO 2024-01-02]
# 组合查询
container.name: "nginx" AND log.level: "ERROR"
# 通配符查询
message: *error*
日志格式规范:
{
"timestamp": "2024-01-01T00:00:00.000Z",
"level": "INFO",
"logger": "com.example.app",
"message": "User login successfully",
"context": {
"user_id": "12345",
"ip": "192.168.1.100",
"user_agent": "Mozilla/5.0..."
},
"container": {
"name": "myapp",
"id": "a1b2c3d4e5f6",
"image": "myapp:v1.0"
},
"host": {
"name": "docker-host",
"ip": "192.168.1.10"
}
}
日志级别规范:
日志级别:
├─ ERROR: 错误,需要立即处理
├─ WARN: 警告,需要注意
├─ INFO: 信息,重要操作
├─ DEBUG: 调试,调试信息
└─ TRACE: 跟踪,详细跟踪
使用原则:
✅ 生产环境: INFO及以上
✅ 测试环境: DEBUG及以上
✅ 开发环境: TRACE及以上
✅ 避免过多DEBUG日志
✅ 关键操作记录INFO日志
✅ 错误必须记录ERROR日志
配置日志轮转:
# 容器级别日志轮转
docker run -d \
--name nginx \
--log-driver json-file \
--log-opt max-size=10m \
--log-opt max-file=3 \
nginx
# 全局日志轮转
# /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
# 重启Docker
systemctl restart docker
日志清理脚本:
#!/bin/bash
# clean-logs.sh
# 清理Docker日志
LOG_DIR="/var/lib/docker/containers"
# 查找并清理大于100MB的日志文件
find $LOG_DIR -name "*-json.log" -size +100M -exec truncate -s 0 {} \;
# 清理旧日志文件
find $LOG_DIR -name "*-json.log" -mtime +30 -exec truncate -s 0 {} \;
echo "Logs cleaned successfully"
监控Docker事件:
# 监控所有事件
docker events
# 输出
2024-01-01T00:00:00.000000000Z container create a1b2c3d4e5f6 (image=nginx, name=nginx)
2024-01-01T00:00:01.000000000Z container start a1b2c3d4e5f6 (image=nginx, name=nginx)
2024-01-01T00:00:02.000000000Z container die a1b2c3d4e5f6 (exitCode=0, image=nginx, name=nginx)
# 过滤事件
docker events --filter 'type=container'
docker events --filter 'event=start'
docker events --filter 'container=nginx'
# 时间范围过滤
docker events --since '2024-01-01'
docker events --until '2024-01-02'
# 格式化输出
docker events --format '{{.Time}} {{.Action}} {{.Actor.ID}}'
使用perf:
# 安装perf
apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r`
# 查看容器进程
docker top nginx
# 性能分析
perf top -p <pid>
# 记录性能数据
perf record -g -p <pid> -- sleep 10
# 查看报告
perf report
使用strace:
# 安装strace
apt-get install strace
# 跟踪容器进程
docker top nginx
strace -p <pid>
# 跟踪系统调用
strace -c -p <pid>
# 输出
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
45.23 0.001234 12 100 0 read
30.15 0.000823 15 55 0 write
24.62 0.000672 18 37 0 open
------ ----------- ----------- --------- --------- ----------------
100.00 0.002729 192 0 total
CPU限制与调优:
# 限制CPU使用
docker run -d \
--name nginx \
--cpus="1.5" \
nginx
# 设置CPU权重
docker run -d \
--name nginx \
--cpu-shares=512 \
nginx
# 绑定CPU核心
docker run -d \
--name nginx \
--cpuset-cpus="0,1" \
nginx
# CPU配额
docker run -d \
--name nginx \
--cpu-quota=50000 \
--cpu-period=100000 \
nginx
CPU性能监控:
# 查看CPU使用
docker stats --no-stream nginx
# 查看CPU限制
docker inspect --format '{{.HostConfig.NanoCpus}}' nginx
# 查看CPU配额
docker inspect --format '{{.HostConfig.CpuQuota}}' nginx
内存限制与调优:
# 限制内存使用
docker run -d \
--name nginx \
--memory="512m" \
--memory-swap="1g" \
nginx
# 设置内存预留
docker run -d \
--name nginx \
--memory-reservation="256m" \
nginx
# 设置OOM优先级
docker run -d \
--name nginx \
--oom-kill-disable=true \
nginx
# 设置内存swappiness
docker run -d \
--name nginx \
--memory-swappiness=0 \
nginx
内存性能监控:
# 查看内存使用
docker stats --no-stream nginx
# 查看内存限制
docker inspect --format '{{.HostConfig.Memory}}' nginx
# 查看内存详情
docker inspect --format '{{json .HostConfig.MemoryReservation}}' nginx
IO限制与调优:
# 限制磁盘IO
docker run -d \
--name nginx \
--device-read-bps=/dev/sda:10mb \
--device-write-bps=/dev/sda:10mb \
nginx
# 限制IO操作数
docker run -d \
--name nginx \
--device-read-iops=/dev/sda:1000 \
--device-write-iops=/dev/sda:1000 \
nginx
# 设置IO权重
docker run -d \
--name nginx \
--blkio-weight=500 \
nginx
监控层次:
├─ 应用层: APM、业务指标
├─ 容器层: 资源、状态、网络
├─ 主机层: 系统、网络、存储
└─ 集群层: 集群状态、服务健康
监控工具:
├─ Docker原生: stats, top, inspect
├─ cAdvisor: 容器监控
├─ Prometheus: 指标收集
├─ Grafana: 可视化展示
└─ ELK Stack: 日志管理
日志类型:
├─ 容器日志: stdout/stderr
├─ 应用日志: 文件日志
├─ 系统日志: syslog/journald
└─ 审计日志: 操作审计
日志工具:
├─ Docker logs: 原生日志查看
├─ Filebeat: 日志收集
├─ Logstash: 日志处理
├─ Elasticsearch: 日志存储
└─ Kibana: 日志展示
性能指标:
├─ CPU: 使用率、负载
├─ Memory: 使用率、缓存
├─ IO: 读写速度、IOPS
└─ Network: 带宽、延迟
性能工具:
├─ docker stats: 资源监控
├─ perf: 性能分析
├─ strace: 系统调用跟踪
└─ docker events: 事件监控
监控原则:
✅ 多层次监控
✅ 实时监控
✅ 历史数据分析
✅ 告警及时响应
✅ 可视化展示
监控指标:
✅ 可用性监控
✅ 性能监控
✅ 资源监控
✅ 错误监控
✅ 容量监控
日志原则:
✅ 结构化日志
✅ 合理的日志级别
✅ 日志轮转
✅ 集中管理
✅ 日志安全
日志规范:
✅ 统一格式
✅ 包含上下文
✅ 避免敏感信息
✅ 合理保留周期
✅ 定期清理
下一章: Docker性能调优
将学习:
容器监控: 使用docker stats监控容器资源使用,分析CPU和内存使用情况。
日志查看: 使用docker logs查看容器日志,并使用grep过滤错误日志。
cAdvisor部署: 部署cAdvisor,查看容器监控指标。
Prometheus+Grafana: 部署Prometheus和Grafana,创建Docker监控仪表板。
ELK Stack: 部署ELK Stack,收集和分析容器日志。
告警配置: 配置Prometheus告警规则,当容器CPU使用率超过80%时发送告警。
完整监控方案: 设计一个完整的Docker监控方案,要求:
性能分析: 对一个性能问题的容器进行分析,找出性能瓶颈并优化。