64 lines
2.5 KiB
Markdown
64 lines
2.5 KiB
Markdown
---
|
||
title: "Prometheus"
|
||
type: entity
|
||
aliases: [Prometheus OSS, Prometheus监控]
|
||
tags: [monitoring, observability, time-series, alerting, prometheus]
|
||
date: 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
|
||
```yaml
|
||
# 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` | 分位数统计 |
|
||
|
||
## Related Sources
|
||
- [[家庭监控方案-prometheus-grafana-node-exporter-cadvisor-blackbox]]
|
||
|
||
## Related Entities
|
||
- [[Grafana]] — 可视化层
|
||
- [[Alertmanager]] — 告警分发
|
||
- [[node_exporter]] — 主机指标采集
|
||
- [[cAdvisor]] — 容器指标采集
|
||
- [[blackbox_exporter]] — HTTP/TCP 探测
|
||
- [[Uptime Kuma]] — 合成监控(互补)
|
||
|
||
## Related Concepts
|
||
- [[PromQL]] — Prometheus 查询语言
|
||
- [[Prometheus告警规则]] — 告警条件定义
|
||
- [[Exporter]] — 指标暴露组件
|
||
- [[时序数据库]] — 数据存储模式
|
||
- [[System Monitoring]] — 上游领域
|
||
- [[Centralized Logging]] — 可互补的日志聚合方案
|