move to /health and exclude metrics from logging.

This commit is contained in:
Miroslav Šedivý 2022-07-04 18:09:47 +02:00
parent e37f5c13ca
commit 8f83089c8e
4 changed files with 8 additions and 8 deletions

View File

@ -128,7 +128,7 @@ COPY --from=build /src/bin/neko /usr/bin/neko
# #
# add healthcheck # add healthcheck
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \ 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 # run neko

View File

@ -57,11 +57,6 @@ func (api *ApiManagerCtx) Route(r types.Router) {
r.Route(path, 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) { func (api *ApiManagerCtx) Authenticate(w http.ResponseWriter, r *http.Request) (context.Context, error) {

View File

@ -17,8 +17,8 @@ type logFormatter struct {
} }
func (l *logFormatter) NewLogEntry(r *http.Request) middleware.LogEntry { func (l *logFormatter) NewLogEntry(r *http.Request) middleware.LogEntry {
// exclude healthcheck from logs // exclude health & metrics from logs
if r.RequestURI == "/api/health" { if r.RequestURI == "/health" || r.RequestURI == "/metrics" {
return &nulllog{} return &nulllog{}
} }

View File

@ -42,6 +42,11 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
return config.AllowOrigin(r.Header.Get("Origin")) 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 { router.Get("/metrics", func(w http.ResponseWriter, r *http.Request) error {
promhttp.Handler().ServeHTTP(w, r) promhttp.Handler().ServeHTTP(w, r)
return nil return nil