TUN-7549: Add metrics route to management service

This commit is contained in:
Devin Carr 2023-06-30 09:38:26 -07:00
parent 2b4815a9f5
commit aca3575b6d
1 changed files with 12 additions and 6 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog"
"nhooyr.io/websocket"
)
@ -38,6 +39,9 @@ type ManagementService struct {
clientID uuid.UUID
label string
// Additional Handlers
metricsHandler http.Handler
log *zerolog.Logger
router chi.Router
@ -62,12 +66,14 @@ func New(managementHostname string,
serviceIP: serviceIP,
clientID: clientID,
label: label,
metricsHandler: promhttp.Handler(),
}
r := chi.NewRouter()
r.Use(ValidateAccessTokenQueryMiddleware)
r.Get("/ping", ping)
r.Head("/ping", ping)
r.Get("/logs", s.logs)
r.Get("/metrics", s.metricsHandler.ServeHTTP)
r.Route("/host_details", func(r chi.Router) {
// CORS middleware required to allow dash to access management.argotunnel.com requests
r.Use(cors.Handler(cors.Options{