v0.1.1
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.
π Documentation
https://docs.rs/substreams-sink-prometheus
Further resources
π Feature Roadmap
Prometheus Gauge
- Set
- Inc
- Dec
- Add
- Sub
- SetToCurrentTime
Install
$ cargo add substreams-sink-prometheus
Quickstart
Cargo.toml
[dependencies]
substreams = "0.5"
substreams-sink-prometheus = "0.1"
src/lib.rs
use substreams::prelude::*;
use substreams::errors::Error;
use substreams_sink_prometheus::PrometheusOperations;
#[substreams::handlers::map]
fn prom_out(
... some stores ...
) -> Result<PrometheusOperations, Error> {
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)
}