class Backup::Notifier::DataDog
Attributes
The aggregation_key
for the event
The alert_type
of the event (error/warning/info/success)
The DataDog
API key
The timestamp for the event
The host that generated the event
The priority of the event (low/normal)
The source_type for the event (nagios, hudson, jenkins, user, my apps, feed, chef, puppet, git, bitbucket, fabric, capistrano)
The title of the event
Public Class Methods
Backup::Notifier::Base::new
# File lib/backup/notifier/datadog.rb, line 49 def initialize(model, &block) super instance_eval(&block) if block_given? @title ||= "Backup #{ model.label }" end
Private Instance Methods
set alert type
# File lib/backup/notifier/datadog.rb, line 97 def default_alert_type(status) case status when :success then 'success' when :warning then 'warning' when :failure then 'error' end end
Notify the user of the backup operation results.
‘status` indicates one of the following:
‘:success` : The backup completed successfully. : Notification will be sent if `on_success` is `true`.
‘:warning` : The backup completed successfully, but warnings were logged. : Notification will be sent if `on_warning` or `on_success` is `true`.
‘:failure` : The backup operation failed. : Notification will be sent if `on_warning` or `on_success` is `true`.
# File lib/backup/notifier/datadog.rb, line 74 def notify!(status) msg = message.call(model, :status => status_data_for(status)) hash = { alert_type: default_alert_type(status) } hash.store(:msg_title, @title) hash.store(:date_happened, @date_happened) if @date_happened hash.store(:priority, @priority) if @priority hash.store(:host, @host) if @host hash.store(:tags, @tags) if @tags hash.store(:aggregation_key, @aggregation_key) if @aggregation_key hash.store(:source_type_name, @source_type_name) if @source_type_name hash.store(:alert_type, @alert_type) if @alert_type send_event(msg, hash) end
Dogapi::Client will raise an error if unsuccessful.
# File lib/backup/notifier/datadog.rb, line 90 def send_event(msg, hash) client = Dogapi::Client.new(@api_key) event = Dogapi::Event.new(msg, hash) client.emit_event(event) end