Skip to content

Commit

Permalink
Merge pull request ManageIQ#11150 from lucasponce/update-hawkular-ale…
Browse files Browse the repository at this point in the history
…rting-prefixes

Add dataId prefixes for Hawkular Alerting
  • Loading branch information
chessbyte authored Sep 15, 2016
2 parents 6fe029e + c8a098a commit f034e77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ def process_alert(operation, miq_alert)

def convert_to_group_trigger(miq_alert)
eval_method = miq_alert[:conditions][:eval_method]
firing_match = case eval_method
when "mw_heap_used", "mw_non_heap_used" then 'ANY'
else 'ALL'
end
firing_match = 'ALL'
# Storing prefixes for Hawkular Metrics integration
# These prefixes are used by alert_profile_manager.rb on member triggers creation
context = { 'dataId.hm.type' => 'gauge', 'dataId.hm.prefix' => 'hm_g_' }
case eval_method
when "mw_heap_used", "mw_non_heap_used"
firing_match = 'ANY'
when "mw_accumulated_gc_duration"
context = { 'dataId.hm.type' => 'counter', 'dataId.hm.prefix' => 'hm_c_' }
end
::Hawkular::Alerts::Trigger.new('id' => "MiQ-#{miq_alert[:id]}",
'name' => miq_alert[:description],
'description' => miq_alert[:description],
'enabled' => miq_alert[:enabled],
'type' => :GROUP,
'eventType' => :EVENT,
'firingMatch' => firing_match,
'context' => context,
'tags' => {
'miq.event_type' => 'hawkular_event',
'miq.resource_type' => miq_alert[:based_on]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ def create_new_member(group_trigger, member_id)

def calculate_member_data_id_map(server, group_trigger)
data_id_map = {}
prefix = group_trigger.context['dataId.hm.prefix'].nil? ? '' : group_trigger.context['dataId.hm.prefix']
group_trigger.conditions.each do |condition|
data_id_map[condition.data_id] = "MI~R~[#{server.feed}/#{server.nativeid}]~MT~#{condition.data_id}"
data_id_map[condition.data_id] = "#{prefix}MI~R~[#{server.feed}/#{server.nativeid}]~MT~#{condition.data_id}"
unless condition.data2_id.nil?
data_id_map[condition.data2_id] = "MI~R~[#{server.feed}/#{server.nativeid}]~MT~#{condition.data2_id}"
data_id_map[condition.data2_id] = "#{prefix}MI~R~[#{server.feed}/#{server.nativeid}]~MT~#{condition.data2_id}"
end
end
data_id_map
Expand Down

0 comments on commit f034e77

Please sign in to comment.