Prometheus + node_exporter + Grafana 搭建机器相关指标性能监控

前置准备

因为下载需要用到 homebrew,所以请提前安装好 homebrew。并且设置好对应的镜像源,否则下载太慢,以下是我的镜像源配置。

以下命令在安装好 homebrew 后执行即可。

cmake 复制代码
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile

1、安装 node_exporter

(1)执行以下命令安装

java 复制代码
brew install node_exporter

(2)执行以下命令启动

java 复制代码
brew services start node_exporter

tip:停止进程命令 brew services stop node_exporter

(3)验证是否成功启动

访问网址:http://localhost:9100/metrics

如果成功则会出现以下界面:

2、安装 prometheus

(1)执行以下命令安装

java 复制代码
brew install prometheus

(2)执行以下命令启动

java 复制代码
brew services start prometheus 

tip:停止进程命令 brew services stop prometheus

(3)验证是否成功启动

访问网址:http://localhost:9090/graph

如果成功则会出现以下界面:

3、prometheus 关联 node_exporter

现在 prometheus 和 node_exporter 的进程都启动起来了,但是目前他们现在还没有关联上,需要在 prometheus 的配置文件中配置 node_exporter。

(1)新建 prometheus.yml

文件内容为:

yaml 复制代码
global:
  scrape_interval: 15s
 
scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["localhost:9090"]
  - job_name: "linux-node-cluster"
    static_configs:
    - targets: ["localhost:9100"]

linux-node-cluster 就表示 node_exporter。

(2)以配置文件方式启动 prometheus

cmake 复制代码
prometheus --config.file=/Users/Desktop/Java/monitor/promethus/install/prometheus.yml

其中--config.file 后面的是 prometheus.yml 的具体文件路径,以自己的为准。

(3)验证是否成功关联

访问网址:http://localhost:9090/targets

如果出现了以下界面则代表关联成功

4、安装 Grafana

(1)执行以下命令安装

java 复制代码
brew install grafana

(2)执行以下命令启动

java 复制代码
brew services start grafana

(3)验证是否成功启动

访问网址:http://localhost:3000/login

如果出现了以下界面则代表启动成功,用户名密码默认都是:admin。

5、使用 Grafana 展示 Prometheus 的数据

(1)

(2)

(3)

(4)

(5)

(6)

(7)

6、最终效果图

相关推荐
好奇的菜鸟1 小时前
如何在IntelliJ IDEA中设置数据库连接全局共享
java·数据库·intellij-idea
DuelCode2 小时前
Windows VMWare Centos Docker部署Springboot 应用实现文件上传返回文件http链接
java·spring boot·mysql·nginx·docker·centos·mybatis
优创学社22 小时前
基于springboot的社区生鲜团购系统
java·spring boot·后端
幽络源小助理2 小时前
SpringBoot基于Mysql的商业辅助决策系统设计与实现
java·vue.js·spring boot·后端·mysql·spring
猴哥源码2 小时前
基于Java+springboot 的车险理赔信息管理系统
java·spring boot
YuTaoShao3 小时前
【LeetCode 热题 100】48. 旋转图像——转置+水平翻转
java·算法·leetcode·职场和发展
Dcs4 小时前
超强推理不止“大”——手把手教你部署 Mistral Small 3.2 24B 大模型
java
东阳马生架构4 小时前
订单初版—1.分布式订单系统的简要设计文档
java
Code blocks4 小时前
使用Jenkins完成springboot项目快速更新
java·运维·spring boot·后端·jenkins
荔枝吻4 小时前
【沉浸式解决问题】idea开发中mapper类中突然找不到对应实体类
java·intellij-idea·mybatis