#prometheus #exporter #hyper #metrics

prometheus_exporter

Helper libary to export prometheus metrics using hyper

7 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

0.4.0 Jun 24, 2019
0.3.2 Apr 3, 2019
0.3.0 Mar 14, 2019
0.2.0 Jan 24, 2019
0.1.1 Jan 24, 2019

#43 in Data formats

Download history 18/week @ 2019-03-11 8/week @ 2019-03-18 17/week @ 2019-03-25 45/week @ 2019-04-01 13/week @ 2019-04-08 1/week @ 2019-04-15 7/week @ 2019-04-22 13/week @ 2019-04-29 14/week @ 2019-05-06 21/week @ 2019-05-13 89/week @ 2019-05-20 13/week @ 2019-05-27 7/week @ 2019-06-03 20/week @ 2019-06-10 28/week @ 2019-06-17

93 downloads per month

MIT license

9KB
145 lines

prometheus_exporter

crates.io docs.rs

Helper libary to export prometheus metrics using hyper. It's intended to help writing prometheus exporters without the need to setup and maintain a http webserver. If the program also uses a http server for other purposes this package is probably not the best way and rust-prometheus should be used directly.

It uses rust-prometheus for collecting and rendering the prometheus metrics and hyper for exposing the metrics through http.

Usage

Add this to your Cargo.toml:

[dependencies]
prometheus_exporter = "0.4"

There are three ways on how to use the exporter:

  • PrometheusExporter::run: Just starts the hyper http server and exports metrics from the global prometheus register under the path /metrics. Allows the most freedom on how and when to update/generate metrics.

  • PrometheusExporter::run_and_notify: Starts the http server and opens channels to allow notification of when a request is made. This is usefull for cases where metrics should be updated everytime somebody calls the /metrics path.

  • PrometheusExporter::run_and_repeat: Starts the http server and opens channels that will send a message to the original caller when a duration inteval is reached. This will be repeated forever. This is usefull for cases where metrics should be gathered in a set interval. For example if the metric collection is expensive it makes more sense to not collect the metrics all the time.

For examples on how to use prometheus_exporter see the examples folder.

Dependencies

~4.5MB
~79K SLoC