https://dagster.io/ logo
#dagster-support
Title
# dagster-support
t

Taqi

08/05/2022, 6:53 AM
Hi Everyone I am new to dagster. I want to set up a Slack Notification on failed jobs. I see a few documents but am not able to figure out where to add that piece of code in the dagster dashboard, can someone please help?
Copy code
@failure_hook(required_resource_keys={'slack'})
def slack_message_on_failure(context):
    message = 'op {} failed'.format(context.op.name)
    context.resources.slack.send_message(message)

@failure_hook
def do_something_on_failure(context):
    do_something()
o

owen

08/05/2022, 8:50 PM
Hi @Taqi! You can add a hook to every op in your job by doing:
Copy code
@job(..., hooks={do_something_on_failure})
def my_job():
    ...
see: https://docs.dagster.io/concepts/ops-jobs-graphs/op-hooks#applying-a-hook-on-every-op-in-a-job
You might also want to consider using make_slack_on_run_failure_sensor. Sensors work differently from hooks, and require the
dagster-daemon
to be running, but can catch more types of errors (such as if the job fails to start).
t

Taqi

08/06/2022, 3:16 PM
Thank you @owen, really appreciated it. I will update here if I need further help🙂.