Prometheus alerts for AWS daily costs
Problem to solve
As someone deploying to AWS, I want to know what my spend is post deployment.
User experience goal
The user will be able to get (daily) notifications on AWS spend and based on these alerts will know if he/she went over budget and may need to rollback
Using AWS CLI
aws ce get-cost-and-usage --time-period Start=$(date +"%Y-%m-%d" --date="-24 hours"),End=$(date +"%Y-%m-%d") --granularity=DAILY --metrics BlendedCost
Using Prometheus exporter that queries the cost explorer for today’s and yesterday’s daily spending and exposes the results as metrics. The code is available in GitHub, together with a Helm chart to be deployed to Kubernetes and a Docker image.
docker run -e METRIC_TODAY_DAILY_COSTS=yes -e METRIC_YESTERDAY_DAILY_COSTS=yes -p 5000:5000 nachomillangarcia/prometheus_aws_cost_exporter:latest --host 0.0.0.0
the Important to note: the Cost Explorer API on a configurable period since each request costs 0.01$.