The dashboard says the API handled 20 requests between 10:00 and 10:05, then 29 between 10:05 and 10:10. The alert says 44 requests in five minutes . You open the alert settings to find out who taught it arithmetic.
Before changing anything, look at the minute-by-minute counts. Each row pairs a minute from the first dashboard bar with a minute from the second. The count at 10:03 covers the minute starting at 10:03.
First bar Requests Second bar Requests
10:00 1 10:05 10
10:01 1 10:06 9
10:02 1 10:07 8
10:03 8 10:08 1
10:04 9 10:09 1
Start at 10:03 and count five minutes: 8 + 9 + 10 + 9 + 8 = 44 . The busiest stretch straddles the line between the bars. The dashboard answered “How many requests were in each of these two blocks?” The alert answered “Did any five consecutive minutes reach 40 requests?” Both got full marks for arithmetic.
Let’s build the function behind the second question.…