前言

Prometheus 是由 SoundCloud 开源监控告警解决方案,从 2012 年开始编写代码,2015 年 GitHub 上开源,2016 年 Prometheus 成为继 Kubernetes 之后,成为 CNCF (Cloud Native Computing Foundation)中的第二个项目成员,也是第二个正式毕业的项目。作为新一代开源解决方案,Prometheus 的很多设计理念与 Google SRE 运维之道不谋而合。

监控作为可观察性实践(监控、日志、追踪)中的关键一环,相较以往的系统监控,在云原生时代产生了诸多变化。一是微服务和容器化,导致监控对象和指标的指数级增加;二是监控对象的生命周期更加短暂,导致监控数据量和复杂度的成倍增加。这就需要一款统一监控指标和数据查询语言的工具,Prometheus 应运而生了。Pemetheus 可以很方便的与众多开源项目集成,帮助我们了解系统和服务的运行状态,另一方面分析其收集的大数据,可以帮助我们进行系统优化和作出决策。它不仅是可以应用在 IT 领域,对于任何需要收集指标数据的情形下都可以使用。

更新历史

2021年07月17日 - 初稿

阅读原文 - https://wsgzao.github.io/post/prometheus/


Prometheus简介和基础架构

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company. To emphasize this, and to clarify the project’s governance structure, Prometheus joined the Cloud Native Computing Foundation in 2016 as the second hosted project, after Kubernetes.

For more elaborate overviews of Prometheus, see the resources linked from the media section.

从这个架构图,也可以看出 Prometheus 的主要模块包含:Server、Exporters、Pushgateway、PromQL、Alertmanager、WebUI 等。

它大致使用逻辑是这样:

  1. Prometheus server 定期从静态配置的 target 或者服务发现的 target 拉取数据。
  2. 当新拉取的数据大于配置内存缓存区的时候,Prometheus 会将数据持久化到磁盘(如果使用 remote storage 将持久化到云端)。
  3. Prometheus 可以配置 rule,然后定时查询数据,当条件触发的时候,会将 alert 推送到配置的 Alertmanager。
  4. Alertmanager 收到警告的时候,可以根据配置,聚合、去重、降噪,最后发送警告。
  5. 可以使用 API、Prometheus Console 或者 Grafana 查询和聚合数据。

Prometheus推荐教程

Prometheus 使用入门系列

Prometheus 使用入门系列 - 陈树义的博客

kubernetes-handbook

Kubernetes中文指南/云原生应用架构实践手册
K8S最佳实战(包括了K8S的Prometheus监控和EFK日志搜集)

https://github.com/rootsongjc/kubernetes-handbook

https://jimmysong.io/kubernetes-handbook/practice/

Prometheus-book

Prometheus操作指南

https://github.com/yunlzheng/prometheus-book

https://yunlzheng.gitbook.io/prometheus-book/

prometheus_practice

Prometheus实战包括 Prometheus 基础知识,性能优化和大量实战经验。

https://github.com/songjiayang/prometheus_practice

https://song-jia-yang.gitbook.io/prometheus/

Prometheus dashboard

  1. Kubernetes for Prometheus Dashboard
  2. Node Exporter for Prometheus Dashboard
  3. Blackbox Exporter for Prometheus Dashboard
  4. windows_exporter for Prometheus Dashboard

https://github.com/starsliao/Prometheus

Awesome Prometheus alerts

Collection of alerting rules

https://github.com/samber/awesome-prometheus-alerts

https://awesome-prometheus-alerts.grep.to/

参考文献

Prometheus Introduction

文章目录
  1. 1. 前言
  2. 2. 更新历史
  3. 3. Prometheus简介和基础架构
  4. 4. Prometheus推荐教程
  5. 5. 参考文献