# Prometheus

Send metrics from Prometheus, Grafana Alloy or any `remote_write` client, and
node-exporter data along with it.

## Endpoint

```
POST https://ingest.tailcove.dev/api/v1/prometheus/write
Authorization: Bearer <source token>
```

Tailcove reads remote-write **1.0** (snappy-compressed protobuf), which is what
Prometheus sends by default. Remote-write 2.0 is not supported yet and is
answered with `415`.

## Prometheus

```yaml
remote_write:
    - url: https://ingest.tailcove.dev/api/v1/prometheus/write
      authorization:
          credentials: YOUR_SOURCE_TOKEN
```

To collect a host's CPU, memory, disk and network, run
[node-exporter](https://github.com/prometheus/node_exporter) and scrape it:

```yaml
scrape_configs:
    - job_name: node
      static_configs:
          - targets: ['localhost:9100']
```

## How samples are stored

- The metric name is the `__name__` label, for example `node_load1`.
- The host is the `instance` label without its port.
- Every other label becomes a series label, at most 8 per series (see
  [Metrics](https://tailcove.dev/docs/metrics/overview#rules)); `job` is kept.
- Counters are stored as the running total Prometheus sent, not as a rate.
- NaN samples (including stale markers) are skipped.
- Native histograms and exemplars are ignored.

Each distinct name, host and label set is one series and counts toward your
[series limit](https://tailcove.dev/docs/metrics/overview#limits). Drop what you do not need with
`write_relabel_configs` to stay under it.

## Limits and responses

The points-per-minute and series limits are the same as for the metrics
endpoint, and a request holds at most 5,000 samples and 5 MB.

| Status | Meaning                                                                  |
| ------ | ------------------------------------------------------------------------ |
| `204`  | Accepted                                                                 |
| `401`  | Missing or invalid token                                                 |
| `413`  | Body too large (compressed or decompressed)                              |
| `415`  | Remote-write 2.0                                                         |
| `422`  | Not a valid remote-write body, or too many samples                       |
| `429`  | Over the points-per-minute limit; Prometheus retries after `Retry-After` |
| `503`  | Buffer full; Prometheus retries                                          |

Lower `queue_config.max_samples_per_send` below 5,000 if you see `422`.
