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.
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.
def detect_degradation(logs, window_size, error_percent, latency_threshold):