View Source prometheus_boolean (prometheus v4.13.0)
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.
Summary
Functions
Creates a boolean using Spec.
Equivalent to deregister(default, Name).
Removes all boolean series with name Name and removes Metric Family from Registry.
Creates a boolean using Spec.
Equivalent to remove(default, Name, []).
Equivalent to remove(default, Name, LabelValues).
Removes boolean series identified by Registry, Name and LabelValues.
Equivalent to reset(default, Name, []).
Equivalent to reset(default, Name, LabelValues).
Resets the value of the boolean identified by Registry, Name and LabelValues.
Equivalent to set(default, Name, [], Value).
Sets the boolean identified by Registry, Name and LabelValues to Value.
Equivalent to toggle(default, Name, []).
Equivalent to toggle(default, Name, LabelValues).
Toggles the boolean identified by Registry, Name and LabelValues.
Equivalent to value(default, Name, []).
Equivalent to value(default, Name, LabelValues).
Returns the value of the boolean identified by Registry, Name and LabelValues.
If there is no boolean for LabelValues, returns undefined.
Functions
-spec declare(prometheus_metric:spec()) -> boolean().
Creates a boolean using Spec.
If a boolean with the same Spec exists returns false.
Raises:
{missing_metric_spec_key, Key, Spec}error if requiredSpeckey is missing.{invalid_metric_name, Name, Message}error if metricNameis invalid.{invalid_metric_help, Help, Message}error if metricHelpis invalid.{invalid_metric_labels, Labels, Message}error ifLabelsisn't a list.{invalid_label_name, Name, Message}error ifNameisn't a valid label name.
-spec deregister(prometheus_metric:name()) -> {boolean(), boolean()}.
Equivalent to deregister(default, Name).
-spec deregister(prometheus_registry:registry(), prometheus_metric:name()) -> {boolean(), boolean()}.
Removes all boolean series with name Name and removes Metric Family from Registry.
After this call new/1 for Name and Registry will succeed.
Returns {true, _} if Name was a registered boolean. Otherwise returns {true, _}.
-spec new(prometheus_metric:spec()) -> ok.
Creates a boolean using Spec.
Raises:
{missing_metric_spec_key, Key, Spec}error if requiredSpeckey is missing.{invalid_metric_name, Name, Message}error if metricNameis invalid.{invalid_metric_help, Help, Message}error if metricHelpis invalid.{invalid_metric_labels, Labels, Message}error ifLabelsisn't a list.{invalid_label_name, Name, Message}error ifNameisn't a valid label name.{mf_already_exists, {Registry, Name}, Message}error if a boolean with the sameSpecalready exists.
-spec remove(prometheus_metric:name()) -> boolean().
Equivalent to remove(default, Name, []).
-spec remove(prometheus_metric:name(), prometheus_metric:labels()) -> boolean().
Equivalent to remove(default, Name, LabelValues).
-spec remove(prometheus_registry:registry(), prometheus_metric:name(), prometheus_metric:labels()) -> boolean().
Removes boolean series identified by Registry, Name and LabelValues.
Raises:
{unknown_metric, Registry, Name}error if boolean with nameNamecan't be found inRegistry.{invalid_metric_arity, Present, Expected}error if labels count mismatch.
-spec reset(prometheus_metric:name()) -> boolean().
Equivalent to reset(default, Name, []).
-spec reset(prometheus_metric:name(), prometheus_metric:labels()) -> boolean().
Equivalent to reset(default, Name, LabelValues).
-spec reset(prometheus_registry:registry(), prometheus_metric:name(), prometheus_metric:labels()) -> boolean().
Resets the value of the boolean identified by Registry, Name and LabelValues.
Raises:
{unknown_metric, Registry, Name}error if boolean with nameNamecan't be found inRegistry.{invalid_metric_arity, Present, Expected}error if labels count mismatch.
-spec set(prometheus_metric:name(), prometheus:prometheus_boolean()) -> ok.
Equivalent to set(default, Name, [], Value).
-spec set(prometheus_metric:name(), prometheus_metric:labels(), prometheus:prometheus_boolean()) -> ok.
Equivalent to set(default, Name, LabelValues, Value).
-spec set(Registry, Name, LabelValues, Value) -> ok when Registry :: prometheus_registry:registry(), Name :: prometheus_metric:name(), LabelValues :: prometheus_metric:labels(), Value :: prometheus:prometheus_boolean().
Sets the boolean identified by Registry, Name and LabelValues to Value.
Valid truthy values:
true;false;0-> false;number > 0-> true;[]-> false;non-empty list-> true;undefined-> undefined;
Other values will generate invalid_value error.
Raises:
{invalid_value, Value, Message}ifValueisn't a boolean orundefined.{unknown_metric, Registry, Name}error if boolean with namedNamecan't be found inRegistry.{invalid_metric_arity, Present, Expected}error if labels count mismatch.
-spec toggle(prometheus_metric:name()) -> ok.
Equivalent to toggle(default, Name, []).
-spec toggle(prometheus_metric:name(), prometheus_metric:labels()) -> ok.
Equivalent to toggle(default, Name, LabelValues).
-spec toggle(prometheus_registry:registry(), prometheus_metric:name(), prometheus_metric:labels()) -> ok.
Toggles the boolean identified by Registry, Name and LabelValues.
If boolean set to undefined, it can't be toggled.
Raises:
{invalid_value, undefined, Message}if boolean is undefined.{unknown_metric, Registry, Name}error if boolean with namedNamecan't be found inRegistry.{invalid_metric_arity, Present, Expected}error if labels count mismatch.
-spec value(prometheus_metric:name()) -> boolean() | undefined.
Equivalent to value(default, Name, []).
-spec value(prometheus_metric:name(), prometheus_metric:labels()) -> boolean() | undefined.
Equivalent to value(default, Name, LabelValues).
-spec value(prometheus_registry:registry(), prometheus_metric:name(), prometheus_metric:labels()) -> boolean() | undefined.
Returns the value of the boolean identified by Registry, Name and LabelValues.
If there is no boolean for LabelValues, returns undefined.
Raises:
{unknown_metric, Registry, Name}error if boolean namedNamecan't be found inRegistry.{invalid_metric_arity, Present, Expected}error if labels count mismatch.
-spec values(prometheus_registry:registry(), prometheus_metric:name()) -> [{list(), boolean()}].