Prometheus监控部署使用node-exporter监控主机

时间:2021-07-12
本文章向大家介绍Prometheus监控部署使用node-exporter监控主机,主要包括Prometheus监控部署使用node-exporter监控主机使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Prometheus监控部署

前提条件

  • 已部署docker
  • 已部署grafana
  • 需要开放 3000 9100 和 9090 端口

启动node-exporter

docker run --name node-exporter -d  \
  --restart=always \
  -p 9100:9100 \
  -v "/proc:/host/proc:ro" \
  -v "/sys:/host/sys:ro" \
  -v "/:/rootfs:ro" \
  --net="host" \
  prom/node-exporter

启动prometheus

新建目录prometheus,编辑配置文件prometheus.yml

mkdir /opt/prometheus
cd /opt/prometheus/
vim prometheus.yml

内容如下:

global:
  scrape_interval:     60s
  evaluation_interval: 60s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus

  - job_name: Host monitoring
    static_configs:
      - targets: ['192.168.3.101:9100']
        labels:
          instance: localhost

注意:修改IP地址,这里的192.168.3.101就是本机地址

启动prometheus

docker run  --name prometheus -d  \
  --restart=always \
  -p 9090:9090 \
  -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  \
  prom/prometheus

访问prometheus web页面

浏览器输入 http://192.168.91.132:9090 ;点击 Status-->Targets 访问Targets效果如下:

如果状态没有UP起来,请等待2分钟左右。

添加数据源

访问grafana web界面,添加数据源

点击Data Source, 选择Add data source

选择Prometheus,在URL中填写Prometheus的访问地址,点击Save & Test,出现绿色提示,则添加成功

导入Dashboard

资源下载地址:https://goodrain-delivery.oss-cn-hangzhou.aliyuncs.com/zhonggonggaoke/nodeexporter.json

将该json文件上传至grafana,点击import即可

监控页面

原文地址:https://www.cnblogs.com/Aaron-23/p/15000755.html