Prometheus + Grafana 实时监控Linux

上篇中介绍了Prometheus, Grafana,并实现了实时监控Windows,回顾:Prometheus + Grafana 实时监控Windows

本篇来介绍一下Linux。

node exporter安装配置

  1. 下载 node exporter

    1
    wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
  2. 解压

    1
    tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz
  3. 添加系统服务 (vi /usr/lib/systemd/system/node_exporter.service)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    [Unit]
    Description=https://prometheus.io

    [Service]
    Restart=on-failure
    ExecStart=/opt/node_exporter-0.18.1.linux-amd64/node_exporter

    [Install]
    WantedBy=multi-user.target
  4. 启动服务

    1
    2
    systemctl start node_exporter
    systemctl status node_exporter
  5. 验证

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    [root@izheyi node_exporter-0.18.1.linux-amd64]# curl http://localhost:9100/metrics
    # HELP go_gc_duration_seconds A summary of the GC invocation durations.
    # TYPE go_gc_duration_seconds summary
    go_gc_duration_seconds{quantile="0"} 0
    go_gc_duration_seconds{quantile="0.25"} 0
    go_gc_duration_seconds{quantile="0.5"} 0
    go_gc_duration_seconds{quantile="0.75"} 0
    go_gc_duration_seconds{quantile="1"} 0
    go_gc_duration_seconds_sum 0
    go_gc_duration_seconds_count 0
    # HELP go_goroutines Number of goroutines that currently exist.
    # TYPE go_goroutines gauge
    go_goroutines 6
    # HELP go_info Information about the Go environment.
    # TYPE go_info gauge
    go_info{version="go1.12.5"} 1

Prometheus配置

  1. 添加prometheus相关配置, prometheus.yml

    1
    2
    3
    - job_name: 'linux'
    static_configs:

    - targets: ['192.168.174.128:9100']
  2. 重启prometheus

  3. 验证

Grafana配置

  1. 配置Prometheus数据源

  2. 搭建Prometheus仪表盘
    Import Dashboard: 8919

  3. 验证

唐胡璐 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
分享创造价值,您的支持将鼓励我继续前行!