Hi, I am trying to send slack notifications if one...
# ask-community
p
Hi, I am trying to send slack notifications if one of our dagster pipelines fails. I followed the this documentation (method:
dagster_slack.make_slack_on_run_failure_sensor
). I will add a code snippet at the end of my message. I added on purpose a
ZeroDivisionError: division by zero
error in my
zin_trend_tool_ingestion_job
. But If I run the pipeline, it only shows the error, but nothing in the logs about sending a slack notification. Is there someone that could help me out with the slack notification? Is there a way to test the slack notification? Should I add an additional configuration somewhere in order to let this work?
Copy code
zin_trend_tool_ingestion_schedule = ScheduleDefinition(
    job=zin_trend_tool_ingestion_job, cron_schedule="0 1 * * *"
)

def my_message_fn(context: PipelineFailureSensorContext) -> str:
    return "Pipeline {pipeline_name} failed! Error: {error}".format(
        pipeline_name=context.pipeline_run.pipeline_name,
        error=context.failure_event.message,
    )

slack_on_pipeline_failure = make_slack_on_pipeline_failure_sensor(
    channel="#notifications",
    slack_token=os.getenv("SLACK_TOKEN"),
    text_fn=my_message_fn,
)

@repository
def zin_trend_tool_repository():
    return [
        zin_trend_tool_ingestion_job,
        slack_on_pipeline_failure
    ]
🤖 1
d
Hi Paulo - just confirming, you have the daemon set up and the sensor turned on in Dagit? If you check the logs in the daemon when the pipeline fails, does it indicate that the slack_on_pipeline_failure sensor is running?
p
Hi @daniel, I have not specified somewhere. I just found this in my settings, I had to manually put it on. I will take a look at the daemon setup 🙂
s
Paulo, have you been able to resolve your issue?
p
Hi @sean, thank you for the question! I am sorry aswell @daniel that I didnt let you know if I resolved it. But I did thanks to your command! When prototyping locally I forgot that our daemon should be turned on manually. Once I put it on, everything worked as expected!
condagster 2