@@ -223,7 +223,11 @@ func (r *Reconciler) getRecommendedActionValue(recommendedAction, ruleName strin
223223
224224func (r * Reconciler ) validateAllSequenceCriteria (ctx context.Context , rule config.HealthEventsAnalyzerRule ,
225225 healthEventWithStatus datamodels.HealthEventWithStatus ) (bool , error ) {
226- slog .Debug ("Evaluating rule for event" , "rule_name" , rule .Name , "event" , healthEventWithStatus )
226+ slog .Info ("→ Evaluating rule for event" ,
227+ "rule_name" , rule .Name ,
228+ "node" , healthEventWithStatus .HealthEvent .NodeName ,
229+ "error_code" , healthEventWithStatus .HealthEvent .ErrorCode ,
230+ "agent" , healthEventWithStatus .HealthEvent .Agent )
227231
228232 // Build aggregation pipeline from stages
229233 pipelineStages , err := r .getPipelineStages (rule , healthEventWithStatus )
@@ -234,12 +238,14 @@ func (r *Reconciler) validateAllSequenceCriteria(ctx context.Context, rule confi
234238 return false , fmt .Errorf ("failed to build pipeline stages: %w" , err )
235239 }
236240
241+ slog .Debug ("Generated pipeline" , "rule_name" , rule .Name , "pipeline_stages" , pipelineStages )
242+
237243 var result []map [string ]interface {}
238244
239245 // Execute aggregation using store-client abstraction
240246 cursor , err := r .databaseClient .Aggregate (ctx , pipelineStages )
241247 if err != nil {
242- slog .Error ("Failed to execute aggregation pipeline" , "error" , err )
248+ slog .Error ("Failed to execute aggregation pipeline" , "error" , err , "rule_name" , rule . Name )
243249 totalEventProcessingError .WithLabelValues ("execute_pipeline_error" ).Inc ()
244250
245251 return false , fmt .Errorf ("failed to execute aggregation pipeline: %w" , err )
@@ -248,33 +254,45 @@ func (r *Reconciler) validateAllSequenceCriteria(ctx context.Context, rule confi
248254 defer cursor .Close (ctx )
249255
250256 if err = cursor .All (ctx , & result ); err != nil {
251- slog .Error ("Failed to decode cursor" , "error" , err )
257+ slog .Error ("Failed to decode cursor" , "error" , err , "rule_name" , rule . Name )
252258 totalEventProcessingError .WithLabelValues ("decode_cursor_error" ).Inc ()
253259
254260 return false , fmt .Errorf ("failed to decode cursor: %w" , err )
255261 }
256262
263+ slog .Debug ("Aggregation results" , "rule_name" , rule .Name , "result_count" , len (result ), "results" , result )
264+
257265 // Check if we have results (rule matched)
258266 if len (result ) > 0 {
259267 // Check for explicit ruleMatched field (used in tests and by SequenceFacet pipelines)
260268 if matched , ok := result [0 ]["ruleMatched" ].(bool ); ok {
261269 if matched {
262- slog .Debug ("Rule matched (via ruleMatched field)" , "rule_name" , rule .Name )
270+ slog .Info ("✓ Rule matched via ruleMatched field" ,
271+ "rule_name" , rule .Name ,
272+ "node" , healthEventWithStatus .HealthEvent .NodeName )
263273 return true , nil
264274 }
265275
266- slog .Debug ("Rule did not match (ruleMatched=false)" , "rule_name" , rule .Name )
276+ slog .Info ("✗ Rule did not match (ruleMatched=false)" ,
277+ "rule_name" , rule .Name ,
278+ "node" , healthEventWithStatus .HealthEvent .NodeName ,
279+ "result" , result [0 ])
267280
268281 return false , nil
269282 }
270283
271284 // For Stage-based pipelines, presence of results indicates a match
272- slog .Debug ("Rule matched (results exist)" , "rule_name" , rule .Name , "result_count" , len (result ))
285+ slog .Info ("✓ Rule matched via results existence" ,
286+ "rule_name" , rule .Name ,
287+ "node" , healthEventWithStatus .HealthEvent .NodeName ,
288+ "result_count" , len (result ))
273289
274290 return true , nil
275291 }
276292
277- slog .Debug ("Rule did not match (no results)" , "rule_name" , rule .Name )
293+ slog .Info ("✗ Rule did not match (no results)" ,
294+ "rule_name" , rule .Name ,
295+ "node" , healthEventWithStatus .HealthEvent .NodeName )
278296
279297 return false , nil
280298}
@@ -297,14 +315,18 @@ func (r *Reconciler) getPipelineStages(
297315
298316 for i , stageStr := range rule .Stage {
299317 // Parse the stage and resolve "this." references
318+ slog .Debug ("Parsing stage" , "stage_index" , i , "stage_string" , stageStr )
319+
300320 stageMap , err := parser .ParseSequenceStage (stageStr , healthEventWithStatus )
301321 if err != nil {
302- slog .Error ("Failed to parse stage" , "stage_index" , i , "error" , err )
322+ slog .Error ("Failed to parse stage" , "stage_index" , i , "error" , err , "stage_string" , stageStr )
303323 totalEventProcessingError .WithLabelValues ("parse_stage_error" ).Inc ()
304324
305325 return nil , fmt .Errorf ("failed to parse stage %d: %w" , i , err )
306326 }
307327
328+ slog .Debug ("Parsed stage successfully" , "stage_index" , i , "parsed_stage" , stageMap )
329+
308330 pipeline = append (pipeline , stageMap )
309331 }
310332
0 commit comments