Skip to content

Commit 3a597c1

Browse files
committed
feat: add available data services metric
1 parent eb1ed8b commit 3a597c1

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed

crates/batcher/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,9 @@ impl Batcher {
19111911
warn!("Failed to upload batch to secondary S3");
19121912
}
19131913

1914+
// Update metrics with number of available data services
1915+
self.metrics.available_data_services.set(successful_urls.len() as i64);
1916+
19141917
// If no uploads succeeded, return error
19151918
if successful_urls.is_empty() {
19161919
error!("Failed to upload batch to both S3 buckets");

crates/batcher/src/metrics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub struct BatcherMetrics {
2727
pub cancel_create_new_task_duration: IntGauge,
2828
pub batcher_gas_cost_create_task_total: GenericCounter<AtomicF64>,
2929
pub batcher_gas_cost_cancel_task_total: GenericCounter<AtomicF64>,
30+
pub available_data_services: IntGauge,
3031
}
3132

3233
impl BatcherMetrics {
@@ -79,6 +80,10 @@ impl BatcherMetrics {
7980
"batcher_gas_cost_cancel_task_total",
8081
"Batcher Gas Cost Cancel Task Total"
8182
))?;
83+
let available_data_services = register_int_gauge!(opts!(
84+
"available_data_services",
85+
"Number of available data services (0-2)"
86+
))?;
8287

8388
registry.register(Box::new(open_connections.clone()))?;
8489
registry.register(Box::new(received_proofs.clone()))?;
@@ -96,6 +101,7 @@ impl BatcherMetrics {
96101
registry.register(Box::new(cancel_create_new_task_duration.clone()))?;
97102
registry.register(Box::new(batcher_gas_cost_create_task_total.clone()))?;
98103
registry.register(Box::new(batcher_gas_cost_cancel_task_total.clone()))?;
104+
registry.register(Box::new(available_data_services.clone()))?;
99105

100106
let metrics_route = warp::path!("metrics")
101107
.and(warp::any().map(move || registry.clone()))
@@ -124,6 +130,7 @@ impl BatcherMetrics {
124130
cancel_create_new_task_duration,
125131
batcher_gas_cost_create_task_total,
126132
batcher_gas_cost_cancel_task_total,
133+
available_data_services,
127134
})
128135
}
129136

grafana/provisioning/dashboards/aligned/aggregator_batcher.json

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"editable": true,
1919
"fiscalYearStartMonth": 0,
2020
"graphTooltip": 0,
21-
"id": 2,
21+
"id": 4,
2222
"links": [],
2323
"liveNow": false,
2424
"panels": [
@@ -1786,6 +1786,84 @@
17861786
"title": "Total Batcher Restarts",
17871787
"type": "stat"
17881788
},
1789+
{
1790+
"datasource": {
1791+
"type": "prometheus",
1792+
"uid": "prometheus"
1793+
},
1794+
"description": "",
1795+
"fieldConfig": {
1796+
"defaults": {
1797+
"color": {
1798+
"mode": "thresholds"
1799+
},
1800+
"mappings": [],
1801+
"max": 2,
1802+
"min": 0,
1803+
"thresholds": {
1804+
"mode": "absolute",
1805+
"steps": [
1806+
{
1807+
"color": "green",
1808+
"value": null
1809+
},
1810+
{
1811+
"color": "red",
1812+
"value": 0
1813+
},
1814+
{
1815+
"color": "orange",
1816+
"value": 1
1817+
},
1818+
{
1819+
"color": "green",
1820+
"value": 2
1821+
}
1822+
]
1823+
},
1824+
"unit": "none"
1825+
},
1826+
"overrides": []
1827+
},
1828+
"gridPos": {
1829+
"h": 5,
1830+
"w": 3,
1831+
"x": 17,
1832+
"y": 25
1833+
},
1834+
"id": 64,
1835+
"options": {
1836+
"colorMode": "value",
1837+
"graphMode": "area",
1838+
"justifyMode": "auto",
1839+
"orientation": "auto",
1840+
"reduceOptions": {
1841+
"calcs": [
1842+
"lastNotNull"
1843+
],
1844+
"fields": "",
1845+
"values": false
1846+
},
1847+
"textMode": "auto"
1848+
},
1849+
"pluginVersion": "10.1.10",
1850+
"targets": [
1851+
{
1852+
"datasource": {
1853+
"type": "prometheus",
1854+
"uid": "prometheus"
1855+
},
1856+
"editorMode": "code",
1857+
"expr": "available_data_services{job=\"aligned-batcher\"}",
1858+
"instant": false,
1859+
"legendFormat": "__auto",
1860+
"range": true,
1861+
"refId": "A"
1862+
}
1863+
],
1864+
"title": "Available Data Services",
1865+
"type": "stat"
1866+
},
17891867
{
17901868
"datasource": {
17911869
"type": "prometheus",
@@ -3929,7 +4007,8 @@
39294007
"mode": "absolute",
39304008
"steps": [
39314009
{
3932-
"color": "green"
4010+
"color": "green",
4011+
"value": null
39334012
}
39344013
]
39354014
},
@@ -4024,7 +4103,8 @@
40244103
"mode": "absolute",
40254104
"steps": [
40264105
{
4027-
"color": "green"
4106+
"color": "green",
4107+
"value": null
40284108
},
40294109
{
40304110
"color": "red",
@@ -4120,7 +4200,8 @@
41204200
"mode": "absolute",
41214201
"steps": [
41224202
{
4123-
"color": "green"
4203+
"color": "green",
4204+
"value": null
41244205
},
41254206
{
41264207
"color": "red",
@@ -4251,7 +4332,8 @@
42514332
"mode": "absolute",
42524333
"steps": [
42534334
{
4254-
"color": "green"
4335+
"color": "green",
4336+
"value": null
42554337
},
42564338
{
42574339
"color": "red",
@@ -4301,21 +4383,21 @@
43014383
"type": "timeseries"
43024384
}
43034385
],
4304-
"refresh": "",
4386+
"refresh": "5s",
43054387
"schemaVersion": 38,
43064388
"style": "dark",
43074389
"tags": [],
43084390
"templating": {
43094391
"list": []
43104392
},
43114393
"time": {
4312-
"from": "now-1h",
4394+
"from": "now-15m",
43134395
"to": "now"
43144396
},
43154397
"timepicker": {},
43164398
"timezone": "browser",
43174399
"title": "System Data",
43184400
"uid": "aggregator",
4319-
"version": 6,
4401+
"version": 18,
43204402
"weekStart": ""
4321-
}
4403+
}

0 commit comments

Comments
 (0)