Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
Free 30-min Web3 Consultation
Book Now
Smart Contract Security Audits
Learn More
Custom DeFi Protocol Development
Explore
Full-Stack Web3 dApp Development
View Services
LABS
Guides

Setting Up Node Log Collection

A technical guide for developers to implement centralized logging for blockchain nodes. Covers configuration for major clients, log aggregation tools, and parsing strategies for debugging and monitoring.
Chainscore © 2026
introduction
OPERATIONAL GUIDE

Setting Up Node Log Collection

A practical guide to implementing robust log collection for blockchain nodes, covering essential tools, configuration, and best practices for monitoring and debugging.

Effective log collection is the foundation of reliable node operation. Unlike traditional servers, blockchain nodes generate structured logs that detail peer connections, block synchronization, transaction processing, and consensus events. Setting up a collection system allows you to monitor node health, debug issues like stalled syncing or mempool problems, and meet compliance requirements. The core components are a logging agent (like Promtail or Fluentd) to collect logs, a time-series database (like Loki or Elasticsearch) to store them, and a visualization tool (like Grafana) for analysis. This pipeline transforms raw console output into actionable operational intelligence.

The first step is configuring your node's log output. Most clients, including Geth, Erigon, and Prysm, support JSON-structured logging, which is essential for parsing. For Geth, you would start the node with flags like --log.json and redirect output to a file: geth --log.json ... 2>&1 | tee /var/log/geth/console.log. For containerized setups using Docker, ensure logs are written to stdout and stderr so your container runtime (e.g., Docker's json-file driver) can capture them. This setup ensures logs are in a consistent, machine-readable format ready for collection.

Next, deploy a log collection agent. Promtail is a popular, lightweight choice designed for Grafana Loki. A basic promtail-config.yaml targets your node's log file and pushes to a Loki instance. Key configuration includes defining scrape targets with job_name: 'geth' and a static_configs path to /var/log/geth/*.log. For more complex environments, Fluentd or Vector offer greater flexibility for parsing, filtering, and routing logs to multiple destinations like Elasticsearch or cloud storage. The agent runs as a sidecar service, continuously tailing log files and forwarding entries.

Finally, you need a storage and query layer. Grafana Loki is optimized for log aggregation, indexing only metadata (like labels) and compressing log lines, making it cost-effective for high-volume node data. After installing Loki, you configure Promtail to send logs to its HTTP endpoint. The stack is completed with Grafana, where you add Loki as a data source. You can then build dashboards with LogQL queries, such as {job="geth"} |= "Syncing" to track synchronization status or {job="prysm"} | json | latency > 1000 to filter high-latency attestations. This enables real-time alerting and historical analysis.

Beyond the basic setup, consider these operational best practices. Implement log rotation using logrotate to prevent disk exhaustion. Enrich logs with contextual labels (e.g., chain="mainnet", node_type="execution") in your collector config for efficient filtering. For security, ensure sensitive data like private keys or RPC payloads are redacted using your agent's filter plugins. In production, run agents and Loki on separate instances from your node to avoid resource contention. Regularly test your log pipeline and define retention policies (e.g., 30 days of detailed logs, 1 year of aggregated metrics) to manage costs.

prerequisites
PREREQUISITES AND SYSTEM REQUIREMENTS

Setting Up Node Log Collection

Before you can analyze your node's performance and health, you need to configure a robust log collection system. This guide outlines the hardware, software, and initial setup required.

Effective log collection begins with a clear understanding of your node's operational environment. You will need a machine running a Linux-based OS (Ubuntu 20.04 LTS or later is recommended) with stable internet connectivity. Ensure your system has sufficient resources: a minimum of 2 CPU cores, 4 GB of RAM, and at least 20 GB of free disk space dedicated to log storage. For production-grade setups, consider using a dedicated logging server or a cloud instance to separate log aggregation from your primary node operations, improving both performance and security.

The core software prerequisites involve installing and configuring a log shipper and a log aggregator. For most setups, we recommend using the ELK Stack (Elasticsearch, Logstash, Kibana) or a lighter alternative like Loki paired with Promtail and Grafana. You must also have curl, wget, and jq installed for fetching and parsing configuration files. Docker and Docker Compose are highly recommended for containerized deployments, which simplify management and ensure consistency across environments. Verify all installations with commands like docker --version and logstash --version.

