Prometheus Rust client library
This is the Rust client library for Prometheus. The main Structures and APIs are ported from Go client.
Usage
-
Add this to your
Cargo.toml
:[] = "0.4"
-
Add this to your crate in
lib.rs
:extern crate prometheus;
-
Or enable nightly feature for better performance.
[] = "https://github.com/pingcap/rust-prometheus.git" = false = ["nightly"]
Note
The crate has a pre-generated protobuf binding file for protobuf
v2.0, if you need use the latest version of protobuf
, you can generate the binding file on building with the gen
feature.
[]
= "https://github.com/pingcap/rust-prometheus.git"
= ["gen"]
Example
use ;
// Create a Counter.
let counter_opts = new;
let counter = with_opts.unwrap;
// Create a Registry and register Counter.
let r = new;
r.register.unwrap;
// Inc.
counter.inc;
// Gather the metrics.
let mut buffer = vec!;
let encoder = new;
let metric_families = r.gather;
encoder.encode.unwrap;
// Output to the standard output.
println!;
Advanced
Static Metric
Static metric helps you make metric vectors faster.
See static-metric directory for details.