Documentation Index
Fetch the complete documentation index at: https://beta.docs.sqd.dev/llms.txt
Use this file to discover all available pages before exploring further.
Pipes SDK can expose a Prometheus-compatible metrics server. You can customize it to add counters, gauges, histograms, and summaries.
import { commonAbis, evmDecoder, evmPortalStream } from "@subsquid/pipes/evm";
import { metricsServer } from "@subsquid/pipes/metrics/node";
async function main() {
const stream = evmPortalStream({
id: 'evm-decoder',
portal: 'https://portal.sqd.dev/datasets/ethereum-mainnet',
outputs: evmDecoder({
range: {
from: 'latest',
},
events: {
transfers: commonAbis.erc20.events.Transfer,
},
}),
metrics: metricsServer({
port: 9090
}), // equivalent to metricsServer(), as 9090 is the default port
})
for await (const { data, ctx } of stream) {
// Add custom counter metric
ctx.metrics
.counter({
name: "my_transfers_counter",
help: "Number of processed transactions",
})
.inc(data.transfers.length);
}
}
void main()
Access metrics at http://localhost:9090/metrics to verify they’re being exposed correctly.# HELP my_transfers_counter Number of processed transactions
# TYPE my_transfers_counter counter
my_transfers_counter 218598
Use Grafana dashboards to visualize block processing rate, error rates, and latency trends from your Prometheus metrics.
Available metric types
You can create different types of Prometheus metrics:
for await (const { data, ctx } of stream) {
// Counter - monotonically increasing value
ctx.metrics.counter({ name: "events_total", help: "Total events" }).inc();
// Gauge - value that can go up or down
ctx.metrics
.gauge({ name: "queue_size", help: "Current queue size" })
.set(queueSize);
// Histogram - observations with configurable buckets
ctx.metrics
.histogram({ name: "batch_size", help: "Batch size distribution" })
.observe(data.transfers.length);
}
Expose metrics with metricsServer() on your source, then visualize them with Pipes UI.
See the Profiling guide for the built-in per-batch profiler exposed on the same metrics endpoint.