Next, configure your node client to output structured logs. For Geth, enable JSON-RPC logging with verbosity flags (e.g., --verbosity 3) and direct output to a file using --log.json. Erigon users should set the --log.dir path and --log.console.verbosity. Besu nodes require configuration in the besu-config.toml file, specifying the logging section with LOG4J format. It is critical to set log rotation policies to prevent disk exhaustion; tools like logrotate can be configured to compress and archive old logs daily.

Finally, establish a secure connection between your node and the log collector. If using a remote aggregator, configure firewall rules to allow traffic on the necessary ports (e.g., 5044 for Logstash Beats, 3100 for Loki). Use SSH tunnels or a VPN for sensitive deployments. Test the pipeline by generating a test log entry on your node and verifying it appears in your Kibana or Grafana dashboard. This initial validation confirms that your prerequisites are correctly met and your collection system is operational, forming the foundation for advanced monitoring and alerting.

key-concepts-text
KEY CONCEPTS IN BLOCKCHAIN LOGGING

Setting Up Node Log Collection

A practical guide to configuring and centralizing logs from blockchain nodes for effective monitoring and debugging.

Effective blockchain node operation requires systematic log collection. Unlike traditional servers, nodes like Geth, Erigon, or Besu generate structured JSON logs containing critical telemetry: peer connections, block synchronization status, transaction pool activity, and consensus events. The first step is to configure your node's logging verbosity. For example, in Geth, you set the --verbosity flag (0=silent, 5=debug). A verbosity of 3 is standard for production, capturing INFO and WARN levels, while debugging requires level 5. Always log to a persistent file using --log.json for machine-readable output and --log.rotate to manage file size.

Centralizing logs is essential for analyzing data across multiple nodes. The ELK Stack (Elasticsearch, Logstash, Kibana) is a common solution. You can use a log shipper like Filebeat to tail the node's JSON log files, parse the entries, and send them to a Logstash pipeline or directly to Elasticsearch. A basic Filebeat configuration (filebeat.yml) would define an input for the Geth log path and an Elasticsearch output. For cloud-native deployments, Loki and Grafana offer a lightweight alternative, using a Promtail agent to ship logs, which are then queried using LogQL.

Parsing structured JSON logs unlocks powerful analytics. In Logstash, you can use the json filter to automatically parse the Geth log's message field. This allows you to index fields like blockNumber, peerID, and txHash separately. In Kibana, you can then create dashboards to visualize sync status, track error rates by type, or alert on specific events like "msg":"Block import failed". For consensus clients like Prysm or Lighthouse, you can correlate logs with execution client data to diagnose missed attestations or proposal failures.

Implementing log rotation and retention policies prevents storage issues. Use the node's built-in rotation (e.g., Geth's --log.rotate) or a system tool like logrotate. A standard policy might keep 7 days of compressed logs locally. Your central log aggregator should have its own retention policy—Elasticsearch uses Index Lifecycle Management (ILM) to roll over indices from hot to cold storage and eventually delete them. This ensures you retain data for forensic analysis without unbounded cost.

Finally, integrate logs with your broader monitoring stack. Key metrics like chain_head_height can be extracted from logs and turned into Prometheus gauges using a tool like mtail or a custom script. This creates a unified view where you can correlate a spike in "level":"error" logs with a drop in peer count on a Grafana dashboard. Always include contextual fields in your logs, such as node_id and network (mainnet, testnet), to filter and aggregate data effectively across your deployment.

CLIENT SUPPORT

Log Configuration Comparison by Node Client

A comparison of native log configuration options and verbosity levels across popular Ethereum execution and consensus clients.

Configuration FeatureGethNethermindLighthouseTeku

Native JSON Logging

Structured Log Format

JSON Lines

NLog (JSON)

Structured (JSON)

Log4j2 (JSON)

Log Level Granularity

6 levels (trace to crit)

5 levels (trace to fatal)

5 levels (trace to error)

5 levels (trace to error)

Per-Module Verbosity

Log Rotation Support

via external tool

via external tool

Default Log Destination

stderr

File & Console

stderr

File & Console

CPU Overhead (Verbose)

< 2%

1-3%

< 1.5%

2-4%

