View Source prometheus_model_helpers (prometheus v4.13.0)
Helpers for working with Prometheus data model. For advanced users.
Probably will be used with prometheus_collector
.
Summary
Functions
Equivalent to boolean_metric(Labels, Value)
.
Creates boolean metric with Labels
and Value
.
Equivalent to lists:map(fun boolean_metric/1, Values)
.
Equivalent to counter_metric(Labels, Value)
.
Creates counter metric with Labels
and Value
.
Equivalent to lists:map(fun counter_metric/1, Values)
.
Create Metric Family of Type
, Name
and Help
.
Create Metric Family of Type
, Name
and Help
.
Equivalent to gauge_metric(Labels, Value)
.
Creates gauge metric with Labels
and Value
.
Equivalent to lists:map(fun gauge_metrics/1, Values)
.
Creates histogram metric with Labels
, Buckets
, Count
and Sum
.
Equivalent to lists:map(fun histogram_metric/1, Specs)
.
Creates prometheus_model:
LabelPair'()' from {Name, Value} tuple.
Label pairs sequentially.
If Name
is a list, looks for atoms and converts them to binaries. Why iolists do not support atoms?
Equivalent to summary_metric(Labels, Count, Sum)
.
Equivalent to summary_metric([], Count, Sum)
.
Creates summary metric with Labels
, Count
and Sum
.
Equivalent to lists:map(fun summary_metric/1, Specs)
.
Equivalent to untyped_metric(Labels, Value)
.
Creates untyped metric with Labels
and Value
.
Equivalent to lists:map(fun untyped_metric/1, Values)
.
Functions
-spec boolean_metric(Boolean) -> prometheus_model:'Metric'() when Boolean :: prometheus:pbool().
Equivalent to boolean_metric(Labels, Value)
.
-spec boolean_metric(Labels, Value) -> prometheus_model:'Metric'() when Labels :: prometheus:labels(), Value :: prometheus:prometheus_boolean().
Creates boolean metric with Labels
and Value
.
-spec boolean_metrics(Values) -> [prometheus_model:'Metric'()] when Values :: [prometheus:pbool()].
Equivalent to lists:map(fun boolean_metric/1, Values)
.
-spec counter_metric(Spec) -> prometheus_model:'Metric'() when Spec :: prometheus:counter().
Equivalent to counter_metric(Labels, Value)
.
-spec counter_metric(Labels, Value) -> prometheus_model:'Metric'() when Labels :: prometheus:labels(), Value :: prometheus:value().
Creates counter metric with Labels
and Value
.
-spec counter_metrics(Specs) -> [prometheus_model:'Metric'()] when Specs :: [prometheus:counter()].
Equivalent to lists:map(fun counter_metric/1, Values)
.
-spec create_mf(Name, Help, Type, Metrics) -> MetricFamily when Name :: prometheus_metric:name(), Help :: prometheus_metric:help(), Type :: atom(), Metrics :: [prometheus_model:'Metric'()] | prometheus_model:'Metric'() | prometheus:metrics(), MetricFamily :: prometheus_model:'MetricFamily'().
Create Metric Family of Type
, Name
and Help
.
Collector:collect_metrics/2
callback will be called and expected to return individual metrics list.
-spec create_mf(Name, Help, Type, Collector, CollectorData) -> MetricFamily when Name :: prometheus_metric:name(), Help :: prometheus_metric:help(), Type :: atom(), Collector :: prometheus_collector:collector(), CollectorData :: prometheus_collector:data(), MetricFamily :: prometheus_model:'MetricFamily'().
Create Metric Family of Type
, Name
and Help
.
Collector:collect_metrics/2
callback will be called and expected to return individual metrics list.
-spec gauge_metric(Gauge) -> prometheus_model:'Metric'() when Gauge :: prometheus:gauge().
Equivalent to gauge_metric(Labels, Value)
.
-spec gauge_metric(Labels, Value) -> prometheus_model:'Metric'() when Labels :: prometheus:labels(), Value :: prometheus:value().
Creates gauge metric with Labels
and Value
.
-spec gauge_metrics(Values) -> [prometheus_model:'Metric'()] when Values :: [prometheus:gauge()].
Equivalent to lists:map(fun gauge_metrics/1, Values)
.
-spec histogram_metric(Histogram) -> prometheus_model:'Metric'() when Histogram :: prometheus:histogram().
Equivalent to histogram_metric(Labels, Buckets, Count, Sum)
.
-spec histogram_metric(Buckets, Count, Sum) -> prometheus_model:'Metric'() when Buckets :: prometheus:buckets(), Count :: non_neg_integer(), Sum :: prometheus:value().
Equivalent to histogram_metric([], Buckets, Count, Sum)
.
-spec histogram_metric(Labels, Buckets, Count, Sum) -> Metric when Labels :: prometheus:labels(), Buckets :: [{Bound, Count}], Bound :: prometheus_buckets:bucket_bound(), Count :: non_neg_integer(), Sum :: prometheus:value(), Metric :: prometheus_model:'Metric'().
Creates histogram metric with Labels
, Buckets
, Count
and Sum
.
-spec histogram_metrics(Specs) -> [prometheus_model:'Metric'()] when Specs :: [prometheus:histogram()].
Equivalent to lists:map(fun histogram_metric/1, Specs)
.
-spec label_pair(prometheus:label()) -> prometheus_model:'LabelPair'().
Creates prometheus_model:
LabelPair'()' from {Name, Value} tuple.
-spec label_pairs(Labels) -> [prometheus_model:'LabelPair'()] when Labels :: prometheus:labels().
Label pairs sequentially.
NB is_binary' clause here is for a special optimization for text format only: client code can pre-generate final labels string, e.g. when it knows when character escaping is not needed. This avoids direct performance cost of character escaping, and also reduces garabage collection pressure, as intermediate lists of tuples/records are not created at all. This optimization is used by RabbitMQ prometheus plugin (which calls
create_mf/5', and it ends
here).
WARNING Works only for text format, protobuf format export will fail with an error.
-spec metric_name(Name) -> binary() when Name :: atom() | binary() | [char() | iolist() | binary() | atom()].
If Name
is a list, looks for atoms and converts them to binaries. Why iolists do not support atoms?
-spec summary_metric(Summary) -> prometheus_model:'Metric'() when Summary :: prometheus:summary().
Equivalent to summary_metric(Labels, Count, Sum)
.
-spec summary_metric(Count, Sum) -> prometheus_model:'Metric'() when Count :: non_neg_integer(), Sum :: prometheus:value().
Equivalent to summary_metric([], Count, Sum)
.
-spec summary_metric(Labels, Count, Sum) -> prometheus_model:'Metric'() when Labels :: prometheus:labels(), Count :: non_neg_integer(), Sum :: prometheus:value().
Equivalent to summary_metric([], Count, Sum, [])
.
-spec summary_metric(Labels, Count, Sum, Quantiles) -> prometheus_model:'Metric'() when Labels :: prometheus:labels(), Count :: non_neg_integer(), Sum :: prometheus:value(), Quantiles :: list().
Creates summary metric with Labels
, Count
and Sum
.
-spec summary_metrics(Specs) -> [prometheus_model:'Metric'()] when Specs :: [prometheus:summary()].
Equivalent to lists:map(fun summary_metric/1, Specs)
.
-spec untyped_metric(Untyped) -> prometheus_model:'Metric'() when Untyped :: prometheus:untyped().
Equivalent to untyped_metric(Labels, Value)
.
-spec untyped_metric(Labels, Value) -> prometheus_model:'Metric'() when Labels :: prometheus:labels(), Value :: prometheus:value().
Creates untyped metric with Labels
and Value
.
-spec untyped_metrics(Values) -> [prometheus_model:'Metric'()] when Values :: [prometheus:untyped()].
Equivalent to lists:map(fun untyped_metric/1, Values)
.