Trả lời nhanh: Prometheus monitor Docker alerts phải bắt đầu từ metric có đơn vị, label bounded, baseline và ngưỡng alert gắn với owner. Bài này kèm query, cách đọc log/trace và điều kiện giảm nhiễu mà không xoá dữ liệu.
Phạm vi: Bài áp dụng cho Metric source trong môi trường staging/standalone. Kiểm tra Nginx/Docker/OS/database và phiên bản CLI thực tế trước khi chạy; không đưa credential thật vào lệnh, log hay artifact.

Tín hiệu cần đối chiếu: Metric source; alert rules; burn-rate; metric/label; query; ngưỡng cảnh báo; owner/runbook
Metric source — thao tác và bằng chứng
Start with metric provenance: cAdvisor/container metrics describe container usage; node_exporter describes host filesystem and memory. Define bounded labels (`job`, `instance`, `container`, `namespace`) and a scrape interval before writing a rule. Query a known container with `rate(container_cpu_usage_seconds_total{container!=""}[5m])`; an empty series means the metric/label is absent, not zero CPU. Record Prometheus and exporter versions in the rule review. Prometheus—Alerting rules
Use recording rules when the same aggregation feeds several alerts, and test them with `promtool test rules`. Never add user IDs or full URLs as labels: cardinality can exhaust the TSDB while the alert still looks green. Expected evidence is a labeled series and a dashboard link to the owner/runbook. (prometheus-alert-docker-cpu-memory-restart-disk · outline 1)
Với Metric source, ghi lại input và phiên bản CLI trước khi chạy; sau đó đối chiếu từng tín hiệu metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate trong stdout, stderr hoặc log audit. Kết quả đạt phải chỉ ra trạng thái và phạm vi tài nguyên; kết quả lỗi phải có chuỗi nhận diện để người trực ca biết bước khoanh vùng kế tiếp. Gắn transcript với prometheus-alert-docker-cpu-memory-restart-disk, commit/config hash, owner và timestamp. Không dùng exit code đơn độc làm bằng chứng. Che token, private key, cookie và PII trước khi lưu artifact; giữ bản raw trong kho có quyền hạn nếu incident yêu cầu.
alert rules — thao tác và bằng chứng
An alert rule needs an expression, `for` duration, severity, labels and annotations that explain the first action. For CPU, alert on sustained container rate relative to a declared limit; for memory, compare working set with `container_spec_memory_limit_bytes` and handle missing/zero limits explicitly. A restart alert should include pod/container labels and link to `kubectl describe`/Docker state. Prometheus—Alerting rules
Validate syntax and behavior with `promtool check rules` and a fixture that fires then recovers. Expected state transitions are pending→firing after the `for` window, then resolved. A rule that fires on one scrape or has no owner is not production-ready even if the expression is valid PromQL. (prometheus-alert-docker-cpu-memory-restart-disk · outline 2)
Một lần kiểm tra alert rules chỉ có giá trị khi lặp lại được. Chốt workload, hostname, digest hoặc schema, rồi chạy lệnh tương ứng với prometheus-alert-docker-cpu-memory-restart-disk. Đối chiếu các tín hiệu bắt buộc (metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate) với expected output và error signature; nếu thiếu dữ liệu, ghi unknown. So sánh baseline trước/sau trong cùng cửa sổ và nêu rõ điều gì không được suy ra từ phép đo. Artifact thay đổi cần ghi config diff đã redact, người chịu trách nhiệm và thời điểm hết hạn exception trước khi promote.
burn-rate — thao tác và bằng chứng
Burn-rate should relate observed error budget consumption to an SLO window, not simply mirror CPU. For an HTTP availability SLO, calculate the bad-request ratio over short and long windows and alert when both exceed the chosen multiplier. Record the SLO target, window (for example 30 days), and threshold in the annotation. Expected output contains the same `job`/route labels used by the SLI. Prometheus—Alerting rules
Test a synthetic error burst and confirm that the short-window alert fires while a single scrape spike does not. Keep the query and threshold versioned; if traffic is too low for a stable ratio, mark the signal unknown instead of paging on noise. Route the alert to the service owner and incident channel. (prometheus-alert-docker-cpu-memory-restart-disk · outline 3)
Đừng gộp burn-rate vào một checklist chung. Tạo một phép thử nhỏ có điều kiện, ghi command, exit code, metric và log line riêng cho prometheus-alert-docker-cpu-memory-restart-disk. Các marker metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate phải xuất hiện ở đúng section để người đọc có thể truy từ claim tới evidence. Khi kết quả không khớp expected (Output của prometheus-alert-docker-cpu-memory-restart-disk phải có trạng thái success và error phân biệt bằng exit code/stderr; unknown flag, permission denied hoặc timeout dẫn tới nhánh khoanh vùng riêng.), dừng rollout/restore, giữ hiện trường và mở issue thay vì sửa nhiều biến cùng lúc. Artifact công khai chỉ chứa giá trị đã che và hash kiểm chứng.