Disk I/O (Verbose)

~100 MB/hr

~80 MB/hr

~50 MB/hr

~70 MB/hr

setup-loki-promtail
LOG COLLECTION

Step 1: Setting Up Loki and Promtail

This guide covers the initial setup of the Loki stack for collecting and centralizing logs from your blockchain node, forming the foundation for monitoring and alerting.

Loki is a log aggregation system designed for efficiency, storing and querying logs without indexing their content, only their labels. It is part of the Grafana Labs ecosystem and pairs with Promtail, the agent responsible for discovering log files, extracting labels, and pushing the log stream to Loki. For node operators, this setup centralizes logs from components like Geth, Erigon, or Besu, enabling powerful search and correlation across your entire infrastructure from a single Grafana dashboard.

Begin by installing Loki and Promtail. The simplest method is using the precompiled binaries or Docker containers. For a binary installation on Linux, download the latest releases from the Grafana Loki GitHub. You will need two key configuration files: loki-config.yaml for the server and promtail-config.yaml for the agent. A basic loki-config.yaml might use the boltdb-shipper schema for single-binary mode and an object_store like filesystem for local development, though s3 is recommended for production.

The promtail-config.yaml file is where you define your scrape_configs to target node logs. A critical section is the pipeline_stages, which processes log lines. For Ethereum clients, you should add a regex stage to parse structured log formats (like JSON) and extract key fields—such as level, peer_id, or block_number—as labels. Extracting these fields as labels is what makes your logs queryable in Grafana. For example, you can then query for all error level logs or filter logs by a specific chain_id.

After configuration, start the Loki server first, then Promtail. Test the setup by checking that both services are running (systemctl status loki) and that Promtail is successfully discovering your node's log files (check Promtail's own logs at /var/log/promtail.log). The final step is to add Loki as a data source in Grafana. Navigate to Configuration > Data Sources, add a Loki source, and set the URL to http://localhost:3100 (or your server's IP). You can now use the Explore tab to run LogQL queries against your node's logs.

configure-node-logging
DATA COLLECTION

Step 2: Configuring Node Client Logging

Configure your Ethereum execution and consensus clients to generate the structured log data required for Chainscore's monitoring and analytics.

Effective monitoring begins with proper log configuration. Chainscore's system parses structured JSON logs from your node clients to track metrics like sync status, peer connections, and block propagation. You must configure both your execution client (e.g., Geth, Nethermind, Erigon) and consensus client (e.g., Lighthouse, Prysm, Teku) to output logs in a compatible JSON format to the standard output (stdout) or a file. The specific flags and log levels vary by client, but the goal is consistent: produce detailed, machine-readable logs without overwhelming verbosity that could impact node performance.

For Geth, the most common execution client, you enable JSON logging by adding the --log.json flag. To capture the necessary detail for network health analysis, a log level of INFO (or 3) is typically sufficient. A complete command might look like: geth --syncmode snap --http --log.json --verbosity 3. For Nethermind, use --JsonRpc.Enabled true and configure log output in the logConfig section of your configuration file, setting the log level to Info. It's critical to avoid the Trace or Debug levels in production, as they generate excessive data.

Consensus clients require similar configuration. For Lighthouse, use the --debug-level info flag. Prysm uses --log-format=json and --verbosity=info. Teku outputs JSON by default; control detail with --logging=INFO. Ensure logs are directed to stdout, as this is where log collection agents like Vector or Fluent Bit will capture them. Test your configuration by starting your node and verifying that a sample log line is a parseable JSON object, not plain text, containing fields like level, msg, and peer_id.

The final step is integrating this log stream with the collection agent you set up in Step 1. The agent is configured to tail the log file or capture stdout, parse each line as JSON, and forward it to Chainscore's ingestion endpoint. This creates a real-time data pipeline. Without correctly formatted JSON logs, the agent cannot extract the specific metrics—such as attestation_success or rpc_latency—that power Chainscore's dashboards and alerts. Proper configuration here is the foundation for all subsequent analysis.

parsing-and-queries
DATA EXTRACTION

Step 3: Writing Log Queries and Parsing Rules

Once your node's logs are being collected, the next step is to define how to extract meaningful data from them. This involves writing targeted queries to filter logs and creating parsing rules to structure the raw text into usable fields.

