In a Databricks observability workflow, you need to process a massive web server log and identify which client IP addresses generated the most server-side failures. Write a function that scans log lines and returns the top k IP addresses by number of HTTP 5xx responses.
Implement a function that takes:
log_lines: a list of strings, where each string is one log entryk: an integerEach valid log line follows this simplified format:
"<ip> - - [timestamp] \"METHOD PATH HTTP/1.1\" status bytes"
A line should count toward an IP only if:
500 to 599Return a list of [ip, count] pairs sorted by:
Ignore malformed lines and lines with non-integer status codes.
1 <= len(log_lines) <= 10^51 <= len(log_lines[i]) <= 3001 <= k <= 10^4def top_5xx_ips(log_lines, k):