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

# Metrics

> Metrics expose account, basin, and stream usage through scoped metric sets, query parameters, and response types.

S2 exposes metrics about account, basin, and stream resources.

The metrics API powers visualizations within the [dashboard](https://s2.dev/dashboard/metrics), but is also accessible from the CLI, SDKs, and REST API for custom uses.

<Note>
  The metrics API *may* show the result of duplicate counts or other slight discrepancies due to our use of materialized views for efficiency. Metrics computed for billing, on the other hand, do not use such views and should always be accurate ([reach out to us](mailto:hi@s2.dev) if you have any questions about something you are seeing).
</Note>

## Metric sets

Metric sets are groupings of metrics evaluated either at the account, basin, or stream level. For example, the account-level [`active-basins`](/api/metrics/account#active-basins) metric set can be obtained with:

```bash theme={null}
curl \
  --request GET \
  --url "https://aws.s2.dev/v1/metrics?set=active-basins&start=${START}&end=${END}" \
  --header "Authorization: Bearer ${S2_ACCESS_TOKEN}"
```

#### Common parameters

* `set` specifies the requested metric set
* `start` and `end` timestamps, in [Unix epoch](https://en.wikipedia.org/wiki/Unix_time) seconds
  * The time period specified should not exceed 30 days
  * The `end` timestamp should not be in the future (though some leeway is given to accommodate clock differences)
* `interval` represents a duration for use by metric sets that return timeseries
  * for [`accumulation`](#accumulation), this specifies the requested bucket length, or the window of time which the relevant value is an aggregation over
  * for [`gauge`](#gauge), this specifies the unit to divide the `start`/`end` period into, and the timeseries will reflect a momentary reading at each of these divisions of time

## Metric types

### `scalar`

Represents a single numeric value. Can represent a summary, or aggregation, if the metric set requires a `start` and `end` period, or an instantaneous value if not.

### `accumulation`

Timeseries where each `(epoch, value)` tuple represents an aggregation `value` for a bucket of time beginning at the `epoch`, lasting for the specified `bucket_length`.

Buckets within the time period which have no data will be omitted (unlike with `GaugeTimeseries`).

### `gauge`

Timeseries where each `(epoch, value)` tuple represents a momentary reading of a value, at the specified `epoch` instance.

Gauge timeseries will contain entries for every interval within the requested time period.

### `label`

A set of string labels representing a set. It can represent a summary or aggregation if the metric set requires a `start` and `end` period, or an instantaneous set if not.

## Available metrics

<CardGroup cols={3}>
  <Card title="Account metrics" href="/api/metrics/account" icon="user">
    Track active basins and account operations.
  </Card>

  <Card title="Basin metrics" href="/api/metrics/basin" icon="bucket">
    Track active streams, storage, operations, and throughput.
  </Card>

  <Card title="Stream metrics" href="/api/metrics/stream" icon="water">
    Track stored bytes for one stream.
  </Card>
</CardGroup>
