Files
nexus/wiki/entities/Prometheus.md
2026-04-22 04:03:04 +08:00

2.5 KiB
Raw Blame History

title, type, aliases, tags, date
title type aliases tags date
Prometheus entity
Prometheus OSS
Prometheus监控
monitoring
observability
time-series
alerting
prometheus
2025-11-11

Prometheus

Overview

Prometheus 是 CNCF 毕业的开源系统监控和告警工具包,最初由 SoundCloud 开发现已广泛用于云原生和家居服务器环境。作为时序数据库Prometheus 通过 pull 模式定期从已配置的 targets 抓取指标数据,支持强大的 PromQL 查询语言和灵活的告警规则引擎。

Key Characteristics

  • Pull 模式Prometheus 服务器定期从各 exporter 的 HTTP /metrics 端点拉取指标,无需在被监控主机安装代理
  • PromQL:强大的查询语言,支持聚合、函数、即时向量和范围向量查询
  • 告警规则:基于 PromQL 表达式定义告警条件,触发后发送给 Alertmanager
  • 多数据出口:支持 Remote Write 远端写入VictoriaMetrics/Thanos/Cortex、Grafana 可视化
  • 服务发现:支持 Kubernetes、Consul、静态配置等多种发现机制

Home Server Deployment

# docker-compose.yml 片段
prometheus:
  image: prom/prometheus:latest
  container_name: prometheus
  volumes:
    - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    - ./prometheus/alerts.yml:/etc/prometheus/alerts.yml:ro
  ports:
    - "9090:9090"
  command:
    - '--config.file=/etc/prometheus/prometheus.yml'
    - '--storage.tsdb.path=/prometheus'
    - '--web.enable-lifecycle'

Core Metrics Types

类型 示例 说明
Gauge node_memory_MemAvailable_bytes 可增可减的当前值
Counter node_cpu_seconds_total 只增不减的累计值
Histogram prometheus_http_request_duration_seconds_bucket 分布统计
Summary go_gc_duration_seconds 分位数统计