Polygon Validator Monitor is a tool for Polygon validators or stakers to monitor the performance of the Polygon validator set or of a particular validator. The tool exposes several Prometheus metrics, which can be used in conjunction with other tools such as Grafana and AlertManager to view the data over time or alert based on several conditions.
- An ETH RPC, preferably with historical data if running for the first time, and you want to get checkpoints included in blocks before the last 128.
- List of validators' signer keys to monitor.
- Install
go
v1.20+ (we are using go1.20.3) andmake
(part ofbuild-essential
). - In
config/config.json
:- Update
"ETHRpcUrl"
with your own ETH node. - Update
"PrometheusPort"
to your preferred port for the metrics. - Update
"DatabaseLocation"
to the path where the database should be stored. - Update
"PublicKeys"
with a list of the validators' signer keys to monitor. You can set this to["*"]
, which will monitor all validators. - Update
"ContinueFromBlock"
to the ETH block number the tool should start looking for checkpoints from. If you are running a non-archival ETH node with default pruning, you might encounter issues if you try setting this to anything more than(current block height - 128)
.
- Update
- Build the tool with
make build
. This will generate the binary inbuild/bin
. - Run the tool and specify the path to the config with the flag
--config=/path/to/you/config/file
. By default, the tool will look for it inconfig/config.json
, but this will not work if your working directory is different. If running the tool on Linux, you can use the provided service file (setup/polygon-monitor.service
).
After running the binary, Prometheus metrics are exported on localhost on your chosen port. The tool queries the provided ETH RPC every minute for any new checkpoint events included in each ETH block. In case of a new checkpoint, it processes it and updates all corresponding metrics. The data is also saved to an sqlite3 database specified in the config (by default in data/checkpoint_data.db
).
Before updating to a newer version or commit, we always recommend saving a copy of your database (i.e. data/checkpoint_data.db
), so that you can rollback.
The tool contains the following list of Prometheus metrics:
current_checkpoint -> int
: The last checkpoint processed by the tool.current_block_number -> int
: The last ETH block number processed by the tool.checkpoints_signed{validator, range} -> int
: The number of checkpoints signed by a validator for the given range {700 checkpoints, total}.checkpoints_total{range} -> int
: The number of checkpoints in a given range {700 checkpoints, total}.validator_performance{validator, range} -> float
: The performance of a validator for the given range {700 checkpoints, total}. It is the number of checkpoints signed by the validator for a certain range, divided by the total number of checkpoints in said range.current_performance_benchmark -> float
: The current performance benchmark of the Polygon validator set. If a validator's performance falls below this value, they enter the grace period.checkpoints_to_performance_benchmark{validator} -> int
: The number of checkpoints the validator must miss in order to enter the grace period, based on the current performance benchmark.checkpoints_to_reduction{validator} -> int
: How many checkpoints a validator has to go through before seeing an improvement in their performance of the last 700 checkpoints.
For any metric that contains a validator
label, the validator must be monitored (i.e. included in "PublicKeys"
in the config) in order for it to be included in the mentioned metrics.