LoginSignup
1
3

More than 3 years have passed since last update.

Digdagでエラー発生時にSlack通知をする

Last updated at Posted at 2019-10-29

概要

Digdagでエラー発生時にSlack通知をする。
Slackのincoming-webhookアプリでWebhook URLの発行を事前にしておき、下記SLACK_INCOMING_WEBHOOK_URLの値として記載する。
※以下サンプルは#general@channel通知なので注意。

slack_test.dig
_export:
  SLACK_INCOMING_WEBHOOK_URL: https://hooks.slack.com/services/xxxxxx/xxxxxx/xxxxxxxxxxxxxxxxxxxxx

_error:
  http>: ${SLACK_INCOMING_WEBHOOK_URL}
  method: POST
  content:
    username: "Digdag workflow"
    icon_emoji: ":x:"
    channel: "#general"
    attachments:
    - title: "Workflow failed!"
      text: <!channel> Error occurred! ${task_name}
      color: danger
  content_format: json

# 存在しないシェルを実行してエラー終了する
+step1:
  sh>: sh exec_not_exist.sh

実行

> digdag run test.dig -a

結果(Slack通知)

image.png

メモ

エラー発生時に以下の様に ${error.message}, ${error.stacktrace} でエラーの内容を参照・通知可能。

      text: <!channel> Error occurred! ${error.message}, ${error.stacktrace}

ただし下記の通り、Digdag自体のエラーなので見る必要なさそう。
image.png

参考

1
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3