# at.happyproto.server.getUsage

> One of the caller's instances' metered usage by hour or day, with the hours that have no report. Customers only.

- Kind: query
- Authority: server.happyproto.at
- Lexicon: 1
- Published by [happyproto.at](https://lexicon.garden/identity/did:plc:mo7vq4jbioxwafy5zkcc3eux), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.server.getUsage)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.server.getUsage/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:mo7vq4jbioxwafy5zkcc3eux/at.happyproto.server.getUsage/analytics)

## Query (`at.happyproto.server.getUsage`)

Type: query · GET

### Parameters (query string)

- `from` (string · datetime): Start of the range. Defaults to one day before `to` at hour grain, 30 days at day grain.
- `grain` (string): Defaults to hour. Hour ranges may span 31 days, day ranges 400.
  - Constraints: knownValues: hour | day, enum: hour | day
- `id` (string, required): The instance's UUID.
- `to` (string · datetime): End of the range. Defaults to now.

### Output (application/json)

- `gaps` (array, required)
  - `items` (ref)
    - Reference: `#gap`
- `grain` (string, required)
  - Constraints: knownValues: hour | day
- `rows` (array, required)
  - `items` (ref)
    - Reference: `#row`
- `tenant` (string, required)

### Errors

- `AuthRequired`: This endpoint requires an authenticated caller.
- `Forbidden`: The caller is not a HappyProto customer, or the provisioner refused them.
- `InvalidRequest`: id is not a UUID, or the range is backwards, too long, or has an unknown grain.
- `NotFound`: No such instance, or it is not the caller's. The two are indistinguishable.
- `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.

## #gap (`at.happyproto.server.getUsage#gap`)

Type: object

### Properties

- `hour` (string · datetime, required)
- `reason` (string, required)
  - Constraints: knownValues: missing | agent_unreachable

## #row (`at.happyproto.server.getUsage#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.

### Properties

- `apiClients` (integer)
- `cpuUsec` (integer, required)
- `day` (string): UTC date, YYYY-MM-DD.
- `diskAvgBytes` (integer)
- `diskPeakBytes` (integer)
- `egressBytes` (integer, required)
- `hour` (string · datetime)
- `ingressBytes` (integer, required)
- `memByteSeconds` (integer, required)
- `memPeakBytes` (integer, required)
- `partial` (boolean, required): Some samples for this period were missing.
- `runningSeconds` (integer, required)
- `seats` (integer)

## 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 of the caller's instances' metered usage by hour or day, with the hours that have no report. Customers only.",
      "errors": [
        {
          "description": "This endpoint requires an authenticated caller.",
          "name": "AuthRequired"
        },
        {
          "description": "The caller is not a HappyProto customer, or the provisioner refused them.",
          "name": "Forbidden"
        },
        {
          "description": "id is not a UUID, or the range is backwards, too long, or has an unknown grain.",
          "name": "InvalidRequest"
        },
        {
          "description": "No such instance, or it is not the caller's. The two are indistinguishable.",
          "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"
          },
          "id": {
            "description": "The instance's UUID.",
            "type": "string"
          },
          "to": {
            "description": "End of the range. Defaults to now.",
            "format": "datetime",
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "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.server.getUsage",
  "lexicon": 1
}
```
