Giter Site home page Giter Site logo

alerter's Introduction

alt text Alerter

Alerter is a decorator that converts a function into an e-mail notifier about errors. This is meant to be an easy way to implement custom state based alerts.

Alerter uses Fibonacci to determine the next time to send an alert, and keeps processes that enter bad states from flooding your inbox.

Setup

Getting started

Update Config.py.example with your configuration parameters. Rename this file Config.py and move it into the src directory.

Configuration

Config.py
notification_emails = [
	'[email protected]'
]

email_user = 'gmailuser'
email_password = 'gmailpassword'

default_directory = 'directory where logs will be saved'

slack_endpoint = 'post endpoint for slack webhook'

Implementation

The function that alerter decorates must return a tuple (bool, string): bool - whether or not an alert should be sent. string - the message to be sent along with the alert.

from Alerter import alerter

@alerter(name='passing_alert', path='~/')
def passing_alert():
	return (False, '')

@alerter(name='failing_alert', path='~/')
def failing_alert():
	return (True, 'This alert is sent because a failure criteria is met.')

# this alert will send an exception indicating the alert itself has failed.
@alerter(name='exception_alert', path='~/')
def exception_alert():
	return 1/0

Webhooks

alt text

Will work out of the box with Slack. Go to: https://api.slack.com/incoming-webhooks to configure.

alerter's People

Contributors

popnfreshspk avatar

Watchers

 avatar James Cloos 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.