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

[8.x] Enhance task failure log to include error source in tags (#199406) #200082

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

)

Resolves elastic#199346

In this PR I'm adding `user-error` and `framework-error` tags to the
associated task failure logs.

## To verify

You can either use the jest test to observe the returned flags or set
your logging to JSON and use the following code samples to test various
types of errors.

kibana.yml to set logging to JSON
```
logging:
  appenders:
    json-layout:
      type: console
      layout:
        type: json
  root:
    appenders: [json-layout]
```

Code samples throwing various types of errors.
```
diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts
index 89432e18220..129b53f71b4 100644
--- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts
+++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts
@@ -649,6 +649,10 @@ export class TaskRunner<
       schedule: taskSchedule,
     } = this.taskInstance;

+    // throw createTaskRunError(new Error('foo'), TaskErrorSource.USER);
+    // throw createTaskRunError(new Error('foo'), TaskErrorSource.FRAMEWORK);
+    // throw new Error('foo');
+
     this.logger = createTaskRunnerLogger({ logger: this.logger, tags: [ruleId, this.ruleType.id] });

     let stateWithMetrics: Result<RuleTaskStateAndMetrics, Error>;
```

(cherry picked from commit 544525d)
@kibanamachine kibanamachine merged commit 19b154f into elastic:8.x Nov 14, 2024
30 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @mikecote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants