CAUTION: This page documents an old version of Prometheus. Check out the latest stable version.

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 (RFC4918).
  • 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.

An array of warnings may be returned if there are errors that do not inhibit the request execution. All of the data that was successfully collected will be returned in the data field.

The JSON response envelope format is as follows:

  1. {
  2. "status": "success" | "error",
  3. "data": <data>,
  4. // Only set if status is "error". The data field may still hold
  5. // additional data.
  6. "errorType": "<string>",
  7. "error": "<string>",
  8. // Only if there were warnings while executing the request.
  9. // There will still be data in the data field.
  10. "warnings": ["<string>"]
  11. }

Generic placeholders are defined as follows:

  • <rfc3339 | unix_timestamp>: Input timestamps may be provided either in RFC3339 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.
  • <series_selector>: Prometheus time series selectors like http_requests_total or http_requests_total{method=~"(GET|POST)"} and need to be URL-encoded.
  • <duration>: Prometheus duration strings. For example, 5m refers to a duration of 5 minutes.
  • <bool>: boolean values (strings true and false).

Note: Names of query parameters that may be repeated end with [].

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:

  1. GET /api/v1/query
  2. POST /api/v1/query

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.

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 has the following format:

  1. {
  2. "resultType": "matrix" | "vector" | "scalar" | "string",
  3. "result": <value>
  4. }

<value> refers to the query result data, which has varying formats depending on the resultType. See the expression query result formats.

The following example evaluates the expression up at the time 2015-07-01T20:10:51.781Z:

  1. $ curl 'http://localhost:9090/api/v1/query?query=up&time=2015-07-01T20:10:51.781Z'
  2. {
  3. "status" : "success",
  4. "data" : {
  5. "resultType" : "vector",
  6. "result" : [
  7. {
  8. "metric" : {
  9. "__name__" : "up",
  10. "job" : "prometheus",
  11. "instance" : "localhost:9090"
  12. },
  13. "value": [ 1435781451.781, "1" ]
  14. },
  15. {
  16. "metric" : {
  17. "__name__" : "up",
  18. "job" : "node",
  19. "instance" : "localhost:9100"
  20. },
  21. "value" : [ 1435781451.781, "0" ]
  22. }
  23. ]
  24. }
  25. }

Range queries

The following endpoint evaluates an expression query over a range of time:

  1. GET /api/v1/query_range
  2. POST /api/v1/query_range

URL query parameters:

  • query=<string>: Prometheus expression query string.
  • start=<rfc3339 | unix_timestamp>: Start timestamp, inclusive.
  • end=<rfc3339 | unix_timestamp>: End timestamp, inclusive.
  • step=<duration | float>: Query resolution step width in duration format or float number of seconds.
  • timeout=<duration>: Evaluation timeout. Optional. Defaults to and is capped by the value of the -query.timeout flag.

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 has the following format:

  1. {
  2. "resultType": "matrix",
  3. "result": <value>
  4. }

For the format of the <value> placeholder, see the range-vector result format.

The following example evaluates the expression up over a 30-second range with a query resolution of 15 seconds.

  1. $ 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'
  2. {
  3. "status" : "success",
  4. "data" : {
  5. "resultType" : "matrix",
  6. "result" : [
  7. {
  8. "metric" : {
  9. "__name__" : "up",
  10. "job" : "prometheus",
  11. "instance" : "localhost:9090"
  12. },
  13. "values" : [
  14. [ 1435781430.781, "1" ],
  15. [ 1435781445.781, "1" ],
  16. [ 1435781460.781, "1" ]
  17. ]
  18. },
  19. {
  20. "metric" : {
  21. "__name__" : "up",
  22. "job" : "node",
  23. "instance" : "localhost:9091"
  24. },
  25. "values" : [
  26. [ 1435781430.781, "0" ],
  27. [ 1435781445.781, "0" ],
  28. [ 1435781460.781, "1" ]
  29. ]
  30. }
  31. ]
  32. }
  33. }

Formatting query expressions

The following endpoint formats a PromQL expression in a prettified way:

  1. GET /api/v1/format_query
  2. 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:

  1. $ curl 'http://localhost:9090/api/v1/format_query?query=foo/bar'
  2. {
  3. "status" : "success",
  4. "data" : "foo / bar"
  5. }

Querying metadata

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.

Finding series by label matchers

