Interview Prep/Python for DevOps/boto3 & AWS automation

What is CloudWatch `get_metric_statistics` vs `get_metric_data`?

AdvancedConceptboto3 & AWS automation
Answer
  • get_metric_statistics: one metric per call, simple, returns Datapoints unordered, limited to 1,440 datapoints per call.
  • get_metric_data: up to 500 metric queries per call, supports metric math and Metrics Insights, returns ordered values with pagination. Far cheaper and faster for scanning a fleet.

For an "idle instance" check across 2,000 instances, batching CPU queries in get_metric_data turns 2,000 calls into 4. Remember that CPUUtilization exists only for running instances, and the default period is 5 minutes (1 minute with detailed monitoring).

All Python for DevOps questions Roadmap: Python for automation

More on boto3 & AWS automation