Grafana
Chapter 39: Grafana Dashboards
Section titled βChapter 39: Grafana DashboardsβOverview
Section titled βOverviewβGrafana is a powerful open-source visualization and monitoring platform that integrates seamlessly with Prometheus and other metrics backends. This chapter covers setting up Grafana dashboards for comprehensive blockchain node monitoring.
39.1 Grafana Setup
Section titled β39.1 Grafana SetupβInstallation
Section titled βInstallationβ# Ubuntu/Debiansudo apt-get updatesudo apt-get install -y grafana
# Or use Dockerdocker run -d \ --name grafana \ -p 3000:3000 \ -v grafana-data:/var/lib/grafana \ grafana/grafana
# Start and enablesudo systemctl start grafana-serversudo systemctl enable grafana-serverInitial Configuration
Section titled βInitial Configurationβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ GRAFANA INITIAL SETUP ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ 1. Access Grafana at http://localhost:3000 ββ 2. Default credentials: admin / admin ββ 3. Change password on first login ββ 4. Add Prometheus data source ββ 5. Import or create dashboards ββ ββ Configuration Files: ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β /etc/grafana/grafana.ini - Main configuration β ββ β /etc/grafana/provisioning/ - Data sources & dashboards β ββ β /var/lib/grafana/dashboards/ - Custom dashboards β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββAdding Prometheus Data Source
Section titled βAdding Prometheus Data Sourceβ# Or configure via APIcurl -X POST http://admin:admin@localhost:3000/api/datasources \ -H "Content-Type: application/json" \ -d '{ "name": "Prometheus", "type": "prometheus", "url": "http://localhost:9090", "access": "proxy", "isDefault": true }'39.2 Essential Ethereum Node Metrics
Section titled β39.2 Essential Ethereum Node MetricsβKey Metrics to Monitor
Section titled βKey Metrics to Monitorβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ KEY METRICS FOR BLOCKCHAIN NODES ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ BLOCKCHAIN METRICS: ββ ββββββββββββββββββββ ββ ββ Metric Description ββ βββββββββββββββββββββββββββββββββββββββββ ββ chain_head_block Current block height ββ chain_head_header Latest header seen ββ chain_head_reorg Reorg count ββ increase(chain_head_block Sync stalled alert (ch38) ββ [10m]) == 0 ββ ββ NETWORK METRICS: ββ βββββββββββββββββ ββ ββ Metric Description ββ βββββββββββββββββββββββββββββββββββββββββ ββ p2p_peers Number of connected peers ββ p2p_dials{error=...} Dial attempts (labeled) ββ p2p_ingress/egress_traffic P2P bytes in/out ββ ββ TRANSACTION POOL: ββ ββββββββββββββββ ββ ββ Metric Description ββ βββββββββββββββββββββββββββββββββββββββββ ββ txpool_pending Pending transactions ββ txpool_queued Queued transactions ββ txpool_invalid Rejected transactions ββ ββ NODE PERFORMANCE: ββ ββββββββββββββββββ ββ ββ Metric Description ββ βββββββββββββββββββββββββββββββββββββββββ ββ process_cpu_seconds_total CPU usage ββ process_resident_memory_bytes Memory usage ββ go_memstats_heap_alloc_bytes Heap allocation ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ39.3 Recommended Dashboards
Section titled β39.3 Recommended DashboardsβPopular Grafana Dashboard IDs
Section titled βPopular Grafana Dashboard IDsβ| Dashboard | ID | Source | Description |
|---|---|---|---|
| Ethereum Metrics | 14611 | Community | Comprehensive Ethereum node metrics |
| Node Exporter Full | 1860 | Community | System-level metrics |
| Blockchain Dashboard | 13516 | Community | General blockchain monitoring |
| Ethereum 2.0 | 13713 | Community | Validator metrics |
| Generic Prometheus | 10000 | Built-in | Custom metrics |
Importing Dashboards
Section titled βImporting Dashboardsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ IMPORTING DASHBOARDS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Method 1: Via Grafana UI ββ ββββββββββββββββββββββββ ββ 1. Navigate to Dashboards β Import ββ 2. Enter dashboard ID (e.g., 14611) ββ 3. Select Prometheus data source ββ 4. Click Import ββ ββ Method 2: Via JSON file ββ βββββββββββββββββββββββ ββ 1. Download dashboard JSON ββ 2. Dashboards β Import β Upload JSON ββ 3. Select data source and import ββ ββ Method 3: Via Provisioning ββ ββββββββββββββββββββββ ββ Create /etc/grafana/provisioning/dashboards/dashboards.yml: ββ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β apiVersion: 1 β ββ β β ββ β providers: β ββ β - name: 'Dashboards' β ββ β orgId: 1 β ββ β folder: '' β ββ β type: file β ββ β options: β ββ β path: /var/lib/grafana/dashboards β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ39.4 Creating Custom Dashboards
Section titled β39.4 Creating Custom DashboardsβPanel Types
Section titled βPanel Typesβ| Panel Type | Use Case |
|---|---|
| Graph | Time series data (block times, peer count) |
| Stat | Current values (block number, sync status) |
| Gauge | Percentage values (CPU, memory usage) |
| Table | Tabular data (peer list, transaction details) |
| Heatmap | Historical patterns |
Sample Prometheus Queries
Section titled βSample Prometheus Queriesβ# Block Production Rate (blocks per minute)rate(eth_block_number[1m])
# Current Block Heighteth_block_number
# Peer Countp2p_peers
# Memory Usage (bytes to GB)process_resident_memory_bytes / 1024 / 1024 / 1024
# CPU Usage %rate(process_cpu_seconds_total[5m]) * 100
# Transaction Pool Sizetxpool_pending + txpool_queued
# Sync Progress %(eth_block_number / eth_head_block_number) * 100
# Average Block Timerate(eth_block_header_slot_seconds_sum[1h]) / rate(eth_block_header_slot_seconds_count[1h])Dashboard JSON Example
Section titled βDashboard JSON Exampleβ{ "dashboard": { "title": "Ethereum Node Dashboard", "panels": [ { "title": "Block Height", "type": "stat", "targets": [ { "expr": "eth_block_number", "legendFormat": "Current Block" } ] }, { "title": "Peer Count", "type": "graph", "targets": [ { "expr": "p2p_peers", "legendFormat": "Peers" } ] }, { "title": "Memory Usage", "type": "gauge", "targets": [ { "expr": "process_resident_memory_bytes / 1024 / 1024 / 1024", "legendFormat": "GB" } ], "field": { "max": 16, "min": 0 } } ] }}39.5 Alerting Configuration
Section titled β39.5 Alerting ConfigurationβSetting Up Alerts
Section titled βSetting Up Alertsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ GRAFANA ALERTING SETUP ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ 1. Enable alerting in grafana.ini: ββ [unified_alerts] ββ enabled = true ββ ββ 2. Configure notification channel: ββ - Email ββ - Slack ββ - PagerDuty ββ - Webhook ββ ββ 3. Create alert rules on panels: ββ - Set conditions ββ - Configure notifications ββ - Add annotations ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSample Alert Rules
Section titled βSample Alert Rulesβ# alerting_rules.yml (can be imported to Grafana)groups: - name: ethereum_node interval: 30s rules: - alert: NodeDown expr: up{job="ethereum"} == 0 for: 2m labels: severity: critical annotations: summary: "Ethereum node is down"
- alert: HighPeerCount expr: p2p_peers < 10 for: 5m labels: severity: warning annotations: summary: "Low peer count: {{ $value }}"
- alert: HighMemory expr: process_resident_memory_bytes > 16000000000 for: 5m labels: severity: warning annotations: summary: "High memory usage"
- alert: SyncStalled expr: increase(chain_head_block[10m]) == 0 for: 10m labels: severity: critical annotations: summary: "Node sync is stalled"39.6 Interview Questions
Section titled β39.6 Interview Questionsβ| Question | Answer |
|---|---|
| What is Grafana? | Open-source visualization and monitoring platform |
| What data source does Grafana commonly use with blockchain nodes? | Prometheus |
| What are key Ethereum node metrics to monitor? | Block height, peer count, memory, CPU, sync status |
| How do you set up alerts in Grafana? | Create alert rules on panels, configure notification channels |
| What dashboard ID for Ethereum metrics? | 14611 |
Summary
Section titled βSummaryβ- Grafana provides powerful visualization for node monitoring
- Use community dashboards for quick setup
- Create custom dashboards for specific needs
- Set up alerting for proactive monitoring
- Integrate with Prometheus for metrics collection
Next Chapter
Section titled βNext ChapterβIn Chapter 40: Health Checks & Uptime, weβll explore health monitoring.
Last Updated: 2026-02-20