Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Log Parsing for Degradation Patterns

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Log Parsing for Degradation Patterns. Start with the requirements 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

Roblox infrastructure logs contain timestamped observations for multiple services. Identify every fixed-size window of consecutive observations for a service that indicates degradation because its error rate or average latency exceeds a configured threshold.

Each log line has the format timestamp service latency_ms status, separated by spaces. timestamp is an integer, service is a single word, latency_ms is a nonnegative integer, and status is either OK or ERROR. Logs may be unordered and may contain multiple services.

Implement detect_degradation(logs, window_size, error_percent, latency_threshold) and return a list of arrays [service, start_timestamp, end_timestamp]. Sort the result by service name, then by start timestamp. Windows may overlap. A window is degraded when its error percentage is at least error_percent or its average latency is at least latency_threshold.

Constraints

  • 1 <= len(logs) <= 10^5
  • 1 <= window_size <= len(logs)
  • 0 <= error_percent <= 100
  • 0 <= latency_threshold <= 10^9
  • Each service has a unique timestamp per observation
  • All log lines follow the specified format

Function Signature

def detect_degradation(logs, window_size, error_percent, latency_threshold):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output