Suppress alerts to not create incident during change scheduled period
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2023 01:16 PM
There is one usecase I have been working on. There is an Alert Management Rule which will create an incident when an alert is created. Whenever a change request is created, and the current state of change request is in scheduled/implementation state, the alert generated within this period should not create incident as the CI would be in maintenance state. I am not allowed to change any alert management rules which is already configured. I have come up with a solution to this, but this is not working.
I have created an event registry:
After that I had created a business rule:
Withing advance, I have added this code(can be seen in picture also):
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.eventQueue('maintenance_flag',current,current.sys_updated_on,current.cmdb_ci);
})(current, previous);
And finally I created a script action:
var tr = new GlideRecord("task_ci");
tr.addEncodedQuery('task.sys_class_name=change_request^task.stateIN-2,-1^ci_item='+event.parm2);
tr.addQuery('task.ref_change_request.end_date','>=',event.parm1);
tr.addQuery('task.ref_change_request.start_date','<=',event.parm1);
tr.query();
while(tr.next())
{
current.maintenance=true;
current.update();
}
But this approach is not working, the incidents are still created.
Please help me.
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 01:06 PM
The most likely reason could be the business rule firing after the incident has been created or Alert Management Flow already triggered and past the maintenance checkpoint.
Try changing the business rule to run before insert and with the same logic you have to populate the maintenance flag at the time of insert. ( This essentially means, you need not have to use the event you created creation 'maintenance_flag' - using this would delay the script action execution by Alert Management and hence is the reason the incident is being created).
Hope this helps you ritesh1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2023 06:41 AM
There is already OOTB functionality to prevent incident creation during change window.
So whenever change is in implementation state, alert will be marked in maintenance & incident won't be created due to condition present in flow designer attached to alert management rule.