From bfc4e8d07b83b76257c1ee474fd25f0ff9b47385 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Thu, 9 Feb 2023 14:27:18 -0500 Subject: [PATCH] update eosmechanics & accounts with latest prometheus --- accounts/Cargo.toml | 2 +- accounts/Makefile | 2 +- accounts/src/sinks.rs | 9 ++--- accounts/substreams.yaml | 4 +-- eosmechanics/Cargo.toml | 2 +- eosmechanics/Makefile | 4 +-- eosmechanics/proto/v1/prometheus.proto | 50 -------------------------- eosmechanics/src/sinks.rs | 10 +++--- eosmechanics/substreams.yaml | 8 ++--- params/Cargo.toml | 2 +- 10 files changed, 23 insertions(+), 70 deletions(-) delete mode 100644 eosmechanics/proto/v1/prometheus.proto diff --git a/accounts/Cargo.toml b/accounts/Cargo.toml index 42f76b7..5fe2cbd 100644 --- a/accounts/Cargo.toml +++ b/accounts/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "accounts" -version = "0.2.0" +version = "0.3.1" authors = ["Yaro ", "Denis "] description = "Antelope newly created accounts" license = "MIT OR Apache-2.0" diff --git a/accounts/Makefile b/accounts/Makefile index ada7f4d..edba900 100644 --- a/accounts/Makefile +++ b/accounts/Makefile @@ -31,7 +31,7 @@ run: .PHONY: gui gui: - substreams gui -e eos.firehose.eosnation.io:9001 map_accounts -s 1000000 -t +10000 + substreams gui -e eos.firehose.eosnation.io:9001 prom_out -s 1000000 -t +10000 .PHONY: sink sink: diff --git a/accounts/src/sinks.rs b/accounts/src/sinks.rs index 887d030..77f9ad9 100644 --- a/accounts/src/sinks.rs +++ b/accounts/src/sinks.rs @@ -1,7 +1,7 @@ use substreams::{log, proto}; use substreams_sink_kv::pb::kv::KvOperations; use substreams::errors::Error; -use substreams_sink_prometheus::PrometheusOperations; +use substreams_sink_prometheus::{PrometheusOperations, Gauge}; use crate::accounts::Accounts; @@ -22,10 +22,11 @@ pub fn kv_out( accounts: Accounts) -> Result { pub fn prom_out(accounts: Accounts) -> Result { let mut prom_out = PrometheusOperations::default(); + let total = accounts.accounts.len() as f64; - if accounts.accounts.len() > 0 { - log::info!("New accounts: {}", accounts.accounts.len()); - prom_out.push_add("accounts_counter", accounts.accounts.len() as f64, vec![]); + if total > 0.0 { + log::info!("New accounts: {}", total); + prom_out.push(Gauge::new("accounts_counter").add(total)); } Ok(prom_out) diff --git a/accounts/substreams.yaml b/accounts/substreams.yaml index 1ba9f54..478feec 100644 --- a/accounts/substreams.yaml +++ b/accounts/substreams.yaml @@ -1,13 +1,13 @@ specVersion: v0.1.0 package: name: "accounts" - version: v0.2.0 + version: v0.3.1 url: https://github.com/pinax-network/substreams doc: Antelope newly created accounts imports: kv: https://github.com/streamingfast/substreams-sink-kv/releases/download/v0.1.2/substreams-sink-kv-v0.1.2.spkg - prom: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.2/substreams-sink-prometheus-v0.1.2.spkg + prom: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.3/substreams-sink-prometheus-v0.1.3.spkg protobuf: files: diff --git a/eosmechanics/Cargo.toml b/eosmechanics/Cargo.toml index df1247d..a0c1276 100644 --- a/eosmechanics/Cargo.toml +++ b/eosmechanics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "eosmechanics" -version = "0.3.0" +version = "0.3.1" authors = ["Denis ", "Fred ", "Charles "] description = "Block Producer Benchmarks" license = "MIT OR Apache-2.0" diff --git a/eosmechanics/Makefile b/eosmechanics/Makefile index 9fe3ad2..67eb962 100644 --- a/eosmechanics/Makefile +++ b/eosmechanics/Makefile @@ -27,11 +27,11 @@ info: .PHONY: run run: - substreams run -e eos.firehose.eosnation.io:9001 map_producer_usage -s 292442484 -t +100000 -o jsonl + substreams run -e eos.firehose.eosnation.io:9001 prom_out -s 292442484 -t +100000 -o jsonl .PHONY: gui gui: - substreams gui -e eos.firehose.eosnation.io:9001 map_producer_usage -s 292103130 -t +100000 + substreams gui -e eos.firehose.eosnation.io:9001 prom_out -s 292103130 -t +100000 .PHONY: sink sink: diff --git a/eosmechanics/proto/v1/prometheus.proto b/eosmechanics/proto/v1/prometheus.proto deleted file mode 100644 index e76249a..0000000 --- a/eosmechanics/proto/v1/prometheus.proto +++ /dev/null @@ -1,50 +0,0 @@ -syntax = "proto3"; - -package pinax.substreams.sink.prometheus.v1; - -option go_package = "github.com/pinax-network/substreams-sink-prometheus/pb;pbkv"; - -// List of Prometheus metrics -message PrometheusOperations { - repeated PrometheusOperation operations = 1; -} - -message PrometheusOperation { - Metrics metric = 1; // Prometheus metric type (COUNTER, GAUGE, HISTOGRAM, SUMMARY) - Operations operation = 2; // Prometheus metric operation - string name = 3; // Name of the Prometheus metric - double value = 4; // Value (Float) to be used in the operation - repeated string labels = 5; // Labels to be used in Metric -} - -enum Metrics { - // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified - METRICS_UNSPECIFIED = 0; - // Prometheus metric of type 'Counter' - METRICS_COUNTER = 1; - // Prometheus metric of type 'Gauge' - METRICS_GAUGE = 2; - // Prometheus metric of type 'Histogram' - METRICS_HISTOGRAM = 3; - // Prometheus metric of type 'Summary' - METRICS_SUMMARY = 4; -} - -enum Operations { - // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified - OPERATIONS_UNSPECIFIED = 0; - // Set sets the Gauge to an arbitrary value. - OPERATIONS_SET = 1; // float - // Inc increments the Gauge by 1. Use Add to increment it by arbitrary values. - OPERATIONS_INC = 2; - // Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary values. - OPERATIONS_DEC = 3; - // Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.) - OPERATIONS_ADD = 4; // float - // Sub subtracts the given value from the Gauge. (The value can be negative, resulting in an increase of the Gauge.) - OPERATIONS_SUB = 5; // float - // SetToCurrentTime sets the Gauge to the current Unix time in seconds. - OPERATIONS_SET_TO_CURRENT_TIME = 7; - // Reset metric - OPERATIONS_RESET = 8; -} \ No newline at end of file diff --git a/eosmechanics/src/sinks.rs b/eosmechanics/src/sinks.rs index 0de326b..1fe8ef5 100644 --- a/eosmechanics/src/sinks.rs +++ b/eosmechanics/src/sinks.rs @@ -1,6 +1,6 @@ use substreams::errors::Error; use substreams::log; -use substreams_sink_prometheus::PrometheusOperations; +use substreams_sink_prometheus::{PrometheusOperations, Counter, Gauge}; use crate::eosmechanics::{ProducerUsage, ScheduleChange}; @@ -16,15 +16,17 @@ pub fn prom_out( // SET producer CPU usage if !producer.is_empty() { log::info!("SET producer_usage={:?}", producer_usage); - prom_out.push_set("producer_usage", producer_usage.cpu_usage as f64, vec![producer.as_str()]); + let mut gauge = Gauge::new("producer_usage"); + gauge.set_label(producer.as_str()); + prom_out.push(gauge.set(producer_usage.cpu_usage as f64)); // INC action count - prom_out.push_inc("action_count", vec![]); + prom_out.push(Counter::new("action_count").inc()); } // SET schedule version if !schedule_change.pending_schedule.is_empty() { - prom_out.push_set("schedule_version", schedule_change.schedule_version as f64, vec![]); + prom_out.push(Gauge::new("schedule_version").set(schedule_change.schedule_version as f64)); } // RESET remove producer diff --git a/eosmechanics/substreams.yaml b/eosmechanics/substreams.yaml index 4ab7902..26bd55d 100644 --- a/eosmechanics/substreams.yaml +++ b/eosmechanics/substreams.yaml @@ -1,12 +1,12 @@ specVersion: v0.1.0 package: name: eosmechanics - version: v0.3.0 + version: v0.3.1 url: https://github.com/pinax-network/substreams doc: Block Producer Benchmarks -# import: -# prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.1/substreams-sink-prometheus-v0.1.1.spkg +imports: + prometheus: https://github.com/pinax-network/substreams-sink-prometheus/releases/download/v0.1.3/substreams-sink-prometheus-v0.1.3.spkg binaries: default: @@ -16,7 +16,7 @@ binaries: protobuf: files: - eosmechanics.proto - - prometheus.proto + importPaths: - proto/v1 diff --git a/params/Cargo.toml b/params/Cargo.toml index eb19c18..6acb365 100644 --- a/params/Cargo.toml +++ b/params/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -substreams = "0.5.2" +substreams = { workspace = true }