Skip to content

Slack Integration

Get notified in Slack when drift is detected.

Installation

pip install driftwatch[alerting]

Setup

1. Create Slack Webhook

  1. Go to Slack API
  2. Create new app
  3. Enable "Incoming Webhooks"
  4. Add webhook to workspace
  5. Copy webhook URL

2. Configure Alerter

from driftwatch.integrations.alerting import SlackAlerter

alerter = SlackAlerter(
    webhook_url="https://hooks.slack.com/services/YOUR/WEBHOOK/URL",
    throttle_minutes=60  # Max 1 alert per hour
)

Usage

from driftwatch import Monitor

monitor = Monitor(reference_data=train_df)
report = monitor.check(prod_df)

if report.has_drift():
    alerter.send(report)

Advanced Configuration

Custom Messages

alerter.send(
    report,
    custom_message="🚨 Production Model Alert - Immediate Action Required"
)

Mention Users

alerter = SlackAlerter(
    webhook_url="...",
    mention_user="U123ABC"  # Slack user ID
)

Channel Override

alerter = SlackAlerter(
    webhook_url="...",
    channel_override="#critical-alerts"
)

See Also