From d8c9ae802dbb52984890709b204655a7286f17fa Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 15 Nov 2023 12:19:12 +0100 Subject: [PATCH] Don't log skipping rules as errors (#1658) Commit 0ef19262ce6fd6f6ff3cbe068fe8189a91f7b7ca added logging for remediation and alert levels, but it turns out that we would even log skipped remediations and alerts as errors which made the logs very spammy. Let's fix all but fatal errors. --- internal/engine/executor.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/engine/executor.go b/internal/engine/executor.go index 36f09f1bcf..3c3e2e68e3 100644 --- a/internal/engine/executor.go +++ b/internal/engine/executor.go @@ -263,14 +263,22 @@ func logEval( evalLog.Err(params.GetEvalErr()).Msg("result - evaluation") // log remediation - logger.Err(params.GetActionsErr().RemediateErr). + logger.Err(filterActionErrorForLogging(params.GetActionsErr().RemediateErr)). Str("action", "remediate"). Str("action_status", string(evalerrors.ErrorAsRemediationStatus(params.GetActionsErr().RemediateErr))). Msg("result - action") // log alert - logger.Err(params.GetActionsErr().AlertErr). + logger.Err(filterActionErrorForLogging(params.GetActionsErr().AlertErr)). Str("action", "alert"). Str("action_status", string(evalerrors.ErrorAsAlertStatus(params.GetActionsErr().AlertErr))). Msg("result - action") } + +func filterActionErrorForLogging(err error) error { + if evalerrors.IsActionFatalError(err) { + return err + } + + return nil +}