View CDN Resource Bandwidth Statistics
The following requests are deprecated in OnApp 5.4-5.5 and are completely removed from OnApp 5.6.
To get bandwidth statistics for the resources or a particular resource, use the following request:
GET /cdn_resources/bandwidth.xml
GET /cdn_resources/bandwidth.json
You can also define a shorter period, specify a particular resource or location, set the type and specify how to sort the result returned:
XML Request Example
curl -i -X GET -u user:userpass "http://onapp.test/cdn_resources/bandwidth.xml" -d '<bandwidth><type>GB</type><group_by>location</group_by><start>2014-11-25T18:25</start><end>2014-11-27T11:43</end><locations type="array"><location>532</location><location>331</location></locations><resources type = "array"><resource>977655738</resource><resource>389478438</resource><resource>725618714</resource></resources></bandwidth>' -H 'Accept: application/xml' -H 'Content-type: application/xml'
JSON Request Example
curl -i -X GET -u user:userpass -H 'Accept: application/json' -H 'Content-type: application/json' --url "http://onapp.test/cdn_resources/bandwidth.json" -d '{"bandwidth":{"start":"2014-11-25T18:25","end":"2014-11-27T11:43","resources":[977655738,389478438,725618714], "locations":[532,331],"type":"GB", "group_by":"location"}}'
Where:
start – the start date to generate statistics in the YYYY-MM-DD+hh:mm:ss format
end – the end date to generate statistics in the YYYY-MM-DD+hh:mm:ss format
resources – the identifier of the resource in Aflexi database. To get the identifier, check with cdn_reference parameter in the GET /cdn_resources/:id.{format} request
locations – the ID of the location
type – the statistics type (MBPS or GB). In MBPS mode you can get statistics for the last 10 days only. The older statistics is removed. There are no restrictions for GB mode.
group_by - to get the bandwidth statistics breaking down per location or per resource via API, use the group_by parameter with two possible values: location and resource. In case group_by = location bandwidth stats is breaking down per location, and if group_by = resource is breaking down per resource. This is the optional parameter.
XML Output Example with resources grouped by resource
<stats type="array"> <stat> <date type="datetime">2014-11-26T18:25:00+02:00</date> <resources type="array"> <resource> <977655738> <cached type="float">1.4193601249999999</cached> <non_cached type="float">0.0</non_cached> </977655738> </resource> <resource> <389478438> <cached type="float">1.4193601249999999</cached> <non_cached type="float">0.0</non_cached> </389478438> </resource> </resources> </stat> <stat> <date type="datetime">2014-11-25T18:25:00+02:00</date> <resources type="array"> <resource> <977655738> <cached type="float">0.425808015</cached> <non_cached type="float">0.047311991</non_cached> </977655738> </resource> <resource> <725618714> <cached type="float">1.187458449</cached> <non_cached type="float">0.13193981700000001</non_cached> </725618714> </resource> <resource> <389478438> <cached type="float">0.425808007</cached> <non_cached type="float">0.047311991</non_cached> </389478438> </resource> </resources> </stat> </stats>
XML Output Example with resources without the group_by parameter
<stats type="array"> <stat> <date type="datetime">2014-11-25T18:25:00+02:00</date> <cached type="float">2.0390744709999997</cached> <non_cached type="float">0.22656379899999998</non_cached> </stat> <stat> <date type="datetime">2014-11-26T18:25:00+02:00</date> <cached type="float">2.8387202499999997</cached> <non_cached type="float">0.0</non_cached> </stat> </stats>
Where:
non_cached – the amount of content which is not cached
cached – the amount of data cached
date – the point of time for which the statistics is generated
The frequency of the points of time for which the statistics is generated depends on the period of time of requested statistics:
Time Period | Frequency in seconds | Equivalent |
---|---|---|
0 - 30 days | 86400 | 1 day |
31 - 93 days | 604800 | 1 week |
equal or more than 93 days | 1209600 | 2 weeks |
Statistics available in the frequency higher than selected will be accumulated to a single point of applicable frequency.
E.g. The statistics was requested for the period of 31-93 days, so the frequency of points in the graph is 7 days. If the statistics was generated few times during those 7 days (day1+day2+dayn) it will be added up and displayed as a single point, with a time stamp marked as the first day of such 7 days.