Log queries act as filters to isolate the specific log lines you need to monitor. For a blockchain node, you'll typically target logs from your consensus client (e.g., Lighthouse, Prysm) and execution client (e.g., Geth, Nethermind). A basic query might filter by the component or logger field, such as logger="beacon" for consensus logs or logger="net" for peer-to-peer networking events. More advanced queries can isolate critical errors (level="error"), track specific events like block proposals, or monitor sync status. Using precise queries reduces noise and focuses your analysis on the most important operational signals.

Parsing rules, often implemented via Grok patterns or regular expressions, transform unstructured log text into structured key-value pairs. For example, a Geth log line "Imported new chain segment" contains embedded data like block number and hash. A parsing rule would extract these into fields: block_number=19283746, block_hash="0xabc...", txns=142. This structured data is essential for creating alerts, dashboards, and metrics. Common fields to parse include timestamps, log levels, error codes, peer IDs, block numbers, transaction counts, and gas usage.

Effective parsing requires understanding your client's log format. JSON-structured logs (common in modern clients) are easier to parse as fields are already keyed. For plain-text logs, you must define patterns manually. Test your parsing rules with sample log lines to ensure accuracy. Incorrect parsing can lead to missing data or false alerts. Tools like the Grok Debugger or regex testers are invaluable for this development phase. Remember to document your parsing schemas so your team understands what data is available for analysis.

Here is a practical example for parsing a Lighthouse attestation log using a Grok pattern. The raw log might be: "INFO Synced" slot=8273612, epoch=258550, finalized_epoch=258548. A corresponding Grok pattern could be: %{LOGLEVEL:log_level} %{GREEDYDATA:message} slot=%{NUMBER:slot}, epoch=%{NUMBER:epoch}, finalized_epoch=%{NUMBER:finalized_epoch}. This would create structured fields for slot, epoch, and finalized_epoch, allowing you to chart sync progress or alert on stalled finalization.

Finally, integrate your queries and parsing rules into your log collection pipeline, whether that's Promtail for Loki, Fluentd, or a Datadog agent. The goal is to feed clean, structured log data into your monitoring system. Well-defined parsing is the foundation for powerful observability, enabling you to track performance metrics, set up proactive alerts for chain reorganizations or peer drops, and quickly debug issues by searching and filtering on specific extracted fields.

alerting-and-monitoring
NODE MONITORING

Step 4: Implementing Alerts and Dashboards

This guide details how to configure log collection for your blockchain node, a critical step for proactive monitoring and alerting.

Effective node monitoring begins with structured log collection. Blockchain clients like Geth, Besu, and Erigon output detailed logs to stdout or log files, containing vital information on block synchronization, peer connections, transaction processing, and errors. To make this data actionable, you need to centralize and parse these logs. This typically involves deploying a log shipper agent, such as Fluent Bit or Vector, on your node server. These agents are lightweight, designed to tail log files, apply parsing rules (often using regex or JSON parsing), and forward the structured data to a central observability platform like Loki, Elasticsearch, or Datadog.

Configuring your log shipper requires defining the correct input source and parsing logic. For a JSON-formatted Geth log, the configuration is straightforward as you can parse the structured fields directly. For line-based logs, you'll need to write a parser to extract key-value pairs. For example, a Fluent Bit configuration to tail and parse Geth logs might look for patterns like level, msg, and peer. This transforms a raw log line like INFO [05-15|10:30:45.000] Imported new chain segment into structured fields such as {level: "INFO", timestamp: "05-15|10:30:45.000", message: "Imported new chain segment"}. This structure is essential for creating precise alerts and dashboards.

Once logs are flowing to your central platform, you can build detection rules for critical events. Common alert conditions include: - Log messages containing "Stopped syncing" or "Fatal error" - A sudden drop in "Imported new chain segment" messages indicating a sync halt - Repeated "Transaction pool is full" warnings signaling network congestion. Tools like Grafana Loki with LogQL or Elasticsearch with Kibana allow you to create alerts that trigger when these log patterns are detected. For instance, a LogQL query {app="geth"} |= "Stopped syncing" can be used to fire an alert to Slack, PagerDuty, or email, enabling a rapid response to node health issues.

