Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Extract KPIs from Unstructured Logs

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Extract KPIs from Unstructured Logs. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Write a script to parse unstructured log data and extract key performance indicators for a software release.

Use the provided release and log tables. Extract status codes and latency values from log messages, treating missing or malformed values as NULL.

Output

  1. One row per release, including releases with no matching logs.
  2. Columns: release_id, version, total_events, successful_events, error_events, error_rate_pct, avg_latency_ms, and p95_latency_ms.
  3. Count 2xx and 3xx statuses as successful, 5xx statuses as errors, and order by release_id ascending.

Schema

software_releases
ColumnTypeDescription
release_idPKINTUnique release identifier
versionVARCHAR(30)Release version label
release_dateDATEDate the release became available
release_logs
ColumnTypeDescription
log_idPKINTUnique log record identifier
release_idINTRelease associated with the log
logged_atTIMESTAMPTime the log event occurred
log_messageTEXTUnstructured event log text
Tablessoftware_releasesrelease_logs
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results