---
title: "List live non-idle backends"
method: GET
path: "/instances/{id}/running-statements"
tags: ["Query Insights"]
---

# List live non-idle backends

`GET /instances/{id}/running-statements`

## Request

- Base URL: `https://api.cloudpepper.io`
- URL: `https://api.cloudpepper.io/instances/{id}/running-statements`
- Auth: HTTP bearer

Real-time snapshot of the non-idle backends on the instance database, from pg_stat_activity (core view; needs no pg_stat_statements). Complements slow-queries (historical/aggregate): for live incidents — lock chains (`blocked_by`/`is_blocked` via pg_blocking_pids), long-open transactions, idle-in-transaction holders (where `query` is the last statement, not a running one), and connection saturation (`connection_summary`). Rows are tenant-scoped by datname; plain-idle pooled connections are counted in the summary but omitted from the list; parallel workers fold into their leader. Query text is redacted of literals. Read-only (READ ONLY transaction as the least-privilege cloudpepper_insights role, statement/lock timeouts); diagnostic only — it does not cancel/terminate. Out-of-range `min_duration_ms`/`limit` are clamped. Hosts without query insights enabled return HTTP 409 with a machine-readable `reason`.

**Key Parameters:**
- `id`: The instance whose database to inspect
- `min_duration_ms`: Floor on how long a backend has been running/stuck
- `limit`: How many to return (longest first)

## Response `200`

Running statements retrieved successfully

- object

## Other responses

- `404`: Instance not found
- `409`: Running statements could not be inspected — body `reason` says which: `query_insights_not_enabled`, `instance_database_not_found`, `external_database_not_supported`, or `running_statements_failed`

---

[API](https://skmtc.dev/cloudpepper/apis/cloudpepper-api-docs.md) · [All operations](https://skmtc.dev/cloudpepper/apis/cloudpepper-api-docs/llms.txt) · [OpenAPI document](https://skmtc.dev/cloudpepper/apis/cloudpepper-api-docs/revisions/b6a59274cedc?raw)
