---
type: api
title: "Find Prometheus series"
description: "Get the time series that match the given selectors."
url: https://www.elastic.co/elastic/docs-builder/docs/5103/api/elasticsearch-serverless/operation/operation-prometheus-series
resource: https://www.elastic.co/elastic/docs-builder/docs/5103/api/elasticsearch-serverless/operation/operation-prometheus-series
products:
  - Elasticsearch Serverless
---

# Find Prometheus series

Authentication: required

Availability: Preview

## Paths

- `POST` (also `GET`) `/_prometheus/{index}/api/v1/series`
- `POST` (also `GET`) `/_prometheus/api/v1/series`

#### Path parameters

- `index` (string) — optional, leave it out to use `/_prometheus/api/v1/series`
  An index expression that restricts which indices are considered, for example `metrics-generic.prometheus-*`.
If you omit it, the default expression `metrics-*` is used.
Only indices with `index.mode: time_series` are considered.
An alias is accepted and index privileges are checked against that alias name.

## Description

Get the time series that match the given selectors.
The endpoint mirrors the Prometheus `/api/v1/series` endpoint.

GET requests send parameters in the query string.
On Serverless and on Elasticsearch 9.5.0 and later, POST requests send the same parameters as an `application/x-www-form-urlencoded` body.
Form-encoded POST requests are accepted only on authenticated TLS connections.
If you send the same parameter in both the query string and the form body, the API returns `400` with the standard Elasticsearch error body.

## Required privileges

- Index privileges: `read`

## Query string parameters

- `match[]` (string[]) — required
  Repeated series selectors, for example `up{job="prometheus"}`. At least one is required.
- `start` (string) — optional
  The start of the time range, as an RFC 3339 timestamp or Unix time in seconds.
Defaults to 24 hours before `end`.
- `end` (string) — optional
  The end of the time range, as an RFC 3339 timestamp or Unix time in seconds.
Defaults to the current time.
- `limit` (number · default: 0) — optional
  The maximum number of series to return.
`0` means no limit from the request.
The cluster can still truncate the response with the `esql.query.result_truncation_max_size` setting.

## Responses

#### `200`

`application/json`

- `status` (string)
  The status of the request: `success`.
- `data` (string to string[])
  The label sets of the matching series.
- `warnings` (string[])
  Warnings, such as a notice that the results were truncated because of `limit`.
#### `400`


The request is not valid after the handler has started.
A failure while reading parameters, such as a missing `match[]`, is the standard Elasticsearch `{ error, status }` body instead, including a form parameter that is also in the query string.

`application/json`

- `status` (enum)
  The status of the request: `error`.
  Values: `error`
- `errorType` (enum)
  The Prometheus error type, from the HTTP status: `400` is `bad_data`; `503`, `408`, and `504` are `timeout`; every other status is `execution`.

Supported values include:
  - `bad_data`: HTTP `400`. The request or expression is not valid.
  - `timeout`: HTTP `503`, `408`, or `504`. The query timed out or a gateway timed out.
  - `execution`: Every other status, including HTTP `403` and `500`.
  Values: `bad_data`, `timeout`, `execution`
- `error` (string)
  The error message.
#### `403`


The caller is not allowed to run the query.

`application/json`

- `status` (enum)
  The status of the request: `error`.
  Values: `error`
- `errorType` (enum)
  The Prometheus error type, from the HTTP status: `400` is `bad_data`; `503`, `408`, and `504` are `timeout`; every other status is `execution`.

Supported values include:
  - `bad_data`: HTTP `400`. The request or expression is not valid.
  - `timeout`: HTTP `503`, `408`, or `504`. The query timed out or a gateway timed out.
  - `execution`: Every other status, including HTTP `403` and `500`.
  Values: `bad_data`, `timeout`, `execution`
- `error` (string)
  The error message.
#### `406`


On Serverless and on Elasticsearch 9.5.0 and later, form-encoded POST requests are accepted only on authenticated TLS connections.
Otherwise the response is `406` with the standard Elasticsearch error body.

`application/json`

