Skip to content

Commit 22661d7

Browse files
authored
feat: Add basic Grafana/Prometheus infra (#12)
- Add grafana/prometheus to run locally - Add declarative dashboard generator - Fix a bunch of issue with exported metrics
1 parent 8714144 commit 22661d7

File tree

19 files changed

+1322
-7
lines changed

19 files changed

+1322
-7
lines changed

ethereum_prover/configs/ethproofs_prod.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ eth_prover:
88
block_mod: 100
99
prover_id: 0
1010
on_failure: "continue"
11+
prometheus_port: 9898

ethereum_prover/configs/ethproofs_staging.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ eth_prover:
88
block_mod: 10
99
prover_id: 0
1010
on_failure: "continue"
11+
prometheus_port: 9898

ethereum_prover/configs/local_debug.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ eth_prover:
77
ethproofs_submission: "off"
88
block_mod: 1
99
prover_id: 0
10-
on_failure: "exit"
10+
on_failure: "continue"
11+
prometheus_port: 9898
1112

ethereum_prover/src/clients/ethproofs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl EthproofsClient {
9393
payload: &T,
9494
context: &'static str,
9595
) -> anyhow::Result<()> {
96-
let latency = METRICS.ethproofs_request_duration_seconds.start();
96+
let latency = METRICS.ethproofs_request_duration.start();
9797
for attempt in 1..=MAX_ATTEMPTS {
9898
let response = self
9999
.client

ethereum_prover/src/metrics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ pub struct ProverMetrics {
1212
pub witness_success_total: Counter<u64>,
1313
pub witness_failure_total: Counter<u64>,
1414
#[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)]
15-
pub witness_duration_seconds: Histogram<Duration>,
15+
pub witness_duration: Histogram<Duration>,
1616
pub inflight_witness_tasks: Gauge<u64>,
1717
pub proof_success_total: Counter<u64>,
1818
pub proof_failure_total: Counter<u64>,
1919
#[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)]
20-
pub proof_duration_seconds: Histogram<Duration>,
20+
pub proof_duration: Histogram<Duration>,
2121
pub inflight_proof_tasks: Gauge<u64>,
2222
pub last_processed_block: Gauge<u64>,
2323
pub ethproofs_request_success_total: Counter<u64>,
2424
pub ethproofs_request_failure_total: Counter<u64>,
2525
#[metrics(buckets = Buckets::LATENCIES, unit = Unit::Seconds)]
26-
pub ethproofs_request_duration_seconds: Histogram<Duration>,
26+
pub ethproofs_request_duration: Histogram<Duration>,
2727
}
2828

2929
#[vise::register]

ethereum_prover/src/tasks/cpu_witness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl CpuWitnessTask {
5555
);
5656
let block_number = witness.block_header.number;
5757
let _inflight = InflightGuard::new(&METRICS.inflight_witness_tasks);
58-
let latency = METRICS.witness_duration_seconds.start();
58+
let latency = METRICS.witness_duration.start();
5959
match self.process_block(witness).await {
6060
Ok(cpu_witness) => {
6161
tracing::info!("Generated CPU witness for block {}", block_number);

ethereum_prover/src/tasks/gpu_prove.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl GpuProveTask {
4343
);
4444
let block_number = witness.block_header.number;
4545
let _inflight = InflightGuard::new(&METRICS.inflight_proof_tasks);
46-
let latency = METRICS.proof_duration_seconds.start();
46+
let latency = METRICS.proof_duration.start();
4747
self.command_sender
4848
.send(CalculationUpdate::ProofQueued { block_number })
4949
.await

infra/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Infra: Local Metrics Stack
2+
3+
This folder contains a local Prometheus + Grafana setup for `ethereum_prover`, plus a
4+
TypeScript (Grafana Foundation SDK) dashboard generator.
5+
6+
## Layout
7+
8+
- `infra/docker-compose.yml`: Prometheus + Grafana services.
9+
- `infra/prometheus/prometheus.yml`: Prometheus scrape config (targets host at `9898`).
10+
- `infra/grafana/provisioning/`: Grafana datasource + dashboard provisioning.
11+
- `infra/grafana/dashboards/`: Generated dashboard JSON output.
12+
- `infra/dashboards/`: Dashboard source (TypeScript) and build script.
13+
14+
## Prerequisites
15+
16+
- `docker` + `docker compose`
17+
- `node` + `yarn` (for dashboard generation)
18+
- `ethereum_prover` running on host with metrics enabled:
19+
- `eth_prover_prometheus_port=9898`
20+
21+
## Generate dashboards
22+
23+
From repo root:
24+
25+
```sh
26+
./infra/dashboards/build.sh
27+
```
28+
29+
This writes `infra/grafana/dashboards/ethereum-prover.json`.
30+
31+
## Run Prometheus + Grafana
32+
33+
```sh
34+
docker compose -f infra/docker-compose.yml up
35+
```
36+
37+
Grafana: http://localhost:3000
38+
39+
Prometheus: http://localhost:9090
40+
41+
## Notes
42+
43+
- Prometheus scrapes `host.docker.internal:9898`. On Linux, `host.docker.internal`
44+
is provided via `extra_hosts: host-gateway` in the compose file.

infra/dashboards/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist
2+
/node_modules
3+
/wasm

infra/dashboards/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
cd "$script_dir"
6+
7+
yarn install
8+
yarn build

0 commit comments

Comments
 (0)