4.0.0 • Published 1 year ago

fastify-metrics-js-prometheus v4.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
1 year ago

Fastify Metrics-js Prometheus

A Fastify plugin for consuming @metrics/client (https://www.npmjs.com/package/@metrics/client) streams and rendering a prometheus scraping page

Usage

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.

Plugin options

app.register(pluginMetrics, {
    client,
    pathname,
    logger,
    guard,
    consumer,
    metrics,
});
namedescriptiontypedefaultrequired
clientmetrics client library. prom-client is currently supported.objectyes
pathnameurl pathname to serve metrics scraping page on.string/metrics
loggerlog4j compatible logger (usually pino) to use for logging.object
guardoptions to be passed to the @metrics/guard module (used internally.)object{}
consumeroptions to be passed to the @metrics/prometheus-consumer module used internally.object{}
metricsStream or streams of metrics generated by @metrics/client to be consumedobject[] or object][]