Getting bucket usage statistics

Last Updated: Jul 07, 2018 10:13PM PDT

NooBaa's API provides bucket read/write counters and throughput.
A simple serverless function will expose this API to external calls. The following steps would help you to quickly create such function.

1. Follow the article create your own serverless function and use the text below as the function content

/* sample event:   
{
"name": "first.bucket",
"since": 1527840000,
"till": 1530655233
}
*/

exports.handler = function(event, context, callback) {
context.rpc_client.bucket.export_bucket_bandwidth_usage(event)
        .then(res => callback(null, JSON.stringify(res)))
        .catch(err => callback(err));
};


2. Save the function and use the Invoke tab to test the function with the following input 

{ "name": "first.bucket", "since": 1527840000, "till": 1530655233 }

3. You should see a csv link. Use it in your browser and check the CSV

You should see text in the following format
 
 
 
Date  Read Count  Bytes Read  Write Count  Bytes Written
Fri Jan 05 2018 00:00:00 GMT-0800 (PST) 0 0 12 37978199
Fri Jun 22 2018 00:00:00 GMT-0700 (PDT) 20 1508360 0 0
Mon Jun 11 2018 00:00:00 GMT-0700 (PDT) 0 0 1 5387
Mon Jun 25 2018 00:00:00 GMT-0700 (PDT) 24 592570 24 592570
Mon Mar 12 2018 00:00:00 GMT-0700 (PDT) 0 0 1 206828
Mon May 14 2018 00:00:00 GMT-0700 (PDT) 18 328607 34 659100
Thu Apr 19 2018 00:00:00 GMT-0700 (PDT) 4 420424 3 316328
Thu May 03 2018 00:00:00 GMT-0700 (PDT) 17 323220 17 323220
Thu May 10 2018 00:00:00 GMT-0700 (PDT) 4 646440 0 0
Thu May 31 2018 00:00:00 GMT-0700 (PDT) 0 0 1 6658425
Tue Jun 12 2018 00:00:00 GMT-0700 (PDT) 26 59708736 17 3898690
Tue Jun 26 2018 00:00:00 GMT-0700 (PDT) 80 43036542 135 4899489701
Tue May 08 2018 00:00:00 GMT-0700 (PDT) 18 484830 17 323220
Tue May 15 2018 00:00:00 GMT-0700 (PDT) 1 5387 0 0
Wed Apr 25 2018 00:00:00 GMT-0700 (PDT) 2 270 2 270
Wed Jun 06 2018 00:00:00 GMT-0700 (PDT) 2 50924672 9 2897128
Wed Jun 27 2018 00:00:00 GMT-0700 (PDT) 1 5387 0 0
Wed May 02 2018 00:00:00 GMT-0700 (PDT) 34 565635 67 1069455
Did you find this article helpful?
195e69fe2c7a9be6b2b2aa6b87f970548@noobaa.desk-mail.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete