Skip to content

Prometheus

一句话解释

Prometheus 是打开-源 monitoring and alerting 系统那个 collects metrics as 时间-级数数据 using 拉取 model.

用大白话说

Prometheus 是the most popular monitoring system in the DevOps world。 It collects and stores metrics as time-series data — each data point has a timestamp and a value, identified by a metric name and labels.

Prometheus uses a pull model: it actively scrapes metrics from your applications at regular intervals (usually 15 seconds). Your application needs to expose a /metrics endpoint in the Prometheus format. Many libraries exist to help with this.

Prometheus has its own query language called PromQL that lets you filter, aggregate, and calculate metrics. It also has a built-in alerting system — you define alert rules in YAML, and when a rule fires, it sends alerts to an Alertmanager which routes them to Slack, email, etc.

示例

yaml
# Alert rule example
groups:
  - name: example
    rules:
      - alert: HighCPUUsage
        expr: rate(cpu_seconds_total[5m]) > 0.8
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "CPU usage above 80% for 5 minutes"

这个 alert fires 当 CPU usage exceeds 80% for 5 minutes continuously.

工作原理

  1. Applications expose metrics at a /metrics endpoint.
  2. Prometheus scrapes these endpoints at configured intervals.
  3. Metrics are stored in Prometheus's time-series database.
  4. You query with PromQL and set up alert rules that fire when conditions are met.

常见混淆

  • 容易混淆的对象: Grafana

    关键区别: Prometheus collects and 存储 metrics; Grafana visualizes 它们. 它们工作 together — Prometheus 是数据源, Grafana 是 dashboard.

相关术语

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表