# Vector metrics

Collect host metrics with [Vector](https://vector.dev) and send them to Tailcove. You need a source's ingest token
([Getting started](https://tailcove.dev/docs/getting-started#3-copy-your-ingest-token)); metrics use the same token as logs.

## 1. Add the config

Add this to Vector's config file (`/etc/vector/vector.toml` on a package install; if yours is `vector.yaml`, the
same keys work in YAML), with your token in place of `YOUR_SOURCE_TOKEN`:

```toml
[sources.host]
type = "host_metrics"
scrape_interval_secs = 30

[sinks.tailcove_metrics]
type = "http"
inputs = ["host"]
uri = "https://ingest.tailcove.dev/api/v1/metrics"
method = "post"
encoding.codec = "json"
auth.strategy = "bearer"
auth.token = "YOUR_SOURCE_TOKEN"
batch.max_events = 500
```

With `encoding.codec = "json"` the `http` sink sends newline-delimited JSON, which the endpoint auto-detects, so no `framing` config is needed.

Counters such as network bytes arrive as running totals. Use the `max` or
`last` aggregate to chart them.

`host_metrics` emits per-core and per-disk series. Each distinct combination
counts toward your [series limit](https://tailcove.dev/docs/metrics/overview#limits) (100 on Free). To stay well under it, collect only
what you chart, for example `collectors = ["cpu", "memory", "filesystem", "network", "load"]` on the source.

## 2. Check it, then restart Vector

```sh
vector validate /etc/vector/vector.toml
sudo systemctl restart vector
```

## 3. See the points

Open the source's **Metrics** tab and pick a metric. The first points appear after one `scrape_interval_secs`.

## If nothing shows up

`journalctl -u vector -n 50` shows the sink's errors:

- **401**: the token is wrong or was rotated. Copy the current one from the source.
- **429**: the plan's points per minute or the monthly quota is reached; Vector retries. A longer
  `scrape_interval_secs` lowers the rate.
- **`over_series_limit` above 0** in a `202` answer: too many distinct series for the plan, so new ones are dropped.
  Narrow `collectors` as above.

Limits and every response code: [Metrics](https://tailcove.dev/docs/metrics/overview#limits).

## Logs from the same Vector

The same Vector can collect the host's log files too: add a `file` source and a second sink that points at the logs
endpoint. The [Vector log collection guide](https://tailcove.dev/guides/vector-server-logs) has the whole `vector.toml`.
