How should the developer modify the Lambda function to meet this requirement with the LEAST operational overhead?
Add a print statement to standard out for each alert and the number of occurrences.
Add a call to the PutMetricData API operation. Pass an array for alerts and the number of occurrences in the Values and Counts fields with a namespace of “Lambda/AlertCounts”.
Add a call to the PutMetricAlarm API operation. Pass an array of alerts in the metrics member with the namespace of “Lambda/AlertCounts”.
Add a call to the PutDashboard API operation. Pass an array of alerts in the metrics member with the namespace of “Lambda/AlertCounts”.
Explanations:
A print statement does not create a custom metric in CloudWatch. It will log to CloudWatch Logs, not CloudWatch Metrics.
The PutMetricData API allows the Lambda function to send custom metrics (alert counts) to CloudWatch. This meets the requirement to track alerts with the least operational overhead.
PutMetricAlarm is used to create CloudWatch Alarms, not to send custom metrics. This does not fulfill the requirement.
PutDashboard is used to create CloudWatch Dashboards, not for logging custom metrics. This does not fulfill the requirement.