【开源监控】Prometheus

一世执手 提交于 2019-12-02 02:02:45

Prometheus

Prometheus介绍

Prometheus新一代开源监控解决方案。github地址

Prometheus主要功能

  • 多维 数据模型(时序由 metric 名字和 k/v 的 labels 构成)。
  • 灵活的查询语句(PromQL)。
  • 无依赖存储,支持 local 和 remote 不同模型。
  • 采用 http 协议,使用 pull 模式,拉取数据,简单易懂。
  • 监控目标,可以采用服务发现或静态配置的方式。
  • 支持多种统计数据模型,图形化友好。

Prometheus核心组件

  • Prometheus Server, 主要用于抓取数据和存储时序数据,另外还提供查询和 Alert Rule 配置管理。
  • client libraries,用于对接 Prometheus Server, 可以查询和上报数据。
  • push gateway ,用于批量,短期的监控数据的汇总节点,主要用于业务数据汇报等。
  • 各种汇报数据的 exporters ,例如汇报机器数据的 node_exporter, 汇报 MongoDB 信息的 MongoDB exporter 等等。
  • 用于告警通知管理的 alertmanager

Prometheus安装

二进制安装

cd /opt wget https://github.com/prometheus/prometheus/releases/download/v2.13.0/prometheus-2.13.0.linux-amd64.tar.gz tar zxvf prometheus-2.13.0.linux-amd64.tar.gz  cd prometheus-2.13.0.linux-amd64

查看版本

[root@localhost prometheus-2.13.0.linux-amd64]# ./prometheus --version prometheus, version 2.13.0 (branch: HEAD, revision: 6ea4252299f542669aca11860abc2192bdc7bede)   build user:       root@f30bdad2c3fd   build date:       20191004-11:25:34   go version:       go1.13.1

启动

./prometheus

或者

cd /opt/prometheus-2.13.0.linux-amd64 nohup ./prometheus &

可以通过浏览器来访问 http://IP:9090,可以看到prometheus管理页面。

Node Exporter安装

cd /opt/ wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz 

Node Exporter启动

./node_exporter 

可以通过浏览器访问http://IP:9100/metrics,访问度量指标。

Prometheus端配置

/opt/prometheus-2.13.0.linux-amd64/prometheus.yml修改prometheus.yml的配置

scrape_configs:   # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.   - job_name: 'prometheus'      # metrics_path defaults to '/metrics'     # scheme defaults to 'http'.     static_configs:     - targets: ['localhost:9090']   ## 以下是node_exporter的添加内容   - job_name: 'node_exporter'     static_configs:     - targets:       - '172.31.1.203:9100'

Prometheus端效果查询

检验Node Exporter的效果

Grafana端配置

1.配置Prometheus数据源

2.添加dashboards的模板

这里使用的是9276模板,连接地址:https://grafana.com/grafana/dashboards/9276

3.展示效果,如下:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!