Prometheus.ex v1.0.0-alpha3 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
Creates a gauge using spec.
If a gauge with the same spec exists returns false
Creates a gauge using spec
Resets the value of the gauge identified by spec
Sets the gauge identified by spec to value
Sets the gauge identified by spec to the current unixtime
Track inprogress functions
Returns the value of the gauge identified by spec
Macros
Creates a gauge using spec.
If a gauge with the same spec exists returns false.
Raises Prometheus.Error.MissingMetricSpecKey if required spec key is missing.
Raises Prometheus.Error.InvalidMetricName if metric name is invalid.
Raises Prometheus.Error.InvalidMetricHelp if help is invalid.
Raises Prometheus.Error.InvalidMetricLabels if labels isn’t a list.
Raises Prometheus.Error.InvalidMetricName if label name is invalid.
Creates a gauge using spec.
Raises Prometheus.Error.MissingMetricSpecKey if required spec key is missing.
Raises Prometheus.Error.InvalidMetricName if metric name is invalid.
Raises Prometheus.Error.InvalidMetricHelp if help is invalid.
Raises Prometheus.Error.InvalidMetricLabels if labels isn’t a list.
Raises Prometheus.Error.InvalidMetricName if label name is invalid.
Raises Prometheus.Error.MFAlreadyExists if a gauge with the same spec exists.
Resets the value of the gauge identified by spec.
Raises Prometheus.Error.UnknownMetric exception if a gauge for spec can’t be found.
Raises Prometheus.Error.InvalidMetricArity exception if labels count mismatch.
Sets the gauge identified by spec to value.
Raises Prometheus.Error.InvalidValue exception if value isn’t a number.
Raises Prometheus.Error.UnknownMetric exception if a gauge for spec can’t be found.
Raises Prometheus.Error.InvalidMetricArity exception if labels count mismatch.
Sets the gauge identified by spec to the current unixtime.
Raises Prometheus.Error.UnknownMetric exception if a gauge for spec can’t be found.
Raises Prometheus.Error.InvalidMetricArity exception if labels count mismatch.
Track inprogress functions.
Raises Prometheus.Error.UnknownMetric exception if a gauge for spec can’t be found.
Raises Prometheus.Error.InvalidMetricArity exception if labels count mismatch.
Returns the value of the gauge identified by spec.
Raises Prometheus.Error.UnknownMetric exception if a gauge for spec can’t be found.
Raises Prometheus.Error.InvalidMetricArity exception if labels count mismatch.