Options
All
  • Public
  • Public/Protected
  • All
Menu

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,
  }
})

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • Parameters

    • name: string

      Name used for the metric

    • Optional options: GaugeOptions

      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.

    Returns Gauge

Properties

Protected name

name: string

Name used for the metric

Protected options

options: MetricOptions

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.

Protected prometheusMetric

prometheusMetric: any

Protected statsdClient

statsdClient: any

Accessors

Protected statsdName

  • get statsdName(): string

Methods

dec

  • dec(value?: number, tags?: Tags): void
  • 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'})

    Parameters

    • Default value value: number = 1

      Value to decrement with; default 1

    • Optional tags: Tags

      Tags to attach to the increment; optional

    Returns void

inc

  • inc(value?: number, tags?: Tags): void
  • 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'})

    Parameters

    • Default value value: number = 1

      Value to increment with; default 1

    • Optional tags: Tags

      Tags to attach to the increment; optional

    Returns void

set

  • set(value: number, tags?: Tags): void
  • 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'})

    Parameters

    • value: number

      Value to set with

    • Optional tags: Tags

      Tags to attach to the increment; optional

    Returns void

startTimer

Legend

  • Property
  • Method
  • Constructor
  • Method
  • Inherited method
  • Protected property
  • Static method

Generated using TypeDoc