Metrics
Chapter 36: Node Metrics & Prometheus
Section titled “Chapter 36: Node Metrics & Prometheus”Overview
Section titled “Overview”Monitoring your blockchain node is essential for maintaining performance, detecting issues, and ensuring uptime.
36.1 Why Monitor?
Section titled “36.1 Why Monitor?”┌─────────────────────────────────────────────────────────────────┐│ MONITORING OBJECTIVES │├─────────────────────────────────────────────────────────────────┤│ ││ 1. PERFORMANCE ││ - Track sync progress ││ - Monitor resource usage ││ ││ 2. AVAILABILITY ││ - Detect node downtime ││ - Alert on failures ││ ││ 3. SECURITY ││ - Detect unusual patterns ││ - Monitor access attempts ││ ││ 4. CAPACITY PLANNING ││ - Track storage growth ││ - Plan upgrades ││ │└─────────────────────────────────────────────────────────────────┘36.2 Enabling Metrics
Section titled “36.2 Enabling Metrics”Geth Metrics
Section titled “Geth Metrics”# Enable metricsgeth --metrics --metrics.addr 0.0.0.0 --metrics.port 6060Metrics Endpoint
Section titled “Metrics Endpoint”http://localhost:6060/debug/metricshttp://localhost:6060/debug/metrics/prometheus36.3 Key Metrics to Track
Section titled “36.3 Key Metrics to Track”Sync Metrics
Section titled “Sync Metrics”| Metric | Description |
|---|---|
eth_block_number | Current block height |
eth_head_header | Latest header number |
eth_syncing | Sync progress |
Performance Metrics
Section titled “Performance Metrics”| Metric | Description |
|---|---|
process_cpu_seconds | CPU usage |
process_memory | Memory usage |
node_disk_io | Disk I/O |
Network Metrics
Section titled “Network Metrics”| Metric | Description |
|---|---|
p2p_peers | Number of connected peers |
p2p_dial_connections | Outgoing connections |
p2p_recv_messages | Messages received |
36.4 Prometheus Configuration
Section titled “36.4 Prometheus Configuration”Install Prometheus
Section titled “Install Prometheus”# Downloadwget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
# Extracttar xzf prometheus-2.45.0.linux-amd64.tar.gz
# Run./prometheus --config.file=prometheus.ymlprometheus.yml
Section titled “prometheus.yml”global: scrape_interval: 15s
scrape_configs: - job_name: 'geth' static_configs: - targets: ['localhost:6060']36.5 Grafana Dashboards
Section titled “36.5 Grafana Dashboards”Import Dashboard
Section titled “Import Dashboard”- Install Grafana
- Add Prometheus data source
- Import dashboard:
- Ethereum: Dashboard ID
14611 - Generic: Create custom
- Ethereum: Dashboard ID
Key Dashboards
Section titled “Key Dashboards”| Dashboard | Description |
|---|---|
| Block Production | Block times, empty blocks |
| Node Health | CPU, memory, disk |
| Network | Peers, transaction pool |
| Consensus | Validator performance |
36.6 Alerting
Section titled “36.6 Alerting”Prometheus Alerts
Section titled “Prometheus Alerts”groups: - name: geth-alerts rules: - alert: NodeDown expr: up{job="geth"} == 0 for: 5m labels: severity: critical annotations: summary: "Geth node is down"
- alert: NoPeers expr: p2p_peers == 0 for: 5m labels: severity: warning
- alert: SyncStalled expr: eth_syncing == true for: 30m labels: severity: warningSummary
Section titled “Summary”- Enable metrics with
--metricsflag - Track sync, performance, and network metrics
- Use Prometheus + Grafana for monitoring
- Set up alerts for critical issues
Next Chapter
Section titled “Next Chapter”In Chapter 37: Logging & Log Management, we’ll explore logging.
Last Updated: 2026-02-20