您现在的位置是:首页 > 文章详情

Prometheus 集成 Node Exporter

日期:2019-08-14点击:395

文章首发于公众号《程序员果果》
地址:https://mp.weixin.qq.com/s/40ULB9UWbXVA21MxqnjBxw

简介

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

实验

Node Exporter 安装及运行

在一台 Linux 机器上安装并运行 Node Exporter,我使用的是一台 ip 为 172.16.2.101 的Linux 虚拟机。

下载地址: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 文件夹 启动node_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 = 8919
  • 注意选中prometheus数据源

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

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

总结

这一节 ,通过集成 Node Exporter 来演示了 exporter 的使用。之后你可以利用Prometheus 官方提供的其他 exporter 应用到你的学习或工作中,例如 MySQL Server Exporter 、Redis exporter 等等。

参考

https://github.com/prometheus/mysqld_exporter

往期内容

原文链接:https://yq.aliyun.com/articles/714425
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章