- `error` (object)
  - `type` (string)
    The type of error
  - `reason` (union string) — nullable
    A human-readable explanation of the error, in English.
    One of: `string`
  - `stack_trace` (string)
    The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
  - `caused_by` (object) — recursive
    Same fields as `error`
  - `root_cause` (object[]) — recursive
    Same fields as `error`
  - `suppressed` (object[]) — recursive
    Same fields as `error`
- `status` (number)
#### `500`


The query ran, but the response could not be written.

`application/json`

- `status` (enum)
  The status of the request: `error`.
  Values: `error`
- `errorType` (enum)
  The Prometheus error type, from the HTTP status: `400` is `bad_data`; `503`, `408`, and `504` are `timeout`; every other status is `execution`.

Supported values include:
  - `bad_data`: HTTP `400`. The request or expression is not valid.
  - `timeout`: HTTP `503`, `408`, or `504`. The query timed out or a gateway timed out.
  - `execution`: Every other status, including HTTP `403` and `500`.
  Values: `bad_data`, `timeout`, `execution`
- `error` (string)
  The error message.
## Code examples

#### Console

```console
POST /_prometheus/api/v1/series?match[]=up
```

#### JavaScript

```javascript
const response = await client.prometheus.series({
  match: "up",
});
```

#### Python

```python
resp = client.prometheus.series(
    match="up",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_prometheus/api/v1/series?match[]=up" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### PHP

```php
$resp = $client->prometheus()->series([
    "match[]" => "up",
]);
```

#### Ruby

```ruby
response = client.prometheus.series(
  match[]: "up"
)
```

## Response examples

#### A successful response

`application/json`

A successful response from `GET /_prometheus/api/v1/series`.

```json
{
  "status": "success",
  "data": [
    {
      "__name__": "up",
      "job": "prometheus",
      "instance": "localhost:9090"
    }
  ]
}
```

#### 400

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "status": "error",
  "errorType": "bad_data",
  "error": "string"
}
```

#### 403

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "status": "error",
  "errorType": "bad_data",
  "error": "string"
}
```

#### 406

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "error": {
    "type": "string",
    "reason": "string",
    "stack_trace": "string",
    "caused_by": {
      "type": "string",
      "reason": "string",
      "stack_trace": "string",
      "caused_by": {
        "type": "string",
        "reason": "string",
        "stack_trace": "string",
        "caused_by": {
          "type": "string",
          "reason": "string",
          "stack_trace": "string",
          "caused_by": {
            "type": "string",
            "stack_trace": "string"
          },
          "root_cause": [],
          "suppressed": []
        },
        "root_cause": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ],
        "suppressed": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ]
      },
      "root_cause": [
        {
          "type": "string",
          "reason": "string",
          "stack_trace": "string",
          "caused_by": {
            "type": "string",
            "stack_trace": "string"
          },
          "root_cause": [],
          "suppressed": []
        }
      ],
      "suppressed": [
        {
          "type": "string",
          "reason": "string",
          "stack_trace": "string",
          "caused_by": {
            "type": "string",
            "stack_trace": "string"
          },
          "root_cause": [],
          "suppressed": []
        }
      ]
    },
    "root_cause": [
      {
        "type": "string",
        "reason": "string",
        "stack_trace": "string",
        "caused_by": {
          "type": "string",
          "reason": "string",
          "stack_trace": "string",
          "caused_by": {
            "type": "string",
            "stack_trace": "string"
          },
          "root_cause": [],
          "suppressed": []
        },
        "root_cause": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ],
        "suppressed": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ]
      }
    ],
    "suppressed": [
      {
        "type": "string",
        "reason": "string",
        "stack_trace": "string",
        "caused_by": {
          "type": "string",
          "reason": "string",
          "stack_trace": "string",
          "caused_by": {
            "type": "string",
            "stack_trace": "string"
          },
          "root_cause": [],
          "suppressed": []
        },
        "root_cause": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ],
        "suppressed": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ]
      }
    ]
  },
  "status": 0
}
```

#### 500

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "status": "error",
  "errorType": "bad_data",
  "error": "string"
}
```

