# 前言

v0.1.0

在过去一年左右时间里，我们使用 Prometheus 完成了对几个机房的基础和业务监控，大大提高了服务质量以及 oncall 水平，在此特别感谢 Promethues 这样优秀的开源软件。

当初选择 Prometheus 并不是偶然，因为：

* Prometheus 是按照 Google SRE 运维之道的理念构建的，具有实用性和前瞻性。
* Prometheus 社区非常活跃，基本稳定在 1个月1个版本的迭代速度，从 2016 年 v1.01 开始接触使用以来，到目前发布的 v1.8.2 以及最新最新的 v2.1 ，你会发现 Prometheus 一直在进步、在优化。
* Go 语言开发，性能不错，安装部署简单，多平台部署兼容性好。
* 丰富的数据收集客户端，官方提供了各种常用 exporter。
* 丰富强大的查询能力。

Prometheus 作为监控后起之秀，虽然还有做的不够好的地方，但是不妨碍我们使用和喜爱它。根据我们长期的使用经验来看，它足以满足大多数场景需求，只不过对于新东西，往往需要花费更多力气才能发挥它的最大能力而已。

本书主要根据个人过去一年多的使用经验总结而成，内容主要包括 Prometheus 基本知识、进阶、实战以及常见问题列表等方面，希望对大家有所帮助。

本开源书籍既适用于具备基础 Linux 知识的运维初学者，也可供渴望理解 Prometheus 原理和实现细节的高级用户参考，同时也希望书中给出的实践案例在实际部署监控中对大家有所帮助。

你准备好了吗？接下来就让我们一起开始这段神奇旅行吧！

## 目录

