View Source Wobserver.Util.Metrics.Prometheus (Wobserver NG v1.14.0)
Prometheus formatter.
Formats metrics in a for Prometheus readable way. See: https://prometheus.io/docs/instrumenting/writing_exporters/
Link to this section Summary
Functions
Combines formatted metrics together.
Format a set of data
with a label
for a Prometheus.
Merges formatted sets of metrics from different nodes together.
Link to this section Functions
Combines formatted metrics together.
Arguments:
metrics
, a list of formatted metrics for one node.
Example:
iex> combine_metrics ["metric1{node="127.0.0.1"} 5\n", "metric2{node="127.0.0.1"} 5\n"]
"metric1{node="127.0.0.1"} 5\n", "metric2{node="127.0.0.1"} 5\n"
@spec format_data( name :: String.t(), data :: [{integer() | float(), keyword()}], type :: :atom, help :: String.t() ) :: String.t()
Format a set of data
with a label
for a Prometheus.
The data
must be given as a list
of tuples with the following format: {value, labels}
, where labels
is a keyword list with labels and their values.
The following options can also be given:
type
, the type of the metric. The following values are currently supported::gauge
,:counter
.help
, a single line text description of the metric.
Merges formatted sets of metrics from different nodes together.
The merge will filter out double declarations of help and type.
Arguments:
metrics
, a list of formatted sets metrics for multiple node.
Example:
iex> combine_metrics ["metric{node="192.168.0.6"} 5\n", "metric{node="192.168.0.5"} 5\n"]
"metric{node="192.168.0.6"} 5\n", "metric{node="192.168.0.7"} 5\n"