Expand description
Drop-in replacement for the prometheus crate with optional per-metric
filtering.
Replace use prometheus::* with use prometheus_filtered::* to control
which metrics are exposed. The active filter combines the node config’s
directives with the METRICS_FILTER environment variable’s; where both
match the same metric, the env var wins.
Filter syntax: comma-separated pattern=LEVEL directives, last-match
wins, where LEVEL is one of off, warn, info, debug, trace.
A bare LEVEL token (no pattern=) sets the global default. A pattern
matches if it is a prefix of the metric name OR is a component/prefix of the
calling module path (e.g. traffic_controller matches
iota_core::traffic_controller::metrics).
Examples:
METRICS_FILTER=off,authority=warnMETRICS_FILTER=authority=off
The directives act as exposure
thresholds deciding which metrics Registry::gather includes in its
output (off exposes none of the matched metrics). Metrics matched by no
directive are exposed unconditionally, so with no filter configured the
crate behaves exactly like plain prometheus; use a bare LEVEL directive
to set a stricter global default.
Re-exports§
pub use core::Histogram;pub use core::HistogramTimer;pub use core::HistogramVec;
Modules§
- core
- Mirrors
prometheus::coreand providesGenericGauge/GenericCounterwrappers compatible with prometheus’s own generic types. - proto
- Protocol buffers format of metrics.
Generated file from
proto_model.proto
Macros§
- histogram_
opts - Create a
HistogramOpts. - opts
- Create an
Opts. - register_
counter - register_counter!(name, help) - global prometheus registry, filtered.
- register_
counter_ vec - register_counter_vec!(name, help, labels) - global registry, filtered.
- register_
counter_ vec_ with_ registry - register_counter_vec_with_registry!(name, help, labels, registry)
- register_
gauge_ vec_ with_ registry - register_gauge_vec_with_registry!(name, help, labels, registry)
- register_
gauge_ with_ registry - register_gauge_with_registry!(name, help, registry)
- register_
histogram_ vec - register_histogram_vec!(opts, labels) or (name, help, labels) or (name, help, labels, buckets) — global prometheus registry, filtered.
- register_
histogram_ vec_ with_ registry - register_histogram_vec_with_registry!(name, help, labels, registry) register_histogram_vec_with_registry!(name, help, labels, buckets, registry)
- register_
histogram_ with_ registry - register_histogram_with_registry!(name, help, registry) register_histogram_with_registry!(name, help, buckets, registry)
- register_
int_ counter_ vec_ with_ registry - register_int_counter_vec_with_registry!(name, help, labels, registry)
- register_
int_ counter_ with_ registry - register_int_counter_with_registry!(name, help, registry)
- register_
int_ gauge_ vec_ with_ registry - register_int_gauge_vec_with_registry!(name, help, labels, registry)
- register_
int_ gauge_ with_ registry - register_int_gauge_with_registry!(name, help, registry)
Structs§
- Filter
- Parses and evaluates
METRICS_FILTER-style directives. - Histogram
Opts - A struct that bundles the options for creating a [
Histogram] metric. It is mandatory to set Name and Help to a non-empty string. All other fields are optional and can safely be left at their zero value. - Opts
- A struct that bundles the options for creating most
Metrictypes. - Protobuf
Encoder - An implementation of an
Encoderthat converts aMetricFamilyproto message into the binary wire format of protobuf. - Registry
- Wraps
prometheus::Registrywith an embeddedFilterso thatregister_*_with_registry!macros can decide at construction time whether a metric should be active. - Text
Encoder - An implementation of an
Encoderthat converts aMetricFamilyproto message into text format.
Enums§
- Error
- The error types for prometheus.
- Metric
Level - Verbosity level for a metric.
Constants§
- DEFAULT_
BUCKETS - The default [
Histogram] buckets. The default buckets are tailored to broadly measure the response time (in seconds) of a network service. Most likely, however, you will be required to define buckets customized to your use case. - PROTOBUF_
FORMAT - The protocol buffer format of metric family.
Traits§
- Encoder
- An interface for encoding metric families into an underlying wire protocol.
Functions§
- default_
registry - Returns a reference to the global default
Registry, wrapping the underlyingprometheus::default_registry(). Metrics registered here appear in the standard prometheus default gather output. - exponential_
buckets - Create
countbuckets, where the lowest bucket has an upper bound ofstartand each following bucket’s upper bound isfactortimes the previous bucket’s upper bound. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field ofHistogramOpts. - gather
- Return all
MetricFamilyofDEFAULT_REGISTRY. - linear_
buckets - Create
countbuckets, eachwidthwide, where the lowest bucket has an upper bound ofstart. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field ofHistogramOpts.
Type Aliases§
- Counter
- Counter
Vec - Gauge
- Gauge
Vec - IntCounter
- IntCounter
Vec - IntGauge
- IntGauge
Vec - Result
- A specialized Result type for prometheus.