Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The alerting framework doesn't log an error to the console when using the addLastRunError API #179924

Closed
mikecote opened this issue Apr 3, 2024 · 1 comment · Fixed by #179962
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@mikecote
Copy link
Contributor

mikecote commented Apr 3, 2024

I've been exploring our metrics in serverless now that we have the fix for the addLastRunError errors (#179551). I noticed we do not log the error message to the console, making it hard to perform analysis on our top reported errors.

Steps to reproduce

  1. Apply the following code
diff --git a/x-pack/plugins/stack_alerts/server/rule_types/es_query/executor.ts b/x-pack/plugins/stack_alerts/server/rule_types/es_query/executor.ts
index 5e23bf9498e..548c36b9423 100644
--- a/x-pack/plugins/stack_alerts/server/rule_types/es_query/executor.ts
+++ b/x-pack/plugins/stack_alerts/server/rule_types/es_query/executor.ts
@@ -71,6 +71,8 @@ export async function executor(core: CoreSetup, options: ExecutorOptions<EsQuery
   let latestTimestamp: string | undefined = tryToParseAsDate(state.latestTimestamp);
   const { dateStart, dateEnd } = getTimeRange(`${params.timeWindowSize}${params.timeWindowUnit}`);

+  services.ruleResultService?.addLastRunError('some failure');
+
   const { parsedResults, link, index } = searchSourceRule
     ? await fetchSearchSourceQuery({
         ruleId,
  1. Create an ES Query rule
  2. Wait for it to run
  3. Notice there are no error logs in the console while they are reflected in the UI
  4. Change addLastRunError to throw new Error('fail');
  5. Wait for the rule to run
  6. Notice there is an error log in the console

Expected outcome

To log the error to the console similar to when an error gets thrown. A message could appear like this:

[2024-04-03T09:02:50.070-04:00][ERROR][plugins.alerting.es-query] Executing Rule default:.es-query:74ae32a2-f745-4137-9d9f-e1e6a4f9fcfe has resulted in the following error(s): fail
@mikecote mikecote added bug Fixes for quality problems that affect the customer experience Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Apr 3, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@mikecote mikecote moved this from Awaiting Triage to Todo in AppEx: ResponseOps - Execution & Connectors Apr 3, 2024
@ersin-erdal ersin-erdal self-assigned this Apr 3, 2024
@ersin-erdal ersin-erdal moved this from In Progress to In Review in AppEx: ResponseOps - Execution & Connectors Apr 3, 2024
ersin-erdal added a commit that referenced this issue Apr 5, 2024
Fixes: #179924

## To verify

Please follow the steps in the issue to reproduce.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants