prometheus

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prometheus

Prometheus

Prometheus is the cloud-native standard for metric collection. Prometheus 3.0 (2025) features a modern UI, Native Histograms, and direct OpenTelemetry (OTLP) ingestion.
Prometheus是云原生领域指标采集的标准工具。Prometheus 3.0(2025版)具备现代化UI、Native Histograms(原生直方图)以及直接接入OpenTelemetry (OTLP)的能力。

When to Use

适用场景

  • Kubernetes: Standard monitoring stack (Prometheus Operator).
  • White-box Monitoring: Measuring internal state (heap usage, request count) via endpoints.
  • Alerting: Alertmanager handles de-duplication and routing to Slack/PagerDuty.
  • Kubernetes:标准监控栈(Prometheus Operator)。
  • 白盒监控:通过端点测量内部状态(如堆内存使用量、请求计数)。
  • 告警:Alertmanager负责告警去重,并将告警路由至Slack/PagerDuty等平台。

Quick Start

快速开始

yaml
undefined
yaml
undefined

prometheus.yml

prometheus.yml

global: scrape_interval: 15s
scrape_configs:
  • job_name: "node" static_configs:
    • targets: ["localhost:9100"]
undefined
global: scrape_interval: 15s
scrape_configs:
  • job_name: "node" static_configs:
    • targets: ["localhost:9100"]
undefined

Core Concepts

核心概念

Time Series Format

时间序列格式

Metrics are identified by name and label pairs.
http_requests_total{method="POST", handler="/api"}
指标由名称和标签对标识。
http_requests_total{method="POST", handler="/api"}

PromQL

PromQL

Powerful query language.
rate(http_requests_total[5m])
功能强大的查询语言。
rate(http_requests_total[5m])

Pull Model

拉取模型

Prometheus scrapes targets. Apps do not push to Prometheus (usually).
Prometheus主动拉取目标的指标数据。通常情况下,应用无需向Prometheus推送数据。

Best Practices (2025)

2025年最佳实践

Do:
  • Use High-Cardinality wisely: Native Histograms in v3.0 help, but keep labels bounded.
  • Use Service Monitors: In K8s, use the Operator's
    ServiceMonitor
    CRD instead of manual config.
  • Use OTLP: Ingest OTel metrics directly if you are transitioning standards.
Don't:
  • Don't use for logs: It is for metrics only. Use Loki for logs.
推荐做法
  • 合理使用高基数指标:3.0版本的Native Histograms有所优化,但仍需控制标签数量。
  • 使用Service Monitors:在K8s环境中,使用Operator的
    ServiceMonitor
    CRD而非手动配置。
  • 使用OTLP:如果正在迁移监控标准,可直接接入OTel指标。
不推荐做法
  • 不要用于日志采集:Prometheus仅适用于指标采集,日志采集请使用Loki。

References

参考资料