With parsed log data, you can construct comprehensive Grafana dashboards to visualize node health. Key panels include: a time-series graph of log levels (ERROR, WARN, INFO) to spot anomaly spikes; a counter for "blocks imported" to monitor sync status; a table of recent error messages; and a gauge showing active peer count parsed from connection logs. These dashboards provide an at-a-glance view of node performance and are the foundation for historical analysis. By correlating log events with metrics (like CPU usage from Step 3), you can diagnose root causes, such as determining if an out-of-memory error log coincided with a memory usage spike.

Finally, integrate your log-based alerts with the metric-based alerts from the previous step to create a defense-in-depth monitoring strategy. A sync halt might first trigger a metric alert on block height stagnation, while the accompanying log alert provides the exact error message for debugging. Regularly review and tune your alert rules to reduce noise, ensuring you're notified for genuine issues. Consistent, structured log collection turns opaque node output into a powerful diagnostic tool, reducing mean time to resolution (MTTR) and improving node reliability.

NODE LOGGING

Troubleshooting Common Log Collection Issues

Diagnose and resolve frequent problems encountered when setting up and maintaining logs for blockchain nodes.

Missing logs are often caused by misconfigured log levels or incorrect file paths. First, verify your node's logging configuration. For example, in a Geth node, ensure the --verbosity flag is set appropriately (e.g., --verbosity 3 for INFO level).

Common checks:

  • Log Destination: Confirm logs are being written to the file or stdout you are monitoring. Check the node's startup command for flags like --log.file.
  • Permissions: The user running the collection agent (e.g., Fluent Bit, Vector) must have read permissions on the log file.
  • Rotation: If logs are rotated (e.g., logfile.log.1), your collection tool's path pattern must match (e.g., /var/log/node/*.log).
  • Buffer Issues: Some logging libraries buffer output. For immediate visibility, you may need to flush logs programmatically or adjust buffer settings.
NODE LOG COLLECTION

Frequently Asked Questions

Common questions and troubleshooting steps for setting up and managing logs from your blockchain node.

If logs are not appearing, check the following common issues:

1. Agent Connection: Verify the Chainscore agent is running and connected to your node's RPC endpoint. Use systemctl status chainscore-agent to check its status. 2. Log File Permissions: The agent user (e.g., chainscore) must have read permissions for your node's log files (e.g., /var/log/geth/). 3. Configuration Paths: Ensure the log_path in your config.yaml points to the correct, active log file. Nodes like Geth and Erigon rotate logs; you may need to target geth.log instead of a timestamped archive. 4. Parsing Errors: Check the agent's own logs (/var/log/chainscore/agent.log) for JSON parsing errors, which indicate a log format mismatch.

conclusion
NODE MONITORING

Conclusion and Next Steps

You have successfully configured a robust logging pipeline for your blockchain node. This final section summarizes the key benefits and outlines advanced steps for operational excellence.

Implementing structured log collection transforms node operations from reactive troubleshooting to proactive health management. With logs flowing into a centralized system like Grafana Loki, you gain real-time visibility into critical metrics: block synchronization status, peer connections, memory usage, and RPC request patterns. This setup allows you to set up alerts for anomalies—such as a sudden drop in peer count or a spike in error logs—enabling intervention before issues affect your service's reliability or your staking rewards.

To deepen your monitoring, consider these next steps. First, integrate metric collection using Prometheus to capture numerical data like CPU load, disk I/O, and chain head block number, complementing your log-based insights. Second, define and implement alerting rules in your monitoring stack. Key alerts to configure include chain_sync_stalled, high_memory_usage, and p2p_peer_count_low. Third, establish a log retention and archiving policy to manage storage costs while ensuring you have sufficient historical data for forensic analysis after an incident.

For production environments, enhance your setup with security and automation. Run your logging agents (Promtail, Vector) and monitoring stack (Loki, Grafana) in isolated containers or on separate machines to limit resource contention with your node. Automate the deployment of your logging configuration using infrastructure-as-code tools like Ansible, Terraform, or Docker Compose. Finally, regularly review and audit your log data to identify subtle performance degradations or unexpected patterns, which are often the early warning signs of larger issues. Your logging system is now a foundational component of your node's operational integrity.

How to Set Up Node Log Collection for Blockchain Networks | ChainScore Guides