当前位置: 首页 > news >正文

一、Prometheus和Grafana搭建

一、服务端Prometheus二进制安装
https://prometheus.io/

下载过慢可使用迅雷下载

tar -zxvf prometheus-2.53.0.linux-amd64.tar.gz

启动

./prometheus --config.file=prometheus.yml

将其配置为系统服务:

vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=https://prometheus.io[Service]
Restart=on-failure
ExecStart=/prometheus/prometheus-2.53.0/prometheus --config.file=/prometheus/prometheus-2.53.0/prometheus.yml --storage.tsdb.path=/prometheus/data --storage.tsdb.retention.time=60d --web.enable-lifecycle
[Install]
WantedBy=multi-user.target

web.enable-lifecycle是让prometheus热重启,开启以后请求reload

curl -XPOST http://ip:9090/-/reload或者浏览器直接请求

启动Prometheus:

systemctl start prometheus

查看Prometheus状态:

systemctl status prometheus

访问地址:http://127.0.0.1:9090

二、Grafana安装
https://grafana.com/grafana/download
tar -zxvf grafana-enterprise-11.1.0.linux-amd64.tar.gz

将其配置为系统服务:

vim /usr/lib/systemd/system/grafana.service
[Unit]
Description=https://docs.grafana.org[Service]
Restart=on-failure
ExecStart=/prometheus/grafana/bin/grafana-server --config=/prometheus/grafana/conf/defaults.ini --homepath=/prometheus/grafana/
[Install]
WantedBy=multi-user.target

修改defaults.ini:

default_language = zh-Hans

启动grafana:

systemctl start grafana

查看grafana状态:

systemctl status grafana

访问地址:http://127.0.0.1:3000 默认账号密码都是admin

三、客户端node_exporter安装
https://prometheus.io/download/
tar -zxvf attachment\;\ filename\=node_exporter-1.8.1.linux-amd64.tar.gz

将其配置为系统服务:

vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/prometheus/node_exporter/node_exporter 
[Install]
WantedBy=multi-user.target

启动node_exporter:

systemctl start node_exporter

查看node_exporter状态:

systemctl status node_exporter

访问地址:http://127.0.0.1:9100/metrics

四、将node_exporter加到Prometheus中

修改prometheus.yml,在scrape_configs下添加

  - job_name: "node_exporter"static_configs:- targets: ["192.168.0.1:9100","192.168.0.2:9100"]
# targets处可添加多个节点

重新加载配置文件

curl -XPOST http://127.0.0.1:9090/-/reload

之后在Prometheus的status下的targets下可以看到node_exporter

五、Grafana添加仪表盘

1.添加prometheus

连接-》数据源-》添加新数据源-》选择prometheus-》在connection处添加prometheus地址-》save & test

2.添加仪表板

仪表板-》新建仪表板-》导入仪表板-》在https://grafana.com/grafana/dashboards选择仪表板并copy id to clipboard-》在导入仪表板的界面粘贴ID并加载

模板下载样例:https://grafana.com/grafana/dashboards/16098-node-exporter-dashboard-20240520-job/ ,内网环境使用JSON导入

http://www.lryc.cn/news/394750.html

相关文章:

  • 从零开始的python学习生活
  • MSP学习
  • 生产力工具|Endnote X9如何自动更新文件信息
  • 【python】字典、列表、集合综合练习
  • 超融合服务器挂载硬盘--linux系统
  • Kafka如何防止消息重复发送
  • 数据库设计原则介绍
  • 反馈神经网络与不同类型的神经网络:BP神经网络,深度感知机,CNN,LSTM
  • 轮播图案例
  • Spring 泛型依赖注入
  • C++ Linux调试(无IDE)
  • FFmpeg——视频拼接总结
  • springboot项目怎么样排除自带tomcat容器使用宝蓝德bes web中间件?
  • 响应式ref()和reactive()
  • 运维系列.Nginx中使用HTTP压缩功能
  • vue3项目图片压缩+rem+自动重启等plugin使用与打包配置
  • 数据库性能优化系统设计
  • MyBatisPlus-分页插件的基本使用
  • 深入探索Python库的奇妙世界:赋能编程的无限可能
  • 力扣爆刷第161天之TOP100五连刷71-75(搜索二叉树、二维矩阵、路径总和)
  • 你真的了解Java内存模型JMM吗?
  • Springboot整合Jsch-Sftp
  • 生成随机的验证码图片(Python)
  • 0/1背包问题总结
  • 模电基础 - 放大电路的频率响应
  • Java 8 到 Java 22 新特性详解
  • 华为OD机试题-提取字符串中最长数学表达式
  • 专家指南:如何为您的电路选择理想的压敏电阻或热敏电阻
  • 基于主流SpringBoot进行JavaWeb开发的学习路线
  • 医疗机器人中的具身智能进展——自主超声策略模型的任务编码和局部探索