0
0
Microservicessystem_design~10 mins

Alerting strategies in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the primary alert condition for high error rates.

Microservices
if service.error_rate [1] threshold:
    trigger_alert()
Drag options to blanks, or click blank then click option'
A==
B<
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causes alerts to trigger on low error rates.
Using '==' may miss cases where error rate is just above threshold.
2fill in blank
medium

Complete the code to add a cooldown period after an alert is triggered.

Microservices
if alert_triggered and time_since_last_alert [1] cooldown_period:
    send_alert()
Drag options to blanks, or click blank then click option'
A<
B==
C!=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' causes alerts to send too often.
Using '==' is too strict and may miss valid alert times.
3fill in blank
hard

Fix the error in the alert escalation logic.

Microservices
if alert.level [1] 'critical':
    notify_oncall_team()
Drag options to blanks, or click blank then click option'
A=
B==
C!=
D=>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' causes syntax errors in conditionals.
Using '=>' is invalid syntax in many languages.
4fill in blank
hard

Fill both blanks to filter alerts for services with high latency and critical severity.

Microservices
alerts = [a for a in all_alerts if a.latency [1] 200 and a.severity [2] 'critical']
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for latency filters low latency alerts incorrectly.
Using '!=' for severity includes non-critical alerts.
5fill in blank
hard

Fill all three blanks to create a dictionary of alerts filtered by service name, severity, and status.

Microservices
filtered_alerts = {a.[1]: a for a in alerts if a.severity [2] 'warning' and a.status [3] 'open'}
Drag options to blanks, or click blank then click option'
Aservice_name
B==
C!=
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' includes unwanted alerts.
Using 'timestamp' as key does not group by service.