Substreams
Prometheus sink module
substreams-sink-prometheus
is a tool that allows developers to pipe data extracted metrics from a blockchain into a Prometheus time series database.
$ cargo add substreams-sink-prometheus
Cargo.toml
toml
[dependencies]
substreams = "0.5"
substreams-sink-prometheus = "0.1"
src/lib.rs
```rust use substreams::prelude::*; use substreams::errors::Error; use substreamssinkprometheus::PrometheusOperations;
fn prom_out(
... some stores ...
) -> Result
let mut prom_ops: PrometheusOperations = Default::default();
// process your data, push to Prometheus metrics
prom_ops.push_set(vec!["some_key"], 123.456);
prom_ops.push_inc(vec!["increment_key"]);
prom_ops.push_dec(vec!["decrement_key"]);
prom_ops.push_add(vec!["add_key"], 2.0);
prom_ops.push_sub(vec!["substract_key"], 100.0);
Ok(prom_ops)
} ```