restart loop — thao tác và bằng chứng
A restart loop requires reason, not just count. Join `increase(container_restart_count[15m])` with container state/exit code and recent logs; distinguish OOMKilled, probe failure, image pull error and deliberate deploy. Expected evidence is a restart count plus a matching reason and timestamp. A count without a reason sends the operator to the wrong layer. Prometheus—Alerting rules
Set a `for` window long enough to survive one planned restart and silence during a recorded maintenance window. If restarts exceed the threshold, stop rollout, capture `docker inspect`/`kubectl describe` and route to the runbook. Do not delete the container before collecting its last state. (prometheus-alert-docker-cpu-memory-restart-disk · outline 4)
Trong runbook của prometheus-alert-docker-cpu-memory-restart-disk, restart loop là điểm quyết định: allow/deny, ready/not-ready, pass/fail hoặc baseline/regression. Định lượng bằng tín hiệu metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate, ghi phiên bản và phạm vi áp dụng, rồi nêu ngưỡng chuyển sang rollback. Một output xanh nhưng dependency hoặc health đỏ vẫn là fail. Sau khi sửa, chạy lại cùng lệnh và lưu kết quả cạnh config hash; revoke/rotate credential trước khi dọn mọi bản sao chứa secret.
OOM — thao tác và bằng chứng
For OOM, alert on working set/limit and corroborate with kernel or container state; a missing memory limit must not divide to a misleading zero. Capture `OOMKilled=true`, limit bytes and restart timestamp. For disk, alert on available bytes and inodes with mount/device labels, then inspect Docker logs, overlay2 and volumes before pruning. Expected evidence names the mount and owner. Prometheus—Alerting rules
Set thresholds from a capacity baseline and retention plan. A full disk can make Prometheus itself fail, so keep a host-level emergency check outside the affected volume. If OOM or disk crosses the stop boundary, preserve logs/TSDB and apply the specific runbook action rather than raising every limit. (prometheus-alert-docker-cpu-memory-restart-disk · outline 5)
Với OOM, ghi lại input và phiên bản CLI trước khi chạy; sau đó đối chiếu từng tín hiệu metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate trong stdout, stderr hoặc log audit. Kết quả đạt phải chỉ ra trạng thái và phạm vi tài nguyên; kết quả lỗi phải có chuỗi nhận diện để người trực ca biết bước khoanh vùng kế tiếp. Gắn transcript với prometheus-alert-docker-cpu-memory-restart-disk, commit/config hash, owner và timestamp. Không dùng exit code đơn độc làm bằng chứng. Che token, private key, cookie và PII trước khi lưu artifact; giữ bản raw trong kho có quyền hạn nếu incident yêu cầu.
disk — thao tác và bằng chứng
Route alerts by stable service/owner labels; use a time-bounded silence only for an approved maintenance window. Include a dashboard and runbook URL in annotations. Test notification delivery with a synthetic firing alert and verify deduplication. Expected output shows receiver, severity, fingerprint and resolved timestamp; do not put secret webhook URLs in the rule file. Prometheus—Alerting rules
Rollback a noisy rule by restoring the previous rule commit and retaining the raw time series. Do not silence indefinitely or delete TSDB blocks to hide a disk alert. When an alert is false positive, fix the metric/label or threshold and record the evidence that justifies the change. (prometheus-alert-docker-cpu-memory-restart-disk · outline 6)
Một lần kiểm tra disk chỉ có giá trị khi lặp lại được. Chốt workload, hostname, digest hoặc schema, rồi chạy lệnh tương ứng với prometheus-alert-docker-cpu-memory-restart-disk. Đối chiếu các tín hiệu bắt buộc (metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate) với expected output và error signature; nếu thiếu dữ liệu, ghi unknown. So sánh baseline trước/sau trong cùng cửa sổ và nêu rõ điều gì không được suy ra từ phép đo. Artifact thay đổi cần ghi config diff đã redact, người chịu trách nhiệm và thời điểm hết hạn exception trước khi promote.
routing/silence — thao tác và bằng chứng
The runbook link must tell the on-call what to run first (`docker stats`, `docker inspect`, `df -h`, or the relevant PromQL), what output means, and when to escalate. Assign an owner and review date. Store rule tests beside the configuration so a refactor cannot remove the alert silently. Evidence includes the rule hash and promtool result. Prometheus—Alerting rules
A useful alert closes when the SLI returns inside the threshold for the declared window and the underlying cause is recorded. If the metric disappears, page the monitoring owner separately; treating no data as healthy is an observability failure. Keep snapshots and annotations for the post-incident review. (prometheus-alert-docker-cpu-memory-restart-disk · outline 7)
Đừng gộp routing/silence vào một checklist chung. Tạo một phép thử nhỏ có điều kiện, ghi command, exit code, metric và log line riêng cho prometheus-alert-docker-cpu-memory-restart-disk. Các marker metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate phải xuất hiện ở đúng section để người đọc có thể truy từ claim tới evidence. Khi kết quả không khớp expected (Output của prometheus-alert-docker-cpu-memory-restart-disk phải có trạng thái success và error phân biệt bằng exit code/stderr; unknown flag, permission denied hoặc timeout dẫn tới nhánh khoanh vùng riêng.), dừng rollout/restore, giữ hiện trường và mở issue thay vì sửa nhiều biến cùng lúc. Artifact công khai chỉ chứa giá trị đã che và hash kiểm chứng.
runbook link — thao tác và bằng chứng
Chạy query `increase(kube_pod_container_status_restarts_total[15m]) > 2` trên time range nhỏ rồi đối chiếu log/trace. metric/label và query phải dẫn đến một hành động cụ thể trong runbook. Prometheus—Alerting rules
Mỗi alert cần owner, severity, link runbook và điều kiện đóng. Dashboard không có hành động tiếp theo chỉ là bảng thống kê. (prometheus-alert-docker-cpu-memory-restart-disk · outline 8)
Trong runbook của prometheus-alert-docker-cpu-memory-restart-disk, runbook link là điểm quyết định: allow/deny, ready/not-ready, pass/fail hoặc baseline/regression. Định lượng bằng tín hiệu metric/label, query, ngưỡng cảnh báo, owner/runbook, Metric source, alert rules, burn-rate, ghi phiên bản và phạm vi áp dụng, rồi nêu ngưỡng chuyển sang rollback. Một output xanh nhưng dependency hoặc health đỏ vẫn là fail. Sau khi sửa, chạy lại cùng lệnh và lưu kết quả cạnh config hash; revoke/rotate credential trước khi dọn mọi bản sao chứa secret.
Recipe lệnh/config cho prometheus-alert-docker-cpu-memory-restart-disk
Chạy ở staging cho Prometheus monitor Docker alerts với hostname, path và digest đã thay bằng giá trị không nhạy cảm. Lưu exit code cùng stdout/stderr đã redact và gắn artifact với prometheus-alert-docker-cpu-memory-restart-disk.
rate(container_cpu_usage_seconds_total{container!=""}[5m]) > 0.8
increase(kube_pod_container_status_restarts_total[15m]) > 2
node_filesystem_avail_bytes / node_filesystem_size_bytes < 0.1
Expected output và error signature — prometheus-alert-docker-cpu-memory-restart-disk
Output của prometheus-alert-docker-cpu-memory-restart-disk phải có trạng thái success và error phân biệt bằng exit code/stderr; unknown flag, permission denied hoặc timeout dẫn tới nhánh khoanh vùng riêng. Đối chiếu thêm version, timestamp, health/readiness và log liên quan; output minh họa không phải kết quả production.

