DriftHound can send notifications to Slack when infrastructure drift is detected or resolved.
- Go to api.slack.com/apps
- Click "Create New App" → "From scratch"
- Name your app (e.g., "DriftHound") and select your workspace
- Click "Create App"
- In your app settings, navigate to "OAuth & Permissions"
- Scroll to "Scopes" → "Bot Token Scopes"
- Add these scopes:
chat:write- Post and update messages in channelschat:write.public- Post to public channels without joiningchannels:read- View basic channel info (needed for message updates)
- Scroll to the top of the "OAuth & Permissions" page
- Click "Install to Workspace"
- Review permissions and click "Allow"
- Copy the "Bot User OAuth Token" (starts with
xoxb-)
Set these environment variables:
export SLACK_NOTIFICATIONS_ENABLED=true
export SLACK_BOT_TOKEN=xoxb-your-token-here
export SLACK_DEFAULT_CHANNEL=#infrastructure-driftThat's it! New projects will automatically send notifications to your default channel.
Configure a specific Slack channel when running drift checks:
bin/drifthound-cli \
--tool=terraform \
--project=my-app \
--environment=production \
--token=$API_TOKEN \
--api-url=$DRIFTHOUND_URL \
--slack-channel=#production-alertsThe channel setting persists - you only need to specify it once. Future runs will use the saved channel.
Set different defaults per environment in config/notifications.yml:
production:
slack:
enabled: <%= ENV.fetch('SLACK_NOTIFICATIONS_ENABLED', 'false') == 'true' %>
token: <%= ENV['SLACK_BOT_TOKEN'] %>
default_channel: <%= ENV.fetch('SLACK_DEFAULT_CHANNEL', '#infrastructure-drift') %>Smart notifications - Only sends alerts when status changes:
ok→drift= New message posteddrift→ok= Original message updated (shows resolution time)drift→drift= No notification (anti-spam)
Message updates - When drift resolves, DriftHound updates the original Slack message in place. The message changes from red/orange to green, showing that the issue was resolved and how long it lasted. This keeps your channel clean and makes it easy to see which alerts are still active.
By default, the first drift check for a new environment does not trigger a notification. This is because:
- New environments start with
unknownstatus - The first check establishes a baseline
- This prevents notification spam when onboarding many environments
To receive notifications on first drift/error detection:
export NOTIFY_ON_FIRST_CHECK=true| First Check Result | NOTIFY_ON_FIRST_CHECK=false (default) |
NOTIFY_ON_FIRST_CHECK=true |
|---|---|---|
unknown → ok |
No notification | No notification |
unknown → drift |
No notification (baseline) | Drift Detected |
unknown → error |
No notification (baseline) | Error Detected |
No notifications?
- Check
SLACK_NOTIFICATIONS_ENABLED=trueis set - Verify
SLACK_BOT_TOKENis set correctly - Ensure background jobs are running:
bin/rails solid_queue:start
Bot can't post to private channels?
- Invite the bot:
/invite @DriftHound
Resolved notifications not updating the original message?
- Your Slack app may be missing required scopes
- Go to your Slack app settings → OAuth & Permissions
- Ensure you have:
chat:write,chat:write.public, andchannels:read - Reinstall the app to your workspace after adding scopes
- Update your
SLACK_BOT_TOKENwith the new token
Need different channels per project?
- Use
--slack-channelflag when runningdrifthound-clifor each environment - Settings are saved automatically