sdvdxl/falcon-message

发送告警时出现runtime error: slice bounds out of range的问题

Closed this issue · 2 comments

下载的编译好的v0.0.4版本的包,配置完成后测试报警,发现有报错,app.log如下
2019/09/09 17:11:44 listening on localhost:23329
2019/09/09 17:14:15 message comming
2019/09/09 17:14:15 tos: [ding]:xxx content: [P0][PROBLEM][SITserver][][开发测试服务器硬盘占用率过高(>80%) all(#3) df.statistics.used.percent 54.46472>=40][O2 2019-09-09 17:14:10]
2019/09/09 17:14:15 {true ok 0}
2019/09/09 17:24:14 tos: [ding]:xxx content: [P0][PROBLEM][SITserver][][开发测试服务器硬盘占用率过高(>80%) lookup(#3,5) df.statistics.used.percent 54.50835>=40][O1 2019-09-09 17:24:10] {"time":"2019-09-09T17:24:14.90493896+08:00","level":"-","prefix":"echo","file":"panic.go","line":"522","message":"[PANIC RECOVER] runtime error: slice bounds out of range goroutine 66 [running]:\ngithub.com/labstack/echo/middleware.RecoverWithConfig.func1.1.1(0x8fd178, 0x1000, 0xc000090000, 0x990760, 0xc00013a000)\n\t/Users/du/Library/Gopath/src/github.com/labstack/echo/middleware/recover.go:71 +0xf1\npanic(0x867b20, 0xc8b510)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/sdvdxl/falcon-message/util.HandleContent(0xc0003565a0, 0x9a, 0x4, 0xc0003565a0, 0x9a)\n\t/Users/du/Library/Gopath/src/github.com/sdvdxl/falcon-message/util/util.go:55 +0x93a\nmain.main.func5(0x990760, 0xc00013a000, 0xc000292330, 0xc00009bc00)\n\t/Users/du/Library/Gopath/src/github.com/sdvdxl/falcon-message/main.go:93 +0x376\ngithub.com/labstack/echo.(*Echo).Add.func1(0x990760, 0xc00013a000, 0x8fd178, 0x1000)\n\t/Users/du/Library/Gopath/src/github.com/labstack/echo/echo.go:477 +0x87\ngithub.com/labstack/echo/middleware.RecoverWithConfig.func1.1(0x990760, 0xc00013a000, 0x0, 0x0)\n\t/Users/du/Library/Gopath/src/github.com/labstack/echo/middleware/recover.go:78 +0xd5\ngithub.com/labstack/echo.(*Echo).ServeHTTP.func1(0x990760, 0xc00013a000, 0xc00023e058, 0x8d9c20)\n\t/Users/du/Library/Gopath/src/github.com/labstack/echo/echo.go:574 +0x105\ngithub.com/labstack/echo.(*Echo).ServeHTTP(0xc00023e000, 0x984d20, 0xc000416380, 0xc000140000)\n\t/Users/du/Library/Gopath/src/github.com/labstack/echo/echo.go:583 +0x1ed\nnet/http.serverHandler.ServeHTTP(0xc0002385b0, 0x984d20, 0xc000416380, 0xc000140000)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc000360000, 0x9856e0, 0xc0000b4080)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/http/server.go:2884 +0x2f4\n\ngoroutine 1 [IO wait]:\ninternal/poll.runtime_pollWait(0x7f394048aff8, 0x72, 0x0)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/runtime/netpoll.go:182 +0x56\ninternal/poll.(*pollDesc).wait(0xc00013ff98, 0x72, 0x0, 0x0, 0x8e0a37)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x9b\ninternal/poll.(*pollDesc).waitRead(...)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/internal/poll/fd_poll_runtime.go:92\ninternal/poll.(*FD).Accept(0xc00013ff80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/internal/poll/fd_unix.go:384 +0x1ba\nnet.(*netFD).accept(0xc00013ff80, 0x42ad7f, 0xc000000008, 0x8fdea0)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/fd_unix.go:238 +0x42\nnet.(*TCPListener).accept(0xc0000a0798, 0x8fdea0, 0xc0002206a0, 0xc000220640)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/tcpsock_posix.go:139 +0x32\nnet.(*TCPListener).Accept(0xc0000a0798, 0xc000341a50, 0x18, 0xc000000180, 0x6b7cb4)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/tcpsock.go:260 +0x48\nnet/http.(*Server).Serve(0xc0002385b0, 0x984a60, 0xc0000a0798, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/net/http/server.go:2859 +0x22d\ngithub.com/tylerb/graceful.(*Server).Serve(0xc000220640, 0x984a60, 0xc0000a0798, 0x984a60, 0xc0000a0798)\n\t/Users/du/Library/Gopath/src/github.com/tylerb/graceful/graceful.go:309 +0x2f2\ngithub.com/tylerb/graceful.(*Server).ListenAndServe(0xc000220640, 0x2, 0x2)\n\t/Users/du/Library/Gopath/src/github.com/tylerb/graceful/graceful.go:147 +0xa1\nmain.main()\n\t/Users/du/Library/Gopath/src/github.com/sdvdxl/falcon-message/main.go:128 +0x73d\n\ngoroutine 18 [syscall, 9 minutes]:\nos/signal.signal_recv(0x0)\n\t/usr/local/Cellar/go/1.12.7/libexec/src/runtime/sigqueue.go:139 +0x9c\nos/signal.loop()\n\t/usr/local/Cellar/go/1.12.7/libexec/src/os/signal/signal_unix.go:23 +0x22\ncreated by os/signal.init.0\n\t/usr/local/Cellar/go/1.12.7/libexec/src/os/signal/signal_unix.go:29 +0x41\n\ngoroutine 21 [select]:\ngithub.com/tylerb/graceful.(*Server).manageConnections(0xc000220640, 0xc00007e720, 0xc00007e780, 0xc00007e7e0, 0xc00007e840, 0xc00007e8a0, 0xc00007e900)\n\t/Users/du/Library/Gopath/src/github.com/tylerb/graceful/graceful.go:366 +0x2da\ncreated by github.com/tylerb/graceful.(*Server).Serve\n\t/Users/du/Library/Gopath/src/github.com/tylerb/graceful/graceful.go:297 +0x220\n\ngoroutine 33 [chan receive, 9 minutes]:\ngithub.com/t\n"} {"time":"2019-09-09T17:24:14.90525154+08:00","level":"ERROR","prefix":"echo","file":"context.go","line":"548","message":"runtime error: slice bounds out of range"}

发现表达式采用all(#3)的就能成功发送告警,用lookup(#3,5)这个表达式的就会报错runtime error: slice bounds out of range
但某些场景的告警是需要使用lookup表达式的,希望能解决下这个问题

我先看一下,平时没用过lookup,解析是按照 all(#3) 格式解析的

已修复 v0.0.5

如有问题再打开issues并描述