Closed gberginc closed 2 years ago
@agrare This is the initial implementation of the event catcher for Intersight provider. The events are collected and pushed to DB with the parsed data:
2.7.2 :001 > pp EventStream.find(55)
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
EventStream Load (6.9ms) SELECT "event_streams".* FROM "event_streams" WHERE "event_streams"."id" = $1 LIMIT $2 [["id", 55], ["LIMIT", 1]]
EventStream Inst Including Associations (1643.8ms - 1rows)
#<EmsEvent:0x00007fbb6a41f730
id: 55,
event_type: "Info",
message:
"Port LAB02D02F01/switch-A/slot-1/ethport-50 has no transceiver inserted",
timestamp: Wed, 23 Feb 2022 04:39:33 UTC +00:00,
However, I can't seem to understand how to show them in the Timelines UI:
Is there any config missing? As the event is from February 23, I think the date filter in the UI should be fine.
@gberginc You will need add config in the event_groups
section of your settings.yml to show things on the timeline. See the event_groups section in the core repo or a provider specific one that uses regexes in the redfish repo.
It's hard to tell but it is organized in sections and then criticality which corresponds to the dropdowns you can choose in the UI for filtering.
Hope that helps.
I noticed your event_type is "Info", which is going to be really difficult to present properly as it's very generic. Is it possible to have a more "detailed" event type name?
That's awesome, @Fryguy, THANKS!
You are correct regarding event_type
, we were using wrong info. I'll push a change that uses the actual name of the event.
After adding the config for an alarm, I was able to see it in the timeline.
Still, I am not sure all is fine. I now have an alarm with the event_type = alarm_EtherTransceiverNotPresent
.
However, if I have this in config, I will not see it in the timeline:
:ems:
:ems_cisco_intersight:
:blacklisted_event_names: []
:event_handling:
:event_groups:
:general:
:critical:
- /^alarm_/
If I change the last line to have a complete event name, it works as shown in the screenshot before.
:ems:
:ems_cisco_intersight:
:blacklisted_event_names: []
:event_handling:
:event_groups:
:general:
:critical:
- alarm_EtherTransceiverNotPresent
I have also tried with /^alarm_.*/
but also did not get it.
Really odd as spec/lib/manageiq/reporting/formatter/timeline_spec.rb
passed all tests when I changed the test to use alarm_
prefix.
Also looking at this change that introduced regular expressions and the associated spec, I am able to pass all of them if I use my /^alarm_/
regex.
On the other hand, when I checked the actual SQL statement being requested in PG, I got the following (truncated for readability):
SELECT
"event_streams"."id" AS t0_r0, "event_streams"."event_type" AS t0_r1,
"event_streams"."message" AS t0_r2, "event_streams"."timestamp" AS t0_r3, ...
WHERE
((event_streams.ems_id = 2)
and (timestamp >= '2021-12-02 00:00:00') and (timestamp <= '2022-04-30 23:59:59')
and ((event_type in 'AD_COMPUTER_ACCOUNT_FAILED','AD_COMPUTER_ACCOUNT_SUCCEEDED', '/^alarm_/'))));
This obviously does not return a record as it's not really matching on regex (I think).
Could it be that there was a change in how we are retrieving events from the database and since the above spec does not check (again, I think) actual DB, it passes?
@agrare, do you have any suggestions how to reformat this code: https://github.com/tjazsch/manageiq-providers-cisco_intersight/blob/c63d19ca73a7586c98b308ec9803645e0590f671/app/models/manageiq/providers/cisco_intersight/physical_infra_manager/event_catcher/stream.rb#L39-L40 according to the miq-bot standards?
@tjazsch yes what rubocop is suggesting is:
def poll(&block)
...
events.each(&block)
workflow_infos.each(&block)
Thanks a lot!
This PR introduces an event catcher for Cisco Intersight provider.
Currently it is collecting Alarms only. A separate API call might be used to also collect some other information, but the logic will be very similar.