Severity mix per service

reshaping

Severity mix per service

Datadog SQL Interview Question

Datadog decides where to spend reliability time from the shape of a service's incidents, not the count. Twenty low severity pages are an alerting problem that a threshold change fixes in an afternoon; two of the highest severity are an architecture problem. On separate rows the two services look alike.

Return the service, and the number of incidents at each level as sev1_incidents, sev2_incidents and sev3_incidents. A level a service never hit counts as zero.

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

servicesev1_incidentssev2_incidentssev3_incidents
billing-worker111
checkout-api111

Explanation

Each service in the example had one incident at each of the three levels. A service with none at a level would show a zero in that column rather than dropping out of the report.

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