• Prometheus系列(2)之EC2安装Node端


    目标

    Prometheus安装Node程序。

    步骤

    node exporter程序

    wget https://github.com/prometheus/node_exporter/releases/download/v1.4.0/node_exporter-1.4.0.linux-amd64.tar.gz
    tar xvzf node_exporter-1.4.0.linux-amd64.tar.gz
    cd node_exporter-1.4.0.linux-amd64/
    
    sudo cp ./node_exporter /usr/local/bin/
    
    • 1
    • 2
    • 3
    • 4
    • 5

    node-exporter.service

    sudo vim /etc/systemd/system/node-exporter.service
    
    • 1

    内容如下:

    [Unit]
    Description=Prometheus Node Exporter Service
    After=network.target
    
    [Service]
    User=node_exporter
    Group=node_exporter
    Type=simple
    ExecStart=/usr/local/bin/node_exporter
    
    [Install]
    WantedBy=multi-user.target
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    node_exporter用户

    sudo useradd --system --no-create-home --shell /sbin/nologin --comment "prometheus node_exporter user" --user-group node_exporter
    
    
    • 1
    • 2

    Sys V

    sudo systemctl daemon-reload
    sudo systemctl enable node-exporter
    sudo systemctl start node-exporter
    sudo systemctl status node-exporter
    
    • 1
    • 2
    • 3
    • 4

    状态如下:
    node-exporter状态

    安全组放开9100端口

    具体如下:
    node开发9100端口

    Prometheus服务器端

    接下来回到《Prometheus系列(1)之EC2安装Server端》这篇文章中的Prometheus的服务器端的EC2机器上面。

    更新/etc/prometheus/prometheus.yml配置

    sudo vim /etc/prometheus/prometheus.yml
    
    • 1

    添加如下内容:

      - job_name: "node_exporter"
        static_configs:
          - targets: ["172.30.2.26:9100"]
    
    • 1
    • 2
    • 3

    整个文件内容如下:

    # my global config
    global:
      scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
      evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
      # scrape_timeout is set to the global default (10s).
    
    # Alertmanager configuration
    alerting:
      alertmanagers:
        - static_configs:
            - targets:
              # - alertmanager:9093
    
    # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
    rule_files:
      # - "first_rules.yml"
      # - "second_rules.yml"
    
    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:
      # The job name is added as a label `job=` 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_exporter"
        static_configs:
          - targets: ["172.30.2.26:9100"]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    重启Prometheus服务端

    sudo systemctl restart prometheus
    
    • 1

    验证Prometheus监听结果

    node-export监听结果

    总结

    这就是Prometheus的Node Export的使用。

    参考:

  • 相关阅读:
    JVM线程模型详解
    Java:计算球形体积
    解析:动态规划 01背包
    3D可视化字母出现频率_vtkLinearExtrusionFilter
    代码质量保障第2讲:单元测试 - 浅谈单元测试
    进程概念(跑路人笔记)
    Dockerfile概念简介
    [SQL] union all
    牛客网之SQL100题(5)
    Flutter真机运行及模拟器运行
  • 原文地址:https://blog.csdn.net/fxtxz2/article/details/127613991