Skip to content

Commit

Permalink
feat: blueprint for errorLogs function (#18)
Browse files Browse the repository at this point in the history
* feat: blueprint for errorLogs function

* Apply suggestions from code review

---------

Co-authored-by: Will Russell <[email protected]>
  • Loading branch information
shrutimantri and wrussell1999 authored Dec 11, 2024
1 parent 9560ccd commit 26580a9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions error-logs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
id: error-logs
namespace: company.team

tasks:
- id: fail
type: io.kestra.plugin.core.execution.Fail
errorMessage: Something went wrong, make sure to fix it asap!

errors:
- id: slack
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK') }}"
payload: |
{
"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'] }}`"
}
extend:
title: Using errorLogs function to send error message to Slack
description: >-
This `fail` task of the workflow will always fail.
The error logs are captured using the `errorLogs()` function which is sent
as a Slack alert message.
The `errorLogs()` function retrieves a list of error logs from the failed task run.
This is useful when sending alerts on failure. When using this function e.g. in a
Slack alert message, you'll have the context about why the execution failed.
tags:
- Error
- Fail
ee: false
demo: false
meta_description: This workflow uses errorLogs function to retrive list of error logs.

0 comments on commit 26580a9

Please sign in to comment.