美文网首页Prometheus+Grafana
3. Node_export安装部署

3. Node_export安装部署

作者: 软件测试汪 | 来源:发表于2019-08-15 14:31 被阅读0次

首先我们要知道什么是Node_export?因为Prometheus本身不具备监控功能,我们要通过Prometheus收集数据,需要安装对应的export。如Node_export用于监控服务器状态,如cpu、内存、网络、磁盘等信息。

注意事项: node_exporter服务需要在两台机器都安装,这里我们以客户端(192.168.229.138)为例

客户端

1.创建运行用户

[root@localhost opt]# groupadd -r prometheus
[root@localhost opt]# useradd -r -g prometheus -d / -s /sbin/nologin -c "prometheus user" prometheus

2.下载安装

[root@localhost opt]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost opt]# tar -xf node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost opt]# cp node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin/

3.配置启动脚本

[root@localhost opt]# vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target
 
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target

4.启动

[root@localhost opt]# systemctl daemon-reload
[root@localhost opt]# systemctl enable node_exporter
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /usr/lib/systemd/system/node_exporter.service.
[root@localhost opt]# systemctl start node_exporter

5.监听9100端口

[root@localhost opt]# netstat -anlptu|grep 9100
tcp        0      0 192.168.229.139:56874   192.168.229.138:9100    ESTABLISHED 8528/prometheus     
tcp        0      0 192.168.229.139:40074   192.168.229.139:9100    ESTABLISHED 8528/prometheus     
tcp6       0      0 :::9100                 :::*                    LISTEN      6064/node_exporter  
tcp6       0      0 192.168.229.139:9100    192.168.229.139:40074   ESTABLISHED 6064/node_exporter  

服务端

1.安装node_exporter,参考客户端安装

2. 修改prometheus.yml

[root@localhost opt]# vim /etc/prometheus/prometheus.yml
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'node'   ### 新增加job
    static_configs:
    - targets: ['192.168.229.139:9100','192.168.229.138:9100']  ### 主机列表

3.访问Prometheus Status > targets

targets.png

4.收集系统CPU监控信息

4.1 CPU使用率

公式:100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)


image.png

4.2 CPU负载

公式:

1分钟负载:node_load1

5分钟负载:node_load5

15分钟负载:node_load15

image.png

5.收集系统内存监控信息

5.1 内存使用率

公式:(1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes ))* 100

5.2 可用内存(单位:M)

公式:node_memory_MemAvailable_bytes / 1024 / 1024

6.收集系统磁盘监控信息

6.1 磁盘总大小(单位: G)

公式:node_filesystem_size_bytes {fstype=~"ext4|xfs"} / 1024 / 1024 / 1024

6.2 磁盘剩余大小(单位: G)

公式:node_filesystem_avail_bytes {fstype=~"ext4|xfs"} / 1024 / 1024 / 1024

6.3 磁盘使用率

公式:(1-(node_filesystem_free_bytes{fstype=~"ext4|xfs"} / node_filesystem_size_bytes{fstype=~"ext4|xfs"})) * 100

7.收集系统网络监控信息(ip add 查看网卡信息)

7.1 网卡入网流量 (指定某一个网卡)

公式:irate(node_network_receive_bytes_total{device='ens33'}[5m])

7.2 网卡出网流量(指定某一个网卡)

公式:irate(node_network_transmit_bytes_total{device='ens33'}[5m])

说明:以上收集系统各信息,都是通过node_exporter服务进行数据的收集,然后通过prometheus内置的PromQL语句进行组合查询,对于每一个公式,都可以在prometheus WEB界面测试查询。关于具体的PromQL语句以及公式中函数的使用参考:PromQL语句

软件测试汪简书地址
软件测试汪博客地址

欢迎关注微信公众号:软件测试汪。软件测试交流群:809111560

转载请注意出处,谢谢合作

相关文章

  • 3. Node_export安装部署

    首先我们要知道什么是Node_export?因为Prometheus本身不具备监控功能,我们要通过Promethe...

  • Lnmt

    1.安装nginx 2.安装tomcat 3.部署jpress

  • ansible批量管理服务部署 2020-03-07

    ansible批量管理服务部署 1. 安装部署软件 2. 编写主机清单 3. 配置密钥免密码连接认证 3. 测试被...

  • LFS258-LAB-helm

    安装helm 下载helm二进制文件安装 给helm创建rbac的授权 3.部署tiller服务器 4.查看部署状...

  • kafka eagle安装部署

    kafka安装部署教程 1.kafka+zookeeper准备 2.JDK环境准备 3.开始安装kafka-eag...

  • gitlab入门

    第1章 gitlab安装部署 1.官方网站 2.安装依赖 3.安装gitlab 方法1:添加清华源,然后安装 方法...

  • (转) gitlab入门

    gitlab入门 第1章 gitlab安装部署 1.官方网站 2.安装依赖 3.安装gitlab 方法1:添加清华...

  • docker-compose部署zk+kafka+storm集群

    **目录:** 1. docker环境安装 2. zookeeper和kafka集群部署 3. influxdb单...

  • 重装系统节点osd的恢复方法

    本文只使用ceph lvm部署的集群节点 1. ceph osd set noout 2. 安装系统 3. 安装c...

  • 打造Linux部署环境

    打造Linux部署环境 简介 所包含的安装项目 1. 静态网络配置 2. 源码方式安装 MySQL 3. JDK ...

网友评论

    本文标题:3. Node_export安装部署

    本文链接:https://www.haomeiwen.com/subject/kskzjctx.html