Complete the code to define the primary alert condition for high error rates.
if service.error_rate [1] threshold: trigger_alert()
The alert should trigger when the error rate is greater than the threshold.
Complete the code to add a cooldown period after an alert is triggered.
if alert_triggered and time_since_last_alert [1] cooldown_period: send_alert()
The cooldown period prevents sending alerts too frequently, so we check if enough time has passed.
Fix the error in the alert escalation logic.
if alert.level [1] 'critical': notify_oncall_team()
Use '==' to compare values in conditions. '=' is assignment and causes errors.
Fill both blanks to filter alerts for services with high latency and critical severity.
alerts = [a for a in all_alerts if a.latency [1] 200 and a.severity [2] 'critical']
We want alerts where latency is greater than 200 and severity equals 'critical'.
Fill all three blanks to create a dictionary of alerts filtered by service name, severity, and status.
filtered_alerts = {a.[1]: a for a in alerts if a.severity [2] 'warning' and a.status [3] 'open'}The dictionary keys are service names. We filter alerts where severity equals 'warning' and status equals 'open'.