Skip to content

Commit 26580a9

Browse files
feat: blueprint for errorLogs function (#18)
* feat: blueprint for errorLogs function * Apply suggestions from code review --------- Co-authored-by: Will Russell <[email protected]>
1 parent 9560ccd commit 26580a9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

error-logs.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
id: error-logs
2+
namespace: company.team
3+
4+
tasks:
5+
- id: fail
6+
type: io.kestra.plugin.core.execution.Fail
7+
errorMessage: Something went wrong, make sure to fix it asap!
8+
9+
errors:
10+
- id: slack
11+
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
12+
url: "{{ secret('SLACK_WEBHOOK') }}"
13+
payload: |
14+
{
15+
"text": "Failure alert for flow `{{ flow.namespace }}.{{ flow.id }}` with ID `{{ execution.id }}`. Here is a bit more context about why the execution failed: `{{ errorLogs()[0]['message'] }}`"
16+
}
17+
18+
extend:
19+
title: Using errorLogs function to send error message to Slack
20+
description: >-
21+
This `fail` task of the workflow will always fail.
22+
23+
The error logs are captured using the `errorLogs()` function which is sent
24+
as a Slack alert message.
25+
26+
The `errorLogs()` function retrieves a list of error logs from the failed task run.
27+
This is useful when sending alerts on failure. When using this function e.g. in a
28+
Slack alert message, you'll have the context about why the execution failed.
29+
tags:
30+
- Error
31+
- Fail
32+
ee: false
33+
demo: false
34+
meta_description: This workflow uses errorLogs function to retrive list of error logs.

0 commit comments

Comments
 (0)