Metrics Overview
Clementine exposes Prometheus-compatible metrics for all entity types:- L1 Sync Status: Bitcoin blockchain synchronization state
- Entity Health: Task status, errors, and stopped processes
- Aggregator Metrics: External entity monitoring from aggregator perspective
- Performance Metrics: Request durations, throughput, success rates
L1 Sync Status Metrics
Current Entity Metrics
Each running entity (verifier/operator) publishes its own sync status under thel1_sync_status scope:
| Metric | Type | Description |
|---|---|---|
wallet_balance_btc | Gauge | Current wallet balance in BTC |
rpc_tip_height | Gauge | Latest block height from Bitcoin Core RPC |
btc_syncer_synced_height | Gauge | Block height processed by Bitcoin Syncer |
hcp_last_proven_height | Gauge | Latest Header Chain Proof block height |
tx_sender_synced_height | Gauge | Block height processed by Transaction Sender |
finalized_synced_height | Gauge | Latest finalized block height |
state_manager_next_height | Gauge | Next block height for State Manager to process |
bitcoin_fee_rate_sat_vb | Gauge | Current Bitcoin fee rate in sat/vB |
Example Query
External Entity Metrics
The aggregator publishes metrics for all connected entities with dynamic scopes:EntityId is formatted as:
Operator(<first_10_chars_of_xonly_pk>)Verifier(<first_10_chars_of_public_key>)
Additional Aggregator Metrics
| Metric | Type | Description |
|---|---|---|
entity_status_error_count | Counter | Number of errors from entity status endpoint |
stopped_tasks_count | Gauge | Number of stopped background tasks for entity |
Sync Status Monitoring
Component Responsibilities
Bitcoin Syncer:- Fetches blocks from Bitcoin Core RPC
- Stores blocks in PostgreSQL database
- Publishes blocks to consumers via event queue
- Metric:
btc_syncer_synced_height
- Monitors blockchain for transaction confirmations
- Automatically broadcasts transactions when conditions met
- Handles fee bumping and replacement
- Metric:
tx_sender_synced_height
- Determines block finality based on confirmations
- Updates finalized height for withdrawal processing
- Metric:
finalized_synced_height
- Generates zero-knowledge proofs of block headers
- Required for withdrawal verification
- Metric:
hcp_last_proven_height
- Processes blockchain events to update deposit/withdrawal states
- Manages state machines for kickoff and round transactions
- Metric:
state_manager_next_height
Sync Lag Detection
Health Status Endpoints
Get Current Status
All entities expose a status endpoint: Verifier:Aggregator Entity Status
Aggregator can query status of all connected entities:Background Task Management
Restart stopped tasks via aggregator:Logging Configuration
Log Levels
Control verbosity with--verbose flag:
- 1: Error
- 2: Warn
- 3: Info
- 4: Debug
- 5: Trace
Structured Logging
Clementine uses structured logging with contextual information:Full Backtraces
Enable detailed error traces:Alerting Examples
Prometheus Alerting Rules
Grafana Dashboard
Example dashboard panels: Sync Status Panel:Performance Monitoring
Request Duration Tracking
Clementine tracks request durations for timeout detection:Database Query Metrics
Debugging Tools
Tokio Console
Debug async task performance:- Task spawn/completion tracking
- Async lock contention detection
- Resource leak identification
- Task duration histograms
Database Inspection
Troubleshooting
Sync Stalled
Symptoms:btc_syncer_synced_height not increasing
Diagnosis:
- Check Bitcoin Core RPC connectivity
- Verify database connection
- Check for error logs
- Ensure sufficient disk space
High Memory Usage
Diagnosis:- Reduce
max_connectionsin database config - Adjust
RUST_MIN_STACKif too high - Check for memory leaks with valgrind
Missing Metrics
Automation Mode Required:tx_sender_synced_height- only in automation modehcp_last_proven_height- only in automation modestate_manager_next_height- only in automation mode
Code References
- Metrics definitions:
core/src/metrics.rs - Status endpoints:
core/src/rpc/ - Aggregator metric publisher:
core/src/task/aggregator_metric_publisher.rs - Database sync tracking:
core/src/database/