Class: Findbug::Alerts::Channels::Slack
- Defined in:
- lib/findbug/alerts/channels/slack.rb
Overview
Slack sends alerts via Slack incoming webhooks.
CONFIGURATION
config.alerts do |alerts|
alerts.slack(
enabled: true,
webhook_url: ENV["SLACK_WEBHOOK_URL"],
channel: "#errors", # optional, overrides webhook default
username: "Findbug", # optional
icon_emoji: ":bug:" # optional
)
end
SETTING UP SLACK WEBHOOK
-
Go to api.slack.com/apps
-
Create a new app (or use existing)
-
Add “Incoming Webhooks” feature
-
Create a webhook for your channel
-
Copy the webhook URL
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Findbug::Alerts::Channels::Base
Instance Method Details
#send_alert(error_event) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/findbug/alerts/channels/slack.rb', line 35 def send_alert(error_event) webhook_url = config[:webhook_url] return if webhook_url.blank? payload = build_payload(error_event) post_to_webhook(webhook_url, payload) end |