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

# metricsServer

> Expose Prometheus metrics and the live-stats API from your pipe

Start a metrics server on the pipe process. Required by [Pipes UI](../../guides/basic-development/pipes-ui) and by anything that scrapes Prometheus (Grafana, Alertmanager, etc.).

```ts theme={"system"}
import { metricsServer } from "@subsquid/pipes/metrics/node";
import { solanaPortalStream } from "@subsquid/pipes/solana";

solanaPortalStream({
  // ...
  metrics: metricsServer({ port: 9090 }),
  // ...
});
```

**Parameters:**

* `port`: HTTP port for the server (default: `9090`).

## Endpoints

`metricsServer()` serves four HTTP endpoints on the configured port. They are all also useful for ad-hoc inspection with `curl`.

| Path        | Content                                                                                                                             |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `/stats`    | JSON — per-pipe progress, speed, portal query, SDK version. This is what [Pipes UI](../../guides/basic-development/pipes-ui) polls. |
| `/metrics`  | Prometheus text — built-in `sqd_*` series plus any custom metrics you registered. Scrape this from Prometheus.                      |
| `/profiler` | JSON — recent per-batch span trees. See [Profiling](../../guides/advanced-topics/profiling). Empty when profiling is disabled.      |
| `/health`   | Responds with `ok`.                                                                                                                 |

## Custom metrics

Register counters, gauges, histograms, and summaries via `ctx.metrics` in [whole-pipe transformers](../basic-components/transformer), [targets](../basic-components/target), or when consuming the pipe as an async iterator. See the [Metrics guide](../../guides/advanced-topics/metrics).

## See also

* [Pipes UI](../../guides/basic-development/pipes-ui) — visual dashboard that consumes `/stats` and `/profiler`.
* [Metrics](../../guides/advanced-topics/metrics) — walkthrough for exposing Prometheus metrics and adding custom series.
* [Profiling](../../guides/advanced-topics/profiling) — interpreting the `/profiler` span tree.
