Complete the code to define a basic metric for monitoring model latency.
model_latency = [1]('model_latency_seconds')
A Histogram is used to observe the distribution of latency values over time, which is ideal for model latency monitoring.
Complete the code to set an alert threshold for SLA violation when error rate exceeds 5%.
if error_rate [1] 0.05: trigger_alert()
The alert triggers when the error_rate is greater than 5% (0.05), indicating SLA violation.
Fix the error in the Prometheus query to calculate 99th percentile latency.
histogram_quantile(0.99, sum(rate([1][5m])) by (le))
The histogram_quantile function requires the bucketed histogram metric, which ends with _bucket.
Fill both blanks to create a dictionary comprehension that maps model names to their error rates above 1%.
{model: [1] for model, [2] in metrics.items() if error_rate > 0.01}We want to map each model to its error_rate when the error rate is above 1%. Both blanks use error_rate.
Fill all three blanks to filter logs for errors, extract timestamps, and count occurrences.
error_counts = {log['[1]']: logs.count([2]) for log in logs if '[3]' in log['message']}The dictionary keys are timestamps, the count is of the log itself, and the filter checks if 'error' is in the message.