A Fastify plugin for consuming @metrics/client (https://www.npmjs.com/package/@metrics/client) streams and rendering a prometheus scraping page
import fastify from 'fastify';
import plugin from 'fastify-metrics-js-prometheus';
import client from 'prom-client';
import Metrics from '@metrics/client';
const app = fastify();
const metrics = new Metrics();
app.register(plugin, { client, metrics });
By default, a metrics scraping page for prometheus will be served at /metrics
. This can be configured by setting the plugin option pathname
.
app.register(pluginMetrics, {
client,
pathname,
logger,
guard,
consumer,
metrics,
});
name | description | type | default | required |
---|---|---|---|---|
client | metrics client library. prom-client is currently supported. | object |
yes |
|
pathname | url pathname to serve metrics scraping page on. | string |
/metrics |
|
logger | log4j compatible logger (usually pino) to use for logging. | object |
||
guard | options to be passed to the @metrics/guard module (used internally.) | object |
{} |
|
consumer | options to be passed to the @metrics/prometheus-consumer module used internally. | object |
{} |
|
metrics | Stream or streams of metrics generated by @metrics/client to be consumed | object[] or object ] |
[] |