The following endpoint returns the list of time series that match a certain label set.

  1. GET /api/v1/series
  2. POST /api/v1/series

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.

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.

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"}:

  1. $ curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=up' --data-urlencode 'match[]=process_start_time_seconds{job="prometheus"}'
  2. {
  3. "status" : "success",
  4. "data" : [
  5. {
  6. "__name__" : "up",
  7. "job" : "prometheus",
  8. "instance" : "localhost:9090"
  9. },
  10. {
  11. "__name__" : "up",
  12. "job" : "node",
  13. "instance" : "localhost:9091"
  14. },
  15. {
  16. "__name__" : "process_start_time_seconds",
  17. "job" : "prometheus",
  18. "instance" : "localhost:9090"
  19. }
  20. ]
  21. }

Getting label names

The following endpoint returns a list of label names:

  1. GET /api/v1/labels
  2. POST /api/v1/labels

URL query parameters:

  • start=<rfc3339 | unix_timestamp>: Start timestamp. Optional.
  • end=<rfc3339 | unix_timestamp>: End timestamp. Optional.
  • match[]=<series_selector>: Repeated series selector argument that selects the series from which to read the label names. Optional.

The data section of the JSON response is a list of string label names.

Here is an example.

  1. $ curl 'localhost:9090/api/v1/labels'
  2. {
  3. "status": "success",
  4. "data": [
  5. "__name__",
  6. "call",
  7. "code",
  8. "config",
  9. "dialer_name",
  10. "endpoint",
  11. "event",
  12. "goversion",
  13. "handler",
  14. "instance",
  15. "interval",
  16. "job",
  17. "le",
  18. "listener_name",
  19. "name",
  20. "quantile",
  21. "reason",
  22. "role",
  23. "scrape_job",
  24. "slice",
  25. "version"
  26. ]
  27. }

Querying label values

The following endpoint returns a list of label values for a provided label name:

  1. GET /api/v1/label/<label_name>/values

URL query parameters:

  • start=<rfc3339 | unix_timestamp>: Start timestamp. Optional.
  • end=<rfc3339 | unix_timestamp>: End timestamp. Optional.
  • match[]=<series_selector>: Repeated series selector argument that selects the series from which to read the label values. Optional.

The data section of the JSON response is a list of string label values.

This example queries for all label values for the job label:

  1. $ curl http://localhost:9090/api/v1/label/job/values
  2. {
  3. "status" : "success",
  4. "data" : [
  5. "node",
  6. "prometheus"
  7. ]
  8. }

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:

  1. GET /api/v1/query_exemplars
  2. 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.
  1. $ 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'
  2. {
  3. "status": "success",
  4. "data": [
  5. {
  6. "seriesLabels": {
  7. "__name__": "test_exemplar_metric_total",
  8. "instance": "localhost:8090",
  9. "job": "prometheus",
  10. "service": "bar"
  11. },
  12. "exemplars": [
  13. {
  14. "labels": {
  15. "traceID": "EpTxMJ40fUus7aGY"
  16. },
  17. "value": "6",
  18. "timestamp": 1600096945.479
  19. }
  20. ]
  21. },
  22. {
  23. "seriesLabels": {
  24. "__name__": "test_exemplar_metric_total",
  25. "instance": "localhost:8090",
  26. "job": "prometheus",
  27. "service": "foo"
  28. },
  29. "exemplars": [
  30. {
  31. "labels": {
  32. "traceID": "Olp9XHlq763ccsfa"
  33. },
  34. "value": "19",
  35. "timestamp": 1600096955.479
  36. },
  37. {
  38. "labels": {
  39. "traceID": "hCtjygkIHwAN9vs4"
  40. },
  41. "value": "20",
  42. "timestamp": 1600096965.489
  43. }
  44. ]
  45. }
  46. ]
  47. }

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.

The keys "histogram" and "histograms" only show up if the experimental native histograms are present in the response. Their placeholder <histogram> is explained in detail in its own section below.

Range vectors

Range vectors are returned as result type matrix. The corresponding result property has the following format:

  1. [
  2. {
  3. "metric": { "<label_name>": "<label_value>", ... },
  4. "values": [ [ <unix_time>, "<sample_value>" ], ... ],
  5. "histograms": [ [ <unix_time>, <histogram> ], ... ]
  6. },
  7. ...
  8. ]

Each series could have the "values" key, or the "histograms" key, or both. For a given timestamp, there will only be one sample of either float or histogram type.

Instant vectors

