@@ -217,6 +217,17 @@ func decRequestConcurrency() {
217217func processSelectRequest (ctx context.Context , w http.ResponseWriter , r * http.Request , path string ) bool {
218218 httpserver .EnableCORS (w , r )
219219 startTime := time .Now ()
220+ if strings .HasPrefix (path , "/select/vmalert/" ) {
221+ vmalertRequests .Inc ()
222+ if len (* vmalertProxyURL ) == 0 {
223+ w .WriteHeader (http .StatusBadRequest )
224+ w .Header ().Set ("Content-Type" , "application/json" )
225+ fmt .Fprintf (w , "%s" , `{"status":"error","msg":"for accessing vmalert flag '-vmalert.proxyURL' must be configured"}` )
226+ return true
227+ }
228+ proxyVMAlertRequests (w , r )
229+ return true
230+ }
220231 switch path {
221232 case "/select/logsql/facets" :
222233 logsqlFacetsRequests .Inc ()
@@ -332,6 +343,7 @@ func proxyVMAlertRequests(w http.ResponseWriter, r *http.Request) {
332343 // Forward other panics to the caller.
333344 panic (err )
334345 }()
346+ r .URL .Path = strings .TrimPrefix (r .URL .Path , "/select" )
335347 r .Host = vmalertProxyHost
336348 vmalertProxy .ServeHTTP (w , r )
337349}
@@ -394,4 +406,5 @@ var (
394406 rulesRequests = metrics .NewCounter (`vl_http_requests_total{path="/select/api/v1/rules"}` )
395407 alertsRequests = metrics .NewCounter (`vl_http_requests_total{path="/select/api/v1/alerts"}` )
396408 notifiersRequests = metrics .NewCounter (`vl_http_requests_total{path="/select/api/v1/notifiers"}` )
409+ vmalertRequests = metrics .NewCounter (`vm_http_requests_total{path="/select/vmalert"}` )
397410)
0 commit comments