Interview Prep/AWS/Observability, Deployments and Governance

How do you alert on an error-rate percentage instead of a raw count?

IntermediateProductionObservability, Deployments and Governance
Answer

Metric math in the alarm:

aws cloudwatch put-metric-alarm --alarm-name orders-5xx-rate \
  --evaluation-periods 5 --datapoints-to-alarm 3 --threshold 2 \
  --comparison-operator GreaterThanThreshold --treat-missing-data notBreaching \
  --metrics '[
   {"Id":"e","Expression":"100*(errors/requests)","Label":"5xx %","ReturnData":true},
   {"Id":"errors","MetricStat":{"Metric":{"Namespace":"AWS/ApplicationELB","MetricName":"HTTPCode_Target_5XX_Count","Dimensions":[{"Name":"LoadBalancer","Value":"app/orders/abc123"}]},"Period":60,"Stat":"Sum"},"ReturnData":false},
   {"Id":"requests","MetricStat":{"Metric":{"Namespace":"AWS/ApplicationELB","MetricName":"RequestCount","Dimensions":[{"Name":"LoadBalancer","Value":"app/orders/abc123"}]},"Period":60,"Stat":"Sum"},"ReturnData":false}]' \
  --alarm-actions arn:aws:sns:eu-west-1:111122223333:oncall
aws All AWS questions

More on Observability, Deployments and Governance