Name used for the metric
Options for the metric
Depending on the metric technology used. Even though the MetricOptions
support almost all options for each supported technology, be careful how you use and setup your
options since they may generated strange behaviors that were not intended with this API.
Name used for the metric
Options for the metric
Depending on the metric technology used. Even though the MetricOptions
support almost all options for each supported technology, be careful how you use and setup your
options since they may generated strange behaviors that were not intended with this API.
Decrement method.
import { Gauge } from '@mists/nestjs-metrics';
const gauge = new Gauge('metric_gauge');
// will decrement by 1 (the default value)
gauge.dec();
// will decrement by 10 (custom value)
gauge.dec(10);
// will decrement by 1, attaching also a `server_id` label
gauge.dec(1, {server_id: 'instance_1'})
Value to decrement with; default 1
Tags to attach to the increment; optional
Increment method.
import { Gauge } from '@mists/nestjs-metrics';
const gauge = new Gauge('metric_gauge');
// will increment by 1 (the default value)
gauge.inc();
// will increment by 10 (custom value)
gauge.inc(10);
// will increment by 1, attaching also a `server_id` label
gauge.inc(1, {server_id: 'instance_1'})
Value to increment with; default 1
Tags to attach to the increment; optional
Set method.
import { Gauge } from '@mists/nestjs-metrics';
const gauge = new Gauge('metric_gauge');
// will set gauge value to 0 (the default value)
gauge.set(0);
// will set gauge value to 10 (custom value)
gauge.set(10);
// will set gauge value to 1, attaching also a `server_id` label
gauge.set(1, {server_id: 'instance_1'})
Value to set with
Tags to attach to the increment; optional
Time method.
See Timer.startTimer for usage.
Generated using TypeDoc
Gauge Metric
Gauges are similar to Gauges. Only difference is that they can be decreased or reset at demand. One more feature for gauges, is the timer metric which can record duration of events.
import { Gauge } from '@mists/nestjs-metrics'; const gauge = new Gauge('metric_gauge'); // force prometheus settings const gauge = new Gauge('metric_gauge', { prometheus: { help: 'This is a gauge metric' } }) // force statsd settings; if no settings are provided here, // default settings will be used const gauge = new Gauge('metric_gauge', { statsd: { host: 'localhost', socketTimeout: 2000, } })