Prometheus2.35.0安装部署以及主机监控 1 .Prometheus的安装

prometheus监控redis指标 prometheus监控部署_数据

Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖。只需要下载对应平
1.1 下载上传安装包到服务器

prometheus监控redis指标 prometheus监控部署_linux_02

1.2 创建解压目录并将安装包解压。

Prometheus这里就基本安装完成,后面就是修改配置并添加相关的监控
1.3 启动Prometheus Server

1.4 配置开机自启动

prometheus监控redis指标 prometheus监控部署_运维_03

1.5 启动服务+验证

prometheus监控redis指标 prometheus监控部署_prometheus监控redis指标_04

2.2 解压并修改目录名

2.3 Pushgateway目录下执行启动命令

prometheus监控redis指标 prometheus监控部署_运维_05

2.4 、prometheus配置文件prometheus.yml中添加pushgateway监控的相关配置 在scrape_configs配置项下添加配置。

2.5 添加 PushGateway 监控配置

prometheus监控redis指标 prometheus监控部署_数据_06

1、global配置块:控制Prometheus服务器的全局配置 ➢ scrape_interval:配置拉取数据的时间间隔,默认为1分钟。 ➢ evaluation_interval:规则验证(生成alert)的时间间隔,默认为1分钟。 2、rule_files配置块:规则配置文件 3、scrape_configs配置块:配置采集目标相关, prometheus监视的目标。Prometheus自身的运行信息可以通过HTTP访问,所以Prometheus可以监控自己的运行数据。 ➢ job_name:监控作业的名称 ➢ static_configs:表示静态目标配置,就是固定从某个target拉取数据 ➢ targets:指定监控的目标,其实就是从哪儿拉取数据。Prometheus会从http://localhost:9090/metrics上拉取数据。 Prometheus是可以在运行时自动加载配置的。启动时需要添加:--web.enable-lifecycle 2.2 安装Pushgateway Prometheus在正常情况下是采用拉模式从产生metric的作业或者exporter(比如专门监控主机的NodeExporter)拉取监控数据。但是我们要监控的是Flink on YARN作业,想要让Prometheus自动发现作业的提交、结束以及自动拉取数据显然是比较困难的。PushGateway就是一个中转组件,通过配置Flink on YARN作业将metric推到PushGateway,Prometheus再从PushGateway拉取就可以了。

2.6 重启Prometheus Server

prometheus监控redis指标 prometheus监控部署_linux_07

prometheus监控redis指标 prometheus监控部署_服务器_08

prometheus、pushgateway都是up状态,表示安装启动成功

3 添加对主机的监控(Node Exporter监控)
Prometheus完整搭建+主机、进程监控(邮件)告警(学习笔记)_十三妹_的博客-CSDN博客_prometheus 搭建【参考链接】
Prometheus的架构设计中,Prometheus Server主要负责数据的收集,存储并且对外提供数据查询支持,而实际的监控样本数据的收集则是由Exporter完成。因此为了能够监控到某些东西,如主机的CPU使用率,我们需要使用到Exporter。Prometheus周期性的从Exporter暴露的HTTP服务地址(通常是/metrics)拉取监控样本数据。 Exporter可以是一个相对开放的概念,其可以是一个独立运行的程序独立于监控目标以外,也可以是直接内置在监控目标中。只要能够向Prometheus提供标准格式的监控样本数据即可。 为了能够采集到主机的运行指标如CPU, 内存,磁盘等信息。我们可以使用Node Exporter。Node Exporter同样采用Golang编写,并且不存在任何的第三方依赖,只需要下载,解压即可运行。可以从https://prometheus.io/download/ 获取最新的node exporter版本的二进制包。
3.1 Node Exporter安装【需要被监控的服务器安装】

prometheus监控redis指标 prometheus监控部署_数据_09

3.2 设置为开机自启

3.3启动服务+验证
3.4 监控端主机监控配置
prometheus配置文件prometheus.yml中添加主机(node_exporter)监控的相关配置 在scrape_configs配置项下添加配置。
方法一:直接在prometheus.yml配置

prometheus监控redis指标 prometheus监控部署_prometheus监控redis指标_10

方法二:上面是直接添加到prometheus.yml文件的还可以将这些主机单独以文件形式配置方便管理
然后在./conf/node.yml文件里配置主机信息

prometheus监控redis指标 prometheus监控部署_运维_11

prometheus监控redis指标 prometheus监控部署_prometheus监控redis指标_12

3.5重新启动prometheus服务
浏览器输入:http://ip:9090/ 1.7.2点击Status,选中Targets

prometheus监控redis指标 prometheus监控部署_服务器_13

node exporter都是up状态,表示安装启动成功

prometheus监控redis指标 prometheus监控部署_linux_14

下面将主机监控添加到grafana界面
4 安装Grafana
grafana 是一款采用Go语言编写的开源应用,主要用于大规模指标数据的可视化展现,是网络架构和应用分析中最流行的时序数据展示工具,目前已经支持绝大部分常用的时序数据库。 下载地址:Download Grafana | Grafana Labs

prometheus监控redis指标 prometheus监控部署_prometheus监控redis指标_15

4.1 安装
4.2 配置开机自启
4.3 启动服务+验证

4.4 Grafana添加数据源
1 打开web:http://ip:3000,默认用户名和密码:admin

prometheus监控redis指标 prometheus监控部署_服务器_16

prometheus监控redis指标 prometheus监控部署_linux_17

2 点击添加按钮:

prometheus监控redis指标 prometheus监控部署_数据_18

3 找到Prometheus,点击Select

prometheus监控redis指标 prometheus监控部署_linux_19

5 配置Prometheus Server地址:

prometheus监控redis指标 prometheus监控部署_服务器_20

点击下方的Save&Test就可以了

grafana社区鼓励用户分享Dashboard,通过https://grafana.com/dashboards网站,可以找到大量可直接使用的Dashboard模板。 Grafana中所有的Dashboard通过JSON进行共享,下载并且导入这些JSON文件,就可以直接使用这些已经定义好的Dashboard:

prometheus监控redis指标 prometheus监控部署_运维_21

搜索 Node Exporter 选中跳转页面后可以直接复制id 也可以下载json文件

prometheus监控redis指标 prometheus监控部署_数据_22

7 在Grafana中导入模板:

prometheus监控redis指标 prometheus监控部署_linux_23

8 效果

prometheus监控redis指标 prometheus监控部署_linux_24

prometheus监控redis指标 prometheus监控部署_prometheus监控redis指标_25

5 进程监控
5.1 被监控端安装process_exporter
下载地址:https://github.com/ncabatoff/process-exporter/releases/ 5.2 配置开机自启
5.3 启动服务+验证

5.4 被监控端添加监控进程

prometheus监控redis指标 prometheus监控部署_运维_26

5.5 prometheus添加进程监控配置

prometheus监控redis指标 prometheus监控部署_prometheus监控redis指标_27

 

prometheus监控redis指标 prometheus监控部署_数据_28

5.6 重新启动prometheus服务
浏览器输入:http://ip:9090/ 点击Status,选中Targets

prometheus监控redis指标 prometheus监控部署_服务器_13

prometheus监控redis指标 prometheus监控部署_数据_30

5.7 将进程监控添加到grafana界面  
id 4202【通过https://grafana.com/dashboards网站,可以找到大量可直接使用的Dashboard模板】

prometheus监控redis指标 prometheus监控部署_linux_31

prometheus监控redis指标 prometheus监控部署_linux_32

mysql监控