> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usechamber.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Metrics

> Query GPU utilization, memory, temperature, and power metrics

## Get Workload Metrics

Retrieve GPU metrics for a specific workload.

```bash theme={null}
GET /v1/workloads/{workload_id}/metrics
```

### Path Parameters

| Parameter     | Type   | Description                    |
| ------------- | ------ | ------------------------------ |
| `workload_id` | string | The unique workload identifier |

### Query Parameters

| Parameter    | Type   | Description                                                                       |
| ------------ | ------ | --------------------------------------------------------------------------------- |
| `time_range` | string | Time range: `last_1h`, `last_6h`, `last_24h`, `job_lifetime` (default: `last_1h`) |
| `metrics`    | string | Comma-separated list of metrics to include                                        |

### Available Metrics

| Metric               | Description                        |
| -------------------- | ---------------------------------- |
| `gpu_utilization`    | GPU compute utilization percentage |
| `memory_utilization` | GPU memory utilization percentage  |
| `temperature`        | GPU temperature in Celsius         |
| `power_usage`        | Power consumption in Watts         |
| `gpu_usage`          | Overall GPU usage metric           |

### Example Request

```bash theme={null}
curl -X GET "https://api.usechamber.io/v1/workloads/wl_abc123/metrics?time_range=last_6h&metrics=gpu_utilization,memory_utilization" \
  -H "Authorization: Bearer <token>" \
  -H "X-Organization-Id: <org-id>"
```

### Example Response

```json theme={null}
{
  "data": {
    "workload_id": "wl_abc123",
    "time_range": "last_6h",
    "metrics": {
      "gpu_utilization": {
        "avg": 85.2,
        "min": 45.0,
        "max": 99.8,
        "current": 92.1
      },
      "memory_utilization": {
        "avg": 78.5,
        "min": 60.2,
        "max": 89.4,
        "current": 82.0
      }
    }
  },
  "request_id": "req_abc123"
}
```

***

## Get Ranked Workload Metrics

Retrieve metrics across workloads, ranked by utilization or consumption.

```bash theme={null}
GET /v1/workloads/metrics
```

### Query Parameters

| Parameter       | Type    | Description                                                                      |
| --------------- | ------- | -------------------------------------------------------------------------------- |
| `sort_by`       | string  | Sort metric: `gpu_utilization`, `memory_utilization`, `power_usage`, `gpu_hours` |
| `order`         | string  | Sort order: `asc`, `desc` (default: `desc`)                                      |
| `limit`         | integer | Number of results (1-100, default: 10)                                           |
| `initiative_id` | string  | Filter to specific team                                                          |
| `status`        | string  | Filter by workload status                                                        |

### Example Request

```bash theme={null}
curl -X GET "https://api.usechamber.io/v1/workloads/metrics?sort_by=gpu_utilization&order=desc&limit=5" \
  -H "Authorization: Bearer <token>" \
  -H "X-Organization-Id: <org-id>"
```

### Example Response

```json theme={null}
{
  "data": {
    "workloads": [
      {
        "workload_id": "wl_abc123",
        "name": "training-large-model",
        "gpu_utilization": {
          "avg": 95.2,
          "current": 97.1
        },
        "initiative_id": "init_ml_team"
      },
      {
        "workload_id": "wl_def456",
        "name": "inference-batch",
        "gpu_utilization": {
          "avg": 88.7,
          "current": 91.0
        },
        "initiative_id": "init_research"
      }
    ],
    "scope_average": {
      "gpu_utilization": 72.5
    }
  },
  "metadata": {
    "total_count": 45
  },
  "request_id": "req_abc123"
}
```
