Prometheus如何集成Node Exporter

2023-05-11,,

小编给大家分享一下Prometheus如何集成Node Exporter,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

简介

Prometheus 官方和一些第三方,已经把一些常用数据库、系统、中间件等的指标数据的采集做成了一个个 exporter,在生产环境中,直接导入使用就可以。 我们就用 Prometheus 官方提供的 Node Exporter 来完成对Linux系统运行数据的采集 。

实验

NodeExporter 安装及运行

下载地址:
https://github.com/prometheus/node_exporter/releases

下载并解压:

wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz

进入
node_exporter-0.18.1.linux-amd64 启动nod
e_exporter:

./node_exporter

Prometheus 配置

在 prometheus.yml 中配置 node_exporter 的metrics 端点,内容如下:

global:
  scrape_interval: 5s
  evaluation_interval: 5s
  scrape_timeout: 5s
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'linux-exporter'
    metrics_path: /metrics
    static_configs:
    - targets: ['172.16.2.101:9100']

启动 prometheus:

docker run --name prometheus -d -p 9090:9090 -v /root/prometheus-data:/prometheus-data \
       prom/prometheus --web.enable-lifecycle --config.file=/prometheus-data/prometheus.yml

访问
http://172.16.2.101:9090/targets 发现已经出现了 target “node_exporter” ,并且为UP状态。

Grafana 导入 DashBoard

Grafana 官方 和 社区 对常用的 DashBoard 已经做好了,可以访问
https://grafana.com/grafana/dashboards 进行查询

选择下载最多的,点击进去:

DashBoard 的 id 为 8919,后面要用到。

启动 Grafana

docker start grafana

通过Grafana的
+ 图标导入(Import) Node Exporter dashboard:

  • grafana id = 2129

  • 注意选中prometheus数据源

点击 “Import” 会跳转到 监控界面:

通过界面可以直观的看到 主机cpu占用率 、负载、磁盘空间、内存等信息。

以上是“Prometheus如何集成Node Exporter”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注本站行业资讯频道!

《Prometheus如何集成Node Exporter.doc》

下载本文的Word格式文档,以方便收藏与打印。