Skip to main content

Atalert slack alerting service helper module

Project description

Atalert Python Package

Atalert.dev

Too many different data notifications or alert packages got you down?

Start by using the Atalert Slack App to generate alert webhooks.

Customize the template, delivery channel, and notify your team.

Then, take note of the webhook URL slug for the code examples below!

It's a best practice to make as many different webhooks as you need for other functional areas, such as code deployments, new user registrations, and results of a long-running data pipeline. If there's information somewhere that's difficult to get to, use Atalert to send it to your Slack workspace.

Installation

pip install atalert or poetry add atalert

Basic Usage

import atalert


# add these to wherever you need to send a slack atalert, customize with your own data payload

# send an 'ok' atalert
atalert.ok('alert_slug_here', data)

# send a 'warning' atalert
atalert.warn('alert_slug_here', data)

# send an 'error' atalert
atalert.err('alert_slug_here', data)

You'll immediately get a custom alert notification in slack according to your webhook configuration.

Then all your data or platform alerts are in the one place you are every day, Slack!

Sending Files to Slack

First, configure your alert within the Atalert Slack App to use the 'attachment' template type.

Then, use any of the following methods:

from atalert import ok_file, warn_file, err_file

# send 'data.json' in the current working directory as a file attachment with OK status
ok_file('alert_slug_here', './data.json')

# send 'error.log' in as a file with ERROR status
err_file('alert_slug_here', './error.log')

# send 'datacat.jpg' as a picture with WARNING status
warn_file('alert_slug_here', './datacat.jpg')

Enjoy fine file-based data in your Slack workspace!

Decorator Usage

Want to simplify error notifications? Need to automatically send a method's return object somewhere? Use the decorators!

from atalert import atalert_on_error
from atalert import atalert_ok_result

# decorator configured with a webhook url slug, will forward any exceptions
@atalert_on_error('alert_slug_here')
def main_processing_method(*args, **kwargs):

	# do some things here that may go wrong and throw exceptions
	numbers = business / 0

	return numbers

@atalert_ok_result('alert_slug_here')
def alternate_processing_method(*args, **kwargs):
	# do some math here that you want to send to slack
	numbers = statistics.stdev(args)
	# whatever you return will automagically go to your predefined slack channel
	return numbers 

You'll get your code exception or method results sent directly to slack!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atalert-0.1.10.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atalert-0.1.10-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file atalert-0.1.10.tar.gz.

File metadata

  • Download URL: atalert-0.1.10.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.4 Darwin/19.6.0

File hashes

Hashes for atalert-0.1.10.tar.gz
Algorithm Hash digest
SHA256 a8cb865c314b558d8693fc2d0ef180dd22f460914e3e9fbbcf842ddbd9e8fd04
MD5 edca16d2784e7daa9625980896c71831
BLAKE2b-256 4260ead7e44e294d5c19f6767ae4783d31fa7fdbf60a5c4ad5613c5a92a33254

See more details on using hashes here.

File details

Details for the file atalert-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: atalert-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.4 Darwin/19.6.0

File hashes

Hashes for atalert-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 dfcb7b517f43ac561f1e19203f56b3d168890e066adee6c08818a7532a79a167
MD5 4fc7e7cc404d1cc0025da4f4b4bb5e0c
BLAKE2b-256 26f0d435390102ff4cab3f1e001a62b66ee90a2d44dcd251203789a15e645756

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page