Instant vectors are returned as result type vector. The corresponding result property has the following format:

  1. [
  2. {
  3. "metric": { "<label_name>": "<label_value>", ... },
  4. "value": [ <unix_time>, "<sample_value>" ],
  5. "histogram": [ <unix_time>, <histogram> ]
  6. },
  7. ...
  8. ]

Each series could have the "value" key, or the "histogram" key, but not both.

Scalars

Scalar results are returned as result type scalar. The corresponding result property has the following format:

  1. [ <unix_time>, "<scalar_value>" ]

Strings

String results are returned as result type string. The corresponding result property has the following format:

  1. [ <unix_time>, "<string_value>" ]

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.

  1. {
  2. "count": "<count_of_observations>",
  3. "sum": "<sum_of_observations>",
  4. "buckets": [ [ <boundary_rule>, "<left_boundary>", "<right_boundary>", "<count_in_bucket>" ], ... ]
  5. }

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”.

Targets

The following endpoint returns an overview of the current state of the Prometheus target discovery:

  1. GET /api/v1/targets

Both the active and dropped targets are part of the response by default. labels represents the label set after relabeling has occurred. discoveredLabels represent the unmodified labels retrieved during service discovery before relabeling has occurred.

  1. $ curl http://localhost:9090/api/v1/targets
  2. {
  3. "status": "success",
  4. "data": {
  5. "activeTargets": [
  6. {
  7. "discoveredLabels": {
  8. "__address__": "127.0.0.1:9090",
  9. "__metrics_path__": "/metrics",
  10. "__scheme__": "http",
  11. "job": "prometheus"
  12. },
  13. "labels": {
  14. "instance": "127.0.0.1:9090",
  15. "job": "prometheus"
  16. },
  17. "scrapePool": "prometheus",
  18. "scrapeUrl": "http://127.0.0.1:9090/metrics",
  19. "globalUrl": "http://example-prometheus:9090/metrics",
  20. "lastError": "",
  21. "lastScrape": "2017-01-17T15:07:44.723715405+01:00",
  22. "lastScrapeDuration": 0.050688943,
  23. "health": "up",
  24. "scrapeInterval": "1m",
  25. "scrapeTimeout": "10s"
  26. }
  27. ],
  28. "droppedTargets": [
  29. {
  30. "discoveredLabels": {
  31. "__address__": "127.0.0.1:9100",
  32. "__metrics_path__": "/metrics",
  33. "__scheme__": "http",
  34. "__scrape_interval__": "1m",
  35. "__scrape_timeout__": "10s",
  36. "job": "node"
  37. },
  38. }
  39. ]
  40. }
  41. }

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.

  1. $ curl 'http://localhost:9090/api/v1/targets?state=active'
  2. {
  3. "status": "success",
  4. "data": {
  5. "activeTargets": [
  6. {
  7. "discoveredLabels": {
  8. "__address__": "127.0.0.1:9090",
  9. "__metrics_path__": "/metrics",
  10. "__scheme__": "http",
  11. "job": "prometheus"
  12. },
  13. "labels": {
  14. "instance": "127.0.0.1:9090",
  15. "job": "prometheus"
  16. },
  17. "scrapePool": "prometheus",
  18. "scrapeUrl": "http://127.0.0.1:9090/metrics",
  19. "globalUrl": "http://example-prometheus:9090/metrics",
  20. "lastError": "",
  21. "lastScrape": "2017-01-17T15:07:44.723715405+01:00",
  22. "lastScrapeDuration": 50688943,
  23. "health": "up"
  24. }
  25. ],
  26. "droppedTargets": []
  27. }
  28. }

The scrapePool query parameter allows the caller to filter by scrape pool name.

  1. $ curl 'http://localhost:9090/api/v1/targets?scrapePool=node_exporter'
  2. {
  3. "status": "success",
  4. "data": {
  5. "activeTargets": [
  6. {
  7. "discoveredLabels": {
  8. "__address__": "127.0.0.1:9091",
  9. "__metrics_path__": "/metrics",
  10. "__scheme__": "http",
  11. "job": "node_exporter"
  12. },
  13. "labels": {
  14. "instance": "127.0.0.1:9091",
  15. "job": "node_exporter"
  16. },
  17. "scrapePool": "node_exporter",
  18. "scrapeUrl": "http://127.0.0.1:9091/metrics",
  19. "globalUrl": "http://example-prometheus:9091/metrics",
  20. "lastError": "",
  21. "lastScrape": "2017-01-17T15:07:44.723715405+01:00",
  22. "lastScrapeDuration": 50688943,
  23. "health": "up"
  24. }
  25. ],
  26. "droppedTargets": []
  27. }
  28. }

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.

  1. GET /api/v1/rules

