构建黑盒导出器时出错 [英] Error building blackbox exporter

查看:89
本文介绍了构建黑盒导出器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Prometheus 完全陌生,目前正在尝试解决构建黑盒导出器时反映的错误 (https://github.com/prometheus/blackbox_exporter).

I am absolutely new to Prometheus and currently trying to troubleshoot the error that is being reflected while building blackbox exporter (https://github.com/prometheus/blackbox_exporter).

[root@sk004 blackbox_exporter]# pwd
/usr/local/blackbox_exporter
[root@sk004 blackbox_exporter]# echo $GOROOT
/usr/local/go/default
[root@sk004 blackbox_exporter]# echo $GOPATH
/usr/local/blackbox_exporter
[root@sk004 blackbox_exporter]# make
>> formatting code
can't load package: package _/usr/local/blackbox_exporter: cannot find package "_/usr/local/blackbox_exporter" in any of:
    /usr/local/go/src/_/usr/local/blackbox_exporter (from $GOROOT)
    /usr/local/blackbox_exporter/src/_/usr/local/blackbox_exporter (from $GOPATH)
make: *** [format] Error 1

请指教.

推荐答案

go 在构建时在 $GOPATHsrc 子文件夹中查找可执行.有关文档,请参阅 https://golang.org/doc/code.html#GOPATH这.我能够使用 make 构建可执行文件,但是 go install 需要更少的步骤.

go looks in the srcsubfolder of $GOPATH when building the executable. See https://golang.org/doc/code.html#GOPATH for documentation about this. I was able to build the executable using make, but go install requires fewer steps.

这些步骤对我有用:

export GOPATH=/usr/local/go
mkdir -p $GOPATH/src
cd $GOPATH/src
git clone https://github.com/prometheus/blackbox_exporter.git
cd blackbox_exporter
go install

如果没有遇到错误,可执行文件应该位于 $GOPATH/bin/blackbox_exporter.可执行文件需要能够找到 blackbox.yml,它位于 $GOPATH/src/blackbox_exporter 中.我使用以下命令运行可执行文件:

If no errors are encountered, the executable should be located at $GOPATH/bin/blackbox_exporter. The executable needs to be able to find blackbox.yml, which is in $GOPATH/src/blackbox_exporter. I ran the executable using:

cd $GOPATH/src/blackbox_exporter
$GOPATH/bin/blackbox_exporter

这篇关于构建黑盒导出器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