Prometheus 是由 SoundCloud 开发的开源监控报警系统和时序列数据库(TSDB),自 2012 年起,许多公司及组织已经采用 Prometheus,并且该项目有着非常活跃的开发者和用户社区,现在已经成为一个独立的开源项目,并且保持独立于任何公司,Prometheus 在 2016 加入 CNCF ( Cloud Native Computing Foundation ), 作为在 kubernetes 之后的第二个由基金会主持的项目。github 地址(https://github.com/prometheus)

今晚九点就将为大家带来 Prometheus 分享 手把手教大家快速搭建一套告警系统。

分享内容如下:

项目演示

知识介绍

  • Prometheus 基础

    • 是什么
    • 架构设计
    • 为什么选择 Promethues
  • Prometheus 组件概览和实战

    • Server
    • NodeExporter
    • Pushgateway
    • Alertmanager
    • Grafana 集成 答疑问题讨论

分享嘉宾:禾木老师

1、Ruby on Rails 爱好者

2、多年 Golang 研发经验

3、3 年 Promethus 二次开发及使用经验及社区代码贡献者

4、《Prometheus: Up & Running: Infrastructure and Application Performance Monitoring》 中文翻译作者(校验完毕待发版)

项目演示效果图

Prometheus 架构

为什么选择 Prometheus ?

  • who not?
  • 现代(用 Go 编写)
  • 无依赖,安装方便,上手容易
  • 很多插件或者 exporter
  • Grafana 默认支持
  • K8s 默认支持,非常适合容器和微服务
  • 社区活跃,它不仅仅是个工具而是生态

Prometheus 组件概览和实战

Prometheus Server

安装

Prometheus Server 的安装比较灵活,可以使用二进制安装包或者 Docker 安装, 下面以二进制的方式为例:

解压缩包并运行 ./prometheus

访问 http://IP:9090 查看 Prometheus console

Prometheus Node Exporter

安装,运行

Prometheus Node Exporter 主要用于物理主机的采样,它同样可以使用二进制安装包和 Docker 的安装, 下面以二进制的方式为例:

Prometheus 添加 Node Job

修改 prometheus.yml 使用 ./promtool check config 进行配置文件检测

使用 kill –HUP PID 进行重启

Prometheus Pushgateway

安装,运行

Prometheus Pushgateway 主要用于无法单独提供 Exporter 的数据的收集,它同样可以使用二进制安装包和 Docker 的安装, 下面以二进制的方式为例:

Pushgateway 添加数据

使用 HTTP 请求添加数据

Prometheus 添加 Pushgateway

修改 prometheus.yml

使用同样的方法,重启 Prometheus。

Alertmanager

安装,运行

Prometheus Alertmanager 主要用于告警信息的管理,使用它可以很方便的对Prometheus 触发的告警进行分组,降噪,设置不同告警渠道。它同样可以使用二进制安装包和 Docker 的安装, 下面以二进制的方式为例:

与 Prometheus 集成

修改 prometheus.yml

添加 node_rules.yml 文件

使用 ./promtool 检查配置文件 重启 Prometheus

Rules Console

触发告警

Grafana 集成

安装,运行

Grafana 是一款非常流行的开源的功能强大的指标展示工具,它和 Prometheus 能够做到无缝对接,它同样可以使用二进制安装包和 Docker 的安装, 下面以二进制的方式为例:

1、访问页面 http://IP:3000 ,并登录 2、默认账号密码(admin/admin),首次登录后提示修改密码

3、配置数据源,并选择 Prometheus

4、创建 dashboard ,添加面板, 并保存

参考资料:

Prometheus 官网 Prometheus UP and Running Prometheus 实战 https://www.robustperception.io/blog