# `Ankusa.Metrics.Router`
[🔗](https://github.com/jamescarr/ankusa/blob/ankusa-v0.7.0/packages/ankusa/lib/ankusa/metrics/router.ex#L1)

The metrics listener (`metrics.enabled`, default port 4004): `GET /metrics`,
`GET /health` and `GET /ready`, and a `404` for everything else. A scraper or
a kubelet probe gets a route to those three and none to the operator API
(`Ankusa.Admin.Router`), which mutates sources, replays and the pen and so
belongs behind a different network rule than a Prometheus job.

The admin listener serves the same three routes through the same functions
(`metrics/1`, `health/1`, `ready/1`), so a scrape answers identically on
either port.

Like every listener it carries no authentication of its own: bind it to an
interface only the scraper reaches, or give it a `metrics.tls` block with
`verify: :verify_peer` so only a client holding a certificate from your CA
can connect (see `Ankusa.Listener`).

# `call`

# `health`

```elixir
@spec health(Plug.Conn.t()) :: Plug.Conn.t()
```

Answer `GET /health`: the instance, its version and its roles.

# `init`

# `metrics`

```elixir
@spec metrics(Plug.Conn.t()) :: Plug.Conn.t()
```

Answer `GET /metrics` with the Prometheus text exposition.

# `ready`

```elixir
@spec ready(Plug.Conn.t()) :: Plug.Conn.t()
```

Answer `GET /ready`: readiness, not liveness. `503` while this node's store
cannot take a synced write. See `Ankusa.Health`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
