跳到主要内容

Node Metrics

Monarch CLI collects time-series metrics from your node every 60 seconds when enabled. This data powers local diagnostics, event detection, and the Monarch Connect dashboard charts.

Enabling Metrics Collection

monarch metrics enable

This installs a cron job that runs every 60 seconds, collecting a snapshot of node and system state. To disable:

monarch metrics disable

Check current collection status:

monarch metrics status

Collected Fields

Each snapshot records 24 fields:

FieldTypeDescription
timestampintUnix timestamp of the snapshot
heightintCurrent block height
sync_statusstringsynced, catching_up, or stalled
catching_upboolWhether the node is still syncing
peersintNumber of connected peers
block_timefloatTime since last block (seconds)
latest_block_timestringISO 8601 timestamp of the latest block
validator_rankintValidator position in the active set (0 if not a validator)
tokensstringTotal bonded tokens (in alyth)
delegator_countintNumber of unique delegators
commission_ratefloatCurrent commission rate
missed_blocksintMissed blocks in the current signing window
jailedboolWhether the validator is jailed
voting_powerintValidator voting power
cpu_percentfloatSystem CPU usage percentage
memory_bytesintMemory used by the node process
memory_totalintTotal system memory
disk_usedintDisk space used (bytes)
disk_totalintTotal disk capacity (bytes)
uptimeintNode process uptime (seconds)
process_statusstringrunning, stopped, or crashed
monod_versionstringInstalled monod version
monarch_versionstringInstalled monarch version
chain_idstringCurrent chain ID

Event Detection

Monarch analyzes collected metrics and detects 14 event types:

EventTriggerSeverity
jailingValidator becomes jailedCritical
unjailingValidator is unjailedInfo
rank_changeValidator rank shifts by 3+ positionsWarning
delegator_changeDelegator count changes significantlyInfo
missed_block_spikeMissed blocks increase sharply within a windowWarning
disk_warningDisk usage exceeds 80%Warning
stale_blockNo new block for 30+ secondsWarning
sync_startedNode begins catching upInfo
sync_completedNode finishes syncingInfo
height_stallBlock height unchanged for 5+ minutesCritical
peer_dropPeer count drops below 3Warning
memory_warningMemory usage exceeds 90% of system totalWarning
process_restartNode process restarted unexpectedlyWarning
upgrade_availableNew monod version detectedInfo

Events are stored alongside metrics and can be queried independently.


Storage

Metrics are stored as JSONL (JSON Lines) files in the node home directory:

~/.mono/metrics/
├── metrics-2026-03-30.jsonl
├── metrics-2026-03-29.jsonl
├── events-2026-03-30.jsonl
└── events-2026-03-29.jsonl

Storage Characteristics

PropertyValue
FormatJSONL (one JSON object per line)
Location~/.mono/metrics/
Daily size~42 KB (metrics)
Auto-rotationFiles rotated at 5 MB
Retention7 days (older files auto-deleted)

At ~42 KB per day, a full week of metrics uses under 300 KB of disk space.


Querying Metrics

CLI Queries

# Query metrics from the last 24 hours
monarch metrics query --since $(date -d '24 hours ago' +%s) --json

# Query with a row limit
monarch metrics query --since 1711756800 --limit 500 --json

# Query detected events
monarch metrics events --since 1711756800 --limit 100 --json

# Query events from the last hour
monarch metrics events --since $(date -d '1 hour ago' +%s) --json

Output is JSON, suitable for piping to jq or other tools:

# Get the latest block height
monarch metrics query --limit 1 --json | jq '.[0].height'

# Find all jailing events
monarch metrics events --json | jq '.[] | select(.type == "jailing")'

Monarch Connect Integration

When Monarch Connect is connected to a server with metrics enabled, the Metrics tab displays interactive charts:

  • Block height -- trend line showing chain progress
  • Peer count -- connection health over time
  • CPU and memory -- resource consumption patterns
  • Disk usage -- capacity planning with threshold markers
  • Validator rank -- rank movement with event markers
  • Token balance -- bonded tokens over time
  • Missed blocks -- signing performance

Time Range Filters

Select from preset ranges: 1 hour, 6 hours, 24 hours, 7 days, or 30 days.

Event Timeline

Events appear as annotated markers on charts and in a chronological timeline view below the charts. Critical events (jailing, height stall) are highlighted in red.


Export Options

Static File Export

Export metrics as a JSON file for use with external analysis tools:

monarch metrics query --since 0 --json > metrics-export.json
Public Exports

If you plan to share exported metrics publicly, be aware that fields like cpu_percent, memory_bytes, and disk_used reveal server resource information. Consider filtering these fields before sharing.

Prometheus Endpoint

Monarch can expose a Prometheus-compatible metrics endpoint for scraping:

# Exposed on localhost only, no authentication
# Configure in ~/.mono/config/monarch.toml
[metrics]
prometheus = true
prometheus_addr = "127.0.0.1:9100"
Localhost Only

The Prometheus endpoint should only be bound to 127.0.0.1. Do not expose it to the public internet. Use an SSH tunnel or reverse proxy with authentication if you need remote access.


Security Considerations

  • Metrics contain no secrets -- no private keys, passwords, or mnemonics
  • Metrics do contain server resource info (CPU, memory, disk) which could reveal infrastructure details
  • The Prometheus endpoint should remain localhost-only
  • Static exports intended for public sharing should have resource fields stripped
  • JSONL files in ~/.mono/metrics/ have standard file permissions (readable only by the node user)