createMetrics #

Creates the Metrics instance of a Node.js service. Call it once, at startup, and share the instance.

import { createMetrics } from 'kuzzle-prometheus';

In a Kuzzle application, use the instance owned by the plugin, prometheus.metrics, instead: the metrics of an instance created with createMetrics() are not exposed by Kuzzle.

Signature #

function createMetrics(options?: MetricsOptions): Metrics

Parameters #

Returns #

A Metrics instance. Node.js process metrics are collected from this point, unless defaultMetrics.enabled is false.

Throws #

When an option is invalid, for example a prefix that is not snake_case.

Example #

import { createMetrics } from 'kuzzle-prometheus';

export const metrics = createMetrics({
  service: 'ingestion-gateway',
  prefix: 'gateway_',
  defaultMetrics: { eventLoopMonitoringPrecision: 20 },
});