Name

sn_em_arm.EvtMgmtCreateAlertMgmtJob

Description

The created alerts job

Script

var EvtMgmtCreateAlertMgmtJob = Class.create();
EvtMgmtCreateAlertMgmtJob.prototype = Object.extendsObject(EvtMgmtAlertMgmtJob, {

  type: 'EvtMgmtCreateAlertMgmtJob',

  getStartTime: function() {
      var startTime = this.lastCreatedTimeHash.getValue('hash');
      return startTime;
  },

  getInProgressTime: function() {
      var queryJobLatestRunEndTime = new GlideDateTime(this.lastQueryJobRunHash.getValue('hash'));

      // Take alert_rule_delay property into consideration
      var alertRuleDelay = new GlideDateTime();
      var backSeconds = gs.getProperty(this.ALERT_MANAGEMENT_DELAY, "5");
      var gt = new GlideTime(1000 * backSeconds);
      alertRuleDelay.subtract(gt);

      // If the query job finished then we have to wait for the delay of evt_mgmt.alert_rule_delay to be over
      // Else, the delay already passed and we have to wait for the query job to finish
      // Therefore, Take the earliest value between the end of the query job and the alert rule delay as end time,
      // to take fewer alerts - the ones that did finish their processing or their delay time passed
      var endTime = alertRuleDelay.before(queryJobLatestRunEndTime) ? alertRuleDelay.getValue() : queryJobLatestRunEndTime.getValue();
      return endTime;
  },

  getAlerts: function(startTime, endTime, jobNum) {
      //cover all the alerts between 2 group executions, in addition do not take the virtual
      //because it should handle in the update script.

      var recentAlerts = this.evtMgmtAlertMgmtUtils.getCreatedAlerts(startTime, endTime, this.chunkSize, jobNum);
      return recentAlerts;
  },

  getAlertsThisSecond: function(exactTime, lastSimultaneousAlertNumber, jobNum) {
      return this.evtMgmtAlertMgmtUtils.getCreatedAlertsThisSecond(exactTime, lastSimultaneousAlertNumber, this.chunkSize, jobNum);
  },

  getLastGrTime: function(gr) {
      return gr.getValue("sys_created_on");
  },

  updateHash: function(inProgressEndTime) {
      // This will update the hash to the earliest time between:
      // * the query job latest run end time
      // * the latest alert rule job run with delay end time
      // * or, to the latest processed alert time in case alerts process count limit was reached (chunkSize).
      this.lastCreatedTimeHash.setValue('hash', inProgressEndTime);
      this.lastCreatedTimeHash.update();
  },

});

Sys ID

1a1c8d6eb79920107c038229ce11a9df

Offical Documentation

Official Docs: