Monitoring your AWS Costs like a pro

Ajar Vashisth
2 min readJan 6, 2024

--

Your AWS resources and their metrics are spread across multiple accounts and you want to monitor your Costs and Usage in one place. More than monitoring the costs and spends you WANT to figure out quickly if there are any anomalies in your usage. You hate to pay thousands of dollars for the services that you didn’t think you consumed !

If you would like to monitor your AWS Cost anomalies like shown below every week this post is for you!

Let’s design a setup where we can collect cost metrics from multiple accounts by calling their AWS Cost and Metrics APIs to fetch the data , convert the data into .csv format and store that data in a single S3 bucket for further analysis via off the shelf tools such as python pandas.

Step 1. Sharing metrics data cross accounts

We will setup the Metrics provider accounts and the metrics collector accounts to mutually trust each other and allow metrics reading. Lets configure IAM policies and roles on all accounts

Metrics Collector account

Resources needed

  • S3 Bucket for collecting metrics data CSV Files — s3://<org-name>-metrics-data
  • IAM Role with policy to run collector operations- cost-metrics-collector

Metrics Provider accounts

Complete code snippet at — https://github.com/ajarv/aws-cost-anomalies

--

--