建设网站硬件,石家庄网站制作软件,有关互联网网站,前端开发岗位介绍文章目录一、概述二、安装Prometheus1.安装node_exporter2.安装Prometheus三、安装Grafana展示监控监控进程一、概述
Prometheus 介绍
Prometheus是一套开源的监控报警时间序列数据库的组合#xff0c;起始是由SoundCloud公司开发的。随着发展#xff0c;越来越多…
文章目录一、概述二、安装Prometheus1.安装node_exporter2.安装Prometheus三、安装Grafana展示监控监控进程一、概述
Prometheus 介绍
Prometheus是一套开源的监控报警时间序列数据库的组合起始是由SoundCloud公司开发的。随着发展越来越多公司和组织接受采用Prometheus社区也十分活跃他们便将它独立成开源项目并且有公司来运作。google SRE的书内也曾提到跟他们BorgMon监控系统相似的实现是Prometheus。现在最常见的Kubernetes容器管理系统中通常会搭配Prometheus进行监控。
Prometheus 的优点
非常少的外部依赖安装使用超简单已经有非常多的系统集成 例如docker HAProxy Nginx JMX等等服务自动化发现直接集成到代码设计思想是按照分布式、微服务架构来实现的
Prometheus 的特性
自定义多维度的数据模型非常高效的存储 平均一个采样数据占 ~3.5 bytes左右320万的时间序列每30秒采样保持60天消耗磁盘大概228G。强大的查询语句轻松实现数据可视化
Grafana介绍
Grafana是一个跨平台的开源的度量分析和可视化工具可以通过将采集的数据查询然后可视化的展示并及时通知。它主要有以下几个特点
展示方式快速灵活的客户端图表面板插件有许多不同方式的可视化指标和日志官方库中具有丰富的仪表盘插件比如热图、折线图、图表等多种展示方式
数据源GraphiteInfluxDBOpenTSDBPrometheusElasticsearchCloudWatch和KairosDB等
通知提醒4.0之后的添加了报警功能可以以可视方式定义最重要指标的警报规则Grafana将不断计算并发送通知在数据达到阈值时通过Slack、PagerDuty等获得通知
混合展示在同一图表中混合使用不同的数据源可以基于每个查询指定数据源甚至自定义数据源
二、安装Prometheus
1.安装node_exporter
源码地址https://github.com/prometheus/node_exporter
在下载安装Prometheus之前我们先安装node_exporter插件用于提供服务器监控的指标(比如CPU、内存、磁盘、磁盘读写速率等指标)是一个非常常用的Prometheus Client插件。
下载
wget -c 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后台运行
nohup node_exporter-0.18.1.linux-amd64/node_exporter node_exporter-0.18.1.linux-amd64/node_exporter.stdout 21 2.安装Prometheus
下载地址https://prometheus.io/download/
下载版本号为2.32.1也可以根据自己需要下载其他版本
wget -c https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz解压 tar -zxvf prometheus-2.32.1.linux-amd64.tar.gz 配置 在prometheus.yml配置文件中追加node_exporter的job监控本机服务器
[monitorr-wb-15 prometheus-2.32.1.linux-amd64]$ pwd
/home/monitor/prometheus-2.32.1.linux-amd64
[monitorr-wb-15 prometheus-2.32.1.linux-amd64]$ ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool在prometheus.yml新增 - job_name: node_exporterstatic_configs:- targets: [192.168.60.15:9100]注如果需要监控多台服务器指标则只需要在其他服务器上安装node_exporter即可不需要安装prometheus。参考配置如下
- job_name: node_exporterstatic_configs:- 192.168.20.165:9100- 192.168.20.166:9100- 192.168.20.167:9100启动服务
nohup ./prometheus prometheus.log 访问prometheus
http://192.168.60.15:9090/graph出现如下页面说明prometheus启动成功
三、安装Grafana展示监控
下载地址: https://grafana.com/grafana/download
下载版本8.3.4
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.3.4-1.x86_64.rpm安装
sudo yum install grafana-enterprise-8.3.4-1.x86_64.rpm安装目录在/usr/share/grafana 下载饼图插件
grafana-cli plugins install grafana-piechart-panel注安装在/var/lib/grafana/plugins目录下
启动Grafana systemctl start grafana-server systemctl enable grafana-server 访问Grafana http://192.168.60.15:3000/login默认账号密码admin/admin 添加数据源
保存 保存成功后再配置页面可以看到我们配置的数据源 导入node_exporter对应的仪表盘 导入成功后查看我们服务器监控 注关于Granafa仪表盘ID可参考
https://grafana.com/grafana/dashboards
监控进程
https://datamining.blog.csdn.net/article/details/122680198