h0rzn/metawatch-agent

Metrics History endpoint throwing error

Closed this issue · 2 comments

Request: http://165.227.170.145:8080/containers/4b21443dfcd1486e69c9a4be7da94dabee3d3fe6e263c40e41b9555baf6f8dc8/metrics?from=2023-01-15T18:00:00Z&to=2023-01-15T18:01:00Z

Console Output:

time="2023-01-16T14:47:14Z" level=info msg="- DB - init..."
time="2023-01-16T14:47:14Z" level=info msg="- DB::Client - connection successful"
time="2023-01-16T14:47:19Z" level=debug msg="- Container - -> sending for cid: 69a72a55446bc3859b84310f4bee367c2e84e720901ffe8f4d4e8e83ff2808fc\n"
time="2023-01-16T14:47:19Z" level=debug msg="- Container - -> sending for cid: 4b21443dfcd1486e69c9a4be7da94dabee3d3fe6e263c40e41b9555baf6f8dc8\n"
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on :8080
time="2023-01-16T14:47:44Z" level=info msg="- HUB - running"
time="2023-01-16T14:47:44Z" level=info msg="- API - starting gin router"
time="2023-01-16T14:48:25Z" level=debug msg="- DB - aggregate for 4b21443dfcd1486e69c9a4be7da94dabee3d3fe6e263c40e41b9555baf6f8dc8 (2023-01-15 18:00:00 +0000 UTC-2023-01-15 18:01:00 +0000 UTC)\n"
time="2023-01-16T14:48:55Z" level=error msg="- DB - metrics aggregation err: server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: localhost:27017, Type: Unknown, Last error: connection() onnection refused }, ] }"


2023/01/16 14:48:55 [Recovery] 2023/01/16 - 14:48:55 panic recovered:
GET /containers/4b21443dfcd1486e69c9a4be7da94dabee3d3fe6e263c40e41b9555baf6f8dc8/metrics?from=2023-01-15T18:00:00Z&to=2023-01-15T18:01:00Z HTTP/1.1
Host: 165.227.170.145:8080
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: de,en-US;q=0.7,en;q=0.3
Connection: keep-alive
Cookie: prefsHttp={}; token=t.C0vm4KLHHEJXpeb7RKaI
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0


runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:260 (0x44d4d5)
        panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:835 (0x44d4a5)
        sigpanic: panicmem()
/go/pkg/mod/go.mongodb.org/mongo-driver@v1.11.0/mongo/cursor.go:312 (0xb0e0d4)
        (*Cursor).closeImplicitSession: if c.clientSession != nil && c.clientSession.SessionType == session.Implicit {
/usr/local/go/src/runtime/panic.go:884 (0x437511)
        gopanic: done = runOpenDeferFrame(gp, d)
/usr/local/go/src/runtime/panic.go:260 (0x44d4d5)
        panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:835 (0x44d4a5)
        sigpanic: panicmem()
/go/pkg/mod/go.mongodb.org/mongo-driver@v1.11.0/mongo/cursor.go:222 (0xb0d5ff)
        (*Cursor).Close: return replaceErrors(c.bc.Close(ctx))
/usr/local/go/src/runtime/panic.go:884 (0x437511)
        gopanic: done = runOpenDeferFrame(gp, d)
/usr/local/go/src/runtime/panic.go:260 (0x44d4d5)
        panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:835 (0x44d4a5)
        sigpanic: panicmem()
/go/pkg/mod/go.mongodb.org/mongo-driver@v1.11.0/mongo/cursor.go:254 (0xb0d8fd)
        (*Cursor).All: batch := c.batch // exhaust the current batch before iterating the batch cursor
/dock/controller/db/db.go:79 (0xb19f84)
        (*DB).Metrics: if err = curs.All(ctx, &result); err != nil {
/api/container.go:55 (0xb22d0a)
        (*API).Metrics: result := api.Controller.DB.Metrics(id, tminP, tmaxP)
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0x8dc301)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/recovery.go:101 (0x8dc2ec)
        CustomRecoveryWithWriter.func1: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0x8db406)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/logger.go:240 (0x8db3e9)
        LoggerWithConfig.func1: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0x8da4d0)
        (*Context).Next: c.handlers[c.index](c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:616 (0x8da138)
        (*Engine).handleHTTPRequest: c.Next()
/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:572 (0x8d9c7c)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/go/src/net/http/server.go:2947 (0x6cb36b)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1991 (0x6c6586)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1594 (0x467fe0)
        goexit: BYTE    $0x90   // NOP

[GIN] 2023/01/16 - 14:48:55 | 500 | 30.016778732s |   80.137.36.184 | GET      "/containers/4b21443dfcd1486e69c9a4be7da94dabee3d3fe6e263c40e41b9555baf6f8dc8/metrics?from=2023-01-15T18:00:00Z&to=2023-01-15T18:01:00Z"
h0rzn commented

@M0ttii Looks like the database cannot be accessed. Is it even running?

h0rzn commented

path to db can now be set in .env

7d1b2b4