Skip to content
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

Add service column to BigQuery views 📈 #7

Merged
merged 12 commits into from
Mar 20, 2024
9 changes: 8 additions & 1 deletion queries/incidents.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
-- Incidents View
SELECT
source,
service,
incident_id,
MIN(IF(root.time_created < issue.time_created, root.time_created, issue.time_created)) AS time_created,
MAX(time_resolved) AS time_resolved,
ARRAY_AGG(root_cause IGNORE NULLS) AS changes,
FROM (
SELECT
source,
CASE
WHEN source LIKE "github%" THEN JSON_EXTRACT_SCALAR(metadata, '$.repository.full_name')
WHEN source LIKE "pagerduty%" THEN JSON_EXTRACT_SCALAR(metadata, '$.event.data.service.summary')
Comment on lines +13 to +14

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that these will match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these won't match. It will require the new services table to join service identifiers across platforms.

But the source field tells us what the context is for service, so we can perform that lookup.

END
AS service,
CASE
WHEN source LIKE "github%" THEN JSON_EXTRACT_SCALAR(metadata, '$.issue.number')
WHEN source LIKE "pagerduty%" THEN JSON_EXTRACT_SCALAR(metadata, '$.event.data.id')
Expand Down Expand Up @@ -48,6 +54,7 @@ ON
root.changes = root_cause
GROUP BY
1,
2
2,
3
HAVING
MAX(bug) IS TRUE ;