Skip to main content

Crete and send Slack messages and alerts through a webhook

Project description

Slackertpy

A simple way to create and send Slack messages through a webhook.

Especially useful for logging and alerting, supports three logging levels Error, Info, Debug and templates to simplify sending the same layout message with different content.

This is a port from a Ruby library Slackert. Follow Slackert's documnetation for in depth description of classes and methods.

Installation

Install using pip

pip install slackertpy

Usage

Slackert sends message through an incoming webhook.

Initialize alerr client that will handle sending out your messages

from slackertpy import Alerter
alerter = Alerter('your-webhook-url)

Create a message with templates

from slackertpy import templates
simple_message = templates.notification(
    text="Hello from Slackert!"
)

Send it on its way with alerter

alerter.info(simple_message)

You can use richer templates or compose messages from scratch using MessageBuilder. Consult the documentation for more information.

alert = templates.notification(text='Incoming debug info!', title='Silly Little Job')
alerter.debug(alert)


alert = templates.job_executed(
    title='Process ABC',
    result='Success',
    overview={
        'Start Time': process_start_time,
        'Server Location': 'US'
    },
    stats={
        'Records': 12345,
        'Retries': 3
    }
)
alerter.info(alert)

Tag users to notify them an exception was raised

error_alert = templates.job_error(
    title='Process ABC',
    error=error_output,
    notify_user_ids=['MemberID1', 'MemberID2'],
    extra={
        'Retries': num_retries
    }
)

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

slackertpy-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

slackertpy-0.1.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file slackertpy-0.1.1.tar.gz.

File metadata

  • Download URL: slackertpy-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for slackertpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ef78825e953682083de26645a5aabaee532e4200cf8648c09ab91ec9700ec99f
MD5 22eb857ffa2b74def318f55a7c5921b7
BLAKE2b-256 a55765821902c7560601d0d3e585f49032fdabb4496c63914aac302eb670cbf7

See more details on using hashes here.

File details

Details for the file slackertpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: slackertpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for slackertpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9692039b623634dc2408b40ec14586d6196d69d573cdef1a13db9937cfbb369
MD5 3e6fc350aa4ae39dc64e1f5deb196648
BLAKE2b-256 efcf2149a49c850f6f9fbb1df5d4c7f5689bb65d86d255968e6028f2a95831b5

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