> ## 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.

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 130+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# metricsServer

> Expose Prometheus metrics and live stats from an EVM Pipes SDK pipeline.

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 { evmPortalStream } from "@subsquid/pipes/evm";

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

**Parameters:**

* `port`: HTTP port for the server (default: `9090`).
* `enabled`: Set to `false` to disable the server without removing it from the config (optional).
* `logger`: A pino-compatible `Logger` instance for the server's own log output (optional).

## Endpoints

`metricsServer()` serves five 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.                                                                           |
| `/preview/transformation` | JSON: a data preview (truncated sample) from the latest batch's transformation plus batch stats (block range, block count, byte size). Rendered by [Pipes UI](../../guides/basic-development/pipes-ui). |
| `/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.


## Related topics

- [metricsServer](/en/sdk/pipes-sdk/solana/reference/utility-components/metrics-server.md)
- [Metrics](/en/sdk/pipes-sdk/evm/guides/advanced-topics/metrics.md)
- [Pipes UI](/en/sdk/pipes-sdk/solana/guides/basic-development/pipes-ui.md)
- [Profiling](/en/sdk/pipes-sdk/evm/guides/advanced-topics/profiling.md)
- [Dev runner](/en/sdk/pipes-sdk/solana/guides/basic-development/dev-runner.md)
