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