From 678fb9938c3358934e2511e83dd1650e2cd86be1 Mon Sep 17 00:00:00 2001 From: Thomas Miceli <27960254+thomiceli@users.noreply.github.com> Date: Thu, 12 Sep 2024 01:45:30 +0200 Subject: [PATCH] Add dummy /metrics endpoint (#327) --- internal/utils/validator.go | 2 +- internal/web/healthcheck.go | 6 ++++++ internal/web/server.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/utils/validator.go b/internal/utils/validator.go index 04cbbc3..af78da4 100644 --- a/internal/utils/validator.go +++ b/internal/utils/validator.go @@ -57,7 +57,7 @@ func validateReservedKeywords(fl validator.FieldLevel) bool { name := fl.Field().String() restrictedNames := map[string]struct{}{} - for _, restrictedName := range []string{"assets", "register", "login", "logout", "settings", "admin-panel", "all", "search", "init", "healthcheck", "preview"} { + for _, restrictedName := range []string{"assets", "register", "login", "logout", "settings", "admin-panel", "all", "search", "init", "healthcheck", "preview", "metrics"} { restrictedNames[restrictedName] = struct{}{} } diff --git a/internal/web/healthcheck.go b/internal/web/healthcheck.go index c814361..6927d28 100644 --- a/internal/web/healthcheck.go +++ b/internal/web/healthcheck.go @@ -23,3 +23,9 @@ func healthcheck(ctx echo.Context) error { "time": time.Now().Format(time.RFC3339), }) } + +// metrics is a dummy handler to satisfy the /metrics endpoint (for Prometheus, Openmetrics, etc.) +// until we have a proper metrics endpoint +func metrics(ctx echo.Context) error { + return ctx.String(200, "") +} diff --git a/internal/web/server.go b/internal/web/server.go index a41f075..91488bc 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -251,6 +251,7 @@ func NewServer(isDev bool, sessionsPath string) *Server { g1.GET("/preview", preview, logged) g1.GET("/healthcheck", healthcheck) + g1.GET("/metrics", metrics) g1.GET("/register", register) g1.POST("/register", processRegister)