# 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

Latest version **4.0.0** (published 2023-02-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install fastify-metrics-js-prometheus
pnpm add fastify-metrics-js-prometheus
yarn add fastify-metrics-js-prometheus
bun add fastify-metrics-js-prometheus
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2023-02-14 |
| First published | 2020-01-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | digitalsadhu, trygve |

## Links

- npm: https://www.npmjs.com/package/fastify-metrics-js-prometheus
- Repository: https://github.com/finn-no/fastify-metrics-js-prometheus
- Homepage: https://github.com/finn-no/fastify-metrics-js-prometheus#readme
- Issues: https://github.com/finn-no/fastify-metrics-js-prometheus/issues
- npm.io page: https://npm.io/package/fastify-metrics-js-prometheus

## Dependencies (5)

- [abslog](https://npm.io/package/abslog.md) ^2.4.0
- [@metrics/guard](https://npm.io/package/@metrics/guard.md) ^1.0.1
- [fastify-plugin](https://npm.io/package/fastify-plugin.md) 4.5.0
- [@metrics/process](https://npm.io/package/@metrics/process.md) ^2.2.0
- [@metrics/prometheus-consumer](https://npm.io/package/@metrics/prometheus-consumer.md) ^3.0.0

## Recent versions

- 4.0.0 (latest) — 2023-02-14
- 3.0.0 — 2021-09-16
- 2.0.0 — 2020-08-20
- 1.0.1 — 2020-02-04
- 1.0.0 — 2020-01-21

## README

# 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

```js
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

```js
app.register(pluginMetrics, {
    client,
    pathname,
    logger,
    guard,
    consumer,
    metrics,
});
```

| name     | description                                                                                                                                    | type                    | default    | required |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | ---------- | -------- |
| client   | metrics client library. [prom-client](https://www.npmjs.com/package/prom-client) is currently supported.                                       | `object`                |            | `yes`    |
| pathname | url pathname to serve metrics scraping page on.                                                                                                | `string`                | `/metrics` |          |
| logger   | log4j compatible logger (usually [pino](https://www.npmjs.com/package/pino)) to use for logging.                                               | `object`                |            |          |
| guard    | options to be passed to the [@metrics/guard](https://www.npmjs.com/package/@metrics/guard) module (used internally.)                           | `object`                | `{}`       |          |
| consumer | options to be passed to the [@metrics/prometheus-consumer](https://www.npmjs.com/package/@metrics/prometheus-consumer) module used internally. | `object`                | `{}`       |          |
| metrics  | Stream or streams of metrics generated by [@metrics/client](https://www.npmjs.com/package/@metrics/client) to be consumed                      | `object[]` or `object`] | `[]`       |          |

---
_Source: https://npm.io/package/fastify-metrics-js-prometheus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
