Metrics
The validator includes a built-in metrics server that exposes various metrics about the validator's operation. These metrics can be used to monitor the validator's performance and health.
Configuration
By default, metrics are disabled. You can enable metrics tracking and customize the host and port with the following flags:
- Docker
- Binary
docker run --network host \
--user "$(id -u):$(id -g)" \
-v /path/to/config.json:/app/config/config.json \
nethermind/starknet-staking-v2 \
--config /app/config/config.json \
--metrics --metrics-host "0.0.0.0" --metrics-port "9090"
./build/validator --metrics --metrics-host "0.0.0.0" --metrics-port "9090" # Listen on all interfaces, port 9090
If the metrics server can't listen on that host and port (an invalid port, a port already in use), the validator exits with an error at startup.
Endpoints
The metrics server exposes two endpoints:
/health: Returns a 200 OK response if the server is running/metrics: Exposes Prometheus metrics
Available Metrics
The following metrics are available:
| Metric | Type | Labels |
|---|---|---|
validator_attestation_starknet_latest_block_number | Gauge | network |
The latest block number seen by the validator on the Starknet network | ||
validator_attestation_current_epoch_id | Gauge | network |
The ID of the current epoch the validator is participating in | ||
validator_attestation_current_epoch_length | Gauge | network |
The total length (in blocks) of the current epoch | ||
validator_attestation_current_epoch_starting_block_number | Gauge | network |
The first block number of the current epoch | ||
validator_attestation_current_epoch_assigned_block_number | Gauge | network |
The specific block number within the current epoch for which the validator is assigned to attest | ||
validator_attestation_last_attestation_timestamp_seconds | Gauge | network |
The Unix timestamp (in seconds) of the last successful attestation submission | ||
validator_attestation_attestation_submitted_count | Counter | network |
The total number of attestations submitted by the validator since startup | ||
validator_attestation_attestation_failure_count | Counter | network |
The total number of attestation transaction submission failures encountered by the validator since startup | ||
validator_attestation_attestation_confirmed_count | Counter | network |
The total number of attestations that have been confirmed on the network since validator startup | ||
validator_attestation_epoch_info_fetch_failure_count | Counter | network |
The total number of failed attempts to fetch the epoch info, at startup or at an epoch switch, since startup. Block headers are not processed while it fails | ||
validator_attestation_signer_balance | Gauge | network |
The balance of the account that signs the attestation after each attest transaction | ||
validator_attestation_signer_below_threshold | Gauge | network |
Set to one if the account that signs the attestation has it's balance below certain threshold | ||
validator_attestation_balance_check_failure_count | Counter | network, account |
The total number of balance checks that could not read the account balance since startup, by account (signer or reward) | ||
validator_attestation_reward_balance | Gauge | network |
The balance of the reward account, checked after each attestation window | ||
validator_attestation_reward_below_threshold | Gauge | network |
Set to one if the reward account has it's balance below certain threshold | ||
validator_attestation_reward_unclaimed | Gauge | network |
The staker's unclaimed rewards, in STRK, checked after each attestation window | ||
validator_attestation_reward_claim_submitted_count | Counter | network |
The total number of reward claim transactions submitted by the validator since startup | ||
validator_attestation_reward_claim_confirmed_count | Counter | network |
The total number of reward claim transactions accepted on L2 with a successful execution since startup | ||
validator_attestation_reward_claim_failure_count | Counter | network |
The total number of reward claim failures encountered by the validator since startup | ||
validator_attestation_reward_claim_max_fee_exceeded_count | Counter | network |
The total number of reward claims skipped since startup because the estimated fee exceeded the claim max fee | ||
validator_attestation_reward_last_claim_timestamp_seconds | Gauge | network |
The Unix timestamp (in seconds) of the last successful reward claim submission | ||
Every metric has a network label with the chain id of the provider's network, such as SN_MAIN or SN_SEPOLIA. Metrics with an account label report signer or reward in it. A scrape of /metrics returns lines such as:
validator_attestation_current_epoch_id{network="SN_SEPOLIA"} 42
Reading the counters:
- An increase of
validator_attestation_epoch_info_fetch_failure_countmeans the validator is stalled, since block headers are not processed while the fetch fails. - While
validator_attestation_balance_check_failure_countgrows, the balance metrics of that account keep their last value. - A reward claim that is submitted but neither confirmed nor counted as a failure was not accepted within 2 minutes: check its status manually.
All the validator_attestation_reward_* metrics are only reported if the auto-claim rewards feature is enabled. The reward account balance metrics are not reported when the reward account is the operational account, whose balance is already reported by the signer metrics.
Using with Prometheus
To monitor these metrics with Prometheus, add the following to your Prometheus configuration:
scrape_configs:
- job_name: 'starknet-validator'
scrape_interval: 15s
static_configs:
- targets: ['localhost:9090']
You can then visualize these metrics using Grafana or any other Prometheus-compatible visualization tool.
Grafana Dashboard
A sample Grafana dashboard is available to visualize the validator metrics: grafana-dashboard.json
This dashboard provides comprehensive monitoring of your validator's performance including:
- Block and epoch progression
- Attestation success rates
- Network status and health metrics