Crate prometheus_exporter_base
source ·Expand description
This crate simplifies the generation of valid Prometheus metrics. You should start by building
a PrometheusMetric
and then adding as many PrometheusInstance
as needed.
PrometheusMetric
specifies the counter name
, type
and help
. Each PrometheusInstance
specifies the value
and the optional labels
and timestamp
.
This crate aslo gives you a zero boilerplate hyper
server behind the hyper_server
feature
gate, check render_prometheus
and the example
folder
for this feature.
Examples
Basic usage:
use prometheus_exporter_base::prelude::*;
let rendered_string = PrometheusMetric::build()
.with_name("folder_size")
.with_metric_type(MetricType::Counter)
.with_help("Size of the folder")
.build()
.render_and_append_instance(
&PrometheusInstance::new()
.with_label("folder", "/var/log")
.with_value(100)
.with_current_timestamp()
.expect("error getting the UNIX epoch"),
)
.render();
Modules
Structs
Enums
Traits
This trait should be implemented by
any instance able to render itself according
to Prometheus specifications.