4
4
"context"
5
5
"flag"
6
6
"net/http"
7
+ "path"
7
8
"strings"
8
9
"time"
9
10
@@ -222,7 +223,7 @@ func (a *API) RegisterDistributor(d *distributor.Distributor, pushConfig distrib
222
223
a .RegisterRoute ("/distributor/ha_tracker" , d .HATracker , false , "GET" )
223
224
224
225
// Legacy Routes
225
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/push" , push .Handler (pushConfig .MaxRecvMsgSize , a .sourceIPs , a .cfg .wrapDistributorPush (d )), true , "POST" )
226
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/push" ) , push .Handler (pushConfig .MaxRecvMsgSize , a .sourceIPs , a .cfg .wrapDistributorPush (d )), true , "POST" )
226
227
a .RegisterRoute ("/all_user_stats" , http .HandlerFunc (d .AllUserStatsHandler ), false , "GET" )
227
228
a .RegisterRoute ("/ha-tracker" , d .HATracker , false , "GET" )
228
229
}
@@ -258,14 +259,14 @@ func (a *API) RegisterIngester(i Ingester, pushConfig distributor.Config) {
258
259
func (a * API ) RegisterChunksPurger (store * purger.DeleteStore , deleteRequestCancelPeriod time.Duration ) {
259
260
deleteRequestHandler := purger .NewDeleteRequestHandler (store , deleteRequestCancelPeriod , prometheus .DefaultRegisterer )
260
261
261
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/admin/tsdb/delete_series" , http .HandlerFunc (deleteRequestHandler .AddDeleteRequestHandler ), true , "PUT" , "POST" )
262
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/admin/tsdb/delete_series" , http .HandlerFunc (deleteRequestHandler .GetAllDeleteRequestsHandler ), true , "GET" )
263
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/admin/tsdb/cancel_delete_request" , http .HandlerFunc (deleteRequestHandler .CancelDeleteRequestHandler ), true , "PUT" , "POST" )
262
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/admin/tsdb/delete_series" ) , http .HandlerFunc (deleteRequestHandler .AddDeleteRequestHandler ), true , "PUT" , "POST" )
263
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/admin/tsdb/delete_series" ) , http .HandlerFunc (deleteRequestHandler .GetAllDeleteRequestsHandler ), true , "GET" )
264
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/admin/tsdb/cancel_delete_request" ) , http .HandlerFunc (deleteRequestHandler .CancelDeleteRequestHandler ), true , "PUT" , "POST" )
264
265
265
266
// Legacy Routes
266
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/admin/tsdb/delete_series" , http .HandlerFunc (deleteRequestHandler .AddDeleteRequestHandler ), true , "PUT" , "POST" )
267
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/admin/tsdb/delete_series" , http .HandlerFunc (deleteRequestHandler .GetAllDeleteRequestsHandler ), true , "GET" )
268
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/admin/tsdb/cancel_delete_request" , http .HandlerFunc (deleteRequestHandler .CancelDeleteRequestHandler ), true , "PUT" , "POST" )
267
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/admin/tsdb/delete_series" ) , http .HandlerFunc (deleteRequestHandler .AddDeleteRequestHandler ), true , "PUT" , "POST" )
268
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/admin/tsdb/delete_series" ) , http .HandlerFunc (deleteRequestHandler .GetAllDeleteRequestsHandler ), true , "GET" )
269
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/admin/tsdb/cancel_delete_request" ) , http .HandlerFunc (deleteRequestHandler .CancelDeleteRequestHandler ), true , "PUT" , "POST" )
269
270
}
270
271
271
272
func (a * API ) RegisterTenantDeletion (api * purger.TenantDeletionAPI ) {
@@ -290,8 +291,8 @@ func (a *API) RegisterRuler(r *ruler.Ruler) {
290
291
// RegisterRulerAPI registers routes associated with the Ruler API
291
292
func (a * API ) RegisterRulerAPI (r * ruler.API ) {
292
293
// Prometheus Rule API Routes
293
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/rules" , http .HandlerFunc (r .PrometheusRules ), true , "GET" )
294
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/alerts" , http .HandlerFunc (r .PrometheusAlerts ), true , "GET" )
294
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/rules" ) , http .HandlerFunc (r .PrometheusRules ), true , "GET" )
295
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/alerts" ) , http .HandlerFunc (r .PrometheusAlerts ), true , "GET" )
295
296
296
297
// Ruler API Routes
297
298
a .RegisterRoute ("/api/v1/rules" , http .HandlerFunc (r .ListRules ), true , "GET" )
@@ -302,16 +303,16 @@ func (a *API) RegisterRulerAPI(r *ruler.API) {
302
303
a .RegisterRoute ("/api/v1/rules/{namespace}" , http .HandlerFunc (r .DeleteNamespace ), true , "DELETE" )
303
304
304
305
// Legacy Prometheus Rule API Routes
305
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/rules" , http .HandlerFunc (r .PrometheusRules ), true , "GET" )
306
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/alerts" , http .HandlerFunc (r .PrometheusAlerts ), true , "GET" )
306
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/rules" ) , http .HandlerFunc (r .PrometheusRules ), true , "GET" )
307
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/alerts" ) , http .HandlerFunc (r .PrometheusAlerts ), true , "GET" )
307
308
308
309
// Legacy Ruler API Routes
309
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/rules" , http .HandlerFunc (r .ListRules ), true , "GET" )
310
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/rules/{namespace}" , http .HandlerFunc (r .ListRules ), true , "GET" )
311
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/rules/{namespace}/{groupName}" , http .HandlerFunc (r .GetRuleGroup ), true , "GET" )
312
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/rules/{namespace}" , http .HandlerFunc (r .CreateRuleGroup ), true , "POST" )
313
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/rules/{namespace}/{groupName}" , http .HandlerFunc (r .DeleteRuleGroup ), true , "DELETE" )
314
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/rules/{namespace}" , http .HandlerFunc (r .DeleteNamespace ), true , "DELETE" )
310
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/rules" ) , http .HandlerFunc (r .ListRules ), true , "GET" )
311
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/rules/{namespace}" ) , http .HandlerFunc (r .ListRules ), true , "GET" )
312
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/rules/{namespace}/{groupName}" ) , http .HandlerFunc (r .GetRuleGroup ), true , "GET" )
313
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/rules/{namespace}" ) , http .HandlerFunc (r .CreateRuleGroup ), true , "POST" )
314
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/rules/{namespace}/{groupName}" ) , http .HandlerFunc (r .DeleteRuleGroup ), true , "DELETE" )
315
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/rules/{namespace}" ) , http .HandlerFunc (r .DeleteNamespace ), true , "DELETE" )
315
316
}
316
317
317
318
// RegisterRing registers the ring UI page associated with the distributor for writes.
@@ -347,28 +348,28 @@ func (a *API) RegisterQueryable(
347
348
a .RegisterRoute ("/api/v1/user_stats" , http .HandlerFunc (distributor .UserStatsHandler ), true , "GET" )
348
349
a .RegisterRoute ("/api/v1/chunks" , querier .ChunksHandler (queryable ), true , "GET" )
349
350
350
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/user_stats" , http .HandlerFunc (distributor .UserStatsHandler ), true , "GET" )
351
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/chunks" , querier .ChunksHandler (queryable ), true , "GET" )
351
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/user_stats" ) , http .HandlerFunc (distributor .UserStatsHandler ), true , "GET" )
352
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/chunks" ) , querier .ChunksHandler (queryable ), true , "GET" )
352
353
}
353
354
354
355
// RegisterQueryAPI registers the Prometheus API routes with the provided handler.
355
356
func (a * API ) RegisterQueryAPI (handler http.Handler ) {
356
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/read" , handler , true , "POST" )
357
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/query" , handler , true , "GET" , "POST" )
358
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/query_range" , handler , true , "GET" , "POST" )
359
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/labels" , handler , true , "GET" , "POST" )
360
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/label/{name}/values" , handler , true , "GET" )
361
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/series" , handler , true , "GET" , "POST" , "DELETE" )
362
- a .RegisterRoute (a .cfg .PrometheusHTTPPrefix + "/api/v1/metadata" , handler , true , "GET" )
357
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/read" ) , handler , true , "POST" )
358
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/query" ) , handler , true , "GET" , "POST" )
359
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/query_range" ) , handler , true , "GET" , "POST" )
360
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/labels" ) , handler , true , "GET" , "POST" )
361
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/label/{name}/values" ) , handler , true , "GET" )
362
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/series" ) , handler , true , "GET" , "POST" , "DELETE" )
363
+ a .RegisterRoute (path . Join ( a .cfg .PrometheusHTTPPrefix , "/api/v1/metadata" ) , handler , true , "GET" )
363
364
364
365
// Register Legacy Routers
365
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/read" , handler , true , "POST" )
366
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/query" , handler , true , "GET" , "POST" )
367
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/query_range" , handler , true , "GET" , "POST" )
368
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/labels" , handler , true , "GET" , "POST" )
369
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/label/{name}/values" , handler , true , "GET" )
370
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/series" , handler , true , "GET" , "POST" , "DELETE" )
371
- a .RegisterRoute (a .cfg .LegacyHTTPPrefix + "/api/v1/metadata" , handler , true , "GET" )
366
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/read" ) , handler , true , "POST" )
367
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/query" ) , handler , true , "GET" , "POST" )
368
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/query_range" ) , handler , true , "GET" , "POST" )
369
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/labels" ) , handler , true , "GET" , "POST" )
370
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/label/{name}/values" ) , handler , true , "GET" )
371
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/series" ) , handler , true , "GET" , "POST" , "DELETE" )
372
+ a .RegisterRoute (path . Join ( a .cfg .LegacyHTTPPrefix , "/api/v1/metadata" ) , handler , true , "GET" )
372
373
}
373
374
374
375
// RegisterQueryFrontend registers the Prometheus routes supported by the
0 commit comments