Skip to main content

Lightweight error alerting via Telegram

Project description

watcherr

Lightweight error alerting via Telegram for Python apps.

Install

pip install watcherr

Optional integrations:

pip install watcherr[fastapi]
pip install watcherr[django]
pip install watcherr[celery]
pip install watcherr[all]

Setup

1. Get chat ID

WATCHERR_BOT_TOKEN=<your-token> watcherr

Send /start to the bot — it will reply with your chat_id.

2. Configure

Via code:

import watcherr

watcherr.configure(
    bot_token="123456:ABC-DEF",
    chat_id="-1001234567890",
    service_name="my-api",
)

Or via .env:

WATCHERR_BOT_TOKEN=123456:ABC-DEF
WATCHERR_CHAT_ID=-1001234567890
WATCHERR_SERVICE_NAME=my-api
WATCHERR_ENVIRONMENT=production

Usage

import watcherr

watcherr.send_alert("Database connection failed", exc=exception)
watcherr.send_warning("Slow query", table="users", duration="5s")
watcherr.send_info("Deployed", version="1.2.0")

Logging handler

import logging
from watcherr.logging_handler import WatcherrHandler

logging.getLogger("myapp").addHandler(WatcherrHandler())

FastAPI middleware

from watcherr.integrations.fastapi_middleware import WatcherrMiddleware

app.add_middleware(WatcherrMiddleware)

Django middleware

# settings.py
MIDDLEWARE = [
    "watcherr.integrations.django_middleware.WatcherrMiddleware",
    # ... other middleware
]

Celery signals

from watcherr.integrations.celery_signals import setup_celery_alerts

setup_celery_alerts()

Config options

Env variable Default Description
WATCHERR_BOT_TOKEN Telegram bot token
WATCHERR_CHAT_ID Telegram chat/group ID
WATCHERR_SERVICE_NAME app Service name in alert title
WATCHERR_ENVIRONMENT production Environment label
WATCHERR_RATE_LIMIT 60 Dedup window in seconds
WATCHERR_ENABLED true Enable/disable sending

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

watcherr-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

watcherr-0.1.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: watcherr-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for watcherr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4ab8552256ee4f7275d9f0b931589696072ffddc886cf395f0378a08be7fdc6b
MD5 7faed4f03ba6eedaaa52b74c343cfab1
BLAKE2b-256 45c543534ba5390af47fb662ab8f18b838edf289e491d22ff2e548d82e28345e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: watcherr-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for watcherr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 154eaedc7f2bad62e75fe33da879e48831839afb617373df84ec1e338293c823
MD5 0bd7fc41cc0ef2ada6b67aab1681e54c
BLAKE2b-256 3e90ab7686c7afd9c00e5f8f90c44043f62558a7b52bbc9ce9a0929ee94dd44d

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