在Prometheus官网的GETTING STARTED 文档中,有个用go语言开发的client_golang的例子,这段示例执行后,可以模拟三个被监控的目标。
代码所属的章节如下:
Starting up some sample targets
Download the Go client library for Prometheus and run three of these example processes:
相关命令行如下:
# Fetch the client library code and compile example.
git clone https://github.com/prometheus/client_golang.git
cd client_golang/examples/random
go get -d
go build
# Start 3 example targets in separate terminals:
./random -listen-address=:8080
./random -listen-address=:8081
./random -listen-address=:8082
下载并安装安装了golang和git后,就可以执行上面的代码了。Prometheus官网给出的示例是linux操作系统的,我的是windows环境,所以我在windows PowerShell下执行,除了提示符不一样,命令都一样。
git clone https://github.com/prometheus/client_golang.git
cd client_golang/examples/random
前两行都正常,没有报错。
当执行到 go get -d 命令时,报了类似下面的错: