---
type: api
title: "Get Prometheus metric metadata"
description: "Get the type and unit of the metrics in time series data streams, over a fixed 24-hour lookback."
url: https://www.elastic.co/elastic/docs-builder/docs/5111/api/elasticsearch-serverless/operation/operation-prometheus-metadata
resource: https://www.elastic.co/elastic/docs-builder/docs/5111/api/elasticsearch-serverless/operation/operation-prometheus-metadata
products:
  - Elasticsearch Serverless
---

# Get Prometheus metric metadata

Authentication: required

Availability: Preview

## Paths

- `GET` `/_prometheus/{index}/api/v1/metadata`
- `GET` `/_prometheus/api/v1/metadata`

#### Path parameters

- `index` (string) — optional, leave it out to use `/_prometheus/api/v1/metadata`
  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 type and unit of the metrics in time series data streams, over a fixed 24-hour lookback.
The `help` field is always an empty string.
The endpoint mirrors the Prometheus `/api/v1/metadata` endpoint, without `match[]`, `start` and `end`.

## Required privileges

- Index privileges: `read`

## Query string parameters

- `metric` (string) — optional
  Restricts the response to one metric name.
- `limit` (number · default: 0) — optional
  The maximum number of distinct metrics 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.
- `limit_per_metric` (number · default: 0) — optional
  The maximum number of metadata entries to return for each metric.
`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` (map string to object)
  The metadata entries, keyed by metric name.
- `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/metadata?metric=http_requests_total
```

#### JavaScript

```javascript
const response = await client.prometheus.metadata({
  metric: "http_requests_total",
});
```

#### Python

```python
resp = client.prometheus.metadata(
    metric="http_requests_total",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_prometheus/api/v1/metadata?metric=http_requests_total" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### C#

```c#
var response = await client.Prometheus
    .MetadataAsync(d1 => d1
        .Metric("http_requests_total")
    );
```

#### PHP

```php
$resp = $client->prometheus()->metadata([
    "metric" => "http_requests_total",
]);
```

#### Ruby

```ruby
response = client.prometheus.metadata(
  metric: "http_requests_total"
)
```

## Response examples

#### A successful response

`application/json`

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

```json
{
  "status": "success",
  "data": {
    "http_requests_total": [
      {
        "type": "counter",
        "help": "",
        "unit": ""
      }
    ]
  }
}
```

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

