使用 prometheus 监控 esxi:获取错误未定义:debug.ReadBuildInfo

分享于2022年09月29日 esxi go prometheus vcenter 问答
【问题标题】:monitoring esxi using prometheus : getting error undefined: debug.ReadBuildInfo使用 prometheus 监控 esxi:获取错误未定义:debug.ReadBuildInfo
【发布时间】:2022-07-27 16:17:31
【问题描述】:

我正在尝试使用 https://github.com/devinotelecom/prometheus-vmware-exporter 通过 prometheus 监控 esxi 到 grafana

当我跑步时

[root@admin01 prometheus-vmware-exporter]# docker build -t prometheus-vmware-exporter .
Sending build context to Docker daemon  157.7kB
Step 1/9 : FROM golang:1.11 as builder
 ---> 43a154fee764
Step 2/9 : WORKDIR /src/github.com/devinotelecom/prometheus-vmware-exporter
 ---> Using cache
 ---> 6b2aad4c7a43
Step 3/9 : COPY ./ /src/github.com/devinotelecom/prometheus-vmware-exporter
 ---> Using cache
 ---> 2f5f1b155f7f
Step 4/9 : RUN go get -d -v
 ---> Using cache
 ---> a48d35b3d5e2
Step 5/9 : RUN CGO_ENABLED=0 GOOS=linux go build
 ---> Running in 86199cee4fcb
# github.com/prometheus/client_golang/prometheus
/go/src/github.com/prometheus/client_golang/prometheus/build_info_collector.go:24:15: undefined: debug.ReadBuildInfo
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go build' returned a non-zero code: 2
[root@admin01 prometheus-vmware-exporter]# 

感谢您在高级方面的帮助


【解决方案1】:

prometheus 中的最小 golang 版本是 1.15,但在 Dockerfile 中显示的是 1.11

来源: https://github.com/prometheus/client_golang/blob/main/go.mod

尝试在 Dockerfile 中将 golang:1.11 更改为 golang:1.15 ++

【讨论】:

  • Jazak Allah Rahmat Fathoni,它可以工作,但在下一个命令中再次出现错误 #docker run -b --restart=always --name=prometheus-vmware-exporter --env=ESX_HOST abc.xyz。 net --env=ESX_USERNAME root --env=ESX_PASSWORD NE$X1of1shn --env=ESX_LOG debug prometheus-vmware-exporter 未知速记标志:-b 中的“b”参见“docker run --help”。删除-b后无法在本地找到图像'abc.xyz.net:latest' docker:来自守护程序的错误响应:abc.xyz.net的拉取访问被拒绝,存储库不存在或可能需要'docker login':拒绝:requeted拒绝访问资源。
  • 现在得到这个错误 "level=fatal msg="default host resolves to multiple instances, please specify"