Monitoring

Torsten exposes a Prometheus-compatible metrics endpoint for monitoring node health and sync progress.

Metrics Endpoint

The metrics server runs on port 12798 by default and responds to any HTTP request with Prometheus exposition format metrics:

http://localhost:12798/metrics

Example response:

# HELP torsten_blocks_received_total Total blocks received from peers
# TYPE torsten_blocks_received_total gauge
torsten_blocks_received_total 1523847

# HELP torsten_blocks_applied_total Total blocks applied to ledger
# TYPE torsten_blocks_applied_total gauge
torsten_blocks_applied_total 1523845

# HELP torsten_slot_number Current slot number
# TYPE torsten_slot_number gauge
torsten_slot_number 142857392

# HELP torsten_block_number Current block number
# TYPE torsten_block_number gauge
torsten_block_number 11283746

# HELP torsten_epoch_number Current epoch number
# TYPE torsten_epoch_number gauge
torsten_epoch_number 512

# HELP torsten_sync_progress_percent Chain sync progress (0-10000, divide by 100 for %)
# TYPE torsten_sync_progress_percent gauge
torsten_sync_progress_percent 9542

# HELP torsten_utxo_count Number of entries in the UTxO set
# TYPE torsten_utxo_count gauge
torsten_utxo_count 15234892

# HELP torsten_mempool_tx_count Number of transactions in the mempool
# TYPE torsten_mempool_tx_count gauge
torsten_mempool_tx_count 42

# HELP torsten_peers_connected Number of connected peers
# TYPE torsten_peers_connected gauge
torsten_peers_connected 8

Available Metrics

MetricTypeDescription
torsten_blocks_received_totalcounterTotal blocks received from peers
torsten_blocks_applied_totalcounterTotal blocks successfully applied to the ledger
torsten_transactions_received_totalcounterTotal transactions received
torsten_transactions_validated_totalcounterTotal transactions validated
torsten_transactions_rejected_totalcounterTotal transactions rejected
torsten_peers_connectedgaugeNumber of connected peers
torsten_peers_coldgaugeNumber of cold (known but unconnected) peers
torsten_peers_warmgaugeNumber of warm (connected, not syncing) peers
torsten_peers_hotgaugeNumber of hot (actively syncing) peers
torsten_sync_progress_percentgaugeChain sync progress (0-10000; divide by 100 for percentage)
torsten_slot_numbergaugeCurrent slot number
torsten_block_numbergaugeCurrent block number
torsten_epoch_numbergaugeCurrent epoch number
torsten_utxo_countgaugeNumber of entries in the UTxO set
torsten_mempool_tx_countgaugeNumber of transactions in the mempool
torsten_mempool_bytesgaugeSize of the mempool in bytes
torsten_rollback_count_totalcounterTotal number of chain rollbacks
torsten_blocks_forged_totalcounterTotal blocks forged by this node
torsten_delegation_countgaugeNumber of active stake delegations
torsten_treasury_lovelacegaugeTotal lovelace in the treasury

Prometheus Configuration

Add the Torsten node as a scrape target in your prometheus.yml:

scrape_configs:
  - job_name: 'torsten'
    scrape_interval: 15s
    static_configs:
      - targets: ['localhost:12798']
        labels:
          network: 'mainnet'
          node: 'relay-1'

Grafana Dashboard

You can create a Grafana dashboard to visualize Torsten metrics. Key panels to consider:

  • Sync Progress: torsten_sync_progress_percent / 100 (percentage)
  • Block Height: torsten_block_number
  • Current Epoch: torsten_epoch_number
  • Blocks/sec throughput: rate(torsten_blocks_applied_total[5m])
  • UTxO Set Size: torsten_utxo_count
  • Mempool Size: torsten_mempool_tx_count
  • Connected Peers: torsten_peers_connected
  • Peer States: torsten_peers_cold, torsten_peers_warm, torsten_peers_hot
  • Transaction Rejection Rate: rate(torsten_transactions_rejected_total[5m])
  • Blocks Forged: torsten_blocks_forged_total
  • Rollback Count: torsten_rollback_count_total
  • Active Delegations: torsten_delegation_count
  • Treasury Balance: torsten_treasury_lovelace / 1e6 (in ADA)

Console Logging

In addition to the Prometheus endpoint, Torsten logs sync progress to the console every 5 seconds. The log output includes:

  • Current slot and block number
  • Epoch number
  • UTxO count
  • Sync percentage
  • Blocks-per-second throughput

Example log line:

INFO torsten_node::node: slot=142857392 block=11283746 epoch=512 utxo=15234892 sync=95.42% speed=312 blk/s

Set the log level via the RUST_LOG environment variable:

RUST_LOG=info torsten-node run ...