Helpers for working with Prometheus data model.
For advanced users.
Probably will be used with prometheus_collector
.
buckets() = [{prometheus_buckets:bucket_bound(), non_neg_integer()}, ...]
histogram() = {buckets(), non_neg_integer(), value()} | {labels(), buckets(), non_neg_integer(), value()}
label() = {label_name(), label_value()}
label_name() = term()
label_value() = term()
labels() = [label()] | pre_rendered_labels()
pbool() = prometheus_boolean() | {prometheus_boolean()} | {labels(), prometheus_boolean()}
pre_rendered_labels() = binary()
prometheus_boolean() = boolean() | number() | list() | undefined
value() = float() | integer() | undefined | infinity
boolean_metric(Boolean) -> prometheus_model:'Metric'()
Boolean = pbool()
Equivalent to
boolean_metric(Labels, Value)
.
boolean_metric(Labels, Value) -> prometheus_model:'Metric'()
Labels = labels()
Value = prometheus_boolean()
Creates boolean metric with Labels
and Value
.
boolean_metrics(Values) -> any()
Equivalent to
lists:map(fun boolean_metric/1, Values)
.
counter_metric(Spec) -> prometheus_model:'Metric'()
Spec = counter()
Equivalent to
counter_metric(Labels, Value)
.
counter_metric(Labels, Value) -> prometheus_model:'Metric'()
Creates counter metric with Labels
and Value
.
counter_metrics(Specs) -> any()
Equivalent to
lists:map(fun counter_metric/1, Specs)
.
create_mf(Name, Help, Type, Metrics) -> MetricFamily
Name = prometheus_metric:name()
Help = prometheus_metric:help()
Type = atom()
Metrics = [prometheus_model:'Metric'()] | prometheus_model:'Metric'() | 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.
create_mf(Name, Help, Type, Collector, CollectorData) -> MetricFamily
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.
gauge_metric(Gauge) -> prometheus_model:'Metric'()
Gauge = gauge()
Equivalent to
gauge_metric(Labels, Value)
.
gauge_metric(Labels, Value) -> prometheus_model:'Metric'()
Creates gauge metric with Labels
and Value
.
gauge_metrics(Values) -> any()
Equivalent to
lists:map(fun gauge_metric/1, Values)
.
histogram_metric(Histogram) -> prometheus_model:'Metric'()
Histogram = histogram()
Equivalent to
histogram_metric(Labels, Buckets, Count, Sum)
.
histogram_metric(Buckets, Count, Sum) -> any()
Equivalent to histogram_metric([], Buckets, Count, Sum)
.
histogram_metric(Labels, Buckets, Count, Sum) -> Metric
Labels = labels()
Buckets = [{Bound, Count}]
Bound = prometheus_buckets:bucket_bound()
Count = non_neg_integer()
Sum = value()
Metric = prometheus_model:'Metric'()
Creates histogram metric with Labels
, Buckets
, Count
and Sum
.
histogram_metrics(Specs) -> any()
Equivalent to
lists:map(fun histogram_metric/1, Specs)
.
label_pair(X1::label()) -> prometheus_model:'LabelPair'()
Creates prometheus_model:
LabelPair'()' from {Name, Value} tuple.
label_pairs(B) -> any()
Equivalent to
lists:map(fun label_pair/1, Labels)
.
metric_name(Name) -> binary()
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?
summary_metric(Summary) -> prometheus_model:'Metric'()
Summary = summary()
Equivalent to
summary_metric(Labels, Count, Sum)
.
summary_metric(Count, Sum) -> any()
Equivalent to summary_metric([], Count, Sum)
.
summary_metric(Labels, Count, Sum) -> any()
Equivalent to summary_metric([], Count, Sum, [])
.
summary_metric(Labels, Count, Sum, Quantiles) -> prometheus_model:'Metric'()
Creates summary metric with Labels
, Count
and Sum
.
summary_metrics(Specs) -> any()
Equivalent to
lists:map(fun summary_metric/1, Specs)
.
untyped_metric(Untyped) -> prometheus_model:'Metric'()
Untyped = untyped()
Equivalent to
untyped_metric(Labels, Value)
.
untyped_metric(Labels, Value) -> prometheus_model:'Metric'()
Creates untyped metric with Labels
and Value
.
untyped_metrics(Values) -> any()
Equivalent to
lists:map(fun untyped_metric/1, Values)
.