Depending on who you are, there are two things that need constant monitoring in almost all cloud services that are usage based. And which ones aren’t? Fixed cost services, like a monthly fee for GoDaddy hosting that never changes, no matter how much traffic.
But AWS and Google Cloud API’s charge based on usage. Google Cloud API has a free tier, but when you request more data that exceeds this free tier, they will start charging you money. AWS also has a free tier, some of which is fixed such as EC2 t2.micro instance. BUT they WILL CHARGE YOU FOR AMOUNT OF DATA THAT GOES THRU A PUBLIC IP YOU “LEASED” from them (versus data sent to their service endpoints such as the AWS management portal). So more traffic, more cost.
I am looking at some ways to monitor AWS. The first thing most IT professionals monitor is the operational components of IT systems. Is it up and running? I’m not going to focus on that here, although the AWS portal does give you a way to watch a particular AWS instance, and set performance alerts. I’m going to focus on the bottom line: cost. There is no bigger alert than a giant bill at the end of the month. This is something that can be watched daily for changes. Here are some ways to monitor AWS bill
1. AWS Management portal. Login in everyday and look at the cost explorer and see if it jives with your expectations.
2. aws-cli. this command line tool can request cost data, just like your cell phone has a text number, to reply w your current phone bill. You just need the aws-cli logged in user, the correct permission to read the cost
https://docs.aws.amazon.com/cli/latest/reference/ce/get-cost-and-usage.html#examples
https://stackoverflow.com/questions/50566905/user-is-not-authorized-to-perform-cegetcostandusage#:~:text=Navigate%20to%20IAM%20%2D%3E%20Policies%20%2D,Tick%20%5BX%5D%20Read%20permissions
3. You can build an app, and call an API to get the cost
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-nodejs.html
https://docs.aws.amazon.com/cost-management/latest/userguide/ce-api.html
I used to do #1, but sometimes you forget
Now I have a cronjob email me #2 for a year, sending me the output for
aws ce get-cost-and-usage --time-period Start=$(date -d '-1year' +%Y-%m-%d),End=$(date +%Y-%m-%d) --granularity MONTHLY --metrics "BlendedCost" "UnblendedCost" "UsageQuantity"
That output looks like
{ "ResultsByTime": [ { "Estimated": false, "TimePeriod": { "Start": "2023-10-14", "End": "2023-11-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2023-11-01", "End": "2023-12-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2023-12-01", "End": "2024-01-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-01-01", "End": "2024-02-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-02-01", "End": "2024-03-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-03-01", "End": "2024-04-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-04-01", "End": "2024-05-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-05-01", "End": "2024-06-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-06-01", "End": "2024-07-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-07-01", "End": "2024-08-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-08-01", "End": "2024-09-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": false, "TimePeriod": { "Start": "2024-09-01", "End": "2024-10-01" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] }, { "Estimated": true, "TimePeriod": { "Start": "2024-10-01", "End": "2024-10-14" }, "Total": { "BlendedCost": { "Amount": "1.00", "Unit": "USD" }, "UnblendedCost": { "Amount": "1.00", "Unit": "USD" }, "UsageQuantity": { "Amount": "1.00", "Unit": "N/A" } }, "Groups": [] } ] }
You can watch for changes in spend you don’t expect.
I got a $80 bill b/c I wrote a monitoring script that polled the public IP, instead of the private IP of the EC2 instance, and it charged me for all the gigabytes that passed thru that public IP of the EC2 instance. The script was innocuous enough that I didn’t think about it, until I got the AWS billing e-mail next month.