diff --git a/Dockerfile b/Dockerfile index 9a2c4cc8..0d509d1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -128,7 +128,7 @@ COPY --from=build /src/bin/neko /usr/bin/neko # # add healthcheck HEALTHCHECK --interval=10s --timeout=5s --retries=8 \ - CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/api/health || exit 1 + CMD wget -O - http://localhost:${NEKO_SERVER_BIND#*:}/health || exit 1 # # run neko diff --git a/internal/api/router.go b/internal/api/router.go index c7d171b9..b05115fd 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -57,11 +57,6 @@ func (api *ApiManagerCtx) Route(r types.Router) { r.Route(path, router) } }) - - r.Get("/health", func(w http.ResponseWriter, r *http.Request) error { - _, err := w.Write([]byte("true")) - return err - }) } func (api *ApiManagerCtx) Authenticate(w http.ResponseWriter, r *http.Request) (context.Context, error) { diff --git a/internal/http/logger.go b/internal/http/logger.go index 3714568e..783caede 100644 --- a/internal/http/logger.go +++ b/internal/http/logger.go @@ -17,8 +17,8 @@ type logFormatter struct { } func (l *logFormatter) NewLogEntry(r *http.Request) middleware.LogEntry { - // exclude healthcheck from logs - if r.RequestURI == "/api/health" { + // exclude health & metrics from logs + if r.RequestURI == "/health" || r.RequestURI == "/metrics" { return &nulllog{} } diff --git a/internal/http/manager.go b/internal/http/manager.go index d81f695e..5175f09e 100644 --- a/internal/http/manager.go +++ b/internal/http/manager.go @@ -42,6 +42,11 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c return config.AllowOrigin(r.Header.Get("Origin")) })) + router.Get("/health", func(w http.ResponseWriter, r *http.Request) error { + _, err := w.Write([]byte("true")) + return err + }) + router.Get("/metrics", func(w http.ResponseWriter, r *http.Request) error { promhttp.Handler().ServeHTTP(w, r) return nil