diff --git a/crates/pbs/src/metrics.rs b/crates/pbs/src/metrics.rs index 917e8047..e3700931 100644 --- a/crates/pbs/src/metrics.rs +++ b/crates/pbs/src/metrics.rs @@ -5,8 +5,8 @@ use lazy_static::lazy_static; use prometheus::{ - register_histogram_vec_with_registry, register_int_counter_vec_with_registry, HistogramVec, - IntCounterVec, Registry, + register_histogram_vec_with_registry, register_int_counter_vec_with_registry, + register_int_gauge_vec_with_registry, HistogramVec, IntCounterVec, IntGaugeVec, Registry, }; lazy_static! { @@ -32,6 +32,15 @@ lazy_static! { ) .unwrap(); + /// Latest slot for which relay delivered a header + pub static ref RELAY_LAST_SLOT: IntGaugeVec = register_int_gauge_vec_with_registry!( + "relay_last_slot", + "Latest slot for which relay delivered a header", + &["relay_id"], + PBS_METRICS_REGISTRY + ) + .unwrap(); + // TO BEACON NODE /// Status code returned to beacon node by endpoint pub static ref BEACON_NODE_STATUS: IntCounterVec = register_int_counter_vec_with_registry!( diff --git a/crates/pbs/src/mev_boost/get_header.rs b/crates/pbs/src/mev_boost/get_header.rs index 97c5f798..df3be77f 100644 --- a/crates/pbs/src/mev_boost/get_header.rs +++ b/crates/pbs/src/mev_boost/get_header.rs @@ -25,7 +25,7 @@ use url::Url; use crate::{ constants::{GET_HEADER_ENDPOINT_TAG, TIMEOUT_ERROR_CODE, TIMEOUT_ERROR_CODE_STR}, - metrics::{RELAY_LATENCY, RELAY_STATUS_CODE}, + metrics::{RELAY_LAST_SLOT, RELAY_LATENCY, RELAY_STATUS_CODE}, state::{BuilderApiState, PbsState}, }; @@ -79,7 +79,10 @@ pub async fn get_header( let relay_id = relays[i].id.as_ref(); match res { - Ok(Some(res)) => relay_bids.push(res), + Ok(Some(res)) => { + RELAY_LAST_SLOT.with_label_values(&[relay_id]).set(params.slot as i64); + relay_bids.push(res) + } Ok(_) => {} Err(err) if err.is_timeout() => error!(err = "Timed Out", relay_id), Err(err) => error!(?err, relay_id), diff --git a/grafana/dashboards/dashboard.json b/grafana/dashboards/dashboard.json index f903affb..a535a43f 100644 --- a/grafana/dashboards/dashboard.json +++ b/grafana/dashboards/dashboard.json @@ -18,16 +18,94 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, + "id": 1, "links": [], "liveNow": true, "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "cb_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "red", + "mode": "thresholds" + }, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "yellow", + "value": null + }, + { + "color": "green", + "value": 100 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 6, + "x": 0, + "y": 0 + }, + "id": 61, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.1.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "cb_prometheus" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "cb_pbs_relay_last_slot", + "format": "time_series", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{relay_id}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Last delivered slot", + "type": "stat" + }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, - "y": 0 + "y": 11 }, "id": 12, "panels": [], @@ -103,7 +181,7 @@ "h": 11, "w": 6, "x": 0, - "y": 1 + "y": 12 }, "id": 11, "options": { @@ -202,7 +280,7 @@ "h": 11, "w": 6, "x": 6, - "y": 1 + "y": 12 }, "id": 13, "options": { @@ -301,7 +379,7 @@ "h": 11, "w": 6, "x": 12, - "y": 1 + "y": 12 }, "id": 43, "options": { @@ -400,7 +478,7 @@ "h": 11, "w": 6, "x": 18, - "y": 1 + "y": 12 }, "id": 44, "options": { @@ -500,7 +578,7 @@ "h": 11, "w": 6, "x": 0, - "y": 12 + "y": 23 }, "id": 20, "options": { @@ -604,7 +682,7 @@ "h": 11, "w": 6, "x": 6, - "y": 12 + "y": 23 }, "id": 29, "options": { @@ -708,7 +786,7 @@ "h": 11, "w": 6, "x": 12, - "y": 12 + "y": 23 }, "id": 30, "options": { @@ -767,6 +845,11 @@ "text": "All", "value": "$__all" }, + { + "selected": false, + "text": "register_validator", + "value": "register_validator" + }, { "selected": false, "text": "get_header", @@ -776,11 +859,6 @@ "selected": false, "text": "submit_blinded_block", "value": "submit_blinded_block" - }, - { - "selected": false, - "text": "register_validator", - "value": "register_validator" } ], "query": "register_validator, get_header, submit_blinded_block", @@ -798,6 +876,6 @@ "timezone": "browser", "title": "PBS Metrics", "uid": "cb_prometheus", - "version": 1, + "version": 2, "weekStart": "" } \ No newline at end of file