github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/docs/api/_index.md (about)

     1  ---
     2  title: "HTTP API"
     3  linkTitle: "HTTP API"
     4  weight: 7
     5  slug: api
     6  menu:
     7  no_section_index_title: true
     8  ---
     9  
    10  Cortex exposes an HTTP API for pushing and querying time series data, and operating the cluster itself.
    11  
    12  For the sake of clarity, in this document we have grouped API endpoints by service, but keep in mind that they're exposed both when running Cortex in microservices and singly-binary mode:
    13  - **Microservices**: each service exposes its own endpoints
    14  - **Single-binary**: the Cortex process exposes all API endpoints for the services running internally
    15  
    16  ## Endpoints
    17  
    18  | API | Service | Endpoint |
    19  | --- | ------- | -------- |
    20  | [Index page](#index-page) | _All services_ | `GET /` |
    21  | [Configuration](#configuration) | _All services_ | `GET /config` |
    22  | [Runtime Configuration](#runtime-configuration) | _All services_ | `GET /runtime_config` |
    23  | [Services status](#services-status) | _All services_ | `GET /services` |
    24  | [Readiness probe](#readiness-probe) | _All services_ | `GET /ready` |
    25  | [Metrics](#metrics) | _All services_ | `GET /metrics` |
    26  | [Pprof](#pprof) | _All services_ | `GET /debug/pprof` |
    27  | [Fgprof](#fgprof) | _All services_ | `GET /debug/fgprof` |
    28  | [Remote write](#remote-write) | Distributor | `POST /api/v1/push` |
    29  | [Tenants stats](#tenants-stats) | Distributor | `GET /distributor/all_user_stats` |
    30  | [HA tracker status](#ha-tracker-status) | Distributor | `GET /distributor/ha_tracker` |
    31  | [Flush chunks / blocks](#flush-chunks--blocks) | Ingester | `GET,POST /ingester/flush` |
    32  | [Shutdown](#shutdown) | Ingester | `GET,POST /ingester/shutdown` |
    33  | [Ingesters ring status](#ingesters-ring-status) | Ingester | `GET /ingester/ring` |
    34  | [Instant query](#instant-query) | Querier, Query-frontend | `GET,POST <prometheus-http-prefix>/api/v1/query` |
    35  | [Range query](#range-query) | Querier, Query-frontend | `GET,POST <prometheus-http-prefix>/api/v1/query_range` |
    36  | [Exemplar query](#exemplar-query) | Querier, Query-frontend | `GET,POST <prometheus-http-prefix>/api/v1/query_exemplars` |
    37  | [Get series by label matchers](#get-series-by-label-matchers) | Querier, Query-frontend | `GET,POST <prometheus-http-prefix>/api/v1/series` |
    38  | [Get label names](#get-label-names) | Querier, Query-frontend | `GET,POST <prometheus-http-prefix>/api/v1/labels` |
    39  | [Get label values](#get-label-values) | Querier, Query-frontend | `GET <prometheus-http-prefix>/api/v1/label/{name}/values` |
    40  | [Get metric metadata](#get-metric-metadata) | Querier, Query-frontend | `GET <prometheus-http-prefix>/api/v1/metadata` |
    41  | [Remote read](#remote-read) | Querier, Query-frontend | `POST <prometheus-http-prefix>/api/v1/read` |
    42  | [Get tenant ingestion stats](#get-tenant-ingestion-stats) | Querier | `GET /api/v1/user_stats` |
    43  | [Get tenant chunks](#get-tenant-chunks) | Querier | `GET /api/v1/chunks` |
    44  | [Ruler ring status](#ruler-ring-status) | Ruler | `GET /ruler/ring` |
    45  | [Ruler rules ](#ruler-rule-groups) | Ruler | `GET /ruler/rule_groups` |
    46  | [List rules](#list-rules) | Ruler | `GET <prometheus-http-prefix>/api/v1/rules` |
    47  | [List alerts](#list-alerts) | Ruler | `GET <prometheus-http-prefix>/api/v1/alerts` |
    48  | [List rule groups](#list-rule-groups) | Ruler | `GET /api/v1/rules` |
    49  | [Get rule groups by namespace](#get-rule-groups-by-namespace) | Ruler | `GET /api/v1/rules/{namespace}` |
    50  | [Get rule group](#get-rule-group) | Ruler | `GET /api/v1/rules/{namespace}/{groupName}` |
    51  | [Set rule group](#set-rule-group) | Ruler | `POST /api/v1/rules/{namespace}` |
    52  | [Delete rule group](#delete-rule-group) | Ruler | `DELETE /api/v1/rules/{namespace}/{groupName}` |
    53  | [Delete namespace](#delete-namespace) | Ruler | `DELETE /api/v1/rules/{namespace}` |
    54  | [Delete tenant configuration](#delete-tenant-configuration) | Ruler | `POST /ruler/delete_tenant_config` |
    55  | [Alertmanager status](#alertmanager-status) | Alertmanager | `GET /multitenant_alertmanager/status` |
    56  | [Alertmanager configs](#alertmanager-configs) | Alertmanager | `GET /multitenant_alertmanager/configs` |
    57  | [Alertmanager ring status](#alertmanager-ring-status) | Alertmanager | `GET /multitenant_alertmanager/ring` |
    58  | [Alertmanager UI](#alertmanager-ui) | Alertmanager | `GET /<alertmanager-http-prefix>` |
    59  | [Alertmanager Delete Tenant Configuration](#alertmanager-delete-tenant-configuration) | Alertmanager | `POST /multitenant_alertmanager/delete_tenant_config` |
    60  | [Get Alertmanager configuration](#get-alertmanager-configuration) | Alertmanager | `GET /api/v1/alerts` |
    61  | [Set Alertmanager configuration](#set-alertmanager-configuration) | Alertmanager | `POST /api/v1/alerts` |
    62  | [Delete Alertmanager configuration](#delete-alertmanager-configuration) | Alertmanager | `DELETE /api/v1/alerts` |
    63  | [Delete series](#delete-series) | Purger | `PUT,POST <prometheus-http-prefix>/api/v1/admin/tsdb/delete_series` |
    64  | [List delete requests](#list-delete-requests) | Purger | `GET <prometheus-http-prefix>/api/v1/admin/tsdb/delete_series` |
    65  | [Cancel delete request](#cancel-delete-request) | Purger | `PUT,POST <prometheus-http-prefix>/api/v1/admin/tsdb/cancel_delete_request` |
    66  | [Tenant delete request](#tenant-delete-request) | Purger | `POST /purger/delete_tenant` |
    67  | [Tenant delete status](#tenant-delete-status) | Purger | `GET /purger/delete_tenant_status` |
    68  | [Store-gateway ring status](#store-gateway-ring-status) | Store-gateway | `GET /store-gateway/ring` |
    69  | [Compactor ring status](#compactor-ring-status) | Compactor | `GET /compactor/ring` |
    70  | [Get rule files](#get-rule-files) | Configs API (deprecated) | `GET /api/prom/configs/rules` |
    71  | [Set rule files](#set-rule-files) | Configs API (deprecated) | `POST /api/prom/configs/rules` |
    72  | [Get template files](#get-template-files) | Configs API (deprecated) | `GET /api/prom/configs/templates` |
    73  | [Set template files](#set-template-files) | Configs API (deprecated) | `POST /api/prom/configs/templates` |
    74  | [Get Alertmanager config file](#get-alertmanager-config-file) | Configs API (deprecated) | `GET /api/prom/configs/alertmanager` |
    75  | [Set Alertmanager config file](#set-alertmanager-config-file) | Configs API (deprecated) | `POST /api/prom/configs/alertmanager` |
    76  | [Validate Alertmanager config](#validate-alertmanager-config-file) | Configs API (deprecated) | `POST /api/prom/configs/alertmanager/validate` |
    77  | [Deactivate configs](#deactivate-configs) | Configs API (deprecated) | `DELETE /api/prom/configs/deactivate` |
    78  | [Restore configs](#restore-configs) | Configs API (deprecated) | `POST /api/prom/configs/restore` |
    79  
    80  
    81  ### Path prefixes
    82  
    83  In this documentation you will find the usage of some placeholders for the path prefixes, whenever the prefix is configurable. The following table shows the supported prefixes.
    84  
    85  | Prefix                       | Default         | CLI Flag                         | YAML Config |
    86  | ---------------------------- | --------------- | -------------------------------- | ----------- |
    87  | `<legacy-http-prefix>`       | `/api/prom`     | `-http.prefix`                   | `http_prefix` |
    88  | `<prometheus-http-prefix>`   | `/prometheus`   | `-http.prometheus-http-prefix`   | `api > prometheus_http_prefix` |
    89  | `<alertmanager-http-prefix>` | `/alertmanager` | `-http.alertmanager-http-prefix` | `api > alertmanager_http_prefix` |
    90  
    91  ### Authentication
    92  
    93  When multi-tenancy is enabled, endpoints requiring authentication are expected to be called with the `X-Scope-OrgID` HTTP request header set to the tenant ID. Otherwise, when multi-tenancy is disabled, Cortex doesn't require any request to have the `X-Scope-OrgID` header.
    94  
    95  Multi-tenancy can be enabled/disabled via the CLI flag `-auth.enabled` or its respective YAML config option.
    96  
    97  _For more information, please refer to the dedicated [Authentication and Authorisation](../guides/authentication-and-authorisation.md) guide._
    98  
    99  ## All services
   100  
   101  The following API endpoints are exposed by all services.
   102  
   103  ### Index page
   104  
   105  ```
   106  GET /
   107  ```
   108  
   109  Displays an index page with links to other web pages exposed by Cortex.
   110  
   111  ### Configuration
   112  
   113  ```
   114  GET /config
   115  ```
   116  
   117  Displays the configuration currently applied to Cortex (in YAML format), including default values and settings via CLI flags. Sensitive data is masked. Please be aware that the exported configuration **doesn't include the per-tenant overrides**.
   118  
   119  #### Different modes
   120  
   121  ```
   122  GET /config?mode=diff
   123  ```
   124  
   125  Displays the configuration currently applied to Cortex (in YAML format) as before, but containing only the values that differ from the default values.
   126  
   127  ```
   128  GET /config?mode=defaults
   129  ```
   130  
   131  Displays the configuration using only the default values.
   132  
   133  ### Runtime Configuration
   134  
   135  ```
   136  GET /runtime_config
   137  ```
   138  
   139  Displays the runtime configuration currently applied to Cortex (in YAML format), including default values. Please be aware that the endpoint will be only available if Cortex is configured with the `-runtime-config.file` option.
   140  
   141  #### Different modes
   142  
   143  ```
   144  GET /runtime_config?mode=diff
   145  ```
   146  
   147  Displays the runtime configuration currently applied to Cortex (in YAML format) as before, but containing only the values that differ from the default values.
   148  
   149  ### Services status
   150  
   151  ```
   152  GET /services
   153  ```
   154  
   155  Displays a web page with the status of internal Cortex services.
   156  
   157  ### Readiness probe
   158  
   159  ```
   160  GET /ready
   161  ```
   162  
   163  Returns 200 when Cortex is ready to serve traffic.
   164  
   165  ### Metrics
   166  
   167  ```
   168  GET /metrics
   169  ```
   170  
   171  Returns the metrics for the running Cortex service in the Prometheus exposition format.
   172  
   173  ### Pprof
   174  
   175  ```
   176  GET /debug/pprof/heap
   177  GET /debug/pprof/block
   178  GET /debug/pprof/profile
   179  GET /debug/pprof/trace
   180  GET /debug/pprof/goroutine
   181  GET /debug/pprof/mutex
   182  ```
   183  
   184  Returns the runtime profiling data in the format expected by the pprof visualization tool. There are many things which can be profiled using this including heap, trace, goroutine, etc.
   185  
   186  _For more information, please check out the official documentation of [pprof](https://golang.org/pkg/net/http/pprof/)._
   187  
   188  ### Fgprof
   189  
   190  ```
   191  GET /debug/fgprof
   192  ```
   193  
   194  Returns the sampling Go profiling data which allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together.
   195  
   196  _For more information, please check out the official documentation of [fgprof](https://github.com/felixge/fgprof)._
   197  
   198  ## Distributor
   199  
   200  ### Remote write
   201  
   202  ```
   203  POST /api/v1/push
   204  
   205  # Legacy
   206  POST <legacy-http-prefix>/push
   207  ```
   208  
   209  Entrypoint for the [Prometheus remote write](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write).
   210  
   211  This API endpoint accepts an HTTP POST request with a body containing a request encoded with [Protocol Buffers](https://developers.google.com/protocol-buffers) and compressed with [Snappy](https://github.com/google/snappy). The definition of the protobuf message can be found in [`cortex.proto`](https://github.com/cortexproject/cortex/blob/master/pkg/cortexpb/cortex.proto#L12). The HTTP request should contain the header `X-Prometheus-Remote-Write-Version` set to `0.1.0`.
   212  
   213  _For more information, please check out Prometheus [Remote storage integrations](https://prometheus.io/docs/prometheus/latest/storage/#remote-storage-integrations)._
   214  
   215  _Requires [authentication](#authentication)._
   216  
   217  ### Distributor ring status
   218  
   219  ```
   220  GET /distributor/ring
   221  ```
   222  
   223  Displays a web page with the distributor hash ring status, including the state, healthy and last heartbeat time of each distributor.
   224  
   225  ### Tenants stats
   226  
   227  ```
   228  GET /distributor/all_user_stats
   229  
   230  # Legacy
   231  GET /all_user_stats
   232  ```
   233  
   234  Displays a web page with per-tenant statistics updated in realtime, including the total number of active series across all ingesters and the current ingestion rate (samples / sec).
   235  
   236  ### HA tracker status
   237  
   238  ```
   239  GET /distributor/ha_tracker
   240  
   241  # Legacy
   242  GET /ha-tracker
   243  ```
   244  
   245  Displays a web page with the current status of the HA tracker, including the elected replica for each Prometheus HA cluster.
   246  
   247  
   248  ## Ingester
   249  
   250  ### Flush chunks / blocks
   251  
   252  ```
   253  GET,POST /ingester/flush
   254  
   255  # Legacy
   256  GET,POST /flush
   257  ```
   258  
   259  Triggers a flush of the in-memory time series data (chunks or blocks) to the long-term storage. This endpoint triggers the flush also when `-ingester.flush-on-shutdown-with-wal-enabled` or `-blocks-storage.tsdb.flush-blocks-on-shutdown` are disabled.
   260  
   261  When using blocks storage, this endpoint accepts `tenant` parameter to specify tenant whose blocks are compacted and shipped. This parameter may be specified multiple times to select more tenants. If no tenant is specified, all tenants are flushed.
   262  
   263  Flush endpoint now also accepts `wait=true` parameter, which makes the call synchronous – it will only return after flushing has finished. Note that returned status code does not reflect the result of flush operation. This parameter is only available when using blocks storage.
   264  
   265  ### Shutdown
   266  
   267  ```
   268  GET,POST /ingester/shutdown
   269  
   270  # Legacy
   271  GET,POST /shutdown
   272  ```
   273  
   274  Flushes in-memory time series data from ingester to the long-term storage, and shuts down the ingester service. Notice that the other Cortex services are still running, and the operator (or any automation) is expected to terminate the process with a `SIGINT` / `SIGTERM` signal after the shutdown endpoint returns. In the meantime, `/ready` will not return 200. This endpoint will unregister the ingester from the ring even if `-ingester.unregister-on-shutdown` is disabled.
   275  
   276  _This API endpoint is usually used by scale down automations._
   277  
   278  ### Ingesters ring status
   279  
   280  ```
   281  GET /ingester/ring
   282  
   283  # Legacy
   284  GET /ring
   285  ```
   286  
   287  Displays a web page with the ingesters hash ring status, including the state, healthy and last heartbeat time of each ingester.
   288  
   289  
   290  ## Querier / Query-frontend
   291  
   292  The following endpoints are exposed both by the querier and query-frontend.
   293  
   294  ### Instant query
   295  
   296  ```
   297  GET,POST <prometheus-http-prefix>/api/v1/query
   298  
   299  # Legacy
   300  GET,POST <legacy-http-prefix>/api/v1/query
   301  ```
   302  
   303  Prometheus-compatible instant query endpoint.
   304  
   305  _For more information, please check out the Prometheus [instant query](https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries) documentation._
   306  
   307  _Requires [authentication](#authentication)._
   308  
   309  ### Range query
   310  
   311  ```
   312  GET,POST <prometheus-http-prefix>/api/v1/query_range
   313  
   314  # Legacy
   315  GET,POST <legacy-http-prefix>/api/v1/query_range
   316  ```
   317  
   318  Prometheus-compatible range query endpoint. When the request is sent through the query-frontend, the query will be accelerated by query-frontend (results caching and execution parallelisation).
   319  
   320  _For more information, please check out the Prometheus [range query](https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries) documentation._
   321  
   322  _Requires [authentication](#authentication)._
   323  
   324  ### Exemplar query
   325  
   326  ```
   327  GET,POST <prometheus-http-prefix>/api/v1/query_exemplars
   328  
   329  # Legacy
   330  GET,POST <legacy-http-prefix>/api/v1/query_exemplars
   331  ```
   332  
   333  Prometheus-compatible exemplar query endpoint.
   334  
   335  _For more information, please check out the Prometheus [exemplar query](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-exemplars) documentation._
   336  
   337  _Requires [authentication](#authentication)._
   338  
   339  ### Get series by label matchers
   340  
   341  ```
   342  GET,POST <prometheus-http-prefix>/api/v1/series
   343  
   344  # Legacy
   345  GET,POST <legacy-http-prefix>/api/v1/series
   346  ```
   347  
   348  Find series by label matchers. Differently than Prometheus and due to scalability and performances reasons, Cortex currently ignores the `start` and `end` request parameters and always fetches the series from in-memory data stored in the ingesters. There is experimental support to query the long-term store with the *blocks* storage engine when `-querier.query-store-for-labels-enabled` is set.
   349  
   350  _For more information, please check out the Prometheus [series endpoint](https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers) documentation._
   351  
   352  _Requires [authentication](#authentication)._
   353  
   354  ### Get label names
   355  
   356  ```
   357  GET,POST <prometheus-http-prefix>/api/v1/labels
   358  
   359  # Legacy
   360  GET,POST <legacy-http-prefix>/api/v1/labels
   361  ```
   362  
   363  Get label names of ingested series. Differently than Prometheus and due to scalability and performances reasons, Cortex currently ignores the `start` and `end` request parameters and always fetches the label names from in-memory data stored in the ingesters. There is experimental support to query the long-term store with the *blocks* storage engine when `-querier.query-store-for-labels-enabled` is set.
   364  
   365  _For more information, please check out the Prometheus [get label names](https://prometheus.io/docs/prometheus/latest/querying/api/#getting-label-names) documentation._
   366  
   367  _Requires [authentication](#authentication)._
   368  
   369  ### Get label values
   370  
   371  ```
   372  GET <prometheus-http-prefix>/api/v1/label/{name}/values
   373  
   374  # Legacy
   375  GET <legacy-http-prefix>/api/v1/label/{name}/values
   376  ```
   377  
   378  Get label values for a given label name. Differently than Prometheus and due to scalability and performances reasons, Cortex currently ignores the `start` and `end` request parameters and always fetches the label values from in-memory data stored in the ingesters. There is experimental support to query the long-term store with the *blocks* storage engine when `-querier.query-store-for-labels-enabled` is set.
   379  
   380  _For more information, please check out the Prometheus [get label values](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-label-values) documentation._
   381  
   382  _Requires [authentication](#authentication)._
   383  
   384  ### Get metric metadata
   385  
   386  ```
   387  GET <prometheus-http-prefix>/api/v1/metadata
   388  
   389  # Legacy
   390  GET <legacy-http-prefix>/api/v1/metadata
   391  ```
   392  
   393  Prometheus-compatible metric metadata endpoint.
   394  
   395  _For more information, please check out the Prometheus [metric metadata](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-metric-metadata) documentation._
   396  
   397  _Requires [authentication](#authentication)._
   398  
   399  ### Remote read
   400  
   401  ```
   402  POST <prometheus-http-prefix>/api/v1/read
   403  
   404  # Legacy
   405  POST <legacy-http-prefix>/api/v1/read
   406  ```
   407  
   408  Prometheus-compatible [remote read](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_read) endpoint.
   409  
   410  _For more information, please check out Prometheus [Remote storage integrations](https://prometheus.io/docs/prometheus/latest/storage/#remote-storage-integrations)._
   411  
   412  _Requires [authentication](#authentication)._
   413  
   414  
   415  ## Querier
   416  
   417  ### Get tenant ingestion stats
   418  
   419  ```
   420  GET /api/v1/user_stats
   421  
   422  # Legacy
   423  GET <legacy-http-prefix>/user_stats
   424  ```
   425  
   426  Returns realtime ingestion rate, for the authenticated tenant, in `JSON` format.
   427  
   428  _Requires [authentication](#authentication)._
   429  
   430  ### Get tenant chunks
   431  
   432  ```
   433  GET /api/v1/chunks
   434  
   435  # Legacy
   436  GET <legacy-http-prefix>/chunks
   437  ```
   438  
   439  Fetch a compressed tar of all the chunks containing samples for the given time range and label matchers. This endpoint is supported only by the **chunks storage**, requires `-querier.ingester-streaming=true` and should **not be exposed to users** but just used for debugging purposes.
   440  
   441  | URL query parameter | Description |
   442  | ------------------- | ----------- |
   443  | `start` | Start timestamp, in RFC3339 format or unix epoch. |
   444  | `end` | End timestamp, in RFC3339 format or unix epoch. |
   445  | `matcher` | Label matcher that selects the series for which chunks should be fetched. |
   446  
   447  _Requires [authentication](#authentication)._
   448  
   449  ## Ruler
   450  
   451  The ruler API endpoints require to configure a backend object storage to store the recording rules and alerts. The ruler API uses the concept of a "namespace" when creating rule groups. This is a stand in for the name of the rule file in Prometheus and rule groups must be named uniquely within a namespace.
   452  
   453  ### Ruler ring status
   454  
   455  ```
   456  GET /ruler/ring
   457  
   458  # Legacy
   459  GET /ruler_ring
   460  ```
   461  
   462  Displays a web page with the ruler hash ring status, including the state, healthy and last heartbeat time of each ruler.
   463  
   464  ### Ruler rules
   465  
   466  ```
   467  GET /ruler/rule_groups
   468  ```
   469  
   470  List all tenant rules. This endpoint is not part of ruler-API and is always available regardless of whether ruler-API is enabled or not. It should not be exposed to end users. This endpoint returns a YAML dictionary with all the rule groups for each tenant and `200` status code on success.
   471  
   472  ### List rules
   473  
   474  ```
   475  GET <prometheus-http-prefix>/api/v1/rules
   476  
   477  # Legacy
   478  GET <legacy-http-prefix>/api/v1/rules
   479  ```
   480  
   481  Prometheus-compatible rules endpoint to list alerting and recording rules that are currently loaded.
   482  
   483  _For more information, please check out the Prometheus [rules](https://prometheus.io/docs/prometheus/latest/querying/api/#rules) documentation._
   484  
   485  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   486  
   487  _Requires [authentication](#authentication)._
   488  
   489  ### List alerts
   490  
   491  ```
   492  GET <prometheus-http-prefix>/api/v1/alerts
   493  
   494  # Legacy
   495  GET <legacy-http-prefix>/api/v1/alerts
   496  ```
   497  
   498  Prometheus-compatible rules endpoint to list of all active alerts.
   499  
   500  _For more information, please check out the Prometheus [alerts](https://prometheus.io/docs/prometheus/latest/querying/api/#alerts) documentation._
   501  
   502  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   503  
   504  _Requires [authentication](#authentication)._
   505  
   506  ### List rule groups
   507  
   508  ```
   509  GET /api/v1/rules
   510  
   511  # Legacy
   512  GET <legacy-http-prefix>/rules
   513  ```
   514  
   515  List all rules configured for the authenticated tenant. This endpoint returns a YAML dictionary with all the rule groups for each namespace and `200` status code on success.
   516  
   517  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   518  
   519  _Requires [authentication](#authentication)._
   520  
   521  #### Example response
   522  
   523  ```yaml
   524  ---
   525  <namespace1>:
   526  - name: <string>
   527    interval: <duration;optional>
   528    rules:
   529    - record: <string>
   530        expr: <string>
   531    - alert: <string>
   532        expr: <string>
   533        for: <duration>
   534        annotations:
   535        <annotation_name>: <string>
   536        labels:
   537        <label_name>: <string>
   538  - name: <string>
   539    interval: <duration;optional>
   540    rules:
   541    - record: <string>
   542        expr: <string>
   543    - alert: <string>
   544        expr: <string>
   545        for: <duration>
   546        annotations:
   547        <annotation_name>: <string>
   548        labels:
   549        <label_name>: <string>
   550  <namespace2>:
   551  - name: <string>
   552    interval: <duration;optional>
   553    rules:
   554    - record: <string>
   555        expr: <string>
   556    - alert: <string>
   557        expr: <string>
   558        for: <duration>
   559        annotations:
   560        <annotation_name>: <string>
   561        labels:
   562        <label_name>: <string>
   563  ```
   564  
   565  ### Get rule groups by namespace
   566  
   567  ```
   568  GET /api/v1/rules/{namespace}
   569  
   570  # Legacy
   571  GET <legacy-http-prefix>/rules/{namespace}
   572  ```
   573  
   574  Returns the rule groups defined for a given namespace.
   575  
   576  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   577  
   578  _Requires [authentication](#authentication)._
   579  
   580  #### Example response
   581  
   582  ```yaml
   583  name: <string>
   584  interval: <duration;optional>
   585  rules:
   586    - record: <string>
   587      expr: <string>
   588    - alert: <string>
   589      expr: <string>
   590      for: <duration>
   591      annotations:
   592        <annotation_name>: <string>
   593      labels:
   594        <label_name>: <string>
   595  ```
   596  
   597  ### Get rule group
   598  
   599  ```
   600  GET /api/v1/rules/{namespace}/{groupName}
   601  
   602  # Legacy
   603  GET <legacy-http-prefix>/rules/{namespace}/{groupName}
   604  ```
   605  
   606  Returns the rule group matching the request namespace and group name.
   607  
   608  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   609  
   610  _Requires [authentication](#authentication)._
   611  
   612  ### Set rule group
   613  
   614  ```
   615  POST /api/v1/rules/{namespace}
   616  
   617  # Legacy
   618  POST <legacy-http-prefix>/rules/{namespace}
   619  ```
   620  
   621  Creates or updates a rule group. This endpoint expects a request with `Content-Type: application/yaml` header and the rules **YAML** definition in the request body, and returns `202` on success.
   622  
   623  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   624  
   625  _Requires [authentication](#authentication)._
   626  
   627  #### Example request
   628  
   629  Request headers:
   630  - `Content-Type: application/yaml`
   631  
   632  Request body:
   633  
   634  ```yaml
   635  name: <string>
   636  interval: <duration;optional>
   637  rules:
   638    - record: <string>
   639      expr: <string>
   640    - alert: <string>
   641      expr: <string>
   642      for: <duration>
   643      annotations:
   644        <annotation_name>: <string>
   645      labels:
   646        <label_name>: <string>
   647  ```
   648  
   649  ### Delete rule group
   650  
   651  ```
   652  DELETE /api/v1/rules/{namespace}/{groupName}
   653  
   654  # Legacy
   655  DELETE <legacy-http-prefix>/rules/{namespace}/{groupName}
   656  ```
   657  
   658  Deletes a rule group by namespace and group name. This endpoints returns `202` on success.
   659  
   660  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   661  
   662  _Requires [authentication](#authentication)._
   663  
   664  ### Delete namespace
   665  
   666  ```
   667  DELETE /api/v1/rules/{namespace}
   668  
   669  # Legacy
   670  DELETE <legacy-http-prefix>/rules/{namespace}
   671  ```
   672  
   673  Deletes all the rule groups in a namespace (including the namespace itself). This endpoint returns `202` on success.
   674  
   675  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.ruler.enable-api` CLI flag (or its respective YAML config option)._
   676  
   677  _Requires [authentication](#authentication)._
   678  
   679  ### Delete tenant configuration
   680  
   681  ```
   682  POST /ruler/delete_tenant_config
   683  ```
   684  
   685  This deletes all rule groups for tenant, and returns `200` on success. Calling endpoint when no rule groups exist for user returns `200`. Authentication is only to identify the tenant.
   686  
   687  This is intended as internal API, and not to be exposed to users. This endpoint is enabled regardless of whether `-experimental.ruler.enable-api` is enabled or not.
   688  
   689  _Requires [authentication](#authentication)._
   690  
   691  ## Alertmanager
   692  
   693  ### Alertmanager status
   694  
   695  ```
   696  GET /multitenant_alertmanager/status
   697  
   698  # Legacy (microservices mode only)
   699  GET /status
   700  ```
   701  
   702  Displays a web page with the current status of the Alertmanager, including the Alertmanager cluster members.
   703  
   704  ### Alertmanager configs
   705  
   706  ```
   707  GET /multitenant_alertmanager/configs
   708  ```
   709  
   710  List all Alertmanager configurations. This endpoint is not part of alertmanager-API and is always available regardless of whether alertmanager-API is enabled or not. It should not be exposed to end users. This endpoint returns a YAML dictionary with all the Alertmanager configurations and `200` status code on success.
   711  
   712  ### Alertmanager ring status
   713  
   714  ```
   715  GET /multitenant_alertmanager/ring
   716  ```
   717  
   718  Displays a web page with the Alertmanager hash ring status, including the state, healthy and last heartbeat time of each Alertmanager instance.
   719  
   720  ### Alertmanager UI
   721  
   722  ```
   723  GET /<alertmanager-http-prefix>
   724  
   725  # Legacy (microservices mode only)
   726  GET /<legacy-http-prefix>
   727  ```
   728  
   729  Displays the Alertmanager UI.
   730  
   731  _Requires [authentication](#authentication)._
   732  
   733  ### Alertmanager Delete Tenant Configuration
   734  
   735  ```
   736  POST /multitenant_alertmanager/delete_tenant_config
   737  ```
   738  
   739  This endpoint deletes configuration for a tenant identified by `X-Scope-OrgID` header.
   740  It is internal, available even if Alertmanager API is not enabled by using `-experimental.alertmanager.enable-api`.
   741  The endpoint returns a status code of `200` if the user's configuration has been deleted, or it didn't exist in the first place.
   742  
   743  _Requires [authentication](#authentication)._
   744  
   745  ### Get Alertmanager configuration
   746  
   747  ```
   748  GET /api/v1/alerts
   749  ```
   750  
   751  Get the current Alertmanager configuration for the authenticated tenant, reading it from the configured object storage.
   752  
   753  This endpoint doesn't accept any URL query parameter and returns `200` on success.
   754  
   755  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.alertmanager.enable-api` CLI flag (or its respective YAML config option)._
   756  
   757  _Requires [authentication](#authentication)._
   758  
   759  ### Set Alertmanager configuration
   760  
   761  ```
   762  POST /api/v1/alerts
   763  ```
   764  
   765  Stores or updates the Alertmanager configuration for the authenticated tenant. The Alertmanager configuration is stored in the configured backend object storage.
   766  
   767  This endpoint expects the Alertmanager **YAML** configuration in the request body and returns `201` on success.
   768  
   769  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.alertmanager.enable-api` CLI flag (or its respective YAML config option)._
   770  
   771  _Requires [authentication](#authentication)._
   772  
   773  > **Note:** When using `curl` send the request body from a file, ensure that you use the `--data-binary` flag instead of `-d`, `--data`, or `--data-ascii`.
   774  > The latter options do not preserve carriage returns and newlines.
   775  
   776  #### Example request body
   777  
   778  ```yaml
   779  template_files:
   780    default_template: |
   781      {{ define "__alertmanager" }}AlertManager{{ end }}
   782      {{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver | urlquery }}{{ end }}
   783  alertmanager_config: |
   784    global:
   785      smtp_smarthost: 'localhost:25'
   786      smtp_from: 'youraddress@example.org'
   787    templates:
   788      - 'default_template'
   789    route:
   790      receiver: example-email
   791    receivers:
   792      - name: example-email
   793        email_configs:
   794        - to: 'youraddress@example.org'
   795  ```
   796  
   797  ### Delete Alertmanager configuration
   798  
   799  ```
   800  DELETE /api/v1/alerts
   801  ```
   802  
   803  Deletes the Alertmanager configuration for the authenticated tenant.
   804  
   805  This endpoint doesn't accept any URL query parameter and returns `200` on success.
   806  
   807  _This experimental endpoint is disabled by default and can be enabled via the `-experimental.alertmanager.enable-api` CLI flag (or its respective YAML config option)._
   808  
   809  _Requires [authentication](#authentication)._
   810  
   811  ## Purger
   812  
   813  The Purger service provides APIs for requesting deletion of series in chunks storage and managing delete requests. For more information about it, please read the [Delete series Guide](../guides/deleting-series.md).
   814  
   815  ### Delete series
   816  
   817  ```
   818  PUT,POST <prometheus-http-prefix>/api/v1/admin/tsdb/delete_series
   819  
   820  # Legacy
   821  PUT,POST <legacy-http-prefix>/api/v1/admin/tsdb/delete_series
   822  ```
   823  
   824  Prometheus-compatible delete series endpoint.
   825  
   826  _For more information, please check out the Prometheus [delete series](https://prometheus.io/docs/prometheus/latest/querying/api/#delete-series) documentation._
   827  
   828  _Requires [authentication](#authentication)._
   829  
   830  ### List delete requests
   831  
   832  ```
   833  GET <prometheus-http-prefix>/api/v1/admin/tsdb/delete_series
   834  
   835  # Legacy
   836  GET <legacy-http-prefix>/api/v1/admin/tsdb/delete_series
   837  ```
   838  
   839  List all the delete requests.
   840  
   841  _Requires [authentication](#authentication)._
   842  
   843  ### Cancel delete request
   844  
   845  ```
   846  PUT,POST <prometheus-http-prefix>/api/v1/admin/tsdb/cancel_delete_request
   847  
   848  # Legacy
   849  PUT,POST <legacy-http-prefix>/api/v1/admin/tsdb/cancel_delete_request
   850  ```
   851  
   852  Cancel a delete request while the request is still in the grace period (before the request is effectively processed by the purger and time series data is hard-deleted from the storage).
   853  
   854  | URL query parameter | Description |
   855  | ------------------- | ----------- |
   856  | `request_id` | Deletion request ID to cancel. Can be obtained by the [List delete requests](#list-delete-requests) endpoint. |
   857  
   858  _Requires [authentication](#authentication)._
   859  
   860  ### Tenant Delete Request
   861  
   862  ```
   863  POST /purger/delete_tenant
   864  ```
   865  
   866  Request deletion of ALL tenant data. Only works with blocks storage. Experimental.
   867  
   868  _Requires [authentication](#authentication)._
   869  
   870  ### Tenant Delete Status
   871  
   872  ```
   873  GET /purger/delete_tenant_status
   874  ```
   875  
   876  Returns status of tenant deletion. Output format to be defined. Experimental.
   877  
   878  _Requires [authentication](#authentication)._
   879  
   880  ## Store-gateway
   881  
   882  ### Store-gateway ring status
   883  ```
   884  GET /store-gateway/ring
   885  ```
   886  
   887  Displays a web page with the store-gateway hash ring status, including the state, healthy and last heartbeat time of each store-gateway.
   888  
   889  ## Compactor
   890  
   891  ### Compactor ring status
   892  
   893  ```
   894  GET /compactor/ring
   895  ```
   896  
   897  Displays a web page with the compactor hash ring status, including the state, healthy and last heartbeat time of each compactor.
   898  
   899  ## Configs API
   900  
   901  _This service has been **deprecated** in favour of [Ruler](#ruler) and [Alertmanager](#alertmanager) API._
   902  
   903  The configs API service provides an API-driven multi-tenant approach to handling various configuration files for Prometheus. The service hosts an API where users can read and write Prometheus rule files, Alertmanager configuration files, and Alertmanager templates to a database. Each tenant will have its own set of rule files, Alertmanager config, and templates.
   904  
   905  #### Request / response schema
   906  
   907  The following schema is used both when retrieving the current configs from the API and when setting new configs via the API:
   908  
   909  ```json
   910  {
   911      "id": 99,
   912      "rule_format_version": "2",
   913      "alertmanager_config": "<standard alertmanager.yaml config>",
   914      "rules_files": {
   915          "rules.yaml": "<standard rules.yaml config>",
   916          "rules2.yaml": "<standard rules.yaml config>"
   917       },
   918      "template_files": {
   919          "templates.tmpl": "<standard template file>",
   920          "templates2.tmpl": "<standard template file>"
   921      }
   922  }
   923  ```
   924  
   925  - **`id`**<br />
   926    Should be incremented every time data is updated; Cortex will use the config with the highest number.
   927  - **`rule_format_version`**<br />
   928    Allows compatibility for tenants with config in Prometheus V1 format. Pass "1" or "2" according to which Prometheus version you want to match.
   929  - **`alertmanager_config`**<br />
   930    The contents of the alertmanager config file should be as described [here](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/), encoded as a single string to fit within the overall JSON payload.
   931  - **`config.rules_files`**<br />
   932    The contents of a rules file should be as described [here](http://prometheus.io/docs/prometheus/latest/configuration/recording_rules/), encoded as a single string to fit within the overall JSON payload.
   933  - **`config.template_files`**<br />
   934    The contents of a template file should be as described [here](https://prometheus.io/docs/alerting/notification_examples/#defining-reusable-templates), encoded as a single string to fit within the overall JSON payload. These entries should match the `templates` entries in `alertmanager_config`. Example:
   935    ```yaml
   936    template_files:
   937      myorg.tmpl: |
   938        {{ define "__alertmanager" }}AlertManager{{ end }}
   939        {{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver | urlquery }}{{ end }}
   940    alertmanager_config: |
   941      templates:
   942        - 'myorg.tmpl'
   943    ```
   944  
   945  ### Get rule files
   946  
   947  ```
   948  GET /api/prom/configs/rules
   949  ```
   950  
   951  Get the current rule files for the authenticated tenant.
   952  
   953  _Requires [authentication](#authentication)._
   954  
   955  ### Set rule files
   956  
   957  ```
   958  POST /api/prom/configs/rules
   959  ```
   960  
   961  Replace the current rule files for the authenticated tenant.
   962  
   963  _Requires [authentication](#authentication)._
   964  
   965  ### Get template files
   966  
   967  ```
   968  GET /api/prom/configs/templates
   969  ```
   970  
   971  Get the current template files for the authenticated tenant.
   972  
   973  _Requires [authentication](#authentication)._
   974  
   975  ### Set template files
   976  
   977  ```
   978  POST /api/prom/configs/templates
   979  ```
   980  
   981  Replace the current template files for the authenticated tenant.
   982  
   983  _Requires [authentication](#authentication)._
   984  
   985  #### Get Alertmanager config file
   986  
   987  ```
   988  GET /api/prom/configs/alertmanager
   989  ```
   990  
   991  Get the current Alertmanager config for the authenticated tenant.
   992  
   993  _Requires [authentication](#authentication)._
   994  
   995  ### Set Alertmanager config file
   996  
   997  ```
   998  POST /api/prom/configs/alertmanager
   999  ```
  1000  
  1001  Replace the current Alertmanager config for the authenticated tenant.
  1002  
  1003  _Requires [authentication](#authentication)._
  1004  
  1005  ### Validate Alertmanager config file
  1006  
  1007  ```
  1008  POST /api/prom/configs/alertmanager/validate
  1009  ```
  1010  
  1011  Validate the Alertmanager config in the request body. The request body is expected to contain only the Alertmanager YAML config.
  1012  
  1013  ### Deactivate configs
  1014  
  1015  ```
  1016  DELETE /api/prom/configs/deactivate
  1017  ```
  1018  
  1019  Disable configs for the authenticated tenant. Please be aware that setting a new config will effectively "re-enable" the Rules and Alertmanager configuration for the tenant.
  1020  
  1021  _Requires [authentication](#authentication)._
  1022  
  1023  ### Restore configs
  1024  
  1025  ```
  1026  POST /api/prom/configs/restore
  1027  ```
  1028  
  1029  Re-enable configs for the authenticated tenant, after being previously deactivated.
  1030  
  1031  _Requires [authentication](#authentication)._