2017-10-26 13:53:27 +00:00
---
title: HTTP API
sort_rank: 7
---
# HTTP API
The current stable HTTP API is reachable under `/api/v1` on a Prometheus
server. Any non-breaking additions will be added under that endpoint.
## Format overview
The API response format is JSON. Every successful API request returns a `2xx`
status code.
Invalid requests that reach the API handlers return a JSON error object
and one of the following HTTP response codes:
- `400 Bad Request` when parameters are missing or incorrect.
- `422 Unprocessable Entity` when an expression can't be executed
2019-02-26 10:16:38 +00:00
([RFC4918](https://tools.ietf.org/html/rfc4918#page-78)).
2017-10-26 13:53:27 +00:00
- `503 Service Unavailable` when queries time out or abort.
Other non-`2xx` codes may be returned for errors occurring before the API
endpoint is reached.
2018-11-30 14:27:12 +00:00
An array of warnings may be returned if there are errors that do
2024-07-06 21:50:40 +00:00
not inhibit the request execution. An additional array of info-level
annotations may be returned for potential query issues that may or may
not be false positives. All of the data that was successfully collected
will be returned in the data field.
2018-11-30 14:27:12 +00:00
2017-10-26 13:53:27 +00:00
The JSON response envelope format is as follows:
```
{
"status": "success" | "error",
"data": < data > ,
// Only set if status is "error". The data field may still hold
// additional data.
"errorType": "< string > ",
2018-11-30 14:27:12 +00:00
"error": "< string > ",
2024-07-06 21:50:40 +00:00
// Only set if there were warnings while executing the request.
2018-11-30 14:27:12 +00:00
// There will still be data in the data field.
2024-07-06 21:50:40 +00:00
"warnings": ["< string > "],
// Only set if there were info-level annnotations while executing the request.
"infos": ["< string > "]
2017-10-26 13:53:27 +00:00
}
```
2020-09-01 08:37:09 +00:00
Generic placeholders are defined as follows:
* `<rfc3339 | unix_timestamp>` : Input timestamps may be provided either in
2017-10-26 13:53:27 +00:00
[RFC3339 ](https://www.ietf.org/rfc/rfc3339.txt ) format or as a Unix timestamp
in seconds, with optional decimal places for sub-second precision. Output
timestamps are always represented as Unix timestamps in seconds.
2020-09-01 08:37:09 +00:00
* `<series_selector>` : Prometheus [time series
2017-10-26 13:53:27 +00:00
selectors](basics.md#time-series-selectors) like `http_requests_total` or
2017-11-22 12:11:21 +00:00
`http_requests_total{method=~"(GET|POST)"}` and need to be URL-encoded.
2024-10-05 18:31:14 +00:00
* `<duration>` : [the subset of Prometheus float literals using time units ](basics.md#float-literals-and-time-durations ).
2020-08-04 19:12:41 +00:00
For example, `5m` refers to a duration of 5 minutes.
2020-09-01 08:37:09 +00:00
* `<bool>` : boolean values (strings `true` and `false` ).
2017-10-26 13:53:27 +00:00
2020-09-01 08:37:09 +00:00
Note: Names of query parameters that may be repeated end with `[]` .
2018-08-04 19:30:53 +00:00
2017-10-26 13:53:27 +00:00
## Expression queries
Query language expressions may be evaluated at a single instant or over a range
of time. The sections below describe the API endpoints for each type of
expression query.
### Instant queries
The following endpoint evaluates an instant query at a single point in time:
```
GET /api/v1/query
2019-04-02 17:00:29 +00:00
POST /api/v1/query
2017-10-26 13:53:27 +00:00
```
URL query parameters:
- `query=<string>` : Prometheus expression query string.
- `time=<rfc3339 | unix_timestamp>` : Evaluation timestamp. Optional.
- `timeout=<duration>` : Evaluation timeout. Optional. Defaults to and
is capped by the value of the `-query.timeout` flag.
The current server time is used if the `time` parameter is omitted.
2019-04-02 17:00:29 +00:00
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
2019-04-02 19:44:03 +00:00
query that may breach server-side URL character limits.
2019-04-02 17:00:29 +00:00
2017-10-26 13:53:27 +00:00
The `data` section of the query result has the following format:
```
{
"resultType": "matrix" | "vector" | "scalar" | "string",
"result": < value >
}
```
`<value>` refers to the query result data, which has varying formats
depending on the `resultType` . See the [expression query result
formats](#expression-query-result-formats).
The following example evaluates the expression `up` at the time
`2015-07-01T20:10:51.781Z` :
```json
$ curl 'http://localhost:9090/api/v1/query?query=up& time=2015-07-01T20:10:51.781Z'
{
"status" : "success",
"data" : {
"resultType" : "vector",
"result" : [
{
"metric" : {
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
"value": [ 1435781451.781, "1" ]
},
{
"metric" : {
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9100"
},
"value" : [ 1435781451.781, "0" ]
}
]
}
}
```
### Range queries
The following endpoint evaluates an expression query over a range of time:
```
GET /api/v1/query_range
2019-04-02 17:00:29 +00:00
POST /api/v1/query_range
2017-10-26 13:53:27 +00:00
```
URL query parameters:
- `query=<string>` : Prometheus expression query string.
2021-07-28 12:52:02 +00:00
- `start=<rfc3339 | unix_timestamp>` : Start timestamp, inclusive.
- `end=<rfc3339 | unix_timestamp>` : End timestamp, inclusive.
2018-07-07 08:20:18 +00:00
- `step=<duration | float>` : Query resolution step width in `duration` format or float number of seconds.
2017-10-26 13:53:27 +00:00
- `timeout=<duration>` : Evaluation timeout. Optional. Defaults to and
is capped by the value of the `-query.timeout` flag.
2019-04-02 17:00:29 +00:00
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
2019-04-02 19:44:03 +00:00
query that may breach server-side URL character limits.
2019-04-02 17:00:29 +00:00
2017-10-26 13:53:27 +00:00
The `data` section of the query result has the following format:
```
{
"resultType": "matrix",
"result": < value >
}
```
For the format of the `<value>` placeholder, see the [range-vector result
format](#range-vectors).
The following example evaluates the expression `up` over a 30-second range with
a query resolution of 15 seconds.
```json
$ curl 'http://localhost:9090/api/v1/query_range?query=up& start=2015-07-01T20:10:30.781Z& end=2015-07-01T20:11:00.781Z& step=15s'
{
"status" : "success",
"data" : {
"resultType" : "matrix",
"result" : [
{
"metric" : {
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
"values" : [
[ 1435781430.781, "1" ],
[ 1435781445.781, "1" ],
[ 1435781460.781, "1" ]
]
},
{
"metric" : {
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9091"
},
"values" : [
[ 1435781430.781, "0" ],
[ 1435781445.781, "0" ],
[ 1435781460.781, "1" ]
]
}
]
}
}
```
2022-07-20 12:55:09 +00:00
## Formatting query expressions
The following endpoint formats a PromQL expression in a prettified way:
```
GET /api/v1/format_query
POST /api/v1/format_query
```
URL query parameters:
- `query=<string>` : Prometheus expression query string.
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
query that may breach server-side URL character limits.
The `data` section of the query result is a string containing the formatted query expression. Note that any comments are removed in the formatted string.
The following example formats the expression `foo/bar` :
```json
$ curl 'http://localhost:9090/api/v1/format_query?query=foo/bar'
{
"status" : "success",
"data" : "foo / bar"
}
```
2024-09-09 08:27:24 +00:00
## Parsing a PromQL expressions into a abstract syntax tree (AST)
This endpoint is **experimental** and might change in the future. It is currently only meant to be used by Prometheus' own web UI, and the endpoint name and exact format returned may change from one Prometheus version to another. It may also be removed again in case it is no longer needed by the UI.
The following endpoint parses a PromQL expression and returns it as a JSON-formatted AST (abstract syntax tree) representation:
```
GET /api/v1/parse_query
POST /api/v1/parse_query
```
URL query parameters:
- `query=<string>` : Prometheus expression query string.
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
query that may breach server-side URL character limits.
The `data` section of the query result is a string containing the AST of the parsed query expression.
The following example parses the expression `foo/bar` :
```json
$ curl 'http://localhost:9090/api/v1/parse_query?query=foo/bar'
{
"data" : {
"bool" : false,
"lhs" : {
"matchers" : [
{
"name" : "__name__",
"type" : "=",
"value" : "foo"
}
],
"name" : "foo",
"offset" : 0,
"startOrEnd" : null,
"timestamp" : null,
"type" : "vectorSelector"
},
"matching" : {
"card" : "one-to-one",
"include" : [],
"labels" : [],
"on" : false
},
"op" : "/",
"rhs" : {
"matchers" : [
{
"name" : "__name__",
"type" : "=",
"value" : "bar"
}
],
"name" : "bar",
"offset" : 0,
"startOrEnd" : null,
"timestamp" : null,
"type" : "vectorSelector"
},
"type" : "binaryExpr"
},
"status" : "success"
}
```
2017-10-26 13:53:27 +00:00
## Querying metadata
2021-03-15 22:09:29 +00:00
Prometheus offers a set of API endpoints to query metadata about series and their labels.
NOTE: These API endpoints may return metadata for series for which there is no sample within the selected time range, and/or for series whose samples have been marked as deleted via the deletion API endpoint. The exact extent of additionally returned series metadata is an implementation detail that may change in the future.
2017-10-26 13:53:27 +00:00
### Finding series by label matchers
The following endpoint returns the list of time series that match a certain label set.
```
GET /api/v1/series
2019-04-02 17:00:29 +00:00
POST /api/v1/series
2017-10-26 13:53:27 +00:00
```
URL query parameters:
- `match[]=<series_selector>` : Repeated series selector argument that selects the
series to return. At least one `match[]` argument must be provided.
- `start=<rfc3339 | unix_timestamp>` : Start timestamp.
- `end=<rfc3339 | unix_timestamp>` : End timestamp.
2024-05-15 18:39:54 +00:00
- `limit=<number>` : Maximum number of returned series. Optional. 0 means disabled.
2017-10-26 13:53:27 +00:00
2019-04-02 17:00:29 +00:00
You can URL-encode these parameters directly in the request body by using the `POST` method and
`Content-Type: application/x-www-form-urlencoded` header. This is useful when specifying a large
or dynamic number of series selectors that may breach server-side URL character limits.
2017-10-26 13:53:27 +00:00
The `data` section of the query result consists of a list of objects that
contain the label name/value pairs which identify each series.
The following example returns all series that match either of the selectors
`up` or `process_start_time_seconds{job="prometheus"}` :
```json
2020-01-14 12:07:48 +00:00
$ curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=up' --data-urlencode 'match[]=process_start_time_seconds{job="prometheus"}'
2017-10-26 13:53:27 +00:00
{
"status" : "success",
"data" : [
{
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
{
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9091"
},
{
"__name__" : "process_start_time_seconds",
"job" : "prometheus",
"instance" : "localhost:9090"
}
]
}
```
2018-11-19 10:21:14 +00:00
### Getting label names
The following endpoint returns a list of label names:
```
GET /api/v1/labels
POST /api/v1/labels
```
2020-05-30 12:50:09 +00:00
URL query parameters:
- `start=<rfc3339 | unix_timestamp>` : Start timestamp. Optional.
- `end=<rfc3339 | unix_timestamp>` : End timestamp. Optional.
2020-12-22 11:02:19 +00:00
- `match[]=<series_selector>` : Repeated series selector argument that selects the
series from which to read the label names. Optional.
2024-05-15 18:39:54 +00:00
- `limit=<number>` : Maximum number of returned series. Optional. 0 means disabled.
2020-05-30 12:50:09 +00:00
2018-11-19 10:21:14 +00:00
The `data` section of the JSON response is a list of string label names.
Here is an example.
```json
$ curl 'localhost:9090/api/v1/labels'
{
"status": "success",
"data": [
"__name__",
"call",
"code",
"config",
"dialer_name",
"endpoint",
"event",
"goversion",
"handler",
"instance",
"interval",
"job",
"le",
"listener_name",
"name",
"quantile",
"reason",
"role",
"scrape_job",
"slice",
"version"
]
}
```
2017-10-26 13:53:27 +00:00
### Querying label values
The following endpoint returns a list of label values for a provided label name:
```
GET /api/v1/label/< label_name > /values
```
2020-05-30 12:50:09 +00:00
URL query parameters:
- `start=<rfc3339 | unix_timestamp>` : Start timestamp. Optional.
- `end=<rfc3339 | unix_timestamp>` : End timestamp. Optional.
2020-12-22 11:02:19 +00:00
- `match[]=<series_selector>` : Repeated series selector argument that selects the
series from which to read the label values. Optional.
2024-05-15 18:39:54 +00:00
- `limit=<number>` : Maximum number of returned series. Optional. 0 means disabled.
2020-05-30 12:50:09 +00:00
2018-11-19 10:21:14 +00:00
The `data` section of the JSON response is a list of string label values.
2017-10-26 13:53:27 +00:00
2024-11-14 15:51:59 +00:00
This example queries for all label values for the `http_status_code` label:
```json
$ curl http://localhost:9090/api/v1/label/http_status_code/values
{
"status" : "success",
"data" : [
"200",
"504"
]
}
```
Label names can optionally be encoded using the Values Escaping method, and is necessary if a name includes the `/` character. To encode a name in this way:
* Prepend the label with `U__` .
* Letters, numbers, and colons appear as-is.
* Convert single underscores to double underscores.
* For all other characters, use the UTF-8 codepoint as a hex integer, surrounded
by underscores. So ` ` becomes `_20_` and a `.` becomes `_2e_` .
More information about text escaping can be found in the original UTF-8 [Proposal document ](https://github.com/prometheus/proposals/blob/main/proposals/2023-08-21-utf8.md#text-escaping ).
This example queries for all label values for the `http.status_code` label:
2017-10-26 13:53:27 +00:00
```json
2024-11-14 15:51:59 +00:00
$ curl http://localhost:9090/api/v1/label/U__http_2e_status_code/values
2017-10-26 13:53:27 +00:00
{
"status" : "success",
"data" : [
2024-11-14 15:51:59 +00:00
"200",
"404"
2017-10-26 13:53:27 +00:00
]
}
```
2021-03-16 09:47:45 +00:00
## Querying exemplars
This is **experimental** and might change in the future.
The following endpoint returns a list of exemplars for a valid PromQL query for a specific time range:
```
GET /api/v1/query_exemplars
POST /api/v1/query_exemplars
```
URL query parameters:
- `query=<string>` : Prometheus expression query string.
- `start=<rfc3339 | unix_timestamp>` : Start timestamp.
- `end=<rfc3339 | unix_timestamp>` : End timestamp.
```json
2021-10-03 10:22:47 +00:00
$ curl -g 'http://localhost:9090/api/v1/query_exemplars?query=test_exemplar_metric_total& start=2020-09-14T15:22:25.479Z& end=2020-09-14T15:23:25.479Z'
2021-03-16 09:47:45 +00:00
{
"status": "success",
"data": [
{
"seriesLabels": {
"__name__": "test_exemplar_metric_total",
"instance": "localhost:8090",
"job": "prometheus",
"service": "bar"
},
"exemplars": [
{
"labels": {
2024-02-15 14:19:54 +00:00
"trace_id": "EpTxMJ40fUus7aGY"
2021-03-16 09:47:45 +00:00
},
"value": "6",
2023-06-09 04:06:09 +00:00
"timestamp": 1600096945.479
2021-03-16 09:47:45 +00:00
}
]
},
{
"seriesLabels": {
"__name__": "test_exemplar_metric_total",
"instance": "localhost:8090",
"job": "prometheus",
"service": "foo"
},
"exemplars": [
{
"labels": {
2024-02-15 14:19:54 +00:00
"trace_id": "Olp9XHlq763ccsfa"
2021-03-16 09:47:45 +00:00
},
"value": "19",
2023-06-09 04:06:09 +00:00
"timestamp": 1600096955.479
2021-03-16 09:47:45 +00:00
},
{
"labels": {
2024-02-15 14:19:54 +00:00
"trace_id": "hCtjygkIHwAN9vs4"
2021-03-16 09:47:45 +00:00
},
"value": "20",
2023-06-09 04:06:09 +00:00
"timestamp": 1600096965.489
}
2021-03-16 09:47:45 +00:00
]
}
]
}
```
2017-10-26 13:53:27 +00:00
## Expression query result formats
Expression queries may return the following response values in the `result`
property of the `data` section. `<sample_value>` placeholders are numeric
sample values. JSON does not support special float values such as `NaN` , `Inf` ,
and `-Inf` , so sample values are transferred as quoted JSON strings rather than
raw numbers.
2022-10-14 11:38:31 +00:00
The keys `"histogram"` and `"histograms"` only show up if the experimental
native histograms are present in the response. Their placeholder `<histogram>`
2024-07-06 21:50:40 +00:00
is explained in detail in its own section below.
2022-10-14 11:38:31 +00:00
2017-10-26 13:53:27 +00:00
### Range vectors
Range vectors are returned as result type `matrix` . The corresponding
`result` property has the following format:
```
[
{
"metric": { "< label_name > ": "< label_value > ", ... },
2022-10-14 11:38:31 +00:00
"values": [ [ < unix_time > , "< sample_value > " ], ... ],
"histograms": [ [ < unix_time > , < histogram > ], ... ]
2017-10-26 13:53:27 +00:00
},
...
]
```
2024-07-06 21:50:40 +00:00
Each series could have the `"values"` key, or the `"histograms"` key, or both.
2023-01-31 08:04:17 +00:00
For a given timestamp, there will only be one sample of either float or histogram type.
2024-05-17 03:54:08 +00:00
Series are returned sorted by `metric` . Functions such as [`sort` ](functions.md#sort )
and [`sort_by_label` ](functions.md#sort_by_label ) have no effect for range vectors.
2017-10-26 13:53:27 +00:00
### Instant vectors
Instant vectors are returned as result type `vector` . The corresponding
`result` property has the following format:
```
[
{
"metric": { "< label_name > ": "< label_value > ", ... },
2022-10-14 11:38:31 +00:00
"value": [ < unix_time > , "< sample_value > " ],
"histogram": [ < unix_time > , < histogram > ]
2017-10-26 13:53:27 +00:00
},
...
]
```
2023-01-31 08:04:17 +00:00
Each series could have the `"value"` key, or the `"histogram"` key, but not both.
2024-05-17 03:54:08 +00:00
Series are not guaranteed to be returned in any particular order unless a function
2024-10-24 06:53:36 +00:00
such as [`sort` ](functions.md#sort ) or [`sort_by_label` ](functions.md#sort_by_label )
2024-05-17 03:54:08 +00:00
is used.
2017-10-26 13:53:27 +00:00
### Scalars
Scalar results are returned as result type `scalar` . The corresponding
`result` property has the following format:
```
[ < unix_time > , "< scalar_value > " ]
```
### Strings
String results are returned as result type `string` . The corresponding
`result` property has the following format:
```
[ < unix_time > , "< string_value > " ]
```
2022-10-14 11:38:31 +00:00
### Native histograms
The `<histogram>` placeholder used above is formatted as follows.
_Note that native histograms are an experimental feature, and the format below
might still change._
```
{
"count": "< count_of_observations > ",
"sum": "< sum_of_observations > ",
"buckets": [ [ < boundary_rule > , "< left_boundary > ", "< right_boundary > ", "< count_in_bucket > " ], ... ]
}
```
The `<boundary_rule>` placeholder is an integer between 0 and 3 with the
following meaning:
* 0: “open left” (left boundary is exclusive, right boundary in inclusive)
* 1: “open right” (left boundary is inclusive, right boundary in exclusive)
* 2: “open both” (both boundaries are exclusive)
* 3: “closed both” (both boundaries are inclusive)
Note that with the currently implemented bucket schemas, positive buckets are
“open left”, negative buckets are “open right”, and the zero bucket (with a
negative left boundary and a positive right boundary) is “closed both”.
2017-10-26 13:53:27 +00:00
## Targets
The following endpoint returns an overview of the current state of the
Prometheus target discovery:
```
GET /api/v1/targets
```
2019-11-11 21:42:24 +00:00
Both the active and dropped targets are part of the response by default.
2023-08-14 14:39:25 +00:00
Dropped targets are subject to `keep_dropped_targets` limit, if set.
2022-07-14 11:49:30 +00:00
`labels` represents the label set after relabeling has occurred.
`discoveredLabels` represent the unmodified labels retrieved during service discovery before relabeling has occurred.
2017-10-26 13:53:27 +00:00
```json
$ curl http://localhost:9090/api/v1/targets
{
2018-05-18 07:32:11 +00:00
"status": "success",
2017-10-26 13:53:27 +00:00
"data": {
"activeTargets": [
{
"discoveredLabels": {
"__address__": "127.0.0.1:9090",
"__metrics_path__": "/metrics",
"__scheme__": "http",
"job": "prometheus"
},
"labels": {
"instance": "127.0.0.1:9090",
"job": "prometheus"
},
2019-11-11 21:42:24 +00:00
"scrapePool": "prometheus",
2017-10-26 13:53:27 +00:00
"scrapeUrl": "http://127.0.0.1:9090/metrics",
2020-03-09 13:07:30 +00:00
"globalUrl": "http://example-prometheus:9090/metrics",
2017-10-26 13:53:27 +00:00
"lastError": "",
"lastScrape": "2017-01-17T15:07:44.723715405+01:00",
2019-11-11 21:42:24 +00:00
"lastScrapeDuration": 0.050688943,
2021-08-31 15:37:32 +00:00
"health": "up",
"scrapeInterval": "1m",
"scrapeTimeout": "10s"
2017-10-26 13:53:27 +00:00
}
2018-02-21 17:26:18 +00:00
],
"droppedTargets": [
{
"discoveredLabels": {
"__address__": "127.0.0.1:9100",
"__metrics_path__": "/metrics",
"__scheme__": "http",
2021-08-31 15:37:32 +00:00
"__scrape_interval__": "1m",
"__scrape_timeout__": "10s",
2018-02-21 17:26:18 +00:00
"job": "node"
},
}
2017-10-26 13:53:27 +00:00
]
}
}
```
2019-11-11 21:42:24 +00:00
The `state` query parameter allows the caller to filter by active or dropped targets,
(e.g., `state=active` , `state=dropped` , `state=any` ).
Note that an empty array is still returned for targets that are filtered out.
Other values are ignored.
```json
$ curl 'http://localhost:9090/api/v1/targets?state=active'
{
"status": "success",
"data": {
"activeTargets": [
{
"discoveredLabels": {
"__address__": "127.0.0.1:9090",
"__metrics_path__": "/metrics",
"__scheme__": "http",
"job": "prometheus"
},
"labels": {
"instance": "127.0.0.1:9090",
"job": "prometheus"
},
"scrapePool": "prometheus",
"scrapeUrl": "http://127.0.0.1:9090/metrics",
2020-03-09 13:07:30 +00:00
"globalUrl": "http://example-prometheus:9090/metrics",
2019-11-11 21:42:24 +00:00
"lastError": "",
"lastScrape": "2017-01-17T15:07:44.723715405+01:00",
"lastScrapeDuration": 50688943,
"health": "up"
}
],
"droppedTargets": []
}
}
```
2022-12-23 10:55:08 +00:00
The `scrapePool` query parameter allows the caller to filter by scrape pool name.
```json
$ curl 'http://localhost:9090/api/v1/targets?scrapePool=node_exporter'
{
"status": "success",
"data": {
"activeTargets": [
{
"discoveredLabels": {
"__address__": "127.0.0.1:9091",
"__metrics_path__": "/metrics",
"__scheme__": "http",
"job": "node_exporter"
},
"labels": {
"instance": "127.0.0.1:9091",
"job": "node_exporter"
},
"scrapePool": "node_exporter",
"scrapeUrl": "http://127.0.0.1:9091/metrics",
"globalUrl": "http://example-prometheus:9091/metrics",
"lastError": "",
"lastScrape": "2017-01-17T15:07:44.723715405+01:00",
"lastScrapeDuration": 50688943,
"health": "up"
}
],
"droppedTargets": []
}
}
```
2018-06-27 07:15:17 +00:00
## Rules
The `/rules` API endpoint returns a list of alerting and recording rules that
are currently loaded. In addition it returns the currently active alerts fired
by the Prometheus instance of each alerting rule.
As the `/rules` endpoint is fairly new, it does not have the same stability
guarantees as the overarching API v1.
```
GET /api/v1/rules
```
2019-12-11 16:06:17 +00:00
URL query parameters:
2023-04-18 09:07:32 +00:00
2019-12-11 16:06:17 +00:00
- `type=alert|record` : return only the alerting rules (e.g. `type=alert` ) or the recording rules (e.g. `type=record` ). When the parameter is absent or empty, no filtering is done.
2023-04-20 08:34:05 +00:00
- `rule_name[]=<string>` : only return rules with the given rule name. If the parameter is repeated, rules with any of the provided names are returned. If we've filtered out all the rules of a group, the group is not returned. When the parameter is absent or empty, no filtering is done.
- `rule_group[]=<string>` : only return rules with the given rule group name. If the parameter is repeated, rules with any of the provided rule group names are returned. When the parameter is absent or empty, no filtering is done.
- `file[]=<string>` : only return rules with the given filepath. If the parameter is repeated, rules with any of the provided filepaths are returned. When the parameter is absent or empty, no filtering is done.
2024-09-09 08:27:24 +00:00
- `exclude_alerts=<bool>` : only return rules, do not return active alerts.
2024-07-10 12:18:29 +00:00
- `match[]=<label_selector>` : only return rules that have configured labels that satisfy the label selectors. If the parameter is repeated, rules that match any of the sets of label selectors are returned. Note that matching is on the labels in the definition of each rule, not on the values after template expansion (for alerting rules). Optional.
2024-10-21 23:04:40 +00:00
- `group_limit=<number>` : The `group_limit` parameter allows you to specify a limit for the number of rule groups that is returned in a single response. If the total number of rule groups exceeds the specified `group_limit` value, the response will include a `groupNextToken` property. You can use the value of this `groupNextToken` property in subsequent requests in the `group_next_token` parameter to paginate over the remaining rule groups. The `groupNextToken` property will not be present in the final response, indicating that you have retrieved all the available rule groups. Please note that there are no guarantees regarding the consistency of the response if the rule groups are being modified during the pagination process.
- `group_next_token` : the pagination token that was returned in previous request when the `group_limit` property is set. The pagination token is used to iteratively paginate over a large number of rule groups. To use the `group_next_token` parameter, the `group_limit` parameter also need to be present. If a rule group that coincides with the next token is removed while you are paginating over the rule groups, a response with status code 400 will be returned.
2019-12-11 16:06:17 +00:00
2018-06-27 07:15:17 +00:00
```json
$ curl http://localhost:9090/api/v1/rules
{
"data": {
"groups": [
{
"rules": [
{
"alerts": [
{
"activeAt": "2018-07-04T20:27:12.60602144+02:00",
"annotations": {
"summary": "High request latency"
},
"labels": {
"alertname": "HighRequestLatency",
"severity": "page"
},
"state": "firing",
2019-05-21 09:41:54 +00:00
"value": "1e+00"
2018-06-27 07:15:17 +00:00
}
],
"annotations": {
"summary": "High request latency"
},
"duration": 600,
2018-08-23 13:00:10 +00:00
"health": "ok",
2018-06-27 07:15:17 +00:00
"labels": {
"severity": "page"
},
"name": "HighRequestLatency",
"query": "job:request_latency_seconds:mean5m{job=\"myjob\"} > 0.5",
"type": "alerting"
},
{
2018-08-23 13:00:10 +00:00
"health": "ok",
2018-06-27 07:15:17 +00:00
"name": "job:http_inprogress_requests:sum",
2020-05-02 11:52:24 +00:00
"query": "sum by (job) (http_inprogress_requests)",
2018-06-27 07:15:17 +00:00
"type": "recording"
}
],
"file": "/rules.yaml",
"interval": 60,
2022-01-12 03:44:22 +00:00
"limit": 0,
2018-06-27 07:15:17 +00:00
"name": "example"
}
]
},
"status": "success"
}
```
## Alerts
The `/alerts` endpoint returns a list of all active alerts.
As the `/alerts` endpoint is fairly new, it does not have the same stability
guarantees as the overarching API v1.
```
GET /api/v1/alerts
```
```json
$ curl http://localhost:9090/api/v1/alerts
{
"data": {
"alerts": [
{
"activeAt": "2018-07-04T20:27:12.60602144+02:00",
"annotations": {},
"labels": {
"alertname": "my-alert"
},
"state": "firing",
2019-05-21 09:41:54 +00:00
"value": "1e+00"
2018-06-27 07:15:17 +00:00
}
]
},
"status": "success"
}
```
2018-06-05 10:30:19 +00:00
## Querying target metadata
2018-05-18 07:32:11 +00:00
2019-12-10 14:56:16 +00:00
The following endpoint returns metadata about metrics currently scraped from targets.
2018-06-05 10:30:19 +00:00
This is **experimental** and might change in the future.
2018-05-18 07:32:11 +00:00
```
GET /api/v1/targets/metadata
```
URL query parameters:
2018-06-05 10:30:19 +00:00
- `match_target=<label_selectors>` : Label selectors that match targets by their label sets. All targets are selected if left empty.
- `metric=<string>` : A metric name to retrieve metadata for. All metric metadata is retrieved if left empty.
2018-05-18 07:32:11 +00:00
- `limit=<number>` : Maximum number of targets to match.
The `data` section of the query result consists of a list of objects that
contain metric metadata and the target label set.
The following example returns all metadata entries for the `go_goroutines` metric
from the first two targets with label `job="prometheus"` .
```json
curl -G http://localhost:9091/api/v1/targets/metadata \
2018-06-05 10:30:19 +00:00
--data-urlencode 'metric=go_goroutines' \
--data-urlencode 'match_target={job="prometheus"}' \
2018-05-18 07:32:11 +00:00
--data-urlencode 'limit=2'
{
"status": "success",
"data": [
{
"target": {
"instance": "127.0.0.1:9090",
"job": "prometheus"
},
"type": "gauge",
2018-10-05 16:11:16 +00:00
"help": "Number of goroutines that currently exist.",
"unit": ""
2018-05-18 07:32:11 +00:00
},
{
"target": {
"instance": "127.0.0.1:9091",
"job": "prometheus"
},
"type": "gauge",
2018-10-05 16:11:16 +00:00
"help": "Number of goroutines that currently exist.",
"unit": ""
2018-05-18 07:32:11 +00:00
}
]
}
```
2018-06-05 10:30:19 +00:00
The following example returns metadata for all metrics for all targets with
2024-10-24 06:53:36 +00:00
label `instance="127.0.0.1:9090"` .
2018-05-18 07:32:11 +00:00
```json
curl -G http://localhost:9091/api/v1/targets/metadata \
2018-06-05 10:30:19 +00:00
--data-urlencode 'match_target={instance="127.0.0.1:9090"}'
2018-05-18 07:32:11 +00:00
{
"status": "success",
"data": [
// ...
{
"target": {
"instance": "127.0.0.1:9090",
"job": "prometheus"
},
"metric": "prometheus_treecache_zookeeper_failures_total",
"type": "counter",
2018-10-05 16:11:16 +00:00
"help": "The total number of ZooKeeper failures.",
"unit": ""
2018-05-18 07:32:11 +00:00
},
{
"target": {
"instance": "127.0.0.1:9090",
"job": "prometheus"
},
"metric": "prometheus_tsdb_reloads_total",
"type": "counter",
2018-10-05 16:11:16 +00:00
"help": "Number of times the database reloaded block data from disk.",
"unit": ""
2018-05-18 07:32:11 +00:00
},
// ...
]
}
```
2019-12-10 14:56:16 +00:00
## Querying metric metadata
2022-08-16 07:30:10 +00:00
It returns metadata about metrics currently scraped from targets. However, it does not provide any target information.
2019-12-10 14:56:16 +00:00
This is considered **experimental** and might change in the future.
```
GET /api/v1/metadata
```
URL query parameters:
- `limit=<number>` : Maximum number of metrics to return.
2023-06-12 15:17:20 +00:00
- `limit_per_metric=<number>` : Maximum number of metadata to return per metric.
2019-12-10 15:22:10 +00:00
- `metric=<string>` : A metric name to filter metadata for. All metric metadata is retrieved if left empty.
2019-12-10 14:56:16 +00:00
The `data` section of the query result consists of an object where each key is a metric name and each value is a list of unique metadata objects, as exposed for that metric name across all targets.
The following example returns two metrics. Note that the metric `http_requests_total` has more than one object in the list. At least one target has a value for `HELP` that do not match with the rest.
```json
curl -G http://localhost:9090/api/v1/metadata?limit=2
{
"status": "success",
"data": {
"cortex_ring_tokens": [
{
"type": "gauge",
"help": "Number of tokens in the ring",
"unit": ""
}
],
"http_requests_total": [
{
"type": "counter",
"help": "Number of HTTP requests",
"unit": ""
},
{
"type": "counter",
"help": "Amount of HTTP requests",
2019-12-10 15:22:10 +00:00
"unit": ""
}
]
}
}
```
2023-06-12 15:17:20 +00:00
The following example returns only one metadata entry for each metric.
```json
curl -G http://localhost:9090/api/v1/metadata?limit_per_metric=1
{
"status": "success",
"data": {
"cortex_ring_tokens": [
{
"type": "gauge",
"help": "Number of tokens in the ring",
"unit": ""
}
],
"http_requests_total": [
{
"type": "counter",
"help": "Number of HTTP requests",
"unit": ""
}
]
}
}
```
2019-12-10 15:22:10 +00:00
The following example returns metadata only for the metric `http_requests_total` .
```json
curl -G http://localhost:9090/api/v1/metadata?metric=http_requests_total
{
"status": "success",
"data": {
"http_requests_total": [
{
"type": "counter",
"help": "Number of HTTP requests",
"unit": ""
},
{
"type": "counter",
"help": "Amount of HTTP requests",
2019-12-10 14:56:16 +00:00
"unit": ""
}
]
}
}
```
2017-10-26 13:53:27 +00:00
## Alertmanagers
The following endpoint returns an overview of the current state of the
Prometheus alertmanager discovery:
```
GET /api/v1/alertmanagers
```
2018-02-21 09:00:07 +00:00
Both the active and dropped Alertmanagers are part of the response.
2017-10-26 13:53:27 +00:00
```json
$ curl http://localhost:9090/api/v1/alertmanagers
{
"status": "success",
"data": {
"activeAlertmanagers": [
{
"url": "http://127.0.0.1:9090/api/v1/alerts"
}
2018-02-21 09:00:07 +00:00
],
"droppedAlertmanagers": [
{
"url": "http://127.0.0.1:9093/api/v1/alerts"
}
2017-10-26 13:53:27 +00:00
]
}
}
```
2017-11-30 16:16:04 +00:00
api: Added v1/status/flags endpoint. (#3864)
Endpoint URL: /api/v1/status/flags
Example Output:
```json
{
"status": "success",
"data": {
"alertmanager.notification-queue-capacity": "10000",
"alertmanager.timeout": "10s",
"completion-bash": "false",
"completion-script-bash": "false",
"completion-script-zsh": "false",
"config.file": "my_cool_prometheus.yaml",
"help": "false",
"help-long": "false",
"help-man": "false",
"log.level": "info",
"query.lookback-delta": "5m",
"query.max-concurrency": "20",
"query.timeout": "2m",
"storage.tsdb.max-block-duration": "36h",
"storage.tsdb.min-block-duration": "2h",
"storage.tsdb.no-lockfile": "false",
"storage.tsdb.path": "data/",
"storage.tsdb.retention": "15d",
"version": "false",
"web.console.libraries": "console_libraries",
"web.console.templates": "consoles",
"web.enable-admin-api": "false",
"web.enable-lifecycle": "false",
"web.external-url": "",
"web.listen-address": "0.0.0.0:9090",
"web.max-connections": "512",
"web.read-timeout": "5m",
"web.route-prefix": "/",
"web.user-assets": ""
}
}
```
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
2018-02-21 08:49:02 +00:00
## Status
Following status endpoints expose current Prometheus configuration.
### Config
The following endpoint returns currently loaded configuration file:
```
GET /api/v1/status/config
```
The config is returned as dumped YAML file. Due to limitation of the YAML
library, YAML comments are not included.
```json
$ curl http://localhost:9090/api/v1/status/config
{
"status": "success",
"data": {
"yaml": "< content of the loaded config file in YAML > ",
}
}
```
### Flags
The following endpoint returns flag values that Prometheus was configured with:
```
GET /api/v1/status/flags
```
2019-11-02 17:18:32 +00:00
All values are of the result type `string` .
api: Added v1/status/flags endpoint. (#3864)
Endpoint URL: /api/v1/status/flags
Example Output:
```json
{
"status": "success",
"data": {
"alertmanager.notification-queue-capacity": "10000",
"alertmanager.timeout": "10s",
"completion-bash": "false",
"completion-script-bash": "false",
"completion-script-zsh": "false",
"config.file": "my_cool_prometheus.yaml",
"help": "false",
"help-long": "false",
"help-man": "false",
"log.level": "info",
"query.lookback-delta": "5m",
"query.max-concurrency": "20",
"query.timeout": "2m",
"storage.tsdb.max-block-duration": "36h",
"storage.tsdb.min-block-duration": "2h",
"storage.tsdb.no-lockfile": "false",
"storage.tsdb.path": "data/",
"storage.tsdb.retention": "15d",
"version": "false",
"web.console.libraries": "console_libraries",
"web.console.templates": "consoles",
"web.enable-admin-api": "false",
"web.enable-lifecycle": "false",
"web.external-url": "",
"web.listen-address": "0.0.0.0:9090",
"web.max-connections": "512",
"web.read-timeout": "5m",
"web.route-prefix": "/",
"web.user-assets": ""
}
}
```
Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
2018-02-21 08:49:02 +00:00
```json
$ curl http://localhost:9090/api/v1/status/flags
{
"status": "success",
"data": {
"alertmanager.notification-queue-capacity": "10000",
"alertmanager.timeout": "10s",
"log.level": "info",
"query.lookback-delta": "5m",
"query.max-concurrency": "20",
...
}
}
```
*New in v2.2*
2017-11-30 16:16:04 +00:00
2019-11-02 17:18:32 +00:00
### Runtime Information
The following endpoint returns various runtime information properties about the Prometheus server:
```
GET /api/v1/status/runtimeinfo
```
The returned values are of different types, depending on the nature of the runtime property.
```json
$ curl http://localhost:9090/api/v1/status/runtimeinfo
{
"status": "success",
"data": {
"startTime": "2019-11-02T17:23:59.301361365+01:00",
"CWD": "/",
"reloadConfigSuccess": true,
"lastConfigTime": "2019-11-02T17:23:59+01:00",
"timeSeriesCount": 873,
"corruptionCount": 0,
"goroutineCount": 48,
"GOMAXPROCS": 4,
"GOGC": "",
"GODEBUG": "",
"storageRetention": "15d"
}
}
```
2021-03-15 22:09:29 +00:00
NOTE: The exact returned runtime properties may change without notice between Prometheus versions.
2019-11-02 17:18:32 +00:00
*New in v2.14*
### Build Information
The following endpoint returns various build information properties about the Prometheus server:
```
GET /api/v1/status/buildinfo
```
All values are of the result type `string` .
```json
$ curl http://localhost:9090/api/v1/status/buildinfo
{
"status": "success",
"data": {
"version": "2.13.1",
"revision": "cb7cbad5f9a2823a622aaa668833ca04f50a0ea7",
"branch": "master",
"buildUser": "julius@desktop",
"buildDate": "20191102-16:19:59",
"goVersion": "go1.13.1"
}
}
```
2021-03-15 22:09:29 +00:00
NOTE: The exact returned build properties may change without notice between Prometheus versions.
2019-11-02 17:18:32 +00:00
2020-01-19 09:54:39 +00:00
*New in v2.14*
2019-11-12 10:15:20 +00:00
### TSDB Stats
The following endpoint returns various cardinality statistics about the Prometheus TSDB:
```
GET /api/v1/status/tsdb
```
2023-05-22 12:37:07 +00:00
URL query parameters:
2024-10-24 06:53:36 +00:00
2023-05-22 12:37:07 +00:00
- `limit=<number>` : Limit the number of returned items to a given number for each set of statistics. By default, 10 items are returned.
2024-10-24 06:53:36 +00:00
The `data` section of the query result consists of:
2020-09-29 20:05:33 +00:00
- **headStats**: This provides the following data about the head block of the TSDB:
- **numSeries**: The number of series.
- **chunkCount**: The number of chunks.
- **minTime**: The current minimum timestamp in milliseconds.
- **maxTime**: The current maximum timestamp in milliseconds.
2019-11-12 10:15:20 +00:00
- **seriesCountByMetricName:** This will provide a list of metrics names and their series count.
- **labelValueCountByLabelName:** This will provide a list of the label names and their value count.
- **memoryInBytesByLabelName** This will provide a list of the label names and memory used in bytes. Memory usage is calculated by adding the length of all values for a given label name.
- **seriesCountByLabelPair** This will provide a list of label value pairs and their series count.
```json
$ curl http://localhost:9090/api/v1/status/tsdb
{
"status": "success",
"data": {
2020-09-29 20:05:33 +00:00
"headStats": {
"numSeries": 508,
"chunkCount": 937,
"minTime": 1591516800000,
"maxTime": 1598896800143,
},
2019-11-12 10:15:20 +00:00
"seriesCountByMetricName": [
{
"name": "net_conntrack_dialer_conn_failed_total",
"value": 20
},
{
"name": "prometheus_http_request_duration_seconds_bucket",
"value": 20
}
],
"labelValueCountByLabelName": [
{
"name": "__name__",
"value": 211
},
{
"name": "event",
"value": 3
}
],
"memoryInBytesByLabelName": [
{
"name": "__name__",
"value": 8266
},
{
"name": "instance",
"value": 28
}
],
"seriesCountByLabelValuePair": [
{
"name": "job=prometheus",
"value": 425
},
{
"name": "instance=localhost:9090",
"value": 425
}
]
}
}
```
2020-01-19 09:54:39 +00:00
*New in v2.15*
2019-11-02 17:18:32 +00:00
2021-06-05 14:29:32 +00:00
### WAL Replay Stats
The following endpoint returns information about the WAL replay:
```
GET /api/v1/status/walreplay
```
2024-10-24 06:53:36 +00:00
- **read**: The number of segments replayed so far.
- **total**: The total number segments needed to be replayed.
- **progress**: The progress of the replay (0 - 100%).
- **state**: The state of the replay. Possible states:
- **waiting**: Waiting for the replay to start.
- **in progress**: The replay is in progress.
- **done**: The replay has finished.
2021-06-05 14:29:32 +00:00
```json
$ curl http://localhost:9090/api/v1/status/walreplay
{
"status": "success",
"data": {
"min": 2,
"max": 5,
"current": 40,
"state": "in progress"
}
}
```
NOTE: This endpoint is available before the server has been marked ready and is updated in real time to facilitate monitoring the progress of the WAL replay.
*New in v2.28*
2017-11-30 16:16:04 +00:00
## TSDB Admin APIs
2017-12-03 05:07:05 +00:00
These are APIs that expose database functionalities for the advanced user. These APIs are not enabled unless the `--web.enable-admin-api` is set.
2017-11-30 16:16:04 +00:00
### Snapshot
Snapshot creates a snapshot of all current data into `snapshots/<datetime>-<rand>` under the TSDB's data directory and returns the directory as response.
2018-03-08 10:43:41 +00:00
It will optionally skip snapshotting data that is only present in the head block, and which has not yet been compacted to disk.
2017-11-30 16:16:04 +00:00
```
2019-06-07 09:21:47 +00:00
POST /api/v1/admin/tsdb/snapshot
PUT /api/v1/admin/tsdb/snapshot
2017-11-30 16:16:04 +00:00
```
2019-06-07 09:21:47 +00:00
URL query parameters:
- `skip_head=<bool>` : Skip data present in the head block. Optional.
2017-11-30 16:16:04 +00:00
```json
2017-12-03 05:07:05 +00:00
$ curl -XPOST http://localhost:9090/api/v1/admin/tsdb/snapshot
2017-11-30 16:16:04 +00:00
{
2017-12-05 16:26:06 +00:00
"status": "success",
"data": {
2017-12-10 19:19:34 +00:00
"name": "20171210T211224Z-2be650b6d019eb54"
2017-12-05 16:26:06 +00:00
}
2017-11-30 16:16:04 +00:00
}
```
2017-12-10 19:19:34 +00:00
The snapshot now exists at `<data-dir>/snapshots/20171210T211224Z-2be650b6d019eb54`
2017-11-30 16:16:04 +00:00
2019-03-20 17:33:45 +00:00
*New in v2.1 and supports PUT from v2.9*
2017-11-30 16:16:04 +00:00
### Delete Series
2020-08-20 11:57:01 +00:00
DeleteSeries deletes data for a selection of series in a time range. The actual data still exists on disk and is cleaned up in future compactions or can be explicitly cleaned up by hitting the [Clean Tombstones ](#clean-tombstones ) endpoint.
2017-11-30 16:16:04 +00:00
2017-12-05 16:26:06 +00:00
If successful, a `204` is returned.
2017-11-30 16:16:04 +00:00
```
2017-12-05 16:26:06 +00:00
POST /api/v1/admin/tsdb/delete_series
2019-03-20 17:33:45 +00:00
PUT /api/v1/admin/tsdb/delete_series
2017-11-30 16:16:04 +00:00
```
2017-12-03 05:07:05 +00:00
URL query parameters:
2017-11-30 16:16:04 +00:00
2017-12-03 05:07:05 +00:00
- `match[]=<series_selector>` : Repeated label matcher argument that selects the series to delete. At least one `match[]` argument must be provided.
2017-12-05 16:26:06 +00:00
- `start=<rfc3339 | unix_timestamp>` : Start timestamp. Optional and defaults to minimum possible time.
- `end=<rfc3339 | unix_timestamp>` : End timestamp. Optional and defaults to maximum possible time.
Not mentioning both start and end times would clear all the data for the matched series in the database.
2017-11-30 16:16:04 +00:00
Example:
```json
2018-04-05 12:06:18 +00:00
$ curl -X POST \
-g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=up& match[]=process_start_time_seconds{job="prometheus"}'
2017-11-30 16:16:04 +00:00
```
2021-03-15 22:09:29 +00:00
NOTE: This endpoint marks samples from series as deleted, but will not necessarily prevent associated series metadata from still being returned in metadata queries for the affected time range (even after cleaning tombstones). The exact extent of metadata deletion is an implementation detail that may change in the future.
2019-03-20 17:33:45 +00:00
*New in v2.1 and supports PUT from v2.9*
2017-11-30 16:16:04 +00:00
### Clean Tombstones
CleanTombstones removes the deleted data from disk and cleans up the existing tombstones. This can be used after deleting series to free up space.
2017-12-05 16:26:06 +00:00
If successful, a `204` is returned.
2017-11-30 16:16:04 +00:00
```
2017-12-03 05:07:05 +00:00
POST /api/v1/admin/tsdb/clean_tombstones
2019-03-20 17:33:45 +00:00
PUT /api/v1/admin/tsdb/clean_tombstones
2017-11-30 16:16:04 +00:00
```
This takes no parameters or body.
```json
2017-12-03 05:07:05 +00:00
$ curl -XPOST http://localhost:9090/api/v1/admin/tsdb/clean_tombstones
2017-12-05 16:26:06 +00:00
```
2019-04-02 19:44:03 +00:00
*New in v2.1 and supports PUT from v2.9*
2022-01-05 14:26:24 +00:00
## Remote Write Receiver
Prometheus can be configured as a receiver for the Prometheus remote write
protocol. This is not considered an efficient way of ingesting samples. Use it
with caution for specific low-volume use cases. It is not suitable for
replacing the ingestion via scraping and turning Prometheus into a push-based
metrics collection system.
Enable the remote write receiver by setting
`--web.enable-remote-write-receiver` . When enabled, the remote write receiver
endpoint is `/api/v1/write` . Find more details [here ](../storage.md#overview ).
*New in v2.33*
2023-08-02 22:11:36 +00:00
## OTLP Receiver
2024-07-06 21:50:40 +00:00
Prometheus can be configured as a receiver for the OTLP Metrics protocol. This
2023-08-02 22:11:36 +00:00
is not considered an efficient way of ingesting samples. Use it
2023-08-03 11:56:54 +00:00
with caution for specific low-volume use cases. It is not suitable for
replacing the ingestion via scraping.
2023-08-02 22:11:36 +00:00
2024-10-01 12:36:52 +00:00
Enable the OTLP receiver by setting
`--web.enable-otlp-receiver` . When enabled, the OTLP receiver
2023-08-03 12:01:43 +00:00
endpoint is `/api/v1/otlp/v1/metrics` .
2023-08-02 22:11:36 +00:00
2023-10-18 02:02:03 +00:00
*New in v2.47*
2024-10-07 10:45:09 +00:00
## Notifications
The following endpoints provide information about active status notifications concerning the Prometheus server itself.
Notifications are used in the web UI.
These endpoints are **experimental** . They may change in the future.
### Active Notifications
The `/api/v1/notifications` endpoint returns a list of all currently active notifications.
```
GET /api/v1/notifications
```
Example:
```
$ curl http://localhost:9090/api/v1/notifications
{
"status": "success",
"data": [
{
"text": "Prometheus is shutting down and gracefully stopping all operations.",
"date": "2024-10-07T12:33:08.551376578+02:00",
"active": true
}
]
}
```
*New in v3.0*
### Live Notifications
The `/api/v1/notifications/live` endpoint streams live notifications as they occur, using [Server-Sent Events ](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events ). Deleted notifications are sent with `active: false` . Active notifications will be sent when connecting to the endpoint.
```
GET /api/v1/notifications/live
```
Example:
```
$ curl http://localhost:9090/api/v1/notifications/live
data: {
"status": "success",
"data": [
{
"text": "Prometheus is shutting down and gracefully stopping all operations.",
"date": "2024-10-07T12:33:08.551376578+02:00",
"active": true
}
]
}
```
**Note:** The `/notifications/live` endpoint will return a `204 No Content` response if the maximum number of subscribers has been reached. You can set the maximum number of listeners with the flag `--web.max-notifications-subscribers` , which defaults to 16.
```
GET /api/v1/notifications/live
204 No Content
```
*New in v3.0*