【监控系统】Prometheus监控组件Node-Exporter配置实战

这一节,我们来配置一下Node-Exporter,那么我们先来了解一下什么是Prometheus的Exporter?

任何向Prometheus提供监控样本数据的程序都可以被称为一个Exporter,它是一种用于将不同数据源的指标提供给Prometheus进行收集和监控的工具。运行在应用程序、计算机、网络设备或者其他系统上的代码,它可以将系统的指标信息以一种标准格式公开。将指标数据公开为HTTP端点或者指定的格式(如Redis、JMX等),Prometheus然后可以通过轮询或指定的抓取器。

Exporter是Prometheus的指标数据收集组件,负责从目标Jobs收集数据。并把收集到的数据转换为Prometheus支持的时序数据格式。只负责收集,并不向Server端发送数据,而是等待Prometheus Server 主动抓取。

Prometheus社区以及其他团队开发了大量的Exporter,覆盖了许多不同类型的系统和服务。Node Exporter、MySQL Exporter、Redis Exporter、MongoDB Exporter、Nginx Exporter...

使用方式:在主机上安装了一个 Exporter程序,该程序对外暴露了一个用于获取当前监控样本数据的HTTP访问地址。Prometheus通过轮询的方式定时从这些Target中获取监控数据样本,并且存储在数据库当中。

案例实战-安装部署 **node_exporter **

node_exporter 用于采集类UNIX内核的硬件以及系统指标,包括CPU、内存和磁盘。

下载node_exporter 组件

bash 复制代码
https://prometheus.io/download/
https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz

下载安装包到Linux服务器

bash 复制代码
#解压
tar -zxvf node_exporter-1.6.0.linux-amd64.tar.gz

配置启动文件,设置自启动:vi /usr/lib/systemd/system/node_exporter.service

注意:ExecStart配置node_exporter目录下的node_exporter启动器

bash 复制代码
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
 
[Service]
Type=simple
ExecStart=/usr/local/software/node_exporter/node_exporter \
--collector.ntp \
--collector.mountstats \
--collector.systemd \
--collector.tcpstat
 
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

启动node_exporter ,设置开机自启,检查服务启动情况

bash 复制代码
systemctl start node_exporter
 
systemctl enable node_exporter
 
netstat -natp | grep :9100

[root@localhost /]# netstat -natp | grep :9100
tcp6       0      0 :::9100                 :::*                    LISTEN      1390/node_exporter  

通过浏览器访问 http://IP+9100/metrics可以查看到监控信息

Prometheus服务器中添加被监控机器的配置 vim prometheus.yml, target的也可以写ip

yml 复制代码
  - job_name: 'agent-1'
    static_configs:
      - targets: ['ip:9100']

动态更新配置 curl -X POST http://localhost:9090/-/reload

查看Web UI界面的target和configuration是否有对应的数据

Ok,Prometheus监控组件Node-Exporter的实操就结束啦,记得三连➕关注哦!

相关推荐
甲鱼9295 小时前
MySQL 实战手记:日志管理与主从复制搭建全指南
运维
YuMiao1 天前
gstatic连接问题导致Google Gemini / Studio页面乱码或图标缺失问题
服务器·网络协议
碳基沙盒2 天前
OpenClaw 多 Agent 配置实战指南
运维
Sinclair4 天前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
Rockbean5 天前
用40行代码搭建自己的无服务器OCR
服务器·python·deepseek
蝎子莱莱爱打怪5 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
茶杯梦轩5 天前
CompletableFuture 在 项目实战 中 创建异步任务 的核心优势及使用场景
服务器·后端·面试
海天鹰6 天前
【免费】PHP主机=域名+解析+主机
服务器
DianSan_ERP6 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
呉師傅6 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