Prometheus.ex v1.0.0 Prometheus.Metric.Gauge
Gauge metric, to report instantaneous values.
Gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
A Gauge is typically used for measured values like temperatures or current memory usage, but also “counts” that can go up and down, like the number of running processes.
Example use cases for Gauges:
- Inprogress requests;
- Number of items in a queue;
- Free memory;
- Total memory;
- Temperature.
Example:
defmodule MyPoolInstrumenter do
use Prometheus.Metric
## to be called at app/supervisor startup.
## to tolerate restarts use declare.
def setup() do
Gauge.declare([name: :my_pool_size,
help: "Pool size."])
Gauge.declare([name: :my_pool_checked_out,
help: "Number of sockets checked out from the pool"])
end
def set_size(size) do
Gauge.set([name: :my_pool_size], size)
end
def track_checked_out_sockets(checkout_fun) do
Gauge.track_inprogress([name: :my_pool_checked_out], checkout_fun)
end
end
Summary
Macros
Decrements the gauge identified by spec
by value
Creates a gauge using spec
.
If a gauge with the same spec
exists returns false
Increments the gauge identified by spec
by value
Creates a gauge using spec
Removes gauge series identified by spec
Resets the value of the gauge identified by spec
Sets the gauge identified by spec
to value
Tracks the amount of time spent executing fun
Sets the gauge identified by spec
to the current unixtime
Sets the gauge identified by spec
to the number of currently executing fun
s
Returns the value of the gauge identified by spec
Macros
Decrements the gauge identified by spec
by value
.
If value
happened to be a float number even one time(!) you shouldn’t use inc/2
or dec/2
after ddec.
Raises Prometheus.InvalidValueError
exception if value
isn’t a number.
Raises Prometheus.UnknownMetricError
exception if a counter for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Decrements the gauge identified by spec
by value
.
Raises Prometheus.InvalidValueError
exception if value
isn’t an integer.
Raises Prometheus.UnknownMetricError
exception if a counter for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Creates a gauge using spec
.
If a gauge 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.InvalidMetricNameError
if label name is invalid.
Raises Prometheus.InvalidValueError
exception if duration_unit is unknown or doesn’t match metric name.
Increments the gauge identified by spec
by value
.
If value
happened to be a float number even one time(!) you shouldn’t use inc/2
or dec/2
after dinc.
Raises Prometheus.InvalidValueError
exception if value
isn’t a number.
Raises Prometheus.UnknownMetricError
exception if a counter for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Increments the gauge identified by spec
by value
.
Raises Prometheus.InvalidValueError
exception if value
isn’t an integer.
Raises Prometheus.UnknownMetricError
exception if a counter for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Creates a gauge 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.InvalidMetricNameError
if label name is invalid.
Raises Prometheus.InvalidValueError
exception if duration_unit is unknown or doesn’t match metric name.
Raises Prometheus.MFAlreadyExistsError
if a gauge with the same spec
exists.
Removes gauge series identified by spec.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Resets the value of the gauge identified by spec
.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Sets the gauge identified by spec
to value
.
Raises Prometheus.InvalidValueError
exception if value
isn’t a number or :undefined
.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Tracks the amount of time spent executing fun
.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Raises Prometheus.InvalidValueError
exception if fun
isn’t a function or block.
Sets the gauge identified by spec
to the current unixtime.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Sets the gauge identified by spec
to the number of currently executing fun
s.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Raises Prometheus.InvalidValueError
exception if fun isn’t a function or block.
Returns the value of the gauge identified by spec
.
If duration unit set, value will be converted to the duration unit. Read more here.
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can’t be found.
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.