Git Product home page Git Product logo

cronitor-airflow's Introduction

cronitor-airflow

Cronitor integration for Airflow

Setting up the Cronitor Airflow provider

Installation

Install the package using pip:

pip install apache-airflow-providers-cronitor

Create a connection

Then, you need to create an Airflow "Connection" to store your Cronitor API key. There are a number of ways you can do this, including storing the connection information using a Secrets Backend.

The simplest way to quickly create the connection is to use the Airflow UI: img.png

Once you've selected "Connections", click "add a new record":

img_1.png

You will then see the "Add Connection" form. Select "Cronitor" as the connection type. It should be available as long as you have properly installed apache-airflow-providers-cronitor in your Airflow environment.

img_2.png

The best name for the connection is cronitor_default, following the default connection names for Airflow. This is the default Cronitor connection name used by the hook and operator. Finally, add your API key, and save.

Usage

Use the Operator directly

With that, you are ready to use the operator. Using the operator directly is simple. To import the operator:

from cronitor_airflow.operators.cronitor_operator import CronitorOperator

For a full example of how to use the operator, take a look at this sample DAG provided.

Usage Notes

  • When using the operator, monitor_key must be the key of your Cronitor monitor. You cannot use the monitor's display name.

Autoprovision monitors

The Cronitor Airflow integration can automatically watch your Airflow instances for active DAGs and create monitors in Cronitor that correspond to those DAGs. This is done via a specialized DAG that we've pre-written for you.

To use it, all you have to do is import and initialize the DAG in any Python file in the folder you are using to store your Airflow DAGs. (This is set by the dags_folder setting in airflow.cfg.)

from cronitor_airflow.example_dags.cronitor_autodiscover import autoprovision_monitors

# Defaults to the connection `cronitor_default`.
dag_1 = autoprovision_monitors()

# To specify a custom connection name:
dag_2 = autoprovision_monitors(cronitor_conn_id='cronitor_connection_2')

Airflow will load the DAG on the next DagBag refresh. Make sure you turn on the DAG in the Airflow UI once it is loaded so that it can start running.

Usage Notes

  • Currently, autodiscover will only provision and update monitors for DAGs that are in the DagBag and turned on.
  • Autodiscover does not currently support complex timetables. Any timetable that cannot be generalized to a cron schedule will be ignored, and noted as such in the logs.

cronitor-airflow's People

Contributors

jdotjdot avatar aflanagan avatar

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.