Skip to content

Commit 207a517

Browse files
committed
add celldb prometheus metrics
1 parent 8b080e6 commit 207a517

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

modules/prometheus.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def to_format(self, value):
2323
'out_of_ser': Metric('validator_out_of_serialization', 'Number of blocks last state serialization was ago', 'gauge'),
2424
'vc_up': Metric('validator_console_up', 'Is `validator-console` up', 'gauge'),
2525
'validator_id': Metric('validator_index', 'Validator index', 'gauge'),
26-
'validator_stake': Metric('validator_stake', 'Validator stake', 'gauge'),
26+
'stake': Metric('validator_stake', 'Validator stake', 'gauge'),
27+
'celldb_gc_block': Metric('validator_celldb_gc_block', 'Celldb GC block latency', 'gauge'),
28+
'celldb_gc_state': Metric('validator_celldb_gc_state', 'Celldb GC queue size', 'gauge'),
2729
}
2830

2931

@@ -43,6 +45,10 @@ def get_validator_status_metrics(self, result: list):
4345
result.append(METRICS['shard_out_of_sync'].to_format(status.shardchain_out_of_sync))
4446
if status.masterchain_out_of_ser is not None:
4547
result.append(METRICS['out_of_ser'].to_format(status.masterchain_out_of_ser))
48+
if status.masterchainblock is not None and status.gcmasterchainblock is not None:
49+
result.append(METRICS['celldb_gc_block'].to_format(status.masterchainblock - status.gcmasterchainblock))
50+
if status.gcmasterchainblock is not None and status.last_deleted_mc_state is not None:
51+
result.append(METRICS['celldb_gc_state'].to_format(status.gcmasterchainblock - status.last_deleted_mc_state))
4652
result.append(METRICS['vc_up'].to_format(int(status.is_working)))
4753

4854
def get_validator_validation_metrics(self, result: list):
@@ -55,7 +61,7 @@ def get_validator_validation_metrics(self, result: list):
5561
adnl = self.ton.GetAdnlAddr()
5662
stake = elections.get(adnl, {}).get('stake')
5763
if stake:
58-
result.append(METRICS['validator_stake'].to_format(round(stake, 2)))
64+
result.append(METRICS['stake'].to_format(round(stake, 2)))
5965

6066
def push_metrics(self):
6167
if not self.ton.using_prometheus():

mytoncore/mytoncore.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ def GetValidatorStatus(self):
796796
status.masterchain_out_of_ser = status.masterchainblock - status.stateserializermasterchainseqno
797797
status.out_of_sync = status.masterchain_out_of_sync if status.masterchain_out_of_sync > status.shardchain_out_of_sync else status.shardchain_out_of_sync
798798
status.out_of_ser = status.masterchain_out_of_ser
799+
status.last_deleted_mc_state = int(parse(result, "last_deleted_mc_state", '\n'))
799800
except Exception as ex:
800801
self.local.add_log(f"GetValidatorStatus warning: {ex}", "warning")
801802
status.is_working = False

0 commit comments

Comments
 (0)