From 88f4eaafb27a828825d15bed161917ccea3d3b16 Mon Sep 17 00:00:00 2001 From: Raphael Pierzina Date: Wed, 29 May 2024 14:54:11 +0200 Subject: [PATCH] Ensure we don't correlate incidents with staging deploys --- queries/incidents.sql | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/queries/incidents.sql b/queries/incidents.sql index eeb6d970..ca5f7be3 100644 --- a/queries/incidents.sql +++ b/queries/incidents.sql @@ -38,7 +38,8 @@ WITH ), issue AS ( SELECT - * + *, + NULL as deployment_environment -- Remove this once we collect deployment_environment FROM github_pagerduty UNION ALL @@ -50,6 +51,7 @@ WITH time_resolved, root_cause, TRUE as bug, + deployment_environment, -- This is expected to always be `production` FROM `four_keys.incidents_google_form` ) @@ -80,11 +82,16 @@ LEFT JOIN ( service, environment FROM - four_keys.deployments d, + `four_keys.deployments` AS d, d.changes ) AS root ON - ( service_catalog.service = root.service AND root_cause = root.changes ) + service_catalog.service = root.service + AND root_cause = root.changes + -- GitHub and PagerDuty incidents don't contain information about the environment. + -- Google Form incidents are always reported for the `production` environment. + -- The following ensures we don't correlate incidents with `staging` deployments. + AND issue.deployment_environment = root.environment GROUP BY 1, 2,