Wobserver v0.1.8 Wobserver.Util.Metrics.Prometheus View Source
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
Link to this function
combine_metrics(metrics)
View Source
combine_metrics(metrics :: list[<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>]) :: String.t
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"
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.
Link to this function
merge_metrics(metrics)
View Source
merge_metrics(metrics :: list[<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>]) :: String.t
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"