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

Add user-error and framework-error tags to task manager run failure logs #199346

Closed
2 tasks done
mikecote opened this issue Nov 7, 2024 · 1 comment · Fixed by #199406
Closed
2 tasks done

Add user-error and framework-error tags to task manager run failure logs #199346

mikecote opened this issue Nov 7, 2024 · 1 comment · Fixed by #199406
Assignees
Labels
Feature:Task Manager Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@mikecote
Copy link
Contributor

mikecote commented Nov 7, 2024

Similar to how we tag alerting rule run failures and connector run failures, we should either add the user-error or framework-error tag whenever logging a task run failure.

Definition of Done

  • user-error or framework-error tag included whenever task manager logs a task run failure with the task-run-failed tag
  • Tests
@mikecote mikecote added Feature:Task Manager Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Nov 7, 2024
@elasticmachine
Copy link
Contributor

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

@mikecote mikecote self-assigned this Nov 8, 2024
@mikecote mikecote changed the title Add user_error and framework_error tags to task manager run failure logs Add user-error and framework-error tags to task manager run failure logs Nov 8, 2024
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Nov 13, 2024
)

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)
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this issue Nov 18, 2024
)

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>;
```
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this issue Nov 18, 2024
)

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>;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Task Manager Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants