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、最终效果图

相关推荐
-大头.2 分钟前
Spring Bean作用域深度解析与实战
java·后端·spring
qq_336313936 分钟前
java基础-排序算法
java·开发语言·排序算法
豆沙沙包?8 分钟前
2025年--Lc298-1019. 链表中的下一个更大节点(栈)--java版
java·数据结构·链表
fengfuyao9859 分钟前
匈牙利算法的MATLAB实现
java·算法·matlab
毕设源码-钟学长10 分钟前
【开题答辩全过程】以 基于springboot农科所农作物信息管理系统的设计与实现为例,包含答辩的问题和答案
java·spring boot·后端
b***66611 小时前
Spring Boot 整合 Apollo 配置中心实战
java·spring boot·后端
CoderYanger1 小时前
递归、搜索与回溯-综合练习:27.黄金矿工
java·算法·leetcode·深度优先·1024程序员节
vx_vxbs661 小时前
【SSM高校普法系统】(免费领源码+演示录像)|可做计算机毕设Java、Python、PHP、小程序APP、C#、爬虫大数据、单片机、文案
android·java·python·mysql·小程序·php·idea
张较瘦_1 小时前
Springboot3 | ResponseEntity 完全使用教程
java·springboot·开发
毕设源码-郭学长1 小时前
【开题答辩全过程】以 高校兼职系统为例,包含答辩的问题和答案
java·spring boot