Docs Home

Usage and metrics

A cluster's storage and document counts over time, its request metrics, and the search terms its users send most. For the current totals only, read stats on the cluster. When the store behind these doesn't answer, they return 503 metrics_unavailable, never an empty list, so an empty list always means there's no data.

On this page: Show a cluster's usage, Show a cluster's request metrics, Show a cluster's top queries.

Show a cluster's usage

GET /v1/clusters/{cluster_id}/usage

  • Scope: clusters:read

One sample per index-stats poll (about every 10 minutes), summed over the cluster's indices, oldest first. At most 90 days. A cluster that was never polled has an empty samples, not a zero sample. The cluster's current totals are stats on the Cluster, not part of this body.

Parameters

NameInTypeDescription
cluster_idpathstringRequired. The cluster's ID, which is its slug. It never changes.
fromquerystring (date-time)Start of the range, RFC 3339. Defaults to one hour before to.
toquerystring (date-time)End of the range, RFC 3339. Defaults to now.

Example request

curl "https://api.bonsai.io/v1/clusters/my-search-4823919/usage?from=2026-10-26T00%3A00%3A00Z&to=2026-10-26T12%3A00%3A00Z" \
  -H "Authorization: Bearer $BONSAI_TOKEN"

Response

200 OK. Usage samples.

FieldTypeDescription
fromstring (date-time)Start of the range.
tostring (date-time)End of the range.
samplesarray of objectsOldest first. Empty when the cluster was never polled in the range.
samples[].atstring (date-time)When the sample was taken.
samples[].bytesintegerBytes on disk.
samples[].docsintegerDocuments.
samples[].docs_deletedintegerDeleted documents not yet merged away.
samples[].shardsintegerShards, primaries and replicas.
samples[].primary_shardsintegerPrimary shards.
samples[].healthstringOne of green, yellow, red. More may be added. Worst index health.
{
  "from": "2026-10-26T00:00:00Z",
  "to": "2026-10-26T12:00:00Z",
  "samples": [
    {
      "at": "2026-10-26T00:04:00Z",
      "bytes": 48103424,
      "docs": 12810,
      "docs_deleted": 31,
      "shards": 2,
      "primary_shards": 1,
      "health": "green"
    },
    {
      "at": "2026-10-26T00:14:00Z",
      "bytes": 48211968,
      "docs": 12840,
      "docs_deleted": 31,
      "shards": 2,
      "primary_shards": 1,
      "health": "green"
    }
  ]
}

Errors

Show a cluster's request metrics

GET /v1/clusters/{cluster_id}/metrics

  • Scope: clusters:read

Bucketed request metrics. Without resolution, the server picks the smallest of 1m, 30m, 1h, 6h, 12h, 1d that gives fewer than 100 buckets (30 days gives 12h). At most 30 days and 1,000 buckets, and from no earlier than the start of the UTC day 30 days ago. A range out of bounds is a 400 naming from, and a resolution not offered or giving too many buckets is a 400 naming resolution.

Parameters

NameInTypeDescription
cluster_idpathstringRequired. The cluster's ID, which is its slug. It never changes.
fromquerystring (date-time)Start of the range, RFC 3339. Defaults to one hour before to.
toquerystring (date-time)End of the range, RFC 3339. Defaults to now.
resolutionquerystringBucket size, one of 1m, 30m, 1h, 6h, 12h, 1d.

Example request

curl "https://api.bonsai.io/v1/clusters/my-search-4823919/metrics?from=2026-10-26T00%3A00%3A00Z&to=2026-10-26T12%3A00%3A00Z&resolution=1h" \
  -H "Authorization: Bearer $BONSAI_TOKEN"

Response

200 OK. Metric buckets.