Rollback và stop boundary của prometheus-alert-docker-cpu-memory-restart-disk
Dừng thay đổi prometheus-alert-docker-cpu-memory-restart-disk khi alert storm, cardinality hoặc sampling làm mất tín hiệu. Giữ log/trace, rollback rule/query và silence có thời hạn thay vì xoá dữ liệu.
Failure mode cần tránh ở Metric source
- Metric source: thay đổi nhiều biến cùng lúc nên không biết nguyên nhân.
- Metric source: đọc exit code nhưng bỏ qua health, dependency hoặc error signature.
- Metric source: lưu secret/PII trong log, image layer, backup hoặc ảnh chụp.
- Metric source: rollback nhầm failure domain làm blast radius lớn hơn.
Đọc tiếp trong cùng cụm Linux/DevOps — prometheus-alert-docker-cpu-memory-restart-disk
giam sat ram swap linux server tranh cham he thong và docker healthcheck production cau hinh dung
Nguồn chính thức cho prometheus-alert-docker-cpu-memory-restart-disk
Prometheus—Alerting rules; cAdvisor
FAQ theo đúng chủ đề Prometheus monitor Docker alerts
Metric source áp dụng cho phiên bản nào?
Kiểm tra version/tool và topology trước khi áp dụng Metric source. Chạy recipe ở trên trong staging; nếu expected/error signature khác, dừng và cập nhật runbook thay vì copy nguyên lệnh.
alert rules áp dụng cho phiên bản nào?
Kiểm tra version/tool và topology trước khi áp dụng alert rules. Chạy recipe ở trên trong staging; nếu expected/error signature khác, dừng và cập nhật runbook thay vì copy nguyên lệnh.
burn-rate áp dụng cho phiên bản nào?
Kiểm tra version/tool và topology trước khi áp dụng burn-rate. Chạy recipe ở trên trong staging; nếu expected/error signature khác, dừng và cập nhật runbook thay vì copy nguyên lệnh.
restart loop áp dụng cho phiên bản nào?
Kiểm tra version/tool và topology trước khi áp dụng restart loop. Chạy recipe ở trên trong staging; nếu expected/error signature khác, dừng và cập nhật runbook thay vì copy nguyên lệnh.
Cập nhật prometheus-alert-docker-cpu-memory-restart-disk: 08/09/2026. Nội dung là runbook tham khảo; phải kiểm tra phiên bản, nguồn chính thức và rollback trong môi trường thật trước khi áp dụng. Safety boundary: Không thay thế tư vấn chuyên môn; kiểm tra tình huống thực tế trước khi áp dụng.
