Skip to content

Instantly share code, notes, and snippets.

@jthomerson
Created November 29, 2018 14:21
Show Gist options
  • Save jthomerson/6d8c8b3e7cb37f971b25e3c5da145897 to your computer and use it in GitHub Desktop.
Save jthomerson/6d8c8b3e7cb37f971b25e3c5da145897 to your computer and use it in GitHub Desktop.
START=2018-10-01T00:00:00Z
END=2018-11-01T00:00:00Z
function GetStats() {
SUMUNITS=$(aws cloudwatch get-metric-statistics --start-time ${START} --end-time ${END} --metric-name $1 --namespace AWS/DynamoDB --statistics Sum --dimensions Name=TableName,Value=$2 --period 3600 | jq .Datapoints[].Sum | awk 'BEGIN {SUM=0}; {SUM=SUM+$1}; END {printf "%.3f\n", SUM}')
}
for TABLENAME in $(aws dynamodb list-tables | jq -r .TableNames[]); do
GetStats "ConsumedReadCapacityUnits" "${TABLENAME}"
echo "${TABLENAME} Read ${SUMUNITS}"
GetStats "ConsumedWriteCapacityUnits" "${TABLENAME}"
echo "${TABLENAME} Write ${SUMUNITS}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment