Struct metrics_exporter_prometheus::PrometheusBuilder [−][src]
pub struct PrometheusBuilder { /* fields omitted */ }
Expand description
Builder for creating and installing a Prometheus recorder/exporter.
Implementations
Creates a new PrometheusBuilder
.
Sets the listen address for the Prometheus scrape endpoint.
The HTTP listener that is spawned will respond to GET requests on any request path.
Defaults to 0.0.0.0:9000
.
Disable the HTTP listener. This is useful when you only want to use the Prometheus push gateway.
Adds an IP address or subnet that is allowed to connect to the Prometheus scrape endpoint.
By default (if this method is never called), no restrictions are enforced.
Note that this on its own is insufficient for access control, if the exporter is running in an environment alongside applications (such as web browsers) that are susceptible to DNS rebinding attacks.
Sets the quantiles to use when rendering histograms.
Quantiles represent a scale of 0 to 1, where percentiles represent a scale of 1 to 100, so a quantile of 0.99 is the 99th percentile, and a quantile of 0.99 is the 99.9th percentile.
By default, the quantiles will be set to: 0.0, 0.5, 0.9, 0.95, 0.99, 0.999, and 1.0. This means that all histograms will be exposed as Prometheus summaries.
If buckets are set (via set_buckets
or
set_buckets_for_metric
) then all histograms will be exposed
as summaries instead.
Sets the buckets to use when rendering histograms.
Buckets values represent the higher bound of each buckets. If buckets are set, then all histograms will be rendered as true Prometheus histograms, instead of summaries.
Sets the bucket for a specific pattern.
The match pattern can be a full match (equality), prefix match, or suffix match. The matchers are applied in that order if two or more matchers would apply to a single metric. That is to say, if a full match and a prefix match applied to a metric, the full match would win, and if a prefix match and a suffix match applied to a metric, the prefix match would win.
Buckets values represent the higher bound of each buckets. If buckets are set, then any histograms that match will be rendered as true Prometheus histograms, instead of summaries.
This option changes the observer’s output of histogram-type metric into summaries. It only affects matching metrics if set_buckets was not used.
Sets the idle timeout for metrics.
If a metric hasn’t been updated within this timeout, it will be removed from the registry and in turn removed from the normal scrape output until the metric is emitted again. This behavior is driven by requests to generate rendered output, and so metrics will not be removed unless a request has been made recently enough to prune the idle metrics.
Further, the metric kind “mask” configures which metrics will be considered by the idle timeout. If the kind of a metric being considered for idle timeout is not of a kind represented by the mask, it will not be affected, even if it would have othered been removed for exceeding the idle timeout.
Refer to the documentation for MetricKindMask
for more
information on defining a metric kind mask.
Adds a global label to this exporter.
Global labels are applied to all metrics. Labels defined on the metric key itself have precedence over any global labels. If this method is called multiple times, the latest value for a given label key will be used.
Builds the recorder and exporter and installs them globally.
An error will be returned if there’s an issue with creating the HTTP server or with installing the recorder as the global recorder.
Builds the recorder and returns it.
pub fn build_with_exporter(
self
) -> Result<(PrometheusRecorder, Pin<Box<dyn Future<Output = Result<(), HyperError>> + Send + 'static>>), InstallError>
pub fn build_with_exporter(
self
) -> Result<(PrometheusRecorder, Pin<Box<dyn Future<Output = Result<(), HyperError>> + Send + 'static>>), InstallError>
Builds the recorder and exporter and returns them both.
In most cases, users should prefer to use PrometheusBuilder::install
to create and
install the recorder and exporter automatically for them. If a caller is combining
recorders, or needs to schedule the exporter to run in a particular way, this method
provides the flexibility to do so.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PrometheusBuilder
impl Send for PrometheusBuilder
impl Sync for PrometheusBuilder
impl Unpin for PrometheusBuilder
impl UnwindSafe for PrometheusBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more