RegisterQueryAPI registers the Prometheus API routes with the provided handler.
(handler http.Handler)
| 444 | |
| 445 | // RegisterQueryAPI registers the Prometheus API routes with the provided handler. |
| 446 | func (a *API) RegisterQueryAPI(handler http.Handler) { |
| 447 | hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 448 | httputil.SetCORS(w, a.corsOrigin, r) |
| 449 | handler.ServeHTTP(w, r) |
| 450 | }) |
| 451 | |
| 452 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/read"), hf, true, "POST") |
| 453 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/query"), hf, true, "GET", "POST") |
| 454 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/query_range"), hf, true, "GET", "POST") |
| 455 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/query_exemplars"), hf, true, "GET", "POST") |
| 456 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/format_query"), hf, true, "GET", "POST") |
| 457 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/parse_query"), hf, true, "GET", "POST") |
| 458 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/labels"), hf, true, "GET", "POST") |
| 459 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/label/{name}/values"), hf, true, "GET") |
| 460 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/series"), hf, true, "GET", "POST", "DELETE") |
| 461 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/metadata"), hf, true, "GET") |
| 462 | |
| 463 | // Register Legacy Routers |
| 464 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/read"), hf, true, "POST") |
| 465 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/query"), hf, true, "GET", "POST") |
| 466 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/query_range"), hf, true, "GET", "POST") |
| 467 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/query_exemplars"), hf, true, "GET", "POST") |
| 468 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/format_query"), hf, true, "GET", "POST") |
| 469 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/parse_query"), hf, true, "GET", "POST") |
| 470 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/labels"), hf, true, "GET", "POST") |
| 471 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/label/{name}/values"), hf, true, "GET") |
| 472 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/series"), hf, true, "GET", "POST", "DELETE") |
| 473 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/metadata"), hf, true, "GET") |
| 474 | |
| 475 | if a.cfg.buildInfoEnabled { |
| 476 | infoHandler := &buildInfoHandler{logger: a.logger} |
| 477 | a.RegisterRoute(path.Join(a.cfg.PrometheusHTTPPrefix, "/api/v1/status/buildinfo"), infoHandler, true, "GET") |
| 478 | a.RegisterRoute(path.Join(a.cfg.LegacyHTTPPrefix, "/api/v1/status/buildinfo"), infoHandler, true, "GET") |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | // RegisterQueryFrontendHandler registers the Prometheus routes supported by the |
| 483 | // Cortex querier service. Currently, this can not be registered simultaneously |
no test coverage detected