criteo / graphite-remote-adapter

Fully featured graphite remote adapter for Prometheus
Apache License 2.0
38 stars 25 forks source link

Problem with building #68

Closed brushek closed 4 years ago

brushek commented 4 years ago

I'm trying to use this adapter, but can't build it:


go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src;
        ignoring go.mod;
        see 'go help modules'
>> building binaries
 >   graphite-remote-adapter
# github.com/criteo/graphite-remote-adapter/client/graphite
client/graphite/read.go:188:19: cannot assign []*prompb.Label to ts.Labels (type []prompb.Label) in multiple assignment
client/graphite/read.go:190:19: cannot assign []*prompb.Label to ts.Labels (type []prompb.Label) in multiple assignment
!! command failed: build -o /root/go/src/github.com/criteo/graphite-remote-adapter/graphite-remote-adapter -ldflags -X github.com/criteo/graphite-remote-adapter/vendor/github.com/prometheus/common/version.Version=0.2.0 -X github.com/criteo/graphite-remote-adapter/vendor/github.com/prometheus/common/version.Revision=7b02e4f3543cf3ff43d4249f30ab5e3daeccba17 -X github.com/criteo/graphite-remote-adapter/vendor/github.com/prometheus/common/version.Branch=master -X github.com/criteo/graphite-remote-adapter/vendor/github.com/prometheus/common/version.BuildUser=root@go-builder -X github.com/criteo/graphite-remote-adapter/vendor/github.com/prometheus/common/version.BuildDate=20191122-15:42:28  -extldflags '-static' -a -tags netgo github.com/criteo/graphite-remote-adapter/cmd/graphite-remote-adapter: exit status 2
Makefile:54: recipe for target 'build' failed
make: *** [build] Error 1```

# go version
go version go1.12.9 linux/amd64
geobeau commented 4 years ago

The adapter use go-modules. From your logs, it seems that Go disable it. Can you try with: export GO111MODULE="on"

brushek commented 4 years ago

After export GO111MODULE="on" I could compile source code, but then - after running graphite-remote-adapter I get:

./graphite-remote-adapter 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x78a2db]

goroutine 1 [running]:
github.com/prometheus/common/promlog.New(0xc0001c1f18, 0xb, 0xc0001d2840)
        /root/go/pkg/mod/github.com/prometheus/common@v0.7.0/promlog/log.go:97 +0x3b
main.main()
        /root/go/src/github.com/criteo/graphite-remote-adapter/cmd/graphite-remote-adapter/main.go:68 +0x75
brushek commented 4 years ago

the format in promlog has changed, following change resolve problem:

diff --git a/cmd/graphite-remote-adapter/main.go b/cmd/graphite-remote-adapter/main.go
index 9f05785..b614f50 100644
--- a/cmd/graphite-remote-adapter/main.go
+++ b/cmd/graphite-remote-adapter/main.go
@@ -65,7 +65,7 @@ func reload(cliCfg *config.Config, logger log.Logger) (*config.Config, error) {
 func main() {
        cliCfg := config.ParseCommandLine()

-       logger := promlog.New(&promlog.Config{Level: &cliCfg.LogLevel})
+       logger := promlog.New(&promlog.Config{Level: &cliCfg.LogLevel, Format: &promlog.AllowedFormat{}})
        level.Info(logger).Log("msg", "Starting graphite-remote-adapter", "version", version.Info())
        level.Info(logger).Log("build_context", version.BuildContext())
mycroft commented 4 years ago

Thanks for the fix! They were included in the main tree.