Prometheus.ex v3.0.5 Prometheus.Metric.Boolean View Source

Boolean metric, to report booleans and flags.

Boolean is a non-standard metric that uses untyped metric underneath.

A Boolean is typically used as a flag i.e. enabled/disabled, online/offline.

Example:

-module(my_fuse_instrumenter).

-export([setup/0,
         fuse_event/2]).

 setup() ->
   prometheus_boolean:declare([{name, app_fuse_state},
                               {labels, [name]}, %% fuse name
                               {help, "State of various app fuses."}]),

 fuse_event(Fuse, Event) ->
   case Event of
     ok -> prometheus_boolean:set(app_fuse_state, [Fuse], true);
     blown -> prometheus_boolean:set(app_fuse_state, [Fuse], false);
     _ -> ok
   end.

Link to this section Summary

Functions

Creates a boolean using spec. If a boolean with the same spec exists returns false

Creates a boolean using spec

Removes boolean series identified by spec

Resets the value of the boolean identified by spec

Sets the boolean identified by spec to value

Toggles the boolean identified by spec to value

Returns the value of the boolean identified by spec. If there is no boolean for given labels combination, returns :undefined

Link to this section Functions

Creates a boolean using spec. If a boolean with the same spec exists returns false.

Raises Prometheus.MissingMetricSpecKeyError if required spec key is missing.
Raises Prometheus.InvalidMetricNameError if metric name is invalid.
Raises Prometheus.InvalidMetricHelpError if help is invalid.
Raises Prometheus.InvalidMetricLabelsError if labels isn't a list.
Raises Prometheus.InvalidLabelNameError if label name is invalid.

Creates a boolean using spec.

Raises Prometheus.MissingMetricSpecKeyError if required spec key is missing.
Raises Prometheus.InvalidMetricNameError if metric name is invalid.
Raises Prometheus.InvalidMetricHelpError if help is invalid.
Raises Prometheus.InvalidMetricLabelsError if labels isn't a list.
Raises Prometheus.InvalidLabelNameError if label name is invalid.
Raises Prometheus.MFAlreadyExistsError if a boolean with the same spec already exists.

Removes boolean series identified by spec.

Raises Prometheus.UnknownMetricError exception if a boolean for spec can't be found.
Raises Prometheus.InvalidMetricArityError exception if labels count mismatch.

Resets the value of the boolean identified by spec.

Raises Prometheus.UnknownMetricError exception if a boolean for spec can't be found.
Raises Prometheus.InvalidMetricArityError exception if labels count mismatch.

Sets the boolean identified by spec to value.

Valid "truthy" values:

  • true;
  • false;
  • 0 -> false;
  • number > 0 -> true;
  • [] -> false
  • non-empty list -> true;
  • :undefined -> undefined

Other values will generate Prometheus.InvalidValueError error.

Raises Prometheus.InvalidValueError exception if value isn't a boolean or :undefined.
Raises Prometheus.UnknownMetricError exception if a boolean for spec can't be found.
Raises Prometheus.InvalidMetricArityError exception if labels count mismatch.

Toggles the boolean identified by spec to value.

Raises Prometheus.InvalidValueError exception if boolean is :undefined.
Raises Prometheus.UnknownMetricError exception if a boolean for spec can't be found.
Raises Prometheus.InvalidMetricArityError exception if labels count mismatch.

Returns the value of the boolean identified by spec. If there is no boolean for given labels combination, returns :undefined.

Raises Prometheus.UnknownMetricError exception if a boolean for spec can't be found.
Raises Prometheus.InvalidMetricArityError exception if labels count mismatch.