Phần 6 — Production checklist: Backup, alerting, troubleshooting
Ý kiến
0
Chưa có ý kiến nào. Hãy là người đầu tiên chia sẻ!
Chưa có ý kiến nào. Hãy là người đầu tiên chia sẻ!
Tổng quan series: Grafana LGTM (Loki, Tempo, Mimir) + Alloy collector + SeaweedFS object storage + Pyroscope/Beyla. Kiến trúc, hardware, thứ tự deploy.
Vì sao SeaweedFS phù hợp cho Loki/Mimir/Tempo hơn MinIO/Ceph. Kiến trúc 4 thành phần, cài đặt single-node và multi-node, replication, best practices.
Hướng dẫn đầy đủ ssh port forwarding (-L local, -R remote, -D SOCKS) và autossh để giữ tunnel luôn sống — bao gồm các tham số quan trọng (ServerAliveInterval, ExitOnForwardFailure, GatewayPorts), biến môi trường autossh, và systemd service. Mọi lệnh đã test trong Docker.
Series Observability với Grafana Stack — 6 phần:
Phần 1 — Tổng quan: Observability với Grafana LGTM, Alloy và SeaweedFS
Phần 2 — SeaweedFS: Object storage gọn nhẹ cho Loki, Mimir, Tempo
Phần 3 — Grafana Alloy: Collector duy nhất cho metrics, logs, traces
Phần 5 — Grafana, Pyroscope, Beyla: UI, profiling và auto-instrumentation
Phần 6 — Production checklist: Backup, alerting, troubleshooting ← bạn đang đọc
Stack đã chạy. Giờ là phần "phòng thủ": backup, alert, monitor stack tự nó, và những lỗi kinh điển cần tránh.
Mất 1 thứ trong danh sách này = mất luôn observability. Phải backup theo tần suất:
| Đối tượng | Tần suất | Ghi chú |
|---|---|---|
| SeaweedFS Filer metadata (Postgres) | Mỗi giờ | Mất = mất tất cả buckets |
| SeaweedFS Master state | Mỗi 6h | Volume mapping |
| Grafana dashboards + datasources | Khi đổi | Provision YAML trong git |
| Mimir ruler + alertmanager configs | Khi đổi | Trong bucket S3, nhưng nên có copy git |
| Object data (logs/metrics/traces) | Tuỳ SLA | SeaweedFS replication 001 là đủ với most case |
Stack monitor app — nhưng ai monitor stack? Phải có self-monitoring rules. Tạo file mimir/rules/observability-stack.yml:
groups:
- name: stack-health
interval: 30s
rules:
- alert: AlloyDown
expr: up{job=~"alloy.*"} == 0
for: 2m
labels: { severity: critical }
annotations:
summary: "Alloy node {{ $labels.instance }} down"
- alert: LokiIngestErrors
expr: rate(loki_distributor_ingester_appends_failures_total[5m]) > 0
for: 5m
labels: { severity: warning }
- alert: MimirIngesterMemoryHigh
expr: container_memory_usage_bytes{name=~"mimir.*"} / container_spec_memory_limit_bytes > 0.85
for: 10m
labels: { severity: warning }
- alert: SeaweedDiskAlmostFull
expr: SeaweedFS_volumeServer_disk_bytes{type="free"} / SeaweedFS_volumeServer_disk_bytes{type="total"} < 0.10
for: 15m
labels: { severity: critical }
annotations:
summary: "SeaweedFS volume {{ $labels.instance }} còn <10% disk"
- alert: TempoIngestionRateDrop
expr: rate(tempo_distributor_spans_received_total[5m]) == 0
for: 10m
labels: { severity: warning }
Công thức gần đúng cho ngân sách hardware:
| Loại | Quy tắc ngón tay cái |
|---|---|
| Logs (Loki) | ~1KB/log nén → 100GB cho 100M log/ngày, retention 30 ngày = 3TB |
| Metrics (Mimir) | ~2 byte/sample → 1M active series × 30s scrape = ~6GB/ngày, 90 ngày = ~540GB |
| Traces (Tempo) | ~500 byte/span, sample rate 1% → 1k req/s × 86400 × 0.01 × 500B = ~430MB/ngày/service |
| Profiles (Pyroscope) | ~100MB/service/ngày, retention 30 ngày = ~3GB/service |
Multiply theo số service, +50% buffer cho growth.
| Triệu chứng | Nguyên nhân thường gặp |
|---|---|
| Loki "max series" error | Label cardinality cao — có ai gắn request_id làm label? |
| Mimir OOM khi scrape | Active series vượt limit — tăng max_global_series_per_user |
| Tempo "trace not found" | Trace bị sample drop ở client, hoặc lookback hết retention |
| Grafana "no data" trên panel | Sai X-Scope-OrgID — datasource và Alloy dùng tenant khác nhau |
| SeaweedFS S3 timeout | Filer chưa kết nối được Postgres → kiểm tra filer.toml |
| Alloy CPU 100% | Loki/Tempo down → buffer đầy → backpressure. Fix root cause |
| Logs/metrics tự nhiên mất 1 khoảng | Restart Alloy không có storage.path persistent |
SeaweedFS: bật IAM (-iam.config), không dùng dummy test/test trong production. Đổi sang access key per-tenant.
TLS: terminate ở reverse proxy (Traefik/Nginx) — Grafana/Mimir/Loki/Tempo nói nhau qua plaintext trong overlay network thì OK.
Grafana: bật OAuth/OIDC, tắt user signup, set GF_AUTH_ANONYMOUS_ENABLED=false.
Multi-tenancy: enforce X-Scope-OrgID ở reverse proxy nếu có nhiều team. Không trust header từ client.
Beyla: privileged + host PID là quyền rộng — chỉ chạy trên node bạn kiểm soát.
Network: không expose port 9333 (SeaweedFS master), 8888 (Filer), 8080 (Mimir) ra public — chỉ Grafana :3000 sau auth.
SeaweedFS disk usage < 80% trên mọi volume?
Alloy nodes "up" full count? (so với count(up{job="docker_swarm_node"}))
Loki / Mimir / Tempo ingestion rate có drop bất thường không?
Backup metadata Filer có chạy đêm qua không?
Có alert nào pending lâu hơn 24h chưa được ack?
Khi 1 component nghẹt, chuyển từ monolithic sang microservice mode:
| Component | Tách khi | Cách tách |
|---|---|---|
| Mimir | > 1M active series | -target=ingester, -target=querier, -target=compactor |
| Loki | > 5TB/ngày | SimpleScalable mode (read + write tách) |
| Tempo | > 10k spans/s | Tách distributor / ingester / querier |
| SeaweedFS | > 50TB hoặc > 100M files | Thêm volume server, bật replication 002 |
Bạn đã có một observability stack production-ready: gọn nhẹ, chi phí vận hành thấp, đủ mạnh cho team nhỏ–vừa, và mở đường scale lên hàng trăm node khi cần.
Series 6 phần đến đây kết thúc. Nếu bạn triển khai theo và gặp issue cụ thể, mở Grafana Alloy UI ở :12345/graph luôn là chỗ đầu tiên cần xem.
← Phần 5: Grafana, Pyroscope, Beyla: UI, profiling và auto-instrumentation