Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] feat: difficulty metrics to Grafana #3194

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions node/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ impl<N: Network> Consensus<N> {
let num_sol = next_block.solutions().len();
let num_tx = next_block.transactions().len();
let num_transmissions = num_tx + num_sol;
let proof_target = next_block.header().proof_target();
let coinbase_target = next_block.header().coinbase_target();
let cumulative_proof_target = next_block.header().cumulative_proof_target();

metrics::gauge(metrics::blocks::HEIGHT, next_block.height() as f64);
metrics::increment_gauge(metrics::blocks::SOLUTIONS, num_sol as f64);
Expand All @@ -431,6 +434,9 @@ impl<N: Network> Consensus<N> {
metrics::gauge(metrics::consensus::COMMITTED_CERTIFICATES, num_committed_certificates as f64);
metrics::histogram(metrics::consensus::CERTIFICATE_COMMIT_LATENCY, elapsed.as_secs_f64());
metrics::histogram(metrics::consensus::BLOCK_LATENCY, block_latency as f64);
metrics::gauge(metrics::blocks::PROOF_TARGET, proof_target as f64);
metrics::gauge(metrics::blocks::COINBASE_TARGET, coinbase_target as f64);
metrics::gauge(metrics::blocks::CUMULATIVE_PROOF_TARGET, cumulative_proof_target as f64);
}
Ok(())
}
Expand Down
129 changes: 128 additions & 1 deletion node/metrics/snarkOS-grafana.json
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,17 @@
"mode": "off"
}
},
"displayName": "Total Transmissions",
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
Expand All @@ -658,6 +661,130 @@
"x": 12,
"y": 17
},
"id": 53,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"maxHeight": 600,
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"disableTextWrap": false,
"editorMode": "code",
"expr": "max(snarkos_blocks_coinbase_target)",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"interval": "",
"legendFormat": "Coinbase Target",
"range": true,
"refId": "A",
"useBackend": false
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "max(snarkos_blocks_proof_target)",
"hide": false,
"instant": false,
"legendFormat": "Proof Target",
"range": true,
"refId": "B"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "max(snarkos_blocks_cumulative_proof_target)",
"hide": false,
"instant": false,
"legendFormat": "Cumulative Proof Target",
"range": true,
"refId": "C"
}
],
"title": "Difficulty",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"displayName": "Total Transmissions",
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 25
},
"id": 42,
"options": {
"legend": {
Expand Down
8 changes: 7 additions & 1 deletion node/metrics/src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED];

pub(super) const GAUGE_NAMES: [&str; 18] = [
pub(super) const GAUGE_NAMES: [&str; 21] = [
bft::CONNECTED,
bft::CONNECTING,
bft::LAST_STORED_ROUND,
Expand All @@ -24,6 +24,9 @@ pub(super) const GAUGE_NAMES: [&str; 18] = [
blocks::SOLUTIONS,
blocks::TRANSACTIONS,
blocks::TRANSMISSIONS,
blocks::PROOF_TARGET,
blocks::COINBASE_TARGET,
blocks::CUMULATIVE_PROOF_TARGET,
consensus::COMMITTED_CERTIFICATES,
consensus::LAST_COMMITTED_ROUND,
consensus::UNCONFIRMED_SOLUTIONS,
Expand Down Expand Up @@ -60,6 +63,9 @@ pub mod blocks {
pub const TRANSACTIONS: &str = "snarkos_blocks_transactions_total";
pub const TRANSMISSIONS: &str = "snarkos_blocks_transmissions_total";
pub const SOLUTIONS: &str = "snarkos_blocks_solutions_total";
pub const PROOF_TARGET: &str = "snarkos_blocks_proof_target";
pub const COINBASE_TARGET: &str = "snarkos_blocks_coinbase_target";
pub const CUMULATIVE_PROOF_TARGET: &str = "snarkos_blocks_cumulative_proof_target";
}

pub mod consensus {
Expand Down