Example logrotate config for Bitcoin (/etc/logrotate.d/bitcoin)
Node Monitoring: Auditing debug.log and System Resource Usage
An operator must know the "Vitals" of their node. Monitoring is how you catch disk failure, network congestion, or memory leaks before they crash your node. In this chapter, we explore the deep art of log auditing and system monitoring, turning the opaque stream of data into actionable intelligence for the node administrator.
The debug.log: The Node’s Biological Log
Located in the root of your data directory, debug.log is a record of every heartbeat of the machine. It is where you go when something feels "off."
- The
UpdateTipMessage: This is the most important recurring log. It tells you that your node has successfully processed a new block. - Example:
2024-05-10T12:00:00Z UpdateTip: new best=0000000000000000000431... height=840231 version=0x20000000 log2_work=94.82 tx=98123122 date='2024-05-10T11:58:30Z' progress=1.000000 cache=23.1MiB(234123tx) - Height: The block number.
- log2_work: The total work done by the network (PoW).
- Progress: 1.000000 means you are fully synced.
- Cache: How much of your
dbcacheis currently being used.
Advanced Log Filtering with grep
The debug.log can grow to several gigabytes. You need to use Linux tools to find the signal in the noise.
-
Monitoring for Peer Bans:
grep "Misbehaving" debug.log. This shows peers that sent your node bad data. -
Monitoring for Disk Errors:
grep -i "error" debug.log. Watch for "LevelDB" or "Read" errors, which indicate your SSD is failing. -
Real-time Monitoring:
tail -f debug.log | grep "UpdateTip"allows you to see blocks arriving in real-time.
System Vitals: Measuring the Hardware Load
A node operator should use tools like htop, iotop, and nload to monitor the physical machine.
- CPU (htop):
- Normal: 1-5% usage during idle.
- Peak: 100% usage on multiple cores when a new block arrives and signatures are being verified.
-
Danger: Constant 100% usage might indicate a "Sync Loop" or a local process interfering with the node.
-
Disk I/O (iotop):
-
Bitcoin is a database-heavy application. Watch the "DISK WRITE" column. If your disk is constantly at 100% "IO Utilization," your node will eventually fall behind the network tip. This is common with low-end microSD cards in Raspberry Pis.
-
Network Bandwidth (nload):
- A node with
listen=1can consume 100GB to 500GB of bandwidth per month. Monitor your outgoing traffic to ensure you aren't hitting data caps set by your ISP.
Professional Monitoring: Prometheus and Grafana
For enterprise-grade deployment, "Looking at a log file" isn't enough.
-
Exporter: You can run a "Bitcoin Exporter" (a small side-car program) that pulls data from the bitcoind RPC.
-
Prometheus: A database that records these metrics over time.
-
Grafana: A dashboard that creates beautiful, real-time graphs of your hashrate, peer count, mempool size, and CPU temperature. This allows you to set "Alerts"—your phone will buzz if your node goes offline or its temperature exceeds 80°C.
Log Rotation: Preventing "Disk Full" Crashes
If you don't manage your debug.log, it will eventually fill up your entire hard drive and crash your node.
- The Solution: Use
logrotate. It is a Linux utility that automatically "rotates" the log file once a week, compressing old logs into.gzfiles and deleting the oldest ones.
# Example logrotate config for Bitcoin (/etc/logrotate.d/bitcoin)
/home/bitcoin/.bitcoin/debug.log {
weekly
rotate 4
copytruncate
compress
missingok
}
By monitoring your node with these tools, you transition from a "Hopeful" operator to a "Certain" one. You know the health of your machine, you can predict failures before they happen, and you ensure your contribution to the network is robust and reliable.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: