Which CloudWatch alarms a backend on ECS and RDS needs, how periods, datapoints and missing data decide when an alarm fires, how to route alarms through SNS, and where application metrics fit.

CloudWatch already collects metrics for every ECS service, load balancer and RDS instance in an account, but nothing happens with them until someone creates an alarm. Teams usually discover this during the first outage, when the database ran out of storage an hour before anyone noticed and the graphs showed it clearly.
This guide covers the alarms worth creating first and the settings that keep them from crying wolf.
The recommended alarms list from AWS covers dozens of services. For a typical backend behind an Application Load Balancer, a short set catches the problems users feel:
The ECS metrics are described in the ECS CloudWatch metrics docs and the RDS ones in the RDS metrics reference. Memory matters more than CPU for ECS, since a task that exceeds its hard memory limit is stopped, while a busy CPU only slows it down.
An alarm evaluates a metric over a period, compares each data point with a threshold, and changes state between OK, ALARM and INSUFFICIENT_DATA. Three settings decide how noisy it is:
--evaluation-periods 5 --datapoints-to-alarm 3, three breaching periods out of the last five trigger the alarm, which ignores single spikes without waiting for five in a row.missing, notBreaching, breaching and ignore. HTTPCode_Target_5XX_Count only publishes when errors occur, so notBreaching is right for it, while a heartbeat metric that stops reporting should use breaching.p95 describe what users see for latency, while an average hides the slow tail.Alarms notify through an SNS topic, which can deliver to email, a chat webhook or an incident tool:
TOPIC_ARN=$(aws sns create-topic --name prod-alarms --query TopicArn --output text)
aws sns subscribe --topic-arn "$TOPIC_ARN" --protocol email --notification-endpoint oncall@example.com
aws cloudwatch put-metric-alarm \
--alarm-name prod-api-5xx \
--namespace AWS/ApplicationELB \
--metric-name HTTPCode_Target_5XX_Count \
--dimensions Name=LoadBalancer,Value=app/prod-alb/50dc6c495c0c9188 \
--statistic Sum --period 60 \
--evaluation-periods 5 --datapoints-to-alarm 3 \
--threshold 20 --comparison-operator GreaterThanOrEqualToThreshold \
--treat-missing-data notBreaching \
--alarm-actions "$TOPIC_ARN" --ok-actions "$TOPIC_ARN"
Send --ok-actions to the same topic so the channel shows when a problem cleared. Once there are more than a handful of alarms, a composite alarm, for example "5xx high AND RDS CPU high", pages on the combination and leaves the individual alarms as context.
CloudWatch metrics describe the infrastructure: CPU, memory, connections, status codes. They cannot tell you that payments are failing with a provider error while the API returns 200, or that a queue consumer stopped processing without crashing. Those need application metrics that the code itself emits, counted at the point where the business event happens.
Best fit: CloudWatch alarms for saturation and availability of ECS and RDS, with application metrics for the failures only the code can see.
Encore brings infrastructure from code, and the ECS or EKS services, RDS database and load balancer it provisions are ordinary resources in your own AWS account, so the CloudWatch alarms above attach to them as they would to anything else. The AWS infrastructure docs list what gets created, and container logs go to CloudWatch Logs organized by service.
For the failures only the code can see, custom metrics are declared in the service next to the logic that counts them:
Run in your terminal to get started locally.
package payments
import (
"context"
"encore.dev/metrics"
"encore.dev/rlog"
)
type ChargeLabels struct {
Outcome string // "succeeded", "declined", "provider_error"
}
var Charges = metrics.NewCounterGroup[ChargeLabels, uint64]("payment_charges", metrics.CounterConfig{})
type ChargeParams struct {
OrderID string `json:"order_id"`
AmountCents int64 `json:"amount_cents"`
}
//encore:api private method=POST path=/payments/charge
func Charge(ctx context.Context, p *ChargeParams) error {
outcome, err := chargeWithProvider(ctx, p)
if err != nil {
rlog.Error("charge failed", "order_id", p.OrderID, "err", err)
outcome = "provider_error"
}
Charges.With(ChargeLabels{Outcome: outcome}).Increment()
return err
}
// chargeWithProvider calls the payment provider and maps its response to an outcome.
func chargeWithProvider(ctx context.Context, p *ChargeParams) (string, error) {
// Provider call goes here.
return "succeeded", nil
}
Encore collects these metrics for the Platform Dashboard and can forward them to Grafana Cloud or Datadog, as the metrics integrations docs describe, so an alert on the provider_error rate lives next to your CloudWatch infrastructure alarms. Every request also produces a trace, which is where an alarm usually leads when someone starts investigating.
An AI coding agent adding a new payment path can add the counter label in the same change as the code that produces the outcome, so the metric exists before the feature ships rather than after the first incident.
Best fit: backends on AWS that want CloudWatch alarms on infrastructure and business metrics defined in the code they describe.
Create the eight alarms in the table, route them through one SNS topic with OK actions, and tune with M out of N evaluation instead of raising thresholds until they never fire. Add application metrics for the outcomes CloudWatch cannot observe, and review which alarms fired in the last month so the noisy ones get fixed rather than ignored.
Start with load balancer 5xx count and target response time, ECS service CPU and memory utilization, and RDS CPU, free storage space, freeable memory and database connections. Those cover user-facing errors, saturation and the database running out of room.
It decides how periods with no data points are evaluated. The options are missing, notBreaching, breaching and ignore, and for error-count metrics that only publish when errors happen, notBreaching stops the alarm from sitting in INSUFFICIENT_DATA during quiet periods.
Use M out of N evaluation, for example datapoints-to-alarm 3 with evaluation-periods 5, so the alarm only fires when three of the last five periods breach the threshold. Composite alarms can further require two conditions at once.
Define a counter or gauge with the encore.dev/metrics package and increment it in your code. Encore collects it for the Platform Dashboard and can forward it to Grafana Cloud or Datadog, where you attach the alert rule.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.