Prometheus.Metric.Gauge (Prometheus.ex v4.0.0)
View SourceGauge 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:
- In progress 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
def track_checked_out_sockets_block(socket) do
Gauge.track_inprogress([name: :my_pool_checked_out]) do
# checkout code
socket
end
end
end
Summary
Functions
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 body
.
Sets the gauge identified by spec
to the current unix time.
Sets the gauge identified by spec
to the number of currently executing body
s.
Returns the value of the gauge identified by spec
.
Functions
Decrements the gauge identified by spec
by value
.
Raises Prometheus.InvalidValueError
exception if value
isn't a number.<br>
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can't be found.<br>
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.<br>
Raises Prometheus.InvalidMetricNameError
if metric name is invalid.<br>
Raises Prometheus.InvalidMetricHelpError
if help is invalid.<br>
Raises Prometheus.InvalidMetricLabelsError
if labels isn't a list.<br>
Raises Prometheus.InvalidMetricNameError
if label name is invalid.<br>
Raises Prometheus.InvalidValueError
exception if duration_unit is unknown or
doesn't match metric name.
Increments the gauge identified by spec
by value
.
Raises Prometheus.InvalidValueError
exception if value
isn't a number.<br>
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can't be found.<br>
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Creates a gauge using spec
.
Raises Prometheus.MissingMetricSpecKeyError
if required spec
key is missing.<br>
Raises Prometheus.InvalidMetricNameError
if metric name is invalid.<br>
Raises Prometheus.InvalidMetricHelpError
if help is invalid.<br>
Raises Prometheus.InvalidMetricLabelsError
if labels isn't a list.<br>
Raises Prometheus.InvalidMetricNameError
if label name is invalid.<br>
Raises Prometheus.InvalidValueError
exception if duration_unit is unknown or
doesn't match metric name.<br>
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.<br>
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.<br>
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
.<br>
Raises Prometheus.UnknownMetricError
exception if a gauge for spec
can't be found.<br>
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Tracks the amount of time spent executing body
.
Raises Prometheus.UnknownMetricError
exception if a gauge
for spec
can't be found.<br>
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 unix time.
Raises Prometheus.UnknownMetricError
exception if a gauge
for spec
can't be found.<br>
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.
Sets the gauge identified by spec
to the number of currently executing body
s.
Raises Prometheus.UnknownMetricError
exception if a gauge
for spec
can't be found.<br>
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.<br>
Raises Prometheus.InvalidMetricArityError
exception if labels count mismatch.