Overview
Viction provides comprehensive metrics collection for monitoring node health, performance, and resource usage. The metrics system is based on the go-metrics library and can export data to various monitoring systems.
Enabling Metrics
Basic Metrics
Enable standard metrics collection:
This enables basic health and performance metrics with minimal overhead.
Expensive Metrics
Enable detailed metrics including resource-intensive measurements:
Expensive metrics can impact node performance. Only enable on nodes with sufficient resources and when detailed monitoring is required.
HTTP Metrics Endpoint
Expose metrics via HTTP for scraping by monitoring systems:
Access metrics:
Options:
--metrics.addr: HTTP server listening interface (default: 127.0.0.1)
--metrics.port: HTTP server listening port (default: 6060)
Never expose the metrics endpoint to the public internet. Always bind to localhost or use firewall rules to restrict access to trusted monitoring systems.
System Metrics
Viction automatically collects system-level metrics every 3 seconds:
CPU Metrics
Memory Metrics
Disk Metrics
Runtime Metrics
Go runtime metrics provide insight into application performance:
Memory Statistics
Garbage Collection
Runtime Details
Blockchain Metrics
Monitor blockchain-specific operations:
Block Processing
Track block import and processing:
- Block import time
- Block size
- Transaction count per block
- Gas used per block
- Uncle rate
Transaction Pool
Monitor mempool activity:
- Pending transactions
- Queued transactions
- Transaction replacement rate
- Pool size limits
P2P Networking
Network connectivity metrics:
- Active peer count
- Peer connect/disconnect events
- Inbound/outbound connections
- Data sent/received per peer
- Protocol handshake success rate
Consensus
PoSV consensus metrics:
- Validator status
- Block signing success rate
- Missed blocks
- Checkpoint events
Metric Types
Viction uses several metric types:
Counter
Monotonically increasing values:
Gauge
Values that can increase or decrease:
Meter
Measures rate of events:
Provides:
- Count
- Mean rate
- 1/5/15 minute moving average
Timer
Measures duration and rate:
Provides:
- Count
- Mean/min/max duration
- Percentiles (50th, 75th, 95th, 99th, 99.9th)
- Rate metrics
Histogram
Measures distribution of values:
Provides:
- Count
- Mean/min/max
- Percentiles
Monitoring Integrations
Prometheus
Export metrics to Prometheus:
- Enable metrics HTTP endpoint:
- Configure Prometheus scraping (
prometheus.yml):
- Query metrics in Prometheus:
Grafana
Visualize metrics with Grafana:
- Add Prometheus data source
- Import Viction dashboard template
- Create custom dashboards for your needs
Example dashboard panels:
- CPU and memory usage over time
- Block height and sync status
- Transaction pool size
- Peer count
- Disk I/O rates
InfluxDB
The metrics library supports InfluxDB export for time-series storage.
Graphite
Export to Graphite for legacy monitoring systems.
Monitoring Best Practices
Alert Thresholds
Set alerts for critical conditions:
High priority:
- Node not syncing (block height not increasing)
- Peer count below minimum (< 3)
- Disk space below 10%
- Memory usage above 90%
- Masternode missing blocks
Medium priority:
- High CPU usage (> 80% sustained)
- Large transaction pool (> 1000 pending)
- Slow block processing
- GC pause time increasing
Low priority:
- Peer churn rate high
- Transaction replacement rate high
Monitoring Queries
Check sync status:
Check peer count:
Check block number:
Resource Planning
Monitor trends to plan capacity:
- Database growth rate: Track disk usage over time
- Memory requirements: Monitor peak memory usage
- CPU utilization: Identify bottlenecks
- Network bandwidth: Plan for peak loads
Health Checks
Implement automated health checks:
Log Analysis
Monitor logs for important events:
Successful block creation (masternode):
Block import:
Peer connections:
Errors:
Use metrics to optimize performance:
- High GC pause time: Increase GOGC environment variable
- High memory usage: Reduce cache sizes
- Slow disk I/O: Use faster storage (SSD/NVMe)
- CPU bottlenecks: Increase worker threads
- Network saturation: Adjust max peers
Monitoring Checklist