fix(content): harden Docker examples

This commit is contained in:
yeasy
2026-05-23 21:28:59 -07:00
parent 6a55219310
commit 28c23d003e
6 changed files with 42 additions and 19 deletions
@@ -66,8 +66,11 @@ docker stats nginx redis
# 一次性输出不进入交互模式
docker stats --no-stream
# 指定刷新间隔(单位:秒,默认 1 秒
docker stats --no-stream --interval 2
# 每 2 秒采样一次(docker stats 没有 --interval 选项
while true; do
docker stats --no-stream
sleep 2
done
# 格式化输出(使用 Go 模板)
docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" --no-stream
@@ -182,6 +185,8 @@ services:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- monitoring
@@ -258,7 +263,7 @@ scrape_configs:
- job_name: 'docker'
static_configs:
- targets: ['localhost:9323']
- targets: ['host.docker.internal:9323']
```
**常用的 Prometheus 查询PromQL**
@@ -276,7 +281,7 @@ rate(container_network_receive_bytes_total[5m]) / 1024 / 1024
rate(container_network_transmit_bytes_total[5m]) / 1024 / 1024
# 容器磁盘读取速率(MB/s
rate(container_fs_io_current[5m]) / 1024 / 1024
rate(container_fs_reads_bytes_total[5m]) / 1024 / 1024
# CPU 限流情况
rate(container_cpu_cfs_throttled_seconds_total[5m])