Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to install promtool #8480

Closed
JarnoRFB opened this issue Feb 12, 2021 · 6 comments
Closed

Error when trying to install promtool #8480

JarnoRFB opened this issue Feb 12, 2021 · 6 comments

Comments

@JarnoRFB
Copy link

What did you do?
go get -v github.com/prometheus/prometheus/cmd/promtool

What did you expect to see?
promtool being installed.

What did you see instead? Under which circumstances?

# github.com/prometheus/prometheus/cmd/promtool
../go/src/github.com/prometheus/prometheus/cmd/promtool/main.go:645:35: not enough arguments in call to api.LabelValues
	have (context.Context, string, time.Time, time.Time)
	want (context.Context, string, []string, time.Time, time.Time)

Environment

  • Go version
    go version go1.15.8 linux/amd64

  • System information:
    Ubuntu 20.04.2 LTS
    Linux 5.4.0-65-generic x86_64

@skorpy2009
Copy link

skorpy2009 commented Feb 12, 2021

The bug was introduced by prometheus/client_golang#828
prometheus/client_golang@babeb35#diff-9a3a8e3f0424115273d9a05e9b087ad13a7872995a962822be6975c287d3857cR236

@roidelapluie
Copy link
Member

Thank you. Promtool builds fine within out CI, so I think it might be in your local setup.

Can you try with a released binary? You can get them at https://prometheus.io/download/ ; it is shipped with Prometheus.

Alternatively, could you try to run:

git clone https://github.com/prometheus/prometheus
cd prometheus
make build

which is the "official" way to build Prometheus.

@ZyanKLee
Copy link

I got the same issue when building in docker with Dockerfile:

FROM golang:1.15.8-buster as prom

RUN go get github.com/prometheus/alertmanager/cmd/amtool ;\
    go get github.com/prometheus/prometheus/cmd/promtool ;\
    /go/bin/amtool --version ;\
    /go/bin/promtool --version

amtool installs fine, but promtool fails with the message mentioned above.

@beorn7
Copy link
Member

beorn7 commented Feb 15, 2021

You have to make sure to be in Go-module mode. If you just build from the lastest state of all the dependencies, you'll run into the breaking change that was merged in prometheus/client_golang recently.

For example, you could run

GO111MODULE=on go get -v github.com/prometheus/prometheus/cmd/promtool@master

In general, it's recommended to use the released binaries published here. If you want to build things yourself, be prepared to run into some Go shenanigans.

@beorn7 beorn7 closed this as completed Feb 15, 2021
@JarnoRFB
Copy link
Author

Using GO111MODULE=on go get -v github.com/prometheus/prometheus/cmd/promtool@master works indeed, thanks!

It should be mentioned that building promtool from source is explicitly mentioned in the docs https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/ . I believe it would make sense then to instead recommended to use the released binaries. I can provide a PR if that makes sense.

@beorn7
Copy link
Member

beorn7 commented Feb 15, 2021

Good catch. I created #8491 to address that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants