Node Exporter

  node_exporter 主要用于 *NIX 系统监控, 用 Golang 编写。

功能对照表

默认开启的功能
名称 说明 系统
arp /proc/net/arp 中收集 ARP 统计信息 Linux
conntrack /proc/sys/net/netfilter/ 中收集 conntrack 统计信息 Linux
cpu 收集 cpu 统计信息

Darwin, Dragonfly,

FreeBSD, Linux

diskstats /proc/diskstats 中收集磁盘 I/O 统计信息 Linux
edac 错误检测与纠正统计信息 Linux
entropy 可用内核熵信息 Linux
exec execution 统计信息 Dragonfly, FreeBSD
filefd                    /proc/sys/fs/file-nr 中收集文件描述符统计信息 Linux
filesystem 文件系统统计信息,例如磁盘已使用空间

Darwin, Dragonfly,

FreeBSD, Linux, OpenBSD

hwmon /sys/class/hwmon/ 中收集监控器或传感器数据信息 Linux
infiniband 从 InfiniBand 配置中收集网络统计信息 Linux
loadavg 收集系统负载信息

Darwin, Dragonfly, FreeBSD,

Linux, NetBSD, OpenBSD, Solaris

mdadm /proc/mdstat 中获取设备统计信息 Linux
meminfo 内存统计信息

Darwin, Dragonfly,

FreeBSD, Linux

netdev 网口流量统计信息,单位 bytes

Darwin, Dragonfly,

FreeBSD, Linux, OpenBSD

netstat /proc/net/netstat 收集网络统计数据,等同于 netstat -s Linux
sockstat /proc/net/sockstat 中收集 socket 统计信息 Linux
stat /proc/stat 中收集各种统计信息,包含系统启动时间,forks, 中断等 Linux
textfile 通过 --collector.textfile.directory参数指定本地文本收集路径,收集文本信息 any
time 系统当前时间 any
uname 通过 uname 系统调用, 获取系统信息 any
vmstat /proc/vmstat 中收集统计信息 Linux
wifi 收集 wifi 设备相关统计数据 Linux
xfs 收集 xfs 运行时统计信息 Linux (kernel 4.4+)
zfs 收集 zfs 性能统计信息 Linux
默认关闭的功能
名称 说明 系统
bonding 收集系统配置以及激活的绑定网卡数量 Linux
buddyinfo /proc/buddyinfo 中收集内存碎片统计信息 Linux
devstat 收集设备统计信息 Dragonfly, FreeBSD
drbd 收集远程镜像块设备(DRBD)统计信息 Linux
interrupts 收集更具体的中断统计信息 Linux,OpenBSD
ipvs /proc/net/ip_vs 中收集 IPVS 状态信息,从 /proc/net/ip_vs_stats 获取统计信息 Linux
ksmd /sys/kernel/mm/ksm 中获取内核和系统统计信息 Linux
logind logind 中收集会话统计信息 Linux
meminfo_numa /proc/meminfo_numa 中收集内存统计信息 Linux
mountstats /proc/self/mountstat 中收集文件系统统计信息,包括 NFS 客户端统计信息 Linux
nfs /proc/net/rpc/nfs 中收集 NFS 统计信息,等同于 nfsstat -c Linux
qdisc 收集队列推定统计信息 Linux
runit 收集 runit 状态信息 any
supervisord 收集 supervisord 状态信息 any
systemd systemd 中收集设备系统状态信息 Linux
tcpstat /proc/net/tcp/proc/net/tcp6 收集 TCP 连接状态信息 Linux

注意:我们可以使用 --collectors.enabled 运行参数指定 node_exporter 收集的功能模块, 如果不指定,将使用默认模块。

程序安装

下载地址:https://prometheus.io/download/#node_exporter

安装node exporter
tar -zxvf node_exporter-0.16.0.linux-amd64.tar.gz

mv node_exporter-0.16.0.linux-amd64 /usr/local/node_exporter
创建systemd服务
vim /etc/systemd/system/node_exporter.service

