---
title: Observability API
description: >-
  The Observability API gives your code the telemetry behind your fleets and
  clusters: metrics, logs, and your Managed Kubernetes clusters' Kubernetes
  audit trail. Results are always scoped to your organization. You never pass an
  organization ID, and a cluster outside your organization is refused.
canonical: 'https://lightning.ai/docs/platform/cluster/observability/overview'
---
# Observability API {#observability-api}

The Observability API gives your code the telemetry behind your fleets and clusters: metrics, logs, and your Managed Kubernetes clusters' Kubernetes audit trail. Results are always scoped to your organization. You never pass an organization ID, and a cluster outside your organization is refused.

## What you can do {#what-you-can-do}

| Capability | How | Guide |
|------------|-----|-------|
| Query metrics for one cluster or your whole organization: GPUs, nodes, Kubernetes workloads, storage, and hardware | PromQL, instant or over a time range | [Metrics](/docs/platform/cluster/observability/metrics.md) |
| Follow metrics live as they change | Python SDK `watch` | [Streaming metrics](/docs/platform/cluster/observability/metrics.md#stream-metrics-live) |
| Search a cluster's logs | LogsQL over a time range | [Logs](/docs/platform/cluster/observability/logs.md) |
| Follow a cluster's logs live | Python SDK `tail` | [Tailing logs](/docs/platform/cluster/observability/logs.md#tail-logs-live) |
| Answer "who did what to this cluster, and when?" for up to 365 days | Asynchronous queries over the Kubernetes audit log | [Kubernetes audit](/docs/platform/cluster/observability/kubernetes-audit.md) |
| List your clusters, the endpoint that serves each, and whether its metrics and logs are ready | `GET /v1/clusters` | [Find your clusters](#find-your-clusters) |

Queries are standard [PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/) and LogsQL, sent as you write them, and metrics results use the Prometheus result format. Existing tools and queries carry over.

## Access {#access}

The Observability API is used with an [Application Principal](/docs/platform/cluster/access/authentication.md#principals): the same client ID and secret you use for the rest of the API. Each capability is a separate permission:

| Permission | Allows |
|------------|--------|
| Metrics read | Metrics queries and `watch` |
| Logs read | Log queries and `tail` |
| Kubernetes audit read | Kubernetes audit queries. Metrics and logs permissions never include it. |

Lightning AI sets these when the Application Principal is provisioned. [Contact support](/docs/platform/cluster/support.md) to enable the Observability API for your organization or to change an Application Principal's permissions. A request without the permission it needs returns `403 Forbidden`.

## Endpoint and tokens {#endpoint-and-tokens}

| | |
|-|-|
| **Endpoint** | `https://observatory.voltagepark.com` |
| **Token** | An access token for the audience `https://observatory.voltagepark.com`. Tokens for the regional API endpoints don't work here, and tokens for this endpoint don't work on the regional API. |
| **API reference** | [`https://observatory.voltagepark.com/openapi.json`](https://observatory.voltagepark.com/openapi.json) (OpenAPI 3) |

**Python SDK**

The [Python SDK](/docs/platform/cluster/get-started/python-sdk.md) gets and refreshes the Observability API token itself, from the same `VPCLOUD_CLIENT_ID` and `VPCLOUD_CLIENT_SECRET` it uses for the rest of the API. There's nothing more to configure.

```python
import vpcloud_client

configuration = vpcloud_client.Configuration()  # reads VPCLOUD_CLIENT_ID / VPCLOUD_CLIENT_SECRET
```

**REST API**

The examples in this section use `$OBS_URL` and `$OBS_TOKEN`. To get a token from your Application Principal's credentials, use the Python SDK:

```bash
export OBS_URL=https://observatory.voltagepark.com
export OBS_TOKEN=$(python3 -c 'import vpcloud_client; print(vpcloud_client.Configuration().auth_settings(service="observatory")["bearerAuth"]["value"].split()[1])')
```

Tokens are short-lived. Get a new one when a call returns `401 Unauthorized`.

## Find your clusters {#find-your-clusters}

Lists your organization's Managed Kubernetes clusters, the endpoint that serves each one's telemetry, and whether its metrics and logs can be queried yet. A cluster that was just created can take a few minutes to become ready.

**Python SDK**

```python
with vpcloud_client.ApiClient(configuration) as api_client:
    for cluster in vpcloud_client.ClustersApi(api_client).resolve_clusters().clusters or []:
        print(cluster.cluster_id, cluster.site, cluster.endpoint, cluster.metrics_ready, cluster.logs_ready)
```

**REST API**

```bash
curl "$OBS_URL/v1/clusters" -H "Authorization: Bearer $OBS_TOKEN"
```

```json
{
  "clusters": [
    {
      "clusterId": "3f2c9a10-5b7e-4d1a-9c2e-8a6f1b0d4e21",
      "site": "sea1",
      "endpoint": "https://sea1.observatory.voltagepark.com",
      "metricsReady": true,
      "logsReady": true
    }
  ]
}
```

- Send a cluster's queries to its `endpoint`. In the SDK, set `Configuration(observatory_host=cluster.endpoint)`.
- A cluster query sent to another region's endpoint returns `400 Bad Request` with the reason `misdirected`, and the right endpoint in the `X-Observatory-Home-Endpoint` response header. Retry there.
- `metricsReady: false` or `logsReady: false` means monitoring isn't set up for that cluster yet. [Contact support](/docs/platform/cluster/support.md) to enable it.

## Errors {#errors}

Errors are a JSON body with a numeric `code`, a `message`, and `details`:

```json
{"code": 7, "message": "missing audit read scope", "details": []}
```

In the Python SDK, they raise `vpcloud_client.rest.ApiException` with `status` and this `body`. Streaming errors raise `vpcloud_client.streaming.ConnectError`, whose `code` is the name in the table, for example `permission_denied`.

| Status | `code` | Meaning | What to do |
|--------|--------|---------|------------|
| `400 Bad Request` | `3` (`invalid_argument`) | The query, time range, or step is invalid. `message` says why. | Fix the request. |
| `400 Bad Request` | `9` (`failed_precondition`) | The cluster is served by another endpoint (`misdirected`), or a Kubernetes audit precondition isn't met. | Retry at the endpoint in `X-Observatory-Home-Endpoint`, or see [Kubernetes audit](/docs/platform/cluster/observability/kubernetes-audit.md#errors-and-limits). |
| `401 Unauthorized` | `16` (`unauthenticated`) | The token is missing, expired, or for another audience. | Get a new token for `https://observatory.voltagepark.com`. |
| `403 Forbidden` | `7` (`permission_denied`) | The Application Principal lacks the permission, or the cluster isn't in your organization. | Check the cluster ID with [`/v1/clusters`](#find-your-clusters), or [contact support](/docs/platform/cluster/support.md) about permissions. |
| `429 Too Many Requests` | `8` (`resource_exhausted`) | Your organization's query limit was reached. | Retry with backoff, after `Retry-After` seconds when it's set. |
| `501 Not Implemented` | `12` (`unimplemented`) | The capability isn't available on this endpoint yet, for example organization-wide metrics or Kubernetes audit in some regions. | [Contact support](/docs/platform/cluster/support.md). |
| `503 Service Unavailable` | `14` (`unavailable`) | Temporarily unavailable. | Retry with backoff. |

---

**Navigation**

- Parent: [Observability](/docs/platform/cluster/observability.md)
