前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Prometheus + Grafana 快速上手

Prometheus + Grafana 快速上手

作者头像
GoCoding
发布2021-05-06 14:46:15
1.3K0
发布2021-05-06 14:46:15
举报
文章被收录于专栏:GoCodingGoCoding

Prometheus[1] + Grafana[2] 快速上手,监控主机的 CPU, GPU, MEM, IO 等状态。

前提

  • Docker[3]

客户端

Node Exporter

用于采集 UNIX 内核主机的数据,这里下载[4]并解压:

wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
tar xvfz node_exporter-1.1.2.linux-amd64.tar.gz
cd node_exporter-1.1.2.linux-amd64
nohup ./node_exporter &

查看数据:

$ curl http://localhost:9100/metrics
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# 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
...

DCGM Exporter

用于采集 NVIDIA GPU 的数据,以 Docker 镜像[5]运行:

docker run -d --restart=always --gpus all -p 9400:9400 nvidia/dcgm-exporter

查看数据:

$ curl localhost:9400/metrics
# HELP DCGM_FI_DEV_SM_CLOCK SM clock frequency (in MHz).
# TYPE DCGM_FI_DEV_SM_CLOCK gauge
# HELP DCGM_FI_DEV_MEM_CLOCK Memory clock frequency (in MHz).
# TYPE DCGM_FI_DEV_MEM_CLOCK gauge
# HELP DCGM_FI_DEV_MEMORY_TEMP Memory temperature (in C).
...

服务器

Prometheus

配置 ~/prometheus.yml

global:
  scrape_interval: 15s

scrape_configs:
# Node Exporter
- job_name: node
  static_configs:
  - targets: ['192.167.200.91:9100']
# DCGM Exporter
- job_name: dcgm
  static_configs:
  - targets: ['192.167.200.91:9400']

运行 Docker 镜像:

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

访问 http://localhost:9090/ :

访问 http://localhost:9090/targets :

Grafana

运行 Docker 镜像:

docker run -d --restart=always -p 3000:3000 grafana/grafana

访问 http://localhost:3000/ :

admin/admin 登录。

新增数据源

新增 Prometheus

点击 Save & Test

导入仪表盘

导入 8919 Node Exporter for Prometheus Dashboard by StarsL.cn[6]

查看仪表盘:

导入 12239 NVIDIA DCGM Exporter Dashboard by nvidia[7]

查看仪表盘:

参考

  • Start Prometheus[8]
  • Prometheus Docs[9]
    • Configuration[10]
    • Node Exporter[11]
    • DCGM Exporter[12]
  • Grafana Docs[13]
    • Dashboards[14]
    • Plugins[15]

脚注

[1]Prometheus: https://github.com/prometheus/

[2]Grafana: https://github.com/grafana/

[3]Docker: https://docs.docker.com/

[4]这里下载: https://prometheus.io/download/#node_exporter

[5]Docker 镜像: https://hub.docker.com/r/nvidia/dcgm-exporter

[6]Node Exporter for Prometheus Dashboard by StarsL.cn: https://grafana.com/grafana/dashboards/8919

[7]NVIDIA DCGM Exporter Dashboard by nvidia: https://grafana.com/grafana/dashboards/12239

[8]Start Prometheus: https://github.com/ikuokuo/start-prometheus

[9]Prometheus Docs: https://prometheus.io/docs/

[10]Configuration: https://prometheus.io/docs/prometheus/latest/configuration/configuration/

[11]Node Exporter: https://github.com/prometheus/node_exporter

[12]DCGM Exporter: https://github.com/NVIDIA/gpu-monitoring-tools#dcgm-exporter

[13]Grafana Docs: https://grafana.com/docs/grafana/latest/

[14]Dashboards: https://grafana.com/grafana/dashboards

[15]Plugins: https://grafana.com/grafana/plugins/

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-04-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 GoCoding 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前提
  • 客户端
    • Node Exporter
      • DCGM Exporter
      • 服务器
        • Prometheus
          • Grafana
            • 新增数据源
            • 导入仪表盘
        • 参考
          • 脚注
          相关产品与服务
          容器镜像服务
          容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档