[Unit]
Description=node_exporter
After=network.target [Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure [Install]
WantedBy=multi-user.target
启动node_exporter
systemctl daemon-reload
systemctl start node_exporter
systemctl status node_exporter
systemctl enable node_exporter
验证启动成功
curl 127.0.0.1:9100
curl 127.0.0.1:9100/metrics

拉取数据

可以利用 Prometheus 的 static_configs 来拉取 node_exporter 的数据。

编辑prometheus.yml文件,添加内容

- job_name: 'node'
static_configs:
- targets: ['localhost:9100']

重启prometheus,然后在Prometheus页面中的Targets中就能看到新加入的node

Node Exporter 常用查询语句

收集到 node_exporter 的数据后,我们可以使用 PromQL 进行一些业务查询和监控,下面是一些比较常见的查询

以下查询均以单个节点作为例子,如果大家想查看所有节点,将 instance="xxx" 去掉即可。

CPU使用率

100 - (avg by (instance) (irate(node_cpu{instance="172.16.8.153:9100", mode="idle"}[5m])) * 100)

CPU各个mode使用率

avg by (instance, mode) (irate(node_cpu{instance="172.16.8.153:9100"}[5m])) * 100
  • User:CPU一共花了多少比例的时间运行在用户态空间或者说是用户进程(running user space processes)。典型的用户态空间程序有:Shells、数据库、web服务器等

  • Nice:可理解为,用户空间进程的CPU的调度优先级,范围为[-20,19]

  • System:System的含义与User相似。System表示:CPU花了多少比例的时间在内核空间运行。分配内存、IO操作、创建子进程……都是内核操作。这也表明,当IO操作频繁时,System参数会很高

  • ioWait:在计算机中,读写磁盘的操作远比CPU运行的速度要慢,CPU负载处理数据,而数据一般在磁盘上需要读到内存中才能处理。当CPU发起读写操作后,需要等着磁盘驱动器将数据读入内存,从而导致CPU 在等待的这一段时间内无事可做。CPU处于这种等待状态的时间由Wait参数来衡量

  • Idle:CPU处于空闲状态时间比例。一般而言,idel + user + nice 约等于100%

机器平均负载

node_load1{instance="172.16.8.153:9100"}   // 1分钟负载
node_load5{instance="172.16.8.153:9100"} // 5分钟负载
node_load15{instance="172.16.8.153:9100"} // 15分钟负载  

内存使用率

100-(node_memory_MemFree{instance="172.16.8.172:9100"}+node_memory_Cached{instance="172.16.8.172:9100"}+node_memory_Buffers{instance="172.16.8.172:9100"})/node_memory_MemTotal{instance="172.16.8.172:9100"} * 100

磁盘使用率

100 - node_filesystem_free{instance="172.16.8.153:9100",fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs|udev|none|devpts|sysfs|debugfs|fuse.*"} / node_filesystem_size{instance="172.16.8.153:9100",fstype!~"rootfs|selinuxfs|autofs|rpc_pipefs|tmpfs|udev|none|devpts|sysfs|debugfs|fuse.*"} * 100

或者你也可以直接使用 {fstype="xxx"} 来指定想查看的磁盘信息

网卡出/入包

// 入包量
sum by (instance) (rate(node_network_receive_bytes{instance="172.16.8.153:9100",device!="lo"}[5m])) // 出包量
sum by (instance) (rate(node_network_transmit_bytes{instance="172.16.8.153:9100",device!="lo"}[5m]))

Node exporter Dashboard 模板

获取node exporter dashboard

1.下载dashboard json文件在上传到grafana中
https://grafana.com/dashboards/1860 2.直接在grafana中输入相应导入的dashboard code_id

输入code_id 或者 导入json文件

有些仪表盘上面是没有数据的,可能有些参数需要调整(模板可能适应以前的版本),对照这PromQL 修改参数

Prometheus Node_exporter的更多相关文章

  1. Centos7.X 搭建Prometheus+node_exporter+Grafana实时监控平台

    Prometheus简介 什么是 Prometheus Prometheus是一个开源监控报警系统和时序列数据库 主要功能 多维数据模型(时序由 metric 名字和 k/v 的 labels 构成) ...

  2. Golang 基于Prometheus Node_Exporter 开发自定义脚本监控

    Golang 基于Prometheus Node_Exporter 开发自定义脚本监控 公司是今年决定将一些传统应用从虚拟机上迁移到Kubernetes上的,项目多而乱,所以迁移工作进展缓慢,为了建立 ...

  3. Centos8.X 搭建Prometheus+node_exporter+Grafana实时监控平台

    Prometheus Promtheus是一个时间序列数据库,其采集的数据会以文件的形式存储在本地中,因此项目目录下需要一个data目录,需要我们自己创建,下面会讲到 下载 下载好的.tar.gz包放 ...

  4. Prometheus node_exporter grafana部署安装

    1.环境 centos7 prometheus-2.10.0.linux-amd64.tar.gz node_exporter-0.18.1.linux-amd64.tar.gz 2.安装 创建sys ...

  5. Grafana+Prometheus+node_exporter监控,Grafana无法显示数据的问题

    环境搭建: 被测linux机器上部署了Grafana,Prometheus,node_exporter,并成功启动了它们. Grafana中已经创建了Prometheus数据源,并测试通过,并且导入了 ...

  6. Prometheus Node_exporter 详解

    Basic CPU / Mem / Disk Info https://www.cnblogs.com/qianyuliang/p/10479515.html Basic CPU / Mem / Di ...

  7. Prometheus Node_exporter 之 Node Exporter

    Node Exporter 1. Node Exporter Scrape Time type: GraphUnit: secondsLabel: Seconds{{collector}} - 各个收 ...

  8. Prometheus Node_exporter 之 Network Netstat ICMP

    Network Netstat ICMP /proc/net/snmp 1. ICMP Errors 1 type: GraphUnit: shortLabel: Messages out (-) / ...

  9. Prometheus Node_exporter 之 Network Netstat UDP

    Network Netstat UDP /proc/net/snmp 1. UDP In / Out type: GraphUnit: shortLabel: Datagrams out (-) / ...

随机推荐

  1. Pair Project1:电梯控制程序

    12061199 程刚  &&   12061204 黎柱金 一.结对编程的优缺点 结对编程相对于一个人的编程有更多的优点,缺点也有很大不同. 首先,优点: 结队可以让两人可以更好的协 ...

  2. Jquery获取和修改img的src值的方法

    转自:http://www.jb51.net/article/46861.htm 获取(代码): $("#imgId")[0].src; 修改(代码): $("#imgI ...

  3. zookeeper安装(Linux)

    安装环境: Linux:centos6.4 Jdk:1.7以上版本 Zookeeper是java开发的可以运行在windows.linux环境.需要先安装jdk. 安装步骤: 第一步:安装jdk 第二 ...

  4. Jenkins and Python

    https://jenkins.io/solutions/python/ In the Python ecosystem there are tools which can be integrated ...

  5. CentOS(6.8)7 安装 Mysql 5.7

    https://blog.csdn.net/zyw_java/article/details/70949596 https://blog.csdn.net/yzl11/article/details/ ...

  6. pandas获取当前时间

    datetime.now()用于获取当前的日期和时间 print pd.datetime.now() #encoding:utf8 import pandas as pd print("(p ...

  7. ElasticSearch 6.x head插件安装

    一.下载node.js yum install -y nodejs 二.安装npm npm install -g cnpm --registry=https://registry.npm.taobao ...

  8. k8s 1.9 安装

    测试环境 主机 系统 master CentOS 7.3 node CentOS 7.3 2.关闭selinux(所有节点都执行) [root@matser ~]# getenforce Disabl ...

  9. 激活win10专业版

    每180天激活一次

  10. Jenkins之前置替换脚本内容

    在执行Jenkins任务前,需要修改执行的工程的某个文件中的内容,在前置步骤中编写脚本进行修改. Pre Steps Windows batch script @echo off CHCP setlo ...