bosun-monitor / bosun

Time Series Alerting Framework
http://bosun.org
MIT License
3.4k stars 495 forks source link

Fix panic when ip address without scheme is used for graphite backend #2487

Closed johnewing1 closed 3 years ago

johnewing1 commented 4 years ago

Description

Fixes panic when an IP address without a scheme was used as the graphite host. E.g.

[GraphiteConf]
    Host = "127.0.0.1:80"

Results in

2020/06/30 17:45:29 enabling syslog
2020/06/30 17:45:29 info: migrate.go:138: checking migrations
2020/06/30 17:45:29 info: search.go:208: Loading last datapoints from redis
2020/06/30 17:45:29 info: search.go:215: Done
2020/06/30 17:45:29 info: check.go:562: check alert example.graphite start with now set to 2020-06-30 16:45:29.095031
2020/06/30 17:45:29 info: check.go:562: check alert example.opentsdb.os.high.cpu start with now set to 2020-06-30 16:45:29.095031
2020/06/30 17:45:29 info: check.go:562: check alert example.opentsdb.cpu.lookup start with now set to 2020-06-30 16:45:29.095031
<nil>2020/06/30 17:45:29 error: expr.go:148: Error: runtime error: invalid memory address or nil pointer dereference. Origin: Schedule: Alert Name: example.graphite. Expression: avg(graphite("*.cpu.*.cpu.user", "5m", "", "host..cpu")) > 1, Stack: goroutine 92 [running]:
runtime/debug.Stack(0x2271b60, 0x2254880, 0x35f4ba0)
    /usr/local/Cellar/go/1.13.7/libexec/src/runtime/debug/stack.go:24 +0x9d
bosun.org/cmd/bosun/expr.errRecover(0xc000169e58, 0xc000290f20)

Type of change

How has this been tested?

Checklist: