Git Product home page Git Product logo

cs-tutorial-msteams-callbacks's Introduction

Airflow Callbacks

Showcasing several ways to implement Airflow callbacks and notifications via Microsoft Teams.

Description

Monitoring tasks and DAGs at scale can be cumbersome. Sometimes you'd like to be notified of certain events, and not others. These DAGs cover several methods of implementing custom Microsoft Teams notifications, so you can be confident you aren't missing critical events that may require immediate attention.

Note: The MS Teams Hook and MS Teams Operator used in this repo were forked from mendhak/Airflow-MS-Teams-Operator

Microsoft Teams Callback Examples

Example Callbacks

Getting Started

Dependencies

To implement notifications Microsoft Teams, add this to your requirements.txt:

apache-airflow-providers-http

Installing

In order to run these demos on your localhost, be sure to install:

Executing demos

Clone this repository, then navigate to the cs-tutorial-msteams-callbacks directory and start your local Airflow instance:

astro dev start

In your browser, navigate to http://localhost:8080/

  • Username: admin

  • Password: admin

Setting up MS Teams Connections in Airflow

In order to receive callback notifications, you must also create your webhooks and set up your connections in the Airflow UI. follow the instructions found in the Appendix section of the accompanying slide deck.

Additional Resources

cs-tutorial-msteams-callbacks's People

Contributors

virajmparekh avatar tjanif avatar aspain avatar

Stargazers

fritz avatar Lucas Cavalcanti Rodrigues avatar  avatar R.A.Walshe avatar Frank Cash avatar Chris Young avatar Fractals avatar Mohammad Isleem avatar

Watchers

James Cloos avatar Marc Lamberti avatar Carlos avatar  avatar  avatar Michael Robinson avatar

cs-tutorial-msteams-callbacks's Issues

Attribute Error

File "/usr/local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 1702, in _run_finished_callback
callback(context)
File "/usr/local/airflow/include/ms_teams_callback_functions.py", line 55, in success_callback
teams_notification = MSTeamsWebhookOperator(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/models/baseoperator.py", line 437, in apply_defaults
result = func(self, **kwargs, default_args=default_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/airflow/include/operators/ms_teams_webhook_operator.py", line 74, in init
self.hook = None
^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airflow/models/baseoperator.py", line 1045, in setattr
super().setattr(key, value)

Receives "Bad payload received by generic incoming webhook." as response

After upgrading to Airflow 2.5.1 recently the ms_teams_webhook_hook.py won't function anymore as intended. The error was in the summary and in the activityTitle overhanded to the webhook here. It was related to the quotation marks used in self.message. Double Quotes are used there and they seem to create a malformed payload.
Replacing them with single quotes won't work either and also creates a malformed payload.

My best Idea to fix it was to

self.message = message

here with

self.message = message.replace('"', '\\"')

The Problem with this workaround is that the Message won't be formatted ideally anymore.

image

I'm open to better Ideas or to create a PR if guided what the best way to create one would be.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.