Class: Findbug::Alerts::Channels::Webhook
- Defined in:
- lib/findbug/alerts/channels/webhook.rb
Overview
Webhook sends alerts to a generic HTTP endpoint.
CONFIGURATION
config.alerts do |alerts|
alerts.webhook(
enabled: true,
url: "https://your-service.com/findbug-webhook",
headers: {
"Authorization" => "Bearer #{ENV['WEBHOOK_TOKEN']}",
"X-Custom-Header" => "value"
},
method: "POST" # optional, defaults to POST
)
end
PAYLOAD FORMAT
The webhook receives a JSON payload with the full error event:
{
"event_type": "error",
"error": {
"id": 123,
"exception_class": "NoMethodError",
"message": "undefined method...",
"severity": "error",
"occurrence_count": 5,
"first_seen_at": "2024-01-01T00:00:00Z",
"last_seen_at": "2024-01-01T01:00:00Z",
"environment": "production",
"release": "abc123",
"backtrace": [...],
"context": {...}
}
}
USE CASES
-
Custom alerting systems
-
Integration with internal tools
-
PagerDuty/OpsGenie (if no native integration)
-
Log aggregation services
-
Custom notification services
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
59 60 61 62 63 64 65 |
# File 'lib/findbug/alerts/channels/webhook.rb', line 59 def send_alert(error_event) url = config[:url] return if url.blank? payload = build_payload(error_event) post_to_webhook(url, payload) end |