-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migration(crons): Add MonitorIncident table #56435
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report
@@ Coverage Diff @@
## master #56435 +/- ##
==========================================
+ Coverage 77.41% 78.62% +1.21%
==========================================
Files 5081 5078 -3
Lines 218868 218355 -513
Branches 37068 36963 -105
==========================================
+ Hits 169435 171686 +2251
+ Misses 43787 41133 -2654
+ Partials 5646 5536 -110
|
starting_checkin = FlexibleForeignKey( | ||
"sentry.MonitorCheckIn", null=True, related_name="created_incidents" | ||
) | ||
starting_timestamp = models.DateTimeField(null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might not want to allow this to be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you ever have a MonitorIncident
that lacks a starting checkin and time?
This PR has a migration; here is the generated SQL for --
-- Create model MonitorIncident
--
CREATE TABLE "sentry_monitorincident" ("id" bigserial NOT NULL PRIMARY KEY, "starting_timestamp" timestamp with time zone NULL, "resolving_timestamp" timestamp with time zone NULL, "grouphash" varchar(32) NOT NULL, "date_added" timestamp with time zone NOT NULL, "monitor_id" bigint NOT NULL, "monitor_environment_id" bigint NOT NULL, "resolving_checkin_id" bigint NULL, "starting_checkin_id" bigint NULL);
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincident_monitor_id_0a9c5983_fk_sentry_monitor_id" FOREIGN KEY ("monitor_id") REFERENCES "sentry_monitor" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincident_monitor_id_0a9c5983_fk_sentry_monitor_id";
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincide_monitor_environment__30d108cb_fk_sentry_mo" FOREIGN KEY ("monitor_environment_id") REFERENCES "sentry_monitorenvironment" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincide_monitor_environment__30d108cb_fk_sentry_mo";
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincide_resolving_checkin_id_9b2daf6a_fk_sentry_mo" FOREIGN KEY ("resolving_checkin_id") REFERENCES "sentry_monitorcheckin" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincide_resolving_checkin_id_9b2daf6a_fk_sentry_mo";
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincide_starting_checkin_id_fc465c34_fk_sentry_mo" FOREIGN KEY ("starting_checkin_id") REFERENCES "sentry_monitorcheckin" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincide_starting_checkin_id_fc465c34_fk_sentry_mo";
CREATE INDEX CONCURRENTLY "sentry_monitorincident_monitor_id_0a9c5983" ON "sentry_monitorincident" ("monitor_id");
CREATE INDEX CONCURRENTLY "sentry_monitorincident_monitor_environment_id_30d108cb" ON "sentry_monitorincident" ("monitor_environment_id");
CREATE INDEX CONCURRENTLY "sentry_monitorincident_resolving_checkin_id_9b2daf6a" ON "sentry_monitorincident" ("resolving_checkin_id");
CREATE INDEX CONCURRENTLY "sentry_monitorincident_starting_checkin_id_fc465c34" ON "sentry_monitorincident" ("starting_checkin_id"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema looks good to me.
This PR has a migration; here is the generated SQL for --
-- Create model MonitorIncident
--
CREATE TABLE "sentry_monitorincident" ("id" bigserial NOT NULL PRIMARY KEY, "starting_timestamp" timestamp with time zone NULL, "resolving_timestamp" timestamp with time zone NULL, "grouphash" varchar(32) NOT NULL, "date_added" timestamp with time zone NOT NULL, "monitor_id" bigint NOT NULL, "monitor_environment_id" bigint NOT NULL, "resolving_checkin_id" bigint NULL, "starting_checkin_id" bigint NULL);
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincident_monitor_id_0a9c5983_fk_sentry_monitor_id" FOREIGN KEY ("monitor_id") REFERENCES "sentry_monitor" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincident_monitor_id_0a9c5983_fk_sentry_monitor_id";
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincide_monitor_environment__30d108cb_fk_sentry_mo" FOREIGN KEY ("monitor_environment_id") REFERENCES "sentry_monitorenvironment" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincide_monitor_environment__30d108cb_fk_sentry_mo";
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincide_resolving_checkin_id_9b2daf6a_fk_sentry_mo" FOREIGN KEY ("resolving_checkin_id") REFERENCES "sentry_monitorcheckin" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincide_resolving_checkin_id_9b2daf6a_fk_sentry_mo";
ALTER TABLE "sentry_monitorincident" ADD CONSTRAINT "sentry_monitorincide_starting_checkin_id_fc465c34_fk_sentry_mo" FOREIGN KEY ("starting_checkin_id") REFERENCES "sentry_monitorcheckin" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_monitorincident" VALIDATE CONSTRAINT "sentry_monitorincide_starting_checkin_id_fc465c34_fk_sentry_mo";
CREATE INDEX CONCURRENTLY "sentry_monitorincident_monitor_id_0a9c5983" ON "sentry_monitorincident" ("monitor_id");
CREATE INDEX CONCURRENTLY "sentry_monitorincident_monitor_environment_id_30d108cb" ON "sentry_monitorincident" ("monitor_environment_id");
CREATE INDEX CONCURRENTLY "sentry_monitorincident_resolving_checkin_id_9b2daf6a" ON "sentry_monitorincident" ("resolving_checkin_id");
CREATE INDEX CONCURRENTLY "sentry_monitorincident_starting_checkin_id_fc465c34" ON "sentry_monitorincident" ("starting_checkin_id"); |
Adds
MonitorIncidentTable
to keep track of open monitor incidents + display them on the timeline view.If a
failure
threshold is set, we will open anincident
and tag it with the appropriatehash
and reference thecheckin
that caused it to pass the threshold.If a
recovery
threshold is set, we will find anyincident
with the appropriatehash
and set it as theclosing_checkin
.In the future, if no thresholds are set, we will move to this behavior. But for now, we will keep existing behavior as-is.
The
thresholds
can be derived from thecheckin
configs, though we may want to add them as top level fields.Closes #56402
Rework of #56403