FieldTypeDescription
fromstring (date-time)Start of the range.
tostring (date-time)End of the range.
resolutionstringThe bucket size asked for, or the one the server picked.
bucketsarray of objectsOne per resolution, oldest first.
buckets[].atstring (date-time)When the bucket starts.
buckets[].requestsintegerRequests in the bucket.
buckets[].writesintegerWrite requests in the bucket.
buckets[].responsesobjectResponses by HTTP status.
buckets[].responses.status_2xx_3xxintegerResponses with a 2xx or 3xx status.
buckets[].responses.status_4xxintegerResponses with a 4xx status.
buckets[].responses.status_5xxintegerResponses with a 5xx status.
buckets[].duration_msobjectPercentiles for this bucket. null when there were no requests.
buckets[].duration_ms.p50number or nullMedian request duration.
buckets[].duration_ms.p95number or null95th percentile request duration.
buckets[].duration_ms.p99number or null99th percentile request duration.
buckets[].duration_histogramarray of objectsRequest counts by duration, always 17 buckets in this order. Each starts at its min_ms and ends where the next starts: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 1000 and 2000 (no upper bound).
buckets[].duration_histogram[].min_msintegerWhere the bucket starts, in milliseconds.
buckets[].duration_histogram[].countintegerRequests that took that long.
buckets[].bytes_sentintegerBytes the cluster sent to clients.
buckets[].bytes_receivedintegerBytes the cluster received from clients.
buckets[].queue_time_msnumberTime requests waited at Bonsai's load balancer, in milliseconds. Ideally 0. See Dashboard metrics.
buckets[].concurrencynumberRequests running at the same time. Queue time rises when this reaches the plan's limit.
{
  "from": "2026-10-26T00:00:00Z",
  "to": "2026-10-26T12:00:00Z",
  "resolution": "1h",
  "buckets": [
    {
      "at": "2026-10-26T00:00:00Z",
      "requests": 4210,
      "writes": 380,
      "responses": { "status_2xx_3xx": 4188, "status_4xx": 22, "status_5xx": 0 },
      "duration_ms": { "p50": 12.4, "p95": 48.1, "p99": 96.7 },
      "duration_histogram": [
        { "min_ms": 0, "count": 1210 },
        { "min_ms": 10, "count": 1530 },
        { "min_ms": 20, "count": 640 },
        { "min_ms": 30, "count": 310 },
        { "min_ms": 40, "count": 190 },
        { "min_ms": 50, "count": 120 },
        { "min_ms": 60, "count": 70 },
        { "min_ms": 70, "count": 45 },
        { "min_ms": 80, "count": 30 },
        { "min_ms": 90, "count": 20 },
        { "min_ms": 100, "count": 35 },
        { "min_ms": 200, "count": 7 },
        { "min_ms": 300, "count": 2 },
        { "min_ms": 400, "count": 1 },
        { "min_ms": 500, "count": 0 },
        { "min_ms": 1000, "count": 0 },
        { "min_ms": 2000, "count": 0 }
      ],
      "bytes_sent": 18432000,
      "bytes_received": 2048000,
      "queue_time_ms": 0.4,
      "concurrency": 1.2
    }
  ]
}

Errors

Show a cluster's top queries

GET /v1/clusters/{cluster_id}/queries

  • Scope: query_logs:read

The top 100 normalized search strings in a window, with volume and averages. These are the customer's end users' search terms, so the token needs query_logs:read.

Parameters

NameInTypeDescription
cluster_idpathstringRequired. The cluster's ID, which is its slug. It never changes.
windowquerystringOne of 1h, 1d, 7d, 14d, 30d. Defaults to 7d.

Example request

curl "https://api.bonsai.io/v1/clusters/my-search-4823919/queries?window=7d" \
  -H "Authorization: Bearer $BONSAI_TOKEN"

Response

200 OK. Top queries.

FieldTypeDescription
windowstringThe window asked for.
window_start_atstring (date-time)When the window starts.
window_end_atstring (date-time)When the window ends.
computed_atstring (date-time)When the list was computed.
queriesarray of objectsUp to 100 search strings, most frequent first.
queries[].querystringLowercased, quotes stripped.
queries[].volumeintegerHow many times it was searched.
queries[].avg_duration_msnumberAverage search duration, in milliseconds.
queries[].avg_hitsnumberAverage number of hits.
{
  "window": "7d",
  "window_start_at": "2026-10-19T14:00:00Z",
  "window_end_at": "2026-10-26T14:00:00Z",
  "computed_at": "2026-10-26T14:05:00Z",
  "queries": [
    {
      "query": "running shoes",
      "volume": 1840,
      "avg_duration_ms": 14.2,
      "avg_hits": 312
    },
    {
      "query": "rain jacket",
      "volume": 960,
      "avg_duration_ms": 11.8,
      "avg_hits": 87
    }
  ]
}

Errors

Ready to power your search with AI?

Launch a fully managed Elasticsearch or OpenSearch cluster, with built-in vector search and AI capabilities.

Create an AI Ready Search Cluster
Calming Bonsai waves