---
type: api
title: Query Prometheus exemplars
description: Get the exemplars of the series selected by a PromQL expression over a time range.
url: https://www.elastic.co/elastic/docs-builder/docs/4922/api/doc/elasticsearch-serverless/operation/operation-prometheus-query-exemplars
resource: https://www.elastic.co/elastic/docs-builder/docs/4922/api/doc/elasticsearch-serverless/operation/operation-prometheus-query-exemplars
products:
  - Elasticsearch Serverless
---

# Query Prometheus exemplars

Authentication: required

Availability: Preview

## Paths

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

#### Path parameters

- `index` (string) — optional, leave it out to use `/_prometheus/api/v1/query_exemplars`
  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.

## Description

Get the exemplars of the series selected by a PromQL expression over a time range.
The endpoint mirrors the Prometheus `/api/v1/query_exemplars` endpoint.

## Required privileges

- Index privileges: `read`

## Query string parameters

- `query` (string) — required
  The PromQL expression that selects the series.
- `start` (string) — required
  The start of the range, as an RFC 3339 timestamp or Unix time in seconds.
- `end` (string) — required
  The end of the range, as an RFC 3339 timestamp or Unix time in seconds.
- `timeout` (string) — optional
  The evaluation timeout, as a number of seconds or a duration such as `30s`.
It must be positive and is capped by the `xpack.prometheus.query.timeout` cluster setting.

## Responses

`application/json`

- `status` (string)
  The status of the request: `success`.
- `data` (object[])
  The exemplars, grouped by series.
  - `seriesLabels` (map string to string)
    The labels of the series that the exemplars belong to.
  - `exemplars` (object[])
    - `labels` (map string to string)
      The labels of the exemplar, such as `trace_id`.
    - `value` (string)
      The exemplar value, as a string.
    - `timestamp` (number)
      The exemplar timestamp, in Unix seconds.
## Code examples

#### Console

```console
POST /_prometheus/api/v1/query_exemplars?query=http_request_duration_seconds_bucket&start=2026-07-09T22:00:00Z&end=2026-07-09T22:01:00Z
```

#### JavaScript

```javascript
const response = await client.prometheus.queryExemplars({
  query: "http_request_duration_seconds_bucket",
  start: "2026-07-09T22:00:00Z",
  end: "2026-07-09T22:01:00Z",
});
```

#### Python

```python
resp = client.prometheus.query_exemplars(
    query="http_request_duration_seconds_bucket",
    start="2026-07-09T22:00:00Z",
    end="2026-07-09T22:01:00Z",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_prometheus/api/v1/query_exemplars?query=http_request_duration_seconds_bucket&start=2026-07-09T22:00:00Z&end=2026-07-09T22:01:00Z" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### PHP

```php
$resp = $client->prometheus()->queryExemplars([
    "query" => "http_request_duration_seconds_bucket",
    "start" => "2026-07-09T22:00:00Z",
    "end" => "2026-07-09T22:01:00Z",
]);
```

#### Ruby

```ruby
response = client.prometheus.query_exemplars(
  query: "http_request_duration_seconds_bucket",
  start: "2026-07-09T22:00:00Z",
  end: "2026-07-09T22:01:00Z"
)
```

## Response examples

#### A successful response

`application/json`

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

```json
{
  "status": "success",
  "data": [
    {
      "seriesLabels": {
        "__name__": "http_request_duration_seconds_bucket",
        "job": "api",
        "le": "0.5"
      },
      "exemplars": [
        {
          "labels": {
            "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736"
          },
          "value": "0.42",
          "timestamp": 1783634412.5
        }
      ]
    }
  ]
}
```

