---
type: api
title: "Get Prometheus label values"
description: "Get the sorted deduplicated values of one label on the matching time series."
url: https://www.elastic.co/elastic/docs-builder/docs/5112/api/elasticsearch-serverless/operation/operation-prometheus-label-values
resource: https://www.elastic.co/elastic/docs-builder/docs/5112/api/elasticsearch-serverless/operation/operation-prometheus-label-values
products:
  - Elasticsearch Serverless
---

# Get Prometheus label values

Authentication: required

Availability: Preview

## Paths

- `GET` `/_prometheus/{index}/api/v1/label/{name}/values`
- `GET` `/_prometheus/api/v1/label/{name}/values`

#### Path parameters

- `index` (string) — optional, leave it out to use `/_prometheus/api/v1/label/{name}/values`
  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.
- `name` (string) — required
  The name of the label.

## Description

Get the sorted deduplicated values of one label on the matching time series.
Label names can use the OpenMetrics `U__` encoding for characters that are not valid in Prometheus label names.
An unknown label returns an empty list.
The endpoint mirrors the Prometheus `/api/v1/label/{name}/values` endpoint.

## Required privileges

- Index privileges: `read`

## Query string parameters

- `match[]` (string[]) — optional
  Repeated series selectors, for example `up{job="prometheus"}`. If you omit all of them, every series in the time range is considered.
- `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 label values 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[])
  The sorted label values.
- `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 is the standard Elasticsearch `{ error, status }` body instead.

`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.
#### `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
GET /_prometheus/api/v1/label/job/values
```

#### JavaScript

```javascript
const response = await client.prometheus.labelValues({
  name: "job",
});
```

#### Python

```python
resp = client.prometheus.label_values(
    name="job",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_prometheus/api/v1/label/job/values" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### C#

```c#
var response = await client.Prometheus
    .LabelValuesAsync(new LabelValuesRequest()
    {
        Name = "job"
    });
```

#### PHP

```php
$resp = $client->prometheus()->labelValues([
    "name" => "job",
]);
```

#### Ruby

```ruby
response = client.prometheus.label_values(
  name: "job"
)
```

## Response examples

#### A successful response

`application/json`

A successful response from `GET /_prometheus/api/v1/label/job/values`.

```json
{
  "status": "success",
  "data": [
    "api",
    "prometheus"
  ]
}
```

#### 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"
}
```

#### 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"
}
```

