Skip to content

Instantly share code, notes, and snippets.

@bfleming-ciena
Last active September 8, 2018 18:59
Show Gist options
  • Save bfleming-ciena/c1d3e5a5b77a156473a8 to your computer and use it in GitHub Desktop.
Save bfleming-ciena/c1d3e5a5b77a156473a8 to your computer and use it in GitHub Desktop.
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