URL query parameters:

  • 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.
  • 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.
  1. $ curl http://localhost:9090/api/v1/rules
  2. {
  3. "data": {
  4. "groups": [
  5. {
  6. "rules": [
  7. {
  8. "alerts": [
  9. {
  10. "activeAt": "2018-07-04T20:27:12.60602144+02:00",
  11. "annotations": {
  12. "summary": "High request latency"
  13. },
  14. "labels": {
  15. "alertname": "HighRequestLatency",
  16. "severity": "page"
  17. },
  18. "state": "firing",
  19. "value": "1e+00"
  20. }
  21. ],
  22. "annotations": {
  23. "summary": "High request latency"
  24. },
  25. "duration": 600,
  26. "health": "ok",
  27. "labels": {
  28. "severity": "page"
  29. },
  30. "name": "HighRequestLatency",
  31. "query": "job:request_latency_seconds:mean5m{job=\"myjob\"} > 0.5",
  32. "type": "alerting"
  33. },
  34. {
  35. "health": "ok",
  36. "name": "job:http_inprogress_requests:sum",
  37. "query": "sum by (job) (http_inprogress_requests)",
  38. "type": "recording"
  39. }
  40. ],
  41. "file": "/rules.yaml",
  42. "interval": 60,
  43. "limit": 0,
  44. "name": "example"
  45. }
  46. ]
  47. },
  48. "status": "success"
  49. }

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.

  1. GET /api/v1/alerts
  1. $ curl http://localhost:9090/api/v1/alerts
  2. {
  3. "data": {
  4. "alerts": [
  5. {
  6. "activeAt": "2018-07-04T20:27:12.60602144+02:00",
  7. "annotations": {},
  8. "labels": {
  9. "alertname": "my-alert"
  10. },
  11. "state": "firing",
  12. "value": "1e+00"
  13. }
  14. ]
  15. },
  16. "status": "success"
  17. }

Querying target metadata

The following endpoint returns metadata about metrics currently scraped from targets. This is experimental and might change in the future.

  1. GET /api/v1/targets/metadata

URL query parameters:

  • 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.
  • 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".

  1. curl -G http://localhost:9091/api/v1/targets/metadata \
  2. --data-urlencode 'metric=go_goroutines' \
  3. --data-urlencode 'match_target={job="prometheus"}' \
  4. --data-urlencode 'limit=2'
  5. {
  6. "status": "success",
  7. "data": [
  8. {
  9. "target": {
  10. "instance": "127.0.0.1:9090",
  11. "job": "prometheus"
  12. },
  13. "type": "gauge",
  14. "help": "Number of goroutines that currently exist.",
  15. "unit": ""
  16. },
  17. {
  18. "target": {
  19. "instance": "127.0.0.1:9091",
  20. "job": "prometheus"
  21. },
  22. "type": "gauge",
  23. "help": "Number of goroutines that currently exist.",
  24. "unit": ""
  25. }
  26. ]
  27. }

The following example returns metadata for all metrics for all targets with label instance="127.0.0.1:9090.

  1. curl -G http://localhost:9091/api/v1/targets/metadata \
  2. --data-urlencode 'match_target={instance="127.0.0.1:9090"}'
  3. {
  4. "status": "success",
  5. "data": [
  6. // ...
  7. {
  8. "target": {
  9. "instance": "127.0.0.1:9090",
  10. "job": "prometheus"
  11. },
  12. "metric": "prometheus_treecache_zookeeper_failures_total",
  13. "type": "counter",
  14. "help": "The total number of ZooKeeper failures.",
  15. "unit": ""
  16. },
  17. {
  18. "target": {
  19. "instance": "127.0.0.1:9090",
  20. "job": "prometheus"
  21. },
  22. "metric": "prometheus_tsdb_reloads_total",
  23. "type": "counter",
  24. "help": "Number of times the database reloaded block data from disk.",
  25. "unit": ""
  26. },
  27. // ...
  28. ]
  29. }

Querying metric metadata

It returns metadata about metrics currently scraped from targets. However, it does not provide any target information. This is considered experimental and might change in the future.

  1. GET /api/v1/metadata

