Skip to content

Commit 8180af5

Browse files
committed
add prometheus ls metrics
1 parent 34c7970 commit 8180af5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

modules/prometheus.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def to_format(self, value):
2626
'stake': Metric('validator_stake', 'Validator stake', 'gauge'),
2727
'celldb_gc_block': Metric('validator_celldb_gc_block', 'Celldb GC block latency', 'gauge'),
2828
'celldb_gc_state': Metric('validator_celldb_gc_state', 'Celldb GC queue size', 'gauge'),
29+
'collated_master_ok': Metric('validator_blocks_collated_master_ok', 'Number of masterchain blocks successfully collated', 'gauge'),
30+
'collated_master_err': Metric('validator_blocks_collated_master_err', 'Number of masterchain blocks failed to collate', 'gauge'),
31+
'collated_shard_ok': Metric('validator_blocks_collated_shard_ok', 'Number of shardchain blocks successfully collated', 'gauge'),
32+
'collated_shard_err': Metric('validator_blocks_collated_shard_err', 'Number of shardchain blocks failed to collate', 'gauge'),
33+
'ls_queries_ok': Metric('validator_ls_queries_ok', 'Number of Liteserver successful queries', 'gauge'),
34+
'ls_queries_err': Metric('validator_ls_queries_err', 'Number of Liteserver failed queries', 'gauge'),
2935
}
3036

3137

@@ -67,6 +73,15 @@ def get_validator_validation_metrics(self, result: list):
6773
if stake:
6874
result.append(METRICS['stake'].to_format(round(stake, 2)))
6975

76+
def get_node_stats_metrics(self, result: list):
77+
stats = self.ton.get_node_statistics()
78+
if stats and 'ls_queries' in stats:
79+
if stats['ls_queries']['time'] < 50:
80+
self.local.add_log(f'Liteserver queries time is too low: {stats}')
81+
return
82+
result.append(METRICS['ls_queries_ok'].to_format(stats['ls_queries']['ok']))
83+
result.append(METRICS['ls_queries_err'].to_format(stats['ls_queries']['error']))
84+
7085
def push_metrics(self):
7186
if not self.ton.using_prometheus():
7287
return
@@ -77,6 +92,7 @@ def push_metrics(self):
7792
metrics = []
7893
self.local.try_function(self.get_validator_status_metrics, args=[metrics])
7994
self.local.try_function(self.get_validator_validation_metrics, args=[metrics])
95+
self.local.try_function(self.get_node_stats_metrics, args=[metrics])
8096
requests.post(url, data='\n'.join(metrics).encode())
8197

8298
def add_console_commands(self, console):

0 commit comments

Comments
 (0)