简单prometheus+grafana+pushgateway采集GPU利用率和交换机流量

1、prometheus+pushgateway

https://prometheus.io/download/下载prometheus和pushgateway

下载后修改prometheus.yaml

pushgateway需要设置honor_labels: true才能保留原来的job、instance等

然后启动:./prometheus --config.file="./prometheus.yml"

./pushgateway

访问pushgateway:http://x.x.x.x:9091

查看pushgateway数据:http://x.x.x.x:9091/metrics

注意:pushgateway只保留最后一次推送的值,prometheus拉取的时候也是拉取pushgateway当前存储的值

查看prometheus:http://x.x.x.x:9090

Status->Targets里面可以检查目标状态、上次拉取时间等

注意:http://x.x.x.x:9090/metrics并不能查看到所有表项

2、grafana

grafana安装:

apt-get install -y software-properties-common

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

apt install grafana

systemctl start grafana-server

systemctl enable grafana-server

登录:http://x.x.x.x:3000

用户名密码admin admin

有的exporter源码会提供grafana配置文件,比如dcgm-exporter中:

dcgm-exporter\grafana\dcgm-exporter-dashboard.json

在Home->Dashboards->New->Import中导入json就可以看到图形

修改Y轴的单位

对应panel右上角三个点中选择Edit,Standard options,Uint中选择(忘了。。待确认)

安装dcgm-exporter

https://github.com/NVIDIA/dcgm-exporter

下载源码,然后:

kubectl create namespace gpu-monitoring

kubectl apply dcgm-exporter/service-monitor.yaml

kubectl apply dcgm-exporter/dcgm-exporter.yaml -n gpu-monitoring

创建nodeport并提交

c 复制代码
apiVersion: v1
kind: Service
metadata:
  name: dcgm-exporter
  namespace: gpu-monitoring
spec:
  selector:
    app.kubernetes.io/name: dcgm-exporter
  ports:
  - port: 9400
    targetPort: 9400
    nodePort: 30094
  type: NodePort

测试:curl http://localhost:30094/metrics

问题1:

c 复制代码
error: resource mapping not found for name: "dcgm-exporter" namespace: "" from "service-monitor.yaml": no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"
ensure CRDs are installed first

下载https://github.com/prometheus-operator/prometheus-operato,提交prometheus-operator\\prometheus-operator\\example\\prometheus-operator-crd\\monitoring.coreos.com_servicemonitors.yaml

相关推荐
SRETalk19 小时前
夜莺监控设计思考(三)时序库、agent 的一些设计考量
prometheus·可观测性·监控告警·nightingale·opentelemetry·夜莺监控·categraf
时空无限1 天前
grafana dashboard 监控 json 文件 uid 长度限制
grafana
q9085447032 天前
Prometheus+Grafana 智能监控告警系统(服务器指标采集、mysql指标采集)
服务器·grafana·prometheus
风清再凯3 天前
03_Pushgateway使用&Prometheus的服务发现机制
服务发现·prometheus
喜欢你,还有大家3 天前
Prometheus监控部署——pushgateway&&自动推送
运维·prometheus
小小的木头人4 天前
基于Docker 搭建 Prometheus & Grafana 环境
运维·docker·容器·grafana·prometheus
奈斯ing4 天前
【prometheus+Grafana篇】避坑指南:实践中常见问题与解决方案总结整理(持续更新...)
运维·grafana·prometheus·1024程序员节
观测云4 天前
通过 Grafana 使用 PromQL 查询分析观测云数据最佳实践
grafana
风清再凯4 天前
02_prometheus监控&Grafana展示
prometheus·1024程序员节
抹香鲸之海5 天前
Prometheus+Grafana实现Springboot服务监控
spring boot·grafana·prometheus