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
- Add the tables to the DB
- 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,nameshould be present -
namelength should be under 72 chars -
descriptionlength should be under 160 chars - Must have at least one
EscalationRule - Unique constraint:
nameshould 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,scheduleshould all be present -
schedule_idshould belong to the project of escalation policy -
statusshould be one ofAlertManagement::Alert::STATUSESvalues for either:acknowlegdedor:resolved(one of[1, 2]) -
elapsed_timeshould be an integer >= 0 & <= 24.hours - Unique constraint: Combo of
policy_id, status, elapsed_time, schedule_idshould be unique. This is all the attributes. Is there a simple way to do this? Should we allow duplicate rules?
Edited by Sarah Yasonik