Last active
September 8, 2018 18:59
-
-
Save bfleming-ciena/c1d3e5a5b77a156473a8 to your computer and use it in GitHub Desktop.
Pull estimated AWS charges Billing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#list metrics | |
aws --profile dev --region us-east-1 cloudwatch list-metrics --namespace "AWS/Billing" | |
# Estimated charges | |
aws --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimension "Name=Currency,Value=USD" --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text | sort -r -k 3 | head -n 1 | cut -f 2 | |
# Marketplace Charges | |
aws --profile dev --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimensions Name=ServiceName,Value=AWSMarketplace Name=Currency,Value=USD --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text | |
# Redshift | |
aws --profile dev --region us-east-1 cloudwatch get-metric-statistics --namespace "AWS/Billing" --metric-name "EstimatedCharges" --dimensions Name=ServiceName,Value=AmazonRedshift Name=Currency,Value=USD --start-time $(gdate +"%Y-%m-%dT%H:%M:00" --date="-12 hours") --end-time $(gdate +"%Y-%m-%dT%H:%M:00") --statistic Maximum --period 60 --output text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment