Get CDN Edge Server Billing Statistics
To view the billing statistics for a particular edge server, use the following request:
GET /edge_servers/:edge_server_id/vm_stats.xml
GET /edge_servers/:edge_server_id/vm_stats.json
Define a shorter period by setting Start and End time in the API call:
GET /edge_servers/12/vm_stats.xml?period[startdate]=YYYY-MM-DD+hh:mm:ss&period[enddate]=YYYY-MM-DD+hh:mm:ss&period[use_local_time]=1
GET /edge_servers/12/vm_stats.json?period[startdate]=YYYY-MM-DD+hh:mm:ss&period[enddate]=YYYY-MM-DD+hh:mm:ss&period[use_local_time]=1
XML Output Example
<vm_stats type="array"> <vm_hourly_stat> <created_at type="datetime">2011-11-01T00:00:13Z</created_at> <updated_at type="datetime">2011-11-01T00:00:13Z</updated_at> <stat_time type="datetime">2011-11-01T00:00:00Z</stat_time> <total_cost type="float">0.0</total_cost> <id type="integer">9582</id> <vm_billing_stat_id type="integer">7795</vm_billing_stat_id> <user_id type="integer">1</user_id> <billing_stats> <virtual_machines type="array"> <virtual_machine> <label>QAVP XEN serveridze</label> <costs type="array"> <cost> <value type="integer">100</value> <resource_name>cpu_shares</resource_name> <cost type="float">0.0</cost> </cost> ... <cost></cost> ... </costs> <id type="integer">237</id> </virtual_machine> </virtual_machines> <network_interfaces type="array"> <network_interface> <label>eth0</label> <costs type="array"> <cost> <value type="integer">1</value> <resource_name>ip_addresses</resource_name> <cost type="float">0.0</cost> </cost> ... <cost></cost> ... </costs> <id type="integer">254</id> </network_interface> </network_interfaces> <disks type="array"> <disk> <label>#499</label> <costs type="array"> <cost> <value type="integer">20</value> <resource_name>disk_size</resource_name> <cost type="float">0.0</cost> </cost> ... <cost></cost> ... </costs> <id type="integer">499</id> </disk> </disks> <edge_servers type="array"> <edge_server> <label>QAVP XEN serveridze</label> <costs type="array"> <cost> <value type="integer">14</value> <resource_name>template</resource_name> <cost type="float">0.0</cost> </cost> </costs> <id type="integer">237</id> </edge_server> </edge_servers> </billing_stats> <usage_cost type="float">0.0</usage_cost> <virtual_machine_id type="integer">237</virtual_machine_id> <currency_code>USD</currency_code> <vm_resources_cost type="float">0.0</vm_resources_cost> </vm_hourly_stat> </vm_stats>
Where:
created_at – the timestamp in DB when this record was created
updated_at – the date when these statistics were updated
cost – the total amount of money owed by this particular edge server for the resources spent at stat_time
stat_time – the particular hour for which these statistics were generated
id – the ID of these statistics
user_id - the ID of edge server owner
currency_code - currency in which this virtual machine is charged within the bucket
billing_stats - an array of billing details for the resources used by this edge server
virtual_machine - an array of edge server billing details:
label – name of the edge server
costs- an array of edge server resources with their total prices for the period specified in the stat-time parameter, where:
- resource_name - the resource in question. This can be cpu_shares, cpus, memory, cpu_usage and template
- value - the amount of resources allocated to this edge server. Here are the units of measurement for each type of resource_name:
- cpu_shares - CPU priority percentage
- cpus - number of CPU cores
- memory - amount of RAM in Mb
- cpu_usage - CPU time in seconds
- cost - the total due for this resource
- id - Virtual machine ID
network_interfaces - an array of network interfaces used by this edge server with their billing statistics:
- label - network interface name used in OnApp
- id - network interface ID
- costs- an array of network interface related resources with their total prices for the period specified in the stat-time parameter, where:
- resource_name - the resource in question. This can be ip_addresses, rate, data_received and data_sent
- value- the amount of resources used by this network interface. Here are the units of measurment for each type of resource_name:
- ip_addresses - number of IPs
- rate - the port speed in Mb per second
- data_received - amount of received data in Kb
- data_sent - amount of sent data in Kb
- cost - the total due for the resource
disks - an array of disks used by this edge server with their billing details:
- label - disk name used in UI
- id - disk ID used in database
- costs- an array of disk related resources with their total prices for the period specified in the stat-time parameter, where:
- resource_name - the resource in question. This can be disk_size, data_read, data_written, reads_completed and writes_completed
- value - the amount of resources used. Here are the units of measurement for each type of resource_name:
- disk_size - size in GB
- data_read - read data in Kb
- data_writen - amount of written data in Kb
- reads - number read operations
- writes - number of write operations
- cost - the total due for the resource
edge_server - an array of edge server with its billing details:
- label – edge server name used in UI
- id – server ID used in database
- costs- an array of related resources with their total prices for the period specified in the stat-time parameter, where:
- resource_name - the resource in question. In this case - template
- value – here, the template ID in the database
- cost - the total due for the resource
total_cost – the total amount of money owed for the edge server specified by id parameter for a particular hour specified by stat_time parameter (total_cost = vm_resources_cost + usage_cost)
vm_resources_cost – the amount of money due for the edge server resources for the particular hour specified by stat_time parameter (memory, disks, templates) usage_cost – the total due for edge server usage for this particular hour specified by stat_time parameter (data sent/received, bandwidth, CPU usage).