Skip to content

Prometheus

The Mollitia Prometheus addon adds metrics on every circuit and module so that you can monitor and analyze your applications.

Quick Start

bash
# Install mollitia
npm install mollitia --save
# Install the prometheus addon
npm install @mollitia/prometheus --save
# Install mollitia
npm install mollitia --save
# Install the prometheus addon
npm install @mollitia/prometheus --save
typescript
// Then add the addon
import * as Mollitia from 'mollitia';
import * as MollitiaPrometheus from '@mollitia/prometheus';

Mollitia.use(new MollitiaPrometheus.PrometheusAddon());
// Then add the addon
import * as Mollitia from 'mollitia';
import * as MollitiaPrometheus from '@mollitia/prometheus';

Mollitia.use(new MollitiaPrometheus.PrometheusAddon());

Then, add Prometheus options when creating circuits or modules:

typescript
const myModule = new Mollitia.Timeout({
	prometheus: {
		name: 'my-module'
	}
});
const myCircuit = new Mollitia.Circuit({
  options: {
    prometheus: {
      name: 'my-circuit',
      labels: {
        tag2: 'val2',
        tag3: 'val3'
      }
    }
  }
});

// ...

const myCircuitMetrics = myCircuit.prometheus.metrics; // Will return an object containing all metrics from this circuit
const myCircuitScrap = myCircuit.prometheus.scrap(); // Will return the Prometheus scrap from this circuit
const myModule = new Mollitia.Timeout({
	prometheus: {
		name: 'my-module'
	}
});
const myCircuit = new Mollitia.Circuit({
  options: {
    prometheus: {
      name: 'my-circuit',
      labels: {
        tag2: 'val2',
        tag3: 'val3'
      }
    }
  }
});

// ...

const myCircuitMetrics = myCircuit.prometheus.metrics; // Will return an object containing all metrics from this circuit
const myCircuitScrap = myCircuit.prometheus.scrap(); // Will return the Prometheus scrap from this circuit

Finally, you can get Prometheus metrics or scrap like this:

typescript
const metrics = MollitiaPrometheus.metrics(); // Will return an object containing all metrics from all circuits and modules
const scrap = MollitiaPrometheus.scrap(); // Will return the Prometheus scrap
const metrics = MollitiaPrometheus.metrics(); // Will return an object containing all metrics from all circuits and modules
const scrap = MollitiaPrometheus.scrap(); // Will return the Prometheus scrap

API Reference

Circuit

NameDescriptionType
total_executionsThe amount of times the circuit has been used.Counter
total_successThe amount of times the circuit succeeded.Counter
total_failuresThe amount of times the circuit failed.Counter
duration_maxThe maximum duration of the circuit execution.Gauge
duration_aveThe average duration of the circuit execution.Gauge
duration_minThe minimum duration of the circuit execution.Gauge

Module

NameDescriptionType
total_executionsThe amount of times the module has been used.Counter
total_successThe amount of times the module succeeded.Counter
total_failuresThe amount of times the module failed.Counter
duration_maxThe maximum duration of the module execution.Gauge
duration_aveThe average duration of the module execution.Gauge
duration_minThe minimum duration of the module execution.Gauge

Timeout

NameDescriptionType
total_failures_timeoutThe amount of times an execution has timed out.Counter

Retry

NameDescriptionType
success_without_retriesThe amount of executions that succeed without retrying.Counter
success_with_retriesThe amount of executions that succeed after retrying.Counter
failures_without_retriesThe amount of executions that failed without retrying.Counter
failures_with_retriesThe amount of executions that failed after retrying.Gauge