Skip to content

Create database tables for escalation policies and rules

The goal of &4638 is to add escalation policies for oncall schedules in projects, so that users can manage who is notified of an alert & when.

To enable the ability to read/write policies, we need to add two tables to the database, as laid out in https://gitlab.com/gitlab-org/monitor/monitor/-/issues/56.

Scope of this issue

  1. Add the tables to the DB
  2. Add the ActiveRecord models with validations

Not in scope: escalating alerts according to the escalation policies; backfilling policies for existing on-call schedules

Table: incident_management_escalation_policies

Model: IncidentManagement::EscalationPolicy

Column Required Type
id true Integer
project_id true Integer
name true text
description false text

Validations/constraints:

  • project, name should be present
  • name length should be under 72 chars
  • description length should be under 160 chars
  • Must have at least one EscalationRule
  • Unique constraint: name should be unique within the project.

Table: incident_management_escalation_rules

Model: IncidentManagement::EscalationRule

Column Required Type Description
id true Integer
policy_id true Integer IncidentManagement::EscalationPolicy to which the escalation rule belongs
status true Integer One of AlertManagement::Alert::STATUSES values for either :acknowlegded or :resolved
elapsed_time true Integer Time in minutes from the creation of an alert at which this rule should be enacted
schedule_id true Integer IncidentManagement::OncallSchedule which should be notified in escalation rule

Validations/constraints:

  • project, status, elapsed_time, schedule should all be present
  • schedule_id should belong to the project of escalation policy
  • status should be one of AlertManagement::Alert::STATUSES values for either :acknowlegded or :resolved (one of [1, 2])
  • elapsed_time should be an integer >= 0 & <= 24.hours
  • Unique constraint: Combo of policy_id, status, elapsed_time, schedule_id should be unique. This is all the attributes. Is there a simple way to do this? Should we allow duplicate rules?
Edited by Sarah Yasonik