@@ -181,13 +181,14 @@ async fn update_alert_state(
181181) -> Result < ( ) , AlertError > {
182182 if final_res {
183183 let message = format ! (
184- "Expected Value : {} {} {}\n Actual Value: {}\n Evaluation Window: {}\n Evaluation Frequency: {}m " ,
185- alert. query ,
184+ "Alert Triggered : {}\n \n Threshold: ( {} {}) \n Current Value: {}\n Evaluation Window: {} | Frequency: {}\n \n Query: \n {} " ,
185+ alert. id ,
186186 alert. threshold_config. operator,
187187 alert. threshold_config. value,
188- actual_value,
188+ format_number ( actual_value) ,
189189 alert. get_eval_window( ) ,
190- alert. get_eval_frequency( )
190+ alert. get_eval_frequency( ) ,
191+ alert. query
191192 ) ;
192193 ALERTS
193194 . update_state ( alert. id , AlertState :: Triggered , Some ( message) )
@@ -203,6 +204,23 @@ async fn update_alert_state(
203204 }
204205}
205206
207+ /// Format a number for better readability
208+ fn format_number ( value : f64 ) -> String {
209+ if value. fract ( ) == 0.0 {
210+ // Integer value
211+ format ! ( "{:.0}" , value)
212+ } else if value. abs ( ) < 1.0 {
213+ // Small decimal, show more precision
214+ format ! ( "{:.4}" , value)
215+ . trim_end_matches ( '0' )
216+ . trim_end_matches ( '.' )
217+ . to_string ( )
218+ } else {
219+ // Regular decimal, show 2 decimal places
220+ format ! ( "{:.2}" , value)
221+ }
222+ }
223+
206224fn get_final_value ( records : Vec < RecordBatch > ) -> f64 {
207225 trace ! ( "records-\n {records:?}" ) ;
208226
0 commit comments