URL query parameters:

  • limit=<number>: Maximum number of metrics to return.
  • limit_per_metric=<number>: Maximum number of metadata to return per metric.
  • metric=<string>: A metric name to filter metadata for. All metric metadata is retrieved if left empty.

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.

  1. curl -G http://localhost:9090/api/v1/metadata?limit=2
  2. {
  3. "status": "success",
  4. "data": {
  5. "cortex_ring_tokens": [
  6. {
  7. "type": "gauge",
  8. "help": "Number of tokens in the ring",
  9. "unit": ""
  10. }
  11. ],
  12. "http_requests_total": [
  13. {
  14. "type": "counter",
  15. "help": "Number of HTTP requests",
  16. "unit": ""
  17. },
  18. {
  19. "type": "counter",
  20. "help": "Amount of HTTP requests",
  21. "unit": ""
  22. }
  23. ]
  24. }
  25. }

The following example returns only one metadata entry for each metric.

  1. curl -G http://localhost:9090/api/v1/metadata?limit_per_metric=1
  2. {
  3. "status": "success",
  4. "data": {
  5. "cortex_ring_tokens": [
  6. {
  7. "type": "gauge",
  8. "help": "Number of tokens in the ring",
  9. "unit": ""
  10. }
  11. ],
  12. "http_requests_total": [
  13. {
  14. "type": "counter",
  15. "help": "Number of HTTP requests",
  16. "unit": ""
  17. }
  18. ]
  19. }
  20. }

The following example returns metadata only for the metric http_requests_total.

  1. curl -G http://localhost:9090/api/v1/metadata?metric=http_requests_total
  2. {
  3. "status": "success",
  4. "data": {
  5. "http_requests_total": [
  6. {
  7. "type": "counter",
  8. "help": "Number of HTTP requests",
  9. "unit": ""
  10. },
  11. {
  12. "type": "counter",
  13. "help": "Amount of HTTP requests",
  14. "unit": ""
  15. }
  16. ]
  17. }
  18. }

Alertmanagers

The following endpoint returns an overview of the current state of the Prometheus alertmanager discovery:

  1. GET /api/v1/alertmanagers

Both the active and dropped Alertmanagers are part of the response.

  1. $ curl http://localhost:9090/api/v1/alertmanagers
  2. {
  3. "status": "success",
  4. "data": {
  5. "activeAlertmanagers": [
  6. {
  7. "url": "http://127.0.0.1:9090/api/v1/alerts"
  8. }
  9. ],
  10. "droppedAlertmanagers": [
  11. {
  12. "url": "http://127.0.0.1:9093/api/v1/alerts"
  13. }
  14. ]
  15. }
  16. }

Status

Following status endpoints expose current Prometheus configuration.

Config

The following endpoint returns currently loaded configuration file:

  1. 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.

  1. $ curl http://localhost:9090/api/v1/status/config
  2. {
  3. "status": "success",
  4. "data": {
  5. "yaml": "<content of the loaded config file in YAML>",
  6. }
  7. }

Flags

The following endpoint returns flag values that Prometheus was configured with:

  1. GET /api/v1/status/flags

All values are of the result type string.

  1. $ curl http://localhost:9090/api/v1/status/flags
  2. {
  3. "status": "success",
  4. "data": {
  5. "alertmanager.notification-queue-capacity": "10000",
  6. "alertmanager.timeout": "10s",
  7. "log.level": "info",
  8. "query.lookback-delta": "5m",
  9. "query.max-concurrency": "20",
  10. ...
  11. }
  12. }

New in v2.2

Runtime Information

The following endpoint returns various runtime information properties about the Prometheus server:

  1. GET /api/v1/status/runtimeinfo

The returned values are of different types, depending on the nature of the runtime property.

  1. $ curl http://localhost:9090/api/v1/status/runtimeinfo
  2. {
  3. "status": "success",
  4. "data": {
  5. "startTime": "2019-11-02T17:23:59.301361365+01:00",
  6. "CWD": "/",
  7. "reloadConfigSuccess": true,
  8. "lastConfigTime": "2019-11-02T17:23:59+01:00",
  9. "timeSeriesCount": 873,
  10. "corruptionCount": 0,
  11. "goroutineCount": 48,
  12. "GOMAXPROCS": 4,
  13. "GOGC": "",
  14. "GODEBUG": "",
  15. "storageRetention": "15d"
  16. }
  17. }

NOTE: The exact returned runtime properties may change without notice between Prometheus versions.

New in v2.14

Build Information

The following endpoint returns various build information properties about the Prometheus server:

  1. GET /api/v1/status/buildinfo

