@@ -26,21 +26,19 @@ use crate::alerts::{
2626} ;
2727
2828/// Block number is stuck for more than duration minutes.
29- fn get_consensus_block_number_stuck (
30- alert_name : & ' static str ,
31- alert_severity : AlertSeverity ,
32- ) -> Alert {
29+ fn get_consensus_block_number_stuck ( title : & ' static str , alert_severity : AlertSeverity ) -> Alert {
30+ let name = title. to_lowercase ( ) . replace ( ' ' , "_" ) ;
3331 let expr_template_string = format ! (
3432 "sum(increase({}[{{}}s])) or vector(0)" ,
3533 CONSENSUS_BLOCK_NUMBER . get_name_with_filter( )
3634 ) ;
3735 Alert :: new (
38- alert_name ,
39- "Consensus block number stuck" ,
36+ & name ,
37+ title ,
4038 AlertGroup :: Consensus ,
4139 ExpressionOrExpressionWithPlaceholder :: Placeholder (
4240 Template :: new ( expr_template_string) ,
43- vec ! [ format_sampling_window( alert_name ) ] ,
41+ vec ! [ format_sampling_window( & name ) ] ,
4442 ) ,
4543 vec ! [ AlertCondition :: new( AlertComparisonOp :: LessThan , 1.0 , AlertLogicalOp :: And ) ] ,
4644 PENDING_DURATION_DEFAULT ,
@@ -52,48 +50,49 @@ fn get_consensus_block_number_stuck(
5250
5351pub ( crate ) fn get_consensus_block_number_stuck_vec ( ) -> Vec < Alert > {
5452 vec ! [
55- get_consensus_block_number_stuck( "consensus_block_number_stuck " , AlertSeverity :: Sos ) ,
53+ get_consensus_block_number_stuck( "Consensus Block Number Stuck " , AlertSeverity :: Sos ) ,
5654 get_consensus_block_number_stuck(
57- "consensus_block_number_stuck_long_time " ,
55+ "Consensus Block Number Stuck Long Time " ,
5856 AlertSeverity :: Regular ,
5957 ) ,
6058 ]
6159}
6260
63- fn get_batched_transactions_stuck ( alert_name : & ' static str ) -> Alert {
61+ fn get_batched_transactions_stuck ( title : & ' static str ) -> Alert {
62+ let name = title. to_lowercase ( ) . replace ( ' ' , "_" ) ;
6463 let expr_template_string =
6564 format ! ( "changes({}[{{}}s])" , BATCHED_TRANSACTIONS . get_name_with_filter( ) ) ;
6665 Alert :: new (
67- alert_name ,
68- "Batched transactions stuck" ,
66+ & name ,
67+ title ,
6968 AlertGroup :: Batcher ,
7069 ExpressionOrExpressionWithPlaceholder :: Placeholder (
7170 Template :: new ( expr_template_string) ,
72- vec ! [ format_sampling_window( alert_name ) ] ,
71+ vec ! [ format_sampling_window( & name ) ] ,
7372 ) ,
7473 vec ! [ AlertCondition :: new( AlertComparisonOp :: LessThan , 1.0 , AlertLogicalOp :: And ) ] ,
7574 PENDING_DURATION_DEFAULT ,
7675 EVALUATION_INTERVAL_SEC_DEFAULT ,
77- SeverityValueOrPlaceholder :: Placeholder ( alert_name . to_string ( ) ) ,
76+ SeverityValueOrPlaceholder :: Placeholder ( name . clone ( ) ) ,
7877 ObserverApplicability :: NotApplicable ,
7978 )
8079}
8180
8281pub ( crate ) fn get_batched_transactions_stuck_vec ( ) -> Vec < Alert > {
8382 vec ! [
84- get_batched_transactions_stuck( "batched_transactions_stuck " ) ,
85- get_batched_transactions_stuck( "batched_transactions_stuck_long_time " ) ,
83+ get_batched_transactions_stuck( "Batched Transactions Stuck " ) ,
84+ get_batched_transactions_stuck( "Batched Transactions Stuck Long Time " ) ,
8685 ]
8786}
8887
8988fn get_consensus_p2p_not_enough_peers_for_quorum (
90- alert_name : & ' static str ,
89+ title : & ' static str ,
9190 duration : Duration ,
9291 alert_severity : AlertSeverity ,
9392) -> Alert {
9493 Alert :: new (
95- alert_name ,
96- "Consensus p2p not enough peers for quorum" ,
94+ title . to_lowercase ( ) . replace ( ' ' , "_" ) ,
95+ title ,
9796 AlertGroup :: Consensus ,
9897 format ! (
9998 "max_over_time({}[{}s])" ,
@@ -117,12 +116,12 @@ fn get_consensus_p2p_not_enough_peers_for_quorum(
117116pub ( crate ) fn get_consensus_p2p_not_enough_peers_for_quorum_vec ( ) -> Vec < Alert > {
118117 vec ! [
119118 get_consensus_p2p_not_enough_peers_for_quorum(
120- "consensus_p2p_not_enough_peers_for_quorum " ,
119+ "Consensus P2P Not Enough Peers For Quorum " ,
121120 Duration :: from_secs( 2 * SECS_IN_MIN ) ,
122121 AlertSeverity :: Sos ,
123122 ) ,
124123 get_consensus_p2p_not_enough_peers_for_quorum(
125- "consensus_p2p_not_enough_peers_for_quorum_long_time " ,
124+ "Consensus P2P Not Enough Peers For Quorum Long Time " ,
126125 Duration :: from_secs( 30 * SECS_IN_MIN ) ,
127126 AlertSeverity :: Regular ,
128127 ) ,
0 commit comments