Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pull estimated AWS charges Billing
#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
You can’t perform that action at this time.