File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ def llmalert(context, df: pd.DataFrame) -> pd.DataFrame:
155155 left_on = "metric_timestamp" ,
156156 right_on = "anomaly_timestamp" ,
157157 )
158+ df_metric ["metric_timestamp" ] = pd .to_datetime (df_metric ["metric_timestamp" ], format = "%Y-%m-%d %H:%M:%S" )
158159
159160 # if there are detected anomalies set metric_alert to 1 if it is not already 1
160161 if not df_metric ["metric_alert" ].any ():
@@ -170,9 +171,12 @@ def llmalert(context, df: pd.DataFrame) -> pd.DataFrame:
170171 latest_anomaly_timestamp = df_metric [
171172 df_metric ["anomaly_timestamp" ].notnull ()
172173 ]["anomaly_timestamp" ].max ()
174+ # prefix each explanation with the timestamp
173175 anomaly_explanations = df_metric [
174176 df_metric ["anomaly_timestamp" ].notnull ()
175- ]["anomaly_explanation" ].unique ()
177+ ][["anomaly_timestamp" , "anomaly_explanation" ]].apply (
178+ lambda x : f"{ x [0 ]} : { x [1 ]} " , axis = 1
179+ ).sort_values (ascending = False )
176180 anomaly_explanations = "\n - " .join (anomaly_explanations )
177181 metric_timestamp_max = df_metric ["metric_timestamp" ].max ()
178182 alert_title = (
You can’t perform that action at this time.
0 commit comments