How to get total usage bandwidth in a month

We have to track total usage of bandwidth monthly to create some rule for limitation. So we can done it manually through AWS CLI.

Step 1: configure AWS CLI through command: aws configure
Step 2: insert AWS Key ID, Secret Key, default region and default output format (JSON)
Step 3: run command aws lightsail get-instance-metric-data

--instance-name <value> # name of Lightsail instance
--metric-name <value> # metric we have to measure. Eg: NetworkOut
--period <value> # period in second. Eg: month is 2592000
--start-time <value> # start date with timestamp format
--end-time <value> # end date with timestamp format
--unit <value> # bytes
--statistics <value> # in this example is Sum

We get sum of NetworkOut from 07/01/2020 to 08/19/2020 with period is 1 month

aws --region ap-northeast-1 lightsail get-instance-metric-data --instance-name MagestoreVPN --metric-name NetworkOut --period 2592000 --start-time 1593536400 --end-time 1597770000 --unit Bytes --statistics


{ "metricName": "NetworkOut", "metricData": [ { "sum": 6883250653.0, "timestamp": 1593536400.0, "unit": "Bytes" }, { "sum": 28879236482.0, "timestamp": 1596128400.0, "unit": "Bytes" } ] }

1 Like