go-pluto / styx

Export Data from Prometheus to csv, gnuplot & matplotlib
https://speakerdeck.com/metalmatze/prometheus-styx
MIT License
99 stars 24 forks source link

Error with the latest version, when specifying the duration flag #17

Closed iwita closed 8 months ago

iwita commented 1 year ago

When I am trying to use styx to query results from Prometheus to CSV using the -d or --duration flag, I get the following errors:

styx --prometheus http://${PROMETHEUS_IP}:${PROMETHEUS_PORT} -d 1h '<some_metric>'

 flag provided but not defined: -d

styx --prometheus http://${PROMETHEUS_IP}:${PROMETHEUS_PORT} --duration 1h '<some_metric>'

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2dbab8]

goroutine 1 [running]:
main.exportAction(0xc000188580)
        /root/go/pkg/mod/github.com/go-pluto/styx@v0.0.0-20230620093618-a4f4604c1052/main.go:101 +0x98
github.com/urfave/cli/v2.(*Command).Run(0xc0002b2840, 0xc000188580, {0xc000000240, 0x6, 0x6})
        /root/go/pkg/mod/github.com/urfave/cli/v2@v2.25.3/command.go:274 +0x76c
github.com/urfave/cli/v2.(*App).RunContext(0xc0002be000, {0x3f5200?, 0xc00001a070}, {0xc000000240, 0x6, 0x6})
        /root/go/pkg/mod/github.com/urfave/cli/v2@v2.25.3/app.go:332 +0x5dc
github.com/urfave/cli/v2.(*App).Run(...)
        /root/go/pkg/mod/github.com/urfave/cli/v2@v2.25.3/app.go:309
main.main()
        /root/go/pkg/mod/github.com/go-pluto/styx@v0.0.0-20230620093618-a4f4604c1052/main.go:90 +0x7d0

I am using version 1.20 of go (have also tried with 1.18)

Tested the commit 144d23073c05e9dfe4722e68515e8a09ff0ad249 and it works.

fossdd commented 9 months ago

same issue here :(

metalmatze commented 9 months ago

Hey, sorry for not responding initially. Must have slipped. If you can please send a PR to fix it. I'm happy to help and review but don't have the time to work on the PR myself.