# at.happyproto.fleet.getTenantUsage

> 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.getTenantUsage)
- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.fleet.getTenantUsage/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.fleet.getTenantUsage/examples)

## Definitions

### `at.happyproto.fleet.getTenantUsage#gap`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `hour` | `string` (datetime) | Yes |  |
| `reason` | `string` | Yes |  |

### `at.happyproto.fleet.getTenantUsage`

**Type**: `query`

One tenant's metered usage by hour or day, with the hours that have no report. Proxied from the provisioner. Admin only.

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `from` | `string` (datetime) | No | Start of the range. Defaults to one day before `to` at hour grain, 30 days at day grain. |
| `grain` | `string` | No | Defaults to hour. Hour ranges may span 31 days, day ranges 400. |
| `tenant` | `string` | Yes | The instance id. |
| `to` | `string` (datetime) | No | End of the range. Defaults to now. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `gaps` | `array` | Yes |  |
| `grain` | `string` | Yes |  |
| `rows` | `array` | Yes |  |
| `tenant` | `string` | Yes |  |

#### Errors

- **AuthRequired**: This endpoint requires an authenticated caller.
- **Forbidden**: The caller is not HappyProto staff, or the provisioner does not treat them as staff.
- **InvalidRequest**: The provisioner refused the range or grain, for example a range that runs backwards or is too long.
- **NotFound**: Passed through from the provisioner.
- **InvalidSlug**: Passed through from the provisioner.
- **SlugTaken**: Passed through from the provisioner.
- **NotEntitled**: Passed through from the provisioner.
- **InstanceLimit**: Passed through from the provisioner.
- **NoCapacity**: Passed through from the provisioner.
- **OperationInProgress**: Passed through from the provisioner.
- **Upstream**: The provisioner could not complete the request.

### `at.happyproto.fleet.getTenantUsage#row`

**Type**: `object`

One hour or day of usage, summed across the tenant's hosts. `hour` is set at hour grain and `day` at day grain.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `apiClients` | `integer` | No |  |
| `cpuUsec` | `integer` | Yes |  |
| `day` | `string` | No | UTC date, YYYY-MM-DD. |
| `diskAvgBytes` | `integer` | No |  |
| `diskPeakBytes` | `integer` | No |  |
| `egressBytes` | `integer` | Yes |  |
| `hour` | `string` (datetime) | No |  |
| `ingressBytes` | `integer` | Yes |  |
| `memByteSeconds` | `integer` | Yes |  |
| `memPeakBytes` | `integer` | Yes |  |
| `partial` | `boolean` | Yes | Some samples for this period were missing. |
| `runningSeconds` | `integer` | Yes |  |
| `seats` | `integer` | No |  |

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "gap": {
      "properties": {
        "hour": {
          "format": "datetime",
          "type": "string"
        },
        "reason": {
          "knownValues": [
            "missing",
            "agent_unreachable"
          ],
          "type": "string"
        }
      },
      "required": [
        "hour",
        "reason"
      ],
      "type": "object"
    },
    "main": {
      "description": "One tenant's metered usage by hour or day, with the hours that have no report. Proxied from the provisioner. Admin only.",
      "errors": [
        {
          "description": "This endpoint requires an authenticated caller.",
          "name": "AuthRequired"
        },
        {
          "description": "The caller is not HappyProto staff, or the provisioner does not treat them as staff.",
          "name": "Forbidden"
        },
        {
          "description": "The provisioner refused the range or grain, for example a range that runs backwards or is too long.",
          "name": "InvalidRequest"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "NotFound"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "InvalidSlug"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "SlugTaken"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "NotEntitled"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "InstanceLimit"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "NoCapacity"
        },
        {
          "description": "Passed through from the provisioner.",
          "name": "OperationInProgress"
        },
        {
          "description": "The provisioner could not complete the request.",
          "name": "Upstream"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "gaps": {
              "items": {
                "ref": "#gap",
                "type": "ref"
              },
              "type": "array"
            },
            "grain": {
              "knownValues": [
                "hour",
                "day"
              ],
              "type": "string"
            },
            "rows": {
              "items": {
                "ref": "#row",
                "type": "ref"
              },
              "type": "array"
            },
            "tenant": {
              "type": "string"
            }
          },
          "required": [
            "tenant",
            "grain",
            "rows",
            "gaps"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "from": {
            "description": "Start of the range. Defaults to one day before `to` at hour grain, 30 days at day grain.",
            "format": "datetime",
            "type": "string"
          },
          "grain": {
            "description": "Defaults to hour. Hour ranges may span 31 days, day ranges 400.",
            "enum": [
              "hour",
              "day"
            ],
            "knownValues": [
              "hour",
              "day"
            ],
            "type": "string"
          },
          "tenant": {
            "description": "The instance id.",
            "type": "string"
          },
          "to": {
            "description": "End of the range. Defaults to now.",
            "format": "datetime",
            "type": "string"
          }
        },
        "required": [
          "tenant"
        ],
        "type": "params"
      },
      "type": "query"
    },
    "row": {
      "description": "One hour or day of usage, summed across the tenant's hosts. `hour` is set at hour grain and `day` at day grain.",
      "properties": {
        "apiClients": {
          "type": "integer"
        },
        "cpuUsec": {
          "type": "integer"
        },
        "day": {
          "description": "UTC date, YYYY-MM-DD.",
          "type": "string"
        },
        "diskAvgBytes": {
          "type": "integer"
        },
        "diskPeakBytes": {
          "type": "integer"
        },
        "egressBytes": {
          "type": "integer"
        },
        "hour": {
          "format": "datetime",
          "type": "string"
        },
        "ingressBytes": {
          "type": "integer"
        },
        "memByteSeconds": {
          "type": "integer"
        },
        "memPeakBytes": {
          "type": "integer"
        },
        "partial": {
          "description": "Some samples for this period were missing.",
          "type": "boolean"
        },
        "runningSeconds": {
          "type": "integer"
        },
        "seats": {
          "type": "integer"
        }
      },
      "required": [
        "runningSeconds",
        "cpuUsec",
        "memByteSeconds",
        "memPeakBytes",
        "egressBytes",
        "ingressBytes",
        "partial"
      ],
      "type": "object"
    }
  },
  "id": "at.happyproto.fleet.getTenantUsage",
  "lexicon": 1
}
```
