目录
Prometheus介绍
Prometheus使用Go语言开发的时序数据库,设计灵感来自Google的Borgmon 项目,主要用于提供近实时的、基于动态云环境和容器的微服务、服务和应用程 序的监控。在 2016 年继 Kurberntes 之后,加入了 Cloud Native Computing Foundation(CNCF)。
Prometheus特性
1. 时间序列数据通过 metric 名和 K/V 标签对来区分。
2. 灵活的查询语言(PromQL)。
3. 数据模型随意,可以设置任意的多维标签。
4. 可以对数据模型进行聚合,切割和切片操作。
5. 支持双精度浮点类型,标签可以设为全 unicode。
6. 基于 HTTP 采用 pull 方式收集数据。
7. 支持 push 数据到中间件(pushgateway)
8. 支持多种多样的图表和界面展示,比如 Grafana 等。
Prometheus架构
1. Prometheus server: 服务端。用于收集和存储时间序列数据。
2. Exporters:采集端。它负责从目标处采集数据,并将其转化为 Prometheus 支持的格式。Server 端定时 Pull 拉取 Exporter 上的数据。
3. Pushgateway:对于短暂运行的任务,负责接收和缓存时间序列数据。
4. Alertmanager:实现 Prometheus 的告警功能。支持电子邮件,pagerduty, OpsGenie, webhook 等方式。
5、Prometheus web UI:前端查询界面,也支持 Grafana 等组件。
Prometheus安装
方式 1、Docker 环境:
(1)下载
docker search prometheus
docker pull prom/prometheus
(2)启动 docker run -p 9090:9090 prom/Prometheus
(3)如果需要映射数据及配置文件
docker run -p 9090:9090 -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml
-v /tmp/prometheus-data:/prometheus-data
prom/prometheus
方式 2、主机环境:
(1)下载并解压 tar 包 https://prometheus.io/download/
(2)启动./prometheus --config.file=prometheus.yml(有关配置文件讲 解放在后续章节详细解释)