* [前言](https://song-jia-yang.gitbook.io/prometheus/readme)
* [修订记录](https://song-jia-yang.gitbook.io/prometheus/revision-record)
* [如何贡献](https://song-jia-yang.gitbook.io/prometheus/how-to-contribute)
* [Prometheus 简介](https://song-jia-yang.gitbook.io/prometheus/introduction)
  * [Prometheus 是什么](https://song-jia-yang.gitbook.io/prometheus/introduction/what)
  * [为什么选择 Prometheus](https://song-jia-yang.gitbook.io/prometheus/introduction/why)
* [Prometheus 安装](https://song-jia-yang.gitbook.io/prometheus/install)
  * [二进制包安装](https://song-jia-yang.gitbook.io/prometheus/install/binary)
  * [Docker 安装](https://song-jia-yang.gitbook.io/prometheus/install/docker)
* [基础概念](https://song-jia-yang.gitbook.io/prometheus/concepts)
  * [数据模型](https://song-jia-yang.gitbook.io/prometheus/concepts/data-model)
  * [指标类型](https://song-jia-yang.gitbook.io/prometheus/concepts/metric-types)
  * [作业与实例](https://song-jia-yang.gitbook.io/prometheus/concepts/jobs-and-instances)
* [PromQL](https://song-jia-yang.gitbook.io/prometheus/promql)
  * [PromQL 基本使用](https://song-jia-yang.gitbook.io/prometheus/promql/summary)
  * [与 SQL 对比](https://song-jia-yang.gitbook.io/prometheus/promql/sql)
* [数据可视化](https://song-jia-yang.gitbook.io/prometheus/visualiztion)
  * [Web Console](https://song-jia-yang.gitbook.io/prometheus/visualiztion/console)
  * [Grafana](https://song-jia-yang.gitbook.io/prometheus/visualiztion/grafana)
* [Prometheus 配置](https://song-jia-yang.gitbook.io/prometheus/configuration)
  * [全局配置](https://song-jia-yang.gitbook.io/prometheus/configuration/global)
  * [告警配置](https://song-jia-yang.gitbook.io/prometheus/configuration/alerting)
  * [规则配置](https://song-jia-yang.gitbook.io/prometheus/configuration/rule_files)
  * [数据拉取配置](https://song-jia-yang.gitbook.io/prometheus/configuration/scrape_configs)
  * [远程可写存储](https://song-jia-yang.gitbook.io/prometheus/configuration/remote_write)
  * [远程可读存储](https://song-jia-yang.gitbook.io/prometheus/configuration/remote_read)
  * [服务发现](https://song-jia-yang.gitbook.io/prometheus/configuration/server_discovery)
  * [配置样例](https://song-jia-yang.gitbook.io/prometheus/configuration/demo)
* [服务发现](https://github.com/songjiayang/prometheus_practice/blob/master/sd/README.md)
  * [静态服务发现](https://song-jia-yang.gitbook.io/prometheus/optimize/logger)
  * [文件服务发现](https://song-jia-yang.gitbook.io/prometheus/fu-wu-fa-xian/consul)
  * [HTTP服务发现](https://song-jia-yang.gitbook.io/prometheus/demo/alertmanager)
  * [Consul服务发现](https://song-jia-yang.gitbook.io/prometheus/fu-wu-fa-xian/moby)
  * [moby服务发现](https://song-jia-yang.gitbook.io/prometheus/rule/what)
  * [kubernetes服务发现](https://song-jia-yang.gitbook.io/prometheus/alertmanager/others)
* [Exporter](https://song-jia-yang.gitbook.io/prometheus/exporter)
  * [文本格式](https://song-jia-yang.gitbook.io/prometheus/exporter/text)
  * [Sample Exporter](https://song-jia-yang.gitbook.io/prometheus/exporter/sample)
  * [Node Exporter 安装使用](https://song-jia-yang.gitbook.io/prometheus/exporter/nodeexporter)
  * [Node Exporter 常用查询](https://song-jia-yang.gitbook.io/prometheus/exporter/nodeexporter_query)
  * [其他 Exporter 介绍](https://song-jia-yang.gitbook.io/prometheus/exporter/other)
* [Pushgateway](https://song-jia-yang.gitbook.io/prometheus/pushgateway)
  * [Pushgateway 是什么](https://song-jia-yang.gitbook.io/prometheus/pushgateway/why)
  * [如何使用 Pushgateway](https://song-jia-yang.gitbook.io/prometheus/pushgateway/how)
* [数据存储](https://song-jia-yang.gitbook.io/prometheus/rule)
  * [Local Store](https://song-jia-yang.gitbook.io/prometheus/optimize/config)
  * [Remote Store](https://song-jia-yang.gitbook.io/prometheus/demo/rule)
* [告警/记录规则](https://song-jia-yang.gitbook.io/prometheus/demo/target)
  * [如何配置](https://song-jia-yang.gitbook.io/prometheus/alertmanager/webhooks)
  * [触发逻辑](https://song-jia-yang.gitbook.io/prometheus/container)
* [Alertmanager](https://song-jia-yang.gitbook.io/prometheus/alertmanager)
  * [Alertmanager 是什么](https://song-jia-yang.gitbook.io/prometheus/alertmanager/what)
  * [配置详情](https://song-jia-yang.gitbook.io/prometheus/alertmanager/config)
  * [通过 Email 接收告警](https://song-jia-yang.gitbook.io/prometheus/alertmanager/email)
  * [通过企业微信接收告警](https://song-jia-yang.gitbook.io/prometheus/alertmanager/wechat)
  * [通过 Slack 接收告警](https://song-jia-yang.gitbook.io/prometheus/alertmanager/slack)
  * [通过 Webhook 接收告警](https://song-jia-yang.gitbook.io/prometheus/container/k8s)
  * [其他告警接收方案](https://song-jia-yang.gitbook.io/prometheus/qa)
* [Prometheus 工具](https://song-jia-yang.gitbook.io/prometheus/demo)
  * [Promtool 介绍和使用](https://song-jia-yang.gitbook.io/prometheus/tools/client)
  * [Client SDK](https://song-jia-yang.gitbook.io/prometheus/optimize)
* [Prometheus 性能调优](https://song-jia-yang.gitbook.io/prometheus/store/remote)
  * [Metrics 仪表盘](https://song-jia-yang.gitbook.io/prometheus/tools)
  * [启动参数优化](https://song-jia-yang.gitbook.io/prometheus/fu-wu-fa-xian/static)
  * [日志查询](https://song-jia-yang.gitbook.io/prometheus/store)
* [Prometheus 与容器](https://song-jia-yang.gitbook.io/prometheus/rule/config)
  * [Docker](https://song-jia-yang.gitbook.io/prometheus/container/docker)
  * [Kubernetes](https://song-jia-yang.gitbook.io/prometheus/fu-wu-fa-xian/k8s)
* [高可用方案探讨](https://song-jia-yang.gitbook.io/prometheus/ha)
  * [Prometheus Server 的高可靠](https://song-jia-yang.gitbook.io/prometheus/ha/prometheus)
  * [AlertManager 的高可靠](https://song-jia-yang.gitbook.io/prometheus/qa/auth)
* [实战练习](https://song-jia-yang.gitbook.io/prometheus/fu-wu-fa-xian/http)
  * [NodeExporter](https://song-jia-yang.gitbook.io/prometheus/fu-wu-fa-xian/file)
  * [配置告警规则](https://song-jia-yang.gitbook.io/prometheus/demo/grafana)
  * [Grafana 集成](https://song-jia-yang.gitbook.io/prometheus/optimize/status)
  * [Alertmanager 告警](https://song-jia-yang.gitbook.io/prometheus/store/local)
* [常见问题收录](https://song-jia-yang.gitbook.io/prometheus/tools/promu)
  * [如何热加载新配置](https://song-jia-yang.gitbook.io/prometheus/qa/hotreload)
  * [如何通过认证后拉取数据](https://song-jia-yang.gitbook.io/prometheus/ha/alertmanger)

## 技术交流

欢迎加入 Prometheus 技术交流微信群，分享 Prometheus 资源，交流 Prometheus 技术。

* 微信群：![weixin.jpeg](https://user-images.githubusercontent.com/1459834/177047283-e60ce419-e499-42d8-89d5-f378b8bccbea.jpeg)

## 关于作者

* small\_fish\_\_

  * [微博](https://weibo.com/songjiayang1)
  * [github](https://github.com/songjiayang)
  * 个人公众号

  <img src="https://git.io/vAQvJ" alt="人人都懂云原生" data-size="original">
* 薛锦

  * [微博](https://weibo.com/1660913012/profile?topnav=1\&wvr=6)
  * [github](https://github.com/csxuejin)
  * 个人公众号

  <img src="https://songjiayang.gitbooks.io/go-basic-courses/content/pics/easy-hacking.jpg" alt="GitHub Logo" data-size="original">
