# at.happyproto.fleet.getCostShape

> Published by [happyproto.at](https://lexicon.garden/identity/did:plc:mo7vq4jbioxwafy5zkcc3eux)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.fleet.getCostShape)
- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.fleet.getCostShape/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.fleet.getCostShape/examples)

## Definitions

### `at.happyproto.fleet.getCostShape`

**Type**: `query`

Disk and memory distribution, and bytes per record. Memory is reported as separate anonymous and file-backed figures and is never totalled. Admin only.

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `bytesPerRecord` | `ref` → `#pair` | No |  |
| `diskBytes` | `ref` → `#pair` | No |  |
| `have` | `integer` | No |  |
| `instances` | `integer` | No |  |
| `memoryAnon` | `ref` → `#pair` | No | Anonymous memory. Never summed with memoryFile. |
| `memoryFile` | `ref` → `#pair` | No | File-backed memory, dominated by page cache. Its own figure: adding it to memoryAnon is how a healthy instance is diagnosed as leaking. |
| `need` | `integer` | No |  |
| `sources` | `ref` → `#sources` | No |  |
| `status` | `string` | Yes | Why a figure is absent. Branch on this, never on field presence. |
| `unit` | `string` | No |  |
| `windowDays` | `integer` | No |  |

#### Errors

- **AuthRequired**: This endpoint requires an authenticated caller.
- **Forbidden**: The caller is not a HappyProto admin.
- **Upstream**: The telemetry store could not be queried.

### `at.happyproto.fleet.getCostShape#pair`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `instances` | `integer` | Yes | Instances contributing to this figure. |
| `p50` | `integer` | Yes |  |
| `p90` | `integer` | Yes |  |

### `at.happyproto.fleet.getCostShape#sources`

**Type**: `object`

Which map each figure came from. These metrics live in `host` on the current fleet (db_bytes, memory_anon_bytes) but the collector's benchmark rollup reads `totals` (database_bytes, rss_anon). Reporting the source makes a disagreement visible rather than silently resolved; "none" means the key is absent from both, so a 0 is not a measurement.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `diskBytes` | `string` | No |  |
| `memoryAnon` | `string` | No |  |
| `memoryFile` | `string` | No |  |

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Disk and memory distribution, and bytes per record. Memory is reported as separate anonymous and file-backed figures and is never totalled. Admin only.",
      "errors": [
        {
          "description": "This endpoint requires an authenticated caller.",
          "name": "AuthRequired"
        },
        {
          "description": "The caller is not a HappyProto admin.",
          "name": "Forbidden"
        },
        {
          "description": "The telemetry store could not be queried.",
          "name": "Upstream"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "bytesPerRecord": {
              "ref": "#pair",
              "type": "ref"
            },
            "diskBytes": {
              "ref": "#pair",
              "type": "ref"
            },
            "have": {
              "type": "integer"
            },
            "instances": {
              "type": "integer"
            },
            "memoryAnon": {
              "description": "Anonymous memory. Never summed with memoryFile.",
              "ref": "#pair",
              "type": "ref"
            },
            "memoryFile": {
              "description": "File-backed memory, dominated by page cache. Its own figure: adding it to memoryAnon is how a healthy instance is diagnosed as leaking.",
              "ref": "#pair",
              "type": "ref"
            },
            "need": {
              "type": "integer"
            },
            "sources": {
              "ref": "#sources",
              "type": "ref"
            },
            "status": {
              "description": "Why a figure is absent. Branch on this, never on field presence.",
              "knownValues": [
                "ok",
                "accruing",
                "withheld"
              ],
              "type": "string"
            },
            "unit": {
              "knownValues": [
                "days",
                "snapshots"
              ],
              "type": "string"
            },
            "windowDays": {
              "type": "integer"
            }
          },
          "required": [
            "status"
          ],
          "type": "object"
        }
      },
      "type": "query"
    },
    "pair": {
      "properties": {
        "instances": {
          "description": "Instances contributing to this figure.",
          "type": "integer"
        },
        "p50": {
          "type": "integer"
        },
        "p90": {
          "type": "integer"
        }
      },
      "required": [
        "p50",
        "p90",
        "instances"
      ],
      "type": "object"
    },
    "sources": {
      "description": "Which map each figure came from. These metrics live in `host` on the current fleet (db_bytes, memory_anon_bytes) but the collector's benchmark rollup reads `totals` (database_bytes, rss_anon). Reporting the source makes a disagreement visible rather than silently resolved; \"none\" means the key is absent from both, so a 0 is not a measurement.",
      "properties": {
        "diskBytes": {
          "knownValues": [
            "host",
            "totals",
            "none"
          ],
          "type": "string"
        },
        "memoryAnon": {
          "knownValues": [
            "host",
            "totals",
            "none"
          ],
          "type": "string"
        },
        "memoryFile": {
          "knownValues": [
            "host",
            "totals",
            "none"
          ],
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "id": "at.happyproto.fleet.getCostShape",
  "lexicon": 1
}
```
