Monitoring
一句话解释
Monitoring 是练习的 collecting and analyzing metrics, logs, and traces 到理解系统 health and 性能.
用大白话说
Monitoring 是about knowing what is happening in your systems at all times。 It involves collecting data — metrics (CPU, memory, request rates), logs (application output), and traces (request flows) — and making it visible through dashboards and alerts.
Good monitoring answers questions like: Is the service up? How fast is it responding? Are there errors? Is CPU usage high? Are we running out of disk space? Instead of waiting for users to report problems, monitoring lets you detect and fix issues proactively.
The monitoring stack typically includes a metrics collector (Prometheus), a visualization tool (Grafana), a log aggregator (ELK or Loki), and an alerting system that notifies the team when something goes wrong.
示例
# Prometheus scrape config
scrape_configs:
- job_name: 'my-app'
metrics_path: '/metrics'
static_configs:
- targets: ['my-app:8080']这个 Prometheus 配置 scrapes metrics 从 my-app service 每个 15 seconds (默认 interval).
工作原理
- Your application exposes metrics (e.g., /metrics endpoint).
- A collector (Prometheus) scrapes metrics at regular intervals.
- Metrics are stored in a time-series database.
- Dashboards (Grafana) visualize the data; alerts fire when thresholds are crossed.
常见混淆
容易混淆的对象: Logging
关键区别: Monitoring aggregates metrics (数字如 CPU usage) for dashboards and alerts; logging 记录 discrete 事件 (文本记录) for 调试.
相关术语
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。