# Limits and fair use

These are the limits the Metrics API and its clients enforce. The API has no
request rate limit or storage quota today. It rejects a value over a limit with
an error that names the limit, and never truncates it. Metrics is free to use
under fair use; there are no paid plans, and for more than this page allows,
email [info@041.io](mailto:info@041.io).

## Requests

| what                                                                                     | limit                                                          |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| envelopes per request to `/api/v2/events` or `/api/v2/experiments/{experimentId}/events` | 1 to 1,000                                                     |
| envelopes per request to `/api/v2/query/series`                                          | exactly 1                                                      |
| `messageId`, `correlationId`                                                             | 1 to 200 characters                                            |
| `messageId` in one experiment batch                                                      | unique; a duplicate rejects the whole request with 400         |
| `tokenRevoke` in a batch                                                                 | must be the last event                                         |
| `query.experiments`, `query.revisions`                                                   | at most 500 `experimentIds`, and the only event in its request |

A batch is not a transaction: events run in order and each one succeeds or fails
on its own. See [HTTP API](https://metrics.041.io/docs/api.md).

## Experiments and folders

| what                       | limit                                                             |
| -------------------------- | ----------------------------------------------------------------- |
| experiment `slug`          | 1 to 200 characters, unique in the organization                   |
| experiment display name    | 1 to 200 characters after trimming; `null` clears it              |
| experiment `description`   | at most 4,000 characters                                          |
| experiment `meta`          | any JSON object                                                   |
| `experiment.error` message | 1 to 8,000 characters                                             |
| folder name                | 1 to 200 characters, not blank, no `/`, unique among its siblings |
| folder nesting             | at most 100 levels below a root folder                            |

## Saved views

| what       | limit                                                          |
| ---------- | -------------------------------------------------------------- |
| view name  | 1 to 200 characters after trimming, unique in the organization |
| view state | a JSON object of at most 65,536 UTF-8 bytes as compact JSON    |

A name another view already has is refused with `view_already_exists`. The app
and the command line write the [workspace state](https://metrics.041.io/docs/app.md#the-workspace-state);
the API stores any JSON object within the limit.

## Metrics

| what                                                | limit                                                                       |
| --------------------------------------------------- | --------------------------------------------------------------------------- |
| metric name                                         | printable ASCII, 1 to 256 bytes, and at most 512 bytes once percent-encoded |
| `metricValue`                                       | a finite number; NaN and infinity are rejected                              |
| `step`                                              | an integer from 0 to 2^53 − 2                                               |
| `timestampMs`                                       | an integer from 0 to 2^53 − 1                                               |
| metadata keys per point                             | at most 32                                                                  |
| metadata key                                        | at most 128 UTF-8 bytes                                                     |
| metadata value                                      | a string of at most 512 UTF-8 bytes                                         |
| metadata, as canonical JSON                         | at most 4,096 UTF-8 bytes                                                   |
| distinct metadata maps per metric in one experiment | 4,096                                                                       |

Every distinct metadata map is its own line on a chart. A write that would give
a metric a 4,097th map fails with a 409 event error; writes that use only
existing maps keep succeeding. Keep metadata to bounded categories such as
`split` or `rank`; see [What to log](https://metrics.041.io/docs/logging-guide.md).

When one metric's local write buffer reaches 2 GiB, it answers writes with a
retryable 503 until flushing to long-term storage frees space. See
[Series storage](https://metrics.041.io/docs/series-storage.md).

## Annotations

| what                | limit                                                   |
| ------------------- | ------------------------------------------------------- |
| annotation text     | 1 to 16,000 characters                                  |
| annotation metadata | at most 65,536 UTF-8 bytes of compact JSON              |
| `query.annotations` | returns at most 100,000 annotations, without pagination |

Store larger records as artifacts and put their paths or URLs in the metadata.

## Reading series

| what                                   | limit                                       |
| -------------------------------------- | ------------------------------------------- |
| `query.series`                         | one series per request                      |
| `query.experimentseries` `seriesNames` | at most 1,000; omit it to read every series |
| `filter` predicates                    | at most 32                                  |
| filter `metadataKey`                   | at most 128 UTF-8 bytes                     |
| filter `metadataValue`                 | at most 512 UTF-8 bytes                     |
| order                                  | ascending by `step` or `timestamp`          |

The API sets no cap on the points one read returns. The API has no slicing,
descending order or aggregation; see [API events](https://metrics.041.io/docs/api-events.md).

## Credentials

| what                           | limit                                                                      |
| ------------------------------ | -------------------------------------------------------------------------- |
| experiment token lifetime      | 24 hours from `experiment.open` or `experiment.tokenRefresh`               |
| old token after a refresh      | valid for at most 30 more seconds                                          |
| refreshing a token             | needs the organization key and a token that is neither expired nor revoked |
| a revoked organization API key | can keep working for up to 60 seconds                                      |

The collector refreshes its tokens five minutes before they expire, so a run
longer than a day keeps working. See [Organizations and keys](https://metrics.041.io/docs/organizations.md).

## The collector

These are the defaults of `syvain-metrics-collector`, not API limits, except
where the API sets the ceiling.

| setting                   | default | range or behavior                                                     |
| ------------------------- | ------- | --------------------------------------------------------------------- |
| `max_queue_items`         | 100,000 | at capacity the oldest queued event is evicted and counted as dropped |
| `max_batch_items`         | 500     | 1 to 1,000, the API's batch ceiling                                   |
| `flush_delay_seconds`     | 0.25    | how long a burst is coalesced                                         |
| `request_timeout_seconds` | 10.0    | per request                                                           |
| opening an experiment     |         | waits up to 120 seconds                                               |
| draining at process exit  |         | up to 30 seconds                                                      |

The collector checks metric and annotation limits when you call `metric()` or
`annotation()` and raises `ValueError` there, so an invalid event never reaches
the queue. It shortens an exception message to fit the 8,000-character error
limit. See [the collector](https://metrics.041.io/docs/collector.md).

## Charts from the command line

`syvain-metrics` renders PNG charts through a renderer with its own limits.

| what                | limit                              |
| ------------------- | ---------------------------------- |
| lines               | 1 to 32                            |
| x positions         | at most 10,000                     |
| lines × x positions | at most 50,000                     |
| width               | 320 to 2,400 px, default 1,200     |
| height              | 240 to 1,600 px, default 720       |
| subplots            | at least 76 px of height per panel |
| title               | at most 200 characters             |

See [Command line](https://metrics.041.io/docs/cli.md).

## Fair use and pricing

Metrics is free to use under fair use. There are no paid plans today.

If you need more than this page allows (higher limits, retention guarantees, an
on-prem or dedicated deployment, or anything Metrics does not do yet), email
[info@041.io](mailto:info@041.io).

---

Metrics by 041 documentation. Every page: https://metrics.041.io/llms.txt
