-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support alerts on container nodes #13812
Conversation
@cben please review |
@miq-bot add_label enhancement, providers/containers |
@simon3z please review |
@cben can you review this first? |
app/models/ems_event.rb
Outdated
@@ -196,6 +196,7 @@ def get_target(target_type) | |||
target_type = "src_vm_or_template" if target_type == "src_vm" | |||
target_type = "dest_vm_or_template" if target_type == "dest_vm" | |||
target_type = "middleware_server" if event.event_type == "hawkular_alert" | |||
target_type = "container_node" if event.event_type == "datawarehouse_event" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these need to be renamed to datawarehouse_alert as @lucasponce pointed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sufficient now but you need a plan for deriving target_type when you'll have more entities beside container_node...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes though of that but I'm not sure yet
@cben please review |
app/models/container_node.rb
Outdated
else | ||
User.super_admin.tap { |u| u.current_group = Tenant.root_tenant.default_miq_group } | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we could stop copy-pasting this black magic, but that would take someone who understands it to suggest an appropriate place...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we can 😄 since TenantIdentityMixin
is already included here 👍
def evaluate_alert(_alert_id, _event) | ||
# currently only EmsEvents from hawkular are tested for node alerts, | ||
# and these should automaticaly be translated to alerts. | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for now, because we don't currently support regular MiqExpression-evaluating alerts on container entities.
But would it be hard to check something on the event to confirm it's a hawkular alerting event, just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to add something that will propegate to this point in #12773 then I will be able to add a check
app/models/ems_event.rb
Outdated
@@ -196,6 +196,7 @@ def get_target(target_type) | |||
target_type = "src_vm_or_template" if target_type == "src_vm" | |||
target_type = "dest_vm_or_template" if target_type == "dest_vm" | |||
target_type = "middleware_server" if event.event_type == "hawkular_alert" | |||
target_type = "container_node" if event.event_type == "datawarehouse_event" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sufficient now but you need a plan for deriving target_type when you'll have more entities beside container_node...
app/models/miq_alert.rb
Outdated
@@ -434,7 +435,9 @@ def self.automate_expressions | |||
:options => [ | |||
{:name => :mw_operator, :description => _("Operator"), :values => [">", ">=", "<", "<=", "="]}, | |||
{:name => :value_mw_garbage_collector, :description => _("Duration Per Minute (ms)"), :numeric => true} | |||
]} | |||
]}, | |||
{:name => "hwk_generic", :description => _("All hawkular alerts"), :db => ["ContainerNode"], :responds_to_events => "datawarehouse_event", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"All hawkular alerts" may need more context given the existing middleware conditions above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "All Datawarehouse Events" ?
4737214
to
0307b70
Compare
Thanks @cben 🎉 |
@cben can you review/ack this? |
LGTM |
@moolitayer @cben anything to test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the size of the PR 👍
@@ -196,6 +196,7 @@ def get_target(target_type) | |||
target_type = "src_vm_or_template" if target_type == "src_vm" | |||
target_type = "dest_vm_or_template" if target_type == "dest_vm" | |||
target_type = "middleware_server" if event.event_type == "hawkular_alert" | |||
target_type = "container_node" if event.event_type == "datawarehouse_alert" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already dislike the one line above, where it does implicitly connects hawkular
to middleware_server
Is it possible to switch on something else than datawarehose_alert
? Maybe not switch on event.event_type
but on some other meta data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This as well as the logic in container_node.evaluate_alert would be much, much easier to improve in #12773 when this is merged. Can we try to do it at that iteration please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I guess you are the only provider that sends datawarehouse_alert
anyway
app/models/miq_alert.rb
Outdated
@@ -434,7 +435,9 @@ def self.automate_expressions | |||
:options => [ | |||
{:name => :mw_operator, :description => _("Operator"), :values => [">", ">=", "<", "<=", "="]}, | |||
{:name => :value_mw_garbage_collector, :description => _("Duration Per Minute (ms)"), :numeric => true} | |||
]} | |||
]}, | |||
{:name => "hwk_generic", :description => _("All Datawarehouse alerts"), :db => ["ContainerNode"], :responds_to_events => "datawarehouse_alert", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be dwh_generic
?
0307b70
to
92cc359
Compare
Checked commit moolitayer@92cc359 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
I'm adding tests for the entire flow in the event collection patch |
Integration failure seems unrelated
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -196,6 +196,7 @@ def get_target(target_type) | |||
target_type = "src_vm_or_template" if target_type == "src_vm" | |||
target_type = "dest_vm_or_template" if target_type == "dest_vm" | |||
target_type = "middleware_server" if event.event_type == "hawkular_alert" | |||
target_type = "container_node" if event.event_type == "datawarehouse_alert" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I guess you are the only provider that sends datawarehouse_alert
anyway
@miq-bot assign @blomquisg |
Add the ability to define miq alerts on container nodes.
The usual flow miq alert statuses are created: an ems event is collected and then evaluated for an alert[1]
Currently only ems events from Hawkular are evaluated for alerts on container nodes.
Since we are offloading the logic of triggering to Hawkular every ems event already means a miq_alert_status needs to be created (if a miq alert has been defined)
Currently we only support defining the miq alert on all the nodes in the enterprise since that is what we would use (actual target object is found based on metadata on the incoming event)
Extracted from #12773
[1]
manageiq/lib/ems_event_helper.rb
Line 33 in ff425fd