Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Rate Limit Log Stream Alerts

GoogleEasyPython00:00
Google
Your interviewer · DevOps Engineer
In session
Interviewer

Welcome to the Python screen for the DevOps Engineer role at Google.

The question is on your right: Rate Limit Log Stream Alerts. Read through the requirements first.

Would you like to talk through your approach, or are you ready to start coding?

Talking through your plan before coding is graded well.

Problem

In Google Cloud monitoring pipelines, SRE tooling often needs to suppress duplicate alerts from noisy log streams. Given a sequence of log events sorted by timestamp, return which events should trigger an alert if the same message may only be alerted once every 10 seconds.

Formal Specification

Implement a function that takes logs, where each element is a pair [timestamp, message]:

  • timestamp is an integer number of seconds
  • message is a string
  • logs is sorted in non-decreasing order by timestamp

Return a list of booleans of the same length where result[i] is true if logs[i] should be alerted, otherwise false.

A message should be alerted if either:

  1. It has never appeared before, or
  2. Its previous alerted occurrence was at least 10 seconds earlier

Constraints

  • 1 <= len(logs) <= 10^5
  • 0 <= timestamp <= 10^9
  • 1 <= len(message) <= 100
  • logs is sorted in non-decreasing order by timestamp

Function Signature

def rate_limit_alerts(logs):
Your solutionPython 3
Run as often as you like, then submit when the output looks right.
Run your code to see test output