Incidents that overlapped

joins

Incidents that overlapped

Datadog SQL Interview Question

When two Datadog alerts fire on one service at the same time, they are usually one failure seen twice, and paging two engineers for it is how an on-call rotation burns out. Before the alerts can be merged, the review needs the pairs that genuinely overlapped. Two incidents that merely touch, one ending exactly as the next begins, are separate events.

Return each overlapping pair once: the service, the lower incident id of the pair as earlier_incident, and the higher one as later_incident.

Asked of

  • Data Analyst
  • Analytics Engineer
  • Data Engineer
  • Data Scientist

datadog_incidentsTable20 rows

Column NameType
incident_idBIGINT
serviceVARCHAR
started_atTIMESTAMP
resolved_atTIMESTAMP
severityVARCHAR

datadog_incidentsExample Input

incident_idservicestarted_atresolved_atseverity
6001checkout-api2024-10-01 02:10:002024-10-01 03:40:00SEV2
6002checkout-api2024-10-01 03:05:002024-10-01 04:25:00SEV3
6003checkout-api2024-10-01 06:00:002024-10-01 06:45:00SEV1
6011billing-worker2024-10-01 12:00:002024-10-01 12:30:00SEV3
6012billing-worker2024-10-01 12:30:002024-10-01 13:15:00SEV2
6013billing-worker2024-10-01 15:40:002024-10-01 16:55:00SEV1

Example Output

serviceearlier_incidentlater_incident
checkout-api60016002

Explanation

In the example, 6001 ran from 2:10 to 3:40 and 6002 started at 3:05, before the first was resolved, so they overlap. The billing worker pair does not: one ended at 12:30 and the next began at 12:30, which is touching rather than overlapping.

The example above is a small slice of the data. Your query runs against the full tables.