MetricConfiguration #

Configuration of a custom metric, given to the declaration methods of Metrics.

import {
  MetricConfiguration,
  GaugeConfiguration,
  HistogramConfiguration,
} from 'kuzzle-prometheus';

L is the union of the label names: TypeScript infers it from labelNames.

MetricConfiguration #

Used by counter(); the base of the two others.

PropertyTypeDescription
namestringsnake_case, without the instance prefix; a counter's name ends with _total (see Naming rules)
helpstringdescription shown by Prometheus and Grafana
labelNamesreadonly L[]optional, the labels each call must give; never project, environment or service

GaugeConfiguration #

Used by gauge(). MetricConfiguration, plus:

PropertyTypeDescription
collect(gauge: Gauge<L>) => void | Promise<void>optional, called at every scrape, before rendering, to set the gauge from a current state. If it throws, or does not settle within 5 seconds, the error is logged and the gauge keeps its previous values.

HistogramConfiguration #

Used by histogram(). MetricConfiguration, plus:

PropertyTypeDefaultDescription
bucketsnumber[][0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]upper bounds of the buckets, in the unit of the metric