Substreams Sink to Prometheus

github crates.io docs.rs GitHub Workflow Status

substreams-sink-prom is a tool that allows developers to pipe data extracted from a blockchain into a Prometheus time series store.

📖 Documentation

https://docs.rs/substreams-sink-prometheus

Further resources

🛠 Feature Roadmap

Gauge - [x] Set - [x] Inc - [x] Dec - [x] Add - [x] Sub - [x] SetToCurrentTime

Install

$ cargo add substreams-sink-prometheus

Quickstart

Cargo.toml

toml [dependencies] substreams = "0.5" substreams-sink-prometheus = "0.1"

src/lib.rs

```rust use substreamssinkprometheus::PrometheusOperations;

[substreams::handlers::map]

fn mapactiontraces( ... 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)

} ```