All values are of the result type string.

  1. $ curl http://localhost:9090/api/v1/status/buildinfo
  2. {
  3. "status": "success",
  4. "data": {
  5. "version": "2.13.1",
  6. "revision": "cb7cbad5f9a2823a622aaa668833ca04f50a0ea7",
  7. "branch": "master",
  8. "buildUser": "julius@desktop",
  9. "buildDate": "20191102-16:19:59",
  10. "goVersion": "go1.13.1"
  11. }
  12. }

NOTE: The exact returned build properties may change without notice between Prometheus versions.

New in v2.14

TSDB Stats

The following endpoint returns various cardinality statistics about the Prometheus TSDB:

  1. GET /api/v1/status/tsdb

URL query parameters: - limit=<number>: Limit the number of returned items to a given number for each set of statistics. By default, 10 items are returned.

The data section of the query result consists of - 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. - 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.

  1. $ curl http://localhost:9090/api/v1/status/tsdb
  2. {
  3. "status": "success",
  4. "data": {
  5. "headStats": {
  6. "numSeries": 508,
  7. "chunkCount": 937,
  8. "minTime": 1591516800000,
  9. "maxTime": 1598896800143,
  10. },
  11. "seriesCountByMetricName": [
  12. {
  13. "name": "net_conntrack_dialer_conn_failed_total",
  14. "value": 20
  15. },
  16. {
  17. "name": "prometheus_http_request_duration_seconds_bucket",
  18. "value": 20
  19. }
  20. ],
  21. "labelValueCountByLabelName": [
  22. {
  23. "name": "__name__",
  24. "value": 211
  25. },
  26. {
  27. "name": "event",
  28. "value": 3
  29. }
  30. ],
  31. "memoryInBytesByLabelName": [
  32. {
  33. "name": "__name__",
  34. "value": 8266
  35. },
  36. {
  37. "name": "instance",
  38. "value": 28
  39. }
  40. ],
  41. "seriesCountByLabelValuePair": [
  42. {
  43. "name": "job=prometheus",
  44. "value": 425
  45. },
  46. {
  47. "name": "instance=localhost:9090",
  48. "value": 425
  49. }
  50. ]
  51. }
  52. }

New in v2.15

WAL Replay Stats

The following endpoint returns information about the WAL replay:

  1. GET /api/v1/status/walreplay

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.

  1. $ curl http://localhost:9090/api/v1/status/walreplay
  2. {
  3. "status": "success",
  4. "data": {
  5. "min": 2,
  6. "max": 5,
  7. "current": 40,
  8. "state": "in progress"
  9. }
  10. }

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

TSDB Admin APIs

These are APIs that expose database functionalities for the advanced user. These APIs are not enabled unless the --web.enable-admin-api is set.

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. It will optionally skip snapshotting data that is only present in the head block, and which has not yet been compacted to disk.

  1. POST /api/v1/admin/tsdb/snapshot
  2. PUT /api/v1/admin/tsdb/snapshot

URL query parameters:

  • skip_head=<bool>: Skip data present in the head block. Optional.
  1. $ curl -XPOST http://localhost:9090/api/v1/admin/tsdb/snapshot
  2. {
  3. "status": "success",
  4. "data": {
  5. "name": "20171210T211224Z-2be650b6d019eb54"
  6. }
  7. }

The snapshot now exists at <data-dir>/snapshots/20171210T211224Z-2be650b6d019eb54

New in v2.1 and supports PUT from v2.9

Delete Series

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 endpoint.

If successful, a 204 is returned.

  1. POST /api/v1/admin/tsdb/delete_series
  2. PUT /api/v1/admin/tsdb/delete_series

URL query parameters:

  • match[]=<series_selector>: Repeated label matcher argument that selects the series to delete. At least one match[] argument must be provided.
  • 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.

Example:

  1. $ curl -X POST \
  2. -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=up&match[]=process_start_time_seconds{job="prometheus"}'

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.

New in v2.1 and supports PUT from v2.9

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.

If successful, a 204 is returned.

  1. POST /api/v1/admin/tsdb/clean_tombstones
  2. PUT /api/v1/admin/tsdb/clean_tombstones

This takes no parameters or body.

  1. $ curl -XPOST http://localhost:9090/api/v1/admin/tsdb/clean_tombstones

New in v2.1 and supports PUT from v2.9

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.

New in v2.33

This documentation is open-source. Please help improve it by filing issues or pull requests.