如何在Ubuntu中安装最新版本的Prometheus / Promtool?

时间:2019-02-22 02:22:26

标签: grafana prometheus rules prometheus-alertmanager

我下载的普罗米修斯版本是2.3.2

wget https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz

未经处理,普罗米修斯已作为服务运行。

我想使用promtool验证我的Prometheus警报管理器规则。 从博客下面创建了一条规则。

https://petargitnik.github.io/blog/2018/01/04/how-to-write-rules-for-prometheus

当我运行 promtool检查规则/etc/prometheus/prometheus.rules.yml

它说,Promtheus没有安装,所以使用 容易得普罗米修斯

但这是安装了较早版本的promtool,这是版本详细信息:

    root@UTVA-kafka-msg-size-2mb-02509:/home/ubuntu# promtool version
prometheus, version 0.16.2+ds (branch: debian/sid, revision: 0.16.2+ds-1ubuntu1)

build user:       pkg-go-maintainers@lists.alioth.debian.org
  build date:       20160408-04:15:29
  go version:       go1.6

Prometheus版本2使用yml文件作为规则,较旧的使用不同的规则,因此我的promtool检查规则失败。

有人可以建议如何升级最新的promtool吗?

谢谢。

1 个答案:

答案 0 :(得分:2)

您可以使用go直接从github安装最新版本/所需版本。确保您已设置 go 。为了方便起见,还可以将GOPATH添加到您的PATH中,例如对于ZSH:

export PATH=$PATH:$GOPATH/bin

然后您可以使用go get安装它:

go get https://github.com/prometheus/prometheus/tree/master/cmd/promtool

现在,您的PATH中有GOPATH了,您只需从shell中调用它即可:

➜  ~ promtool --version
promtool, version  (branch: , revision: )
 build user:
 build date:
 go version:       go1.12.7