Get VS Billing Statistics
You can view the billing statistics for a particular VM using the following request:
GET /virtual_machines/:virtual_machine_id/vm_stats.xml
GET /virtual_machines/:virtual_machine_id/vm_stats.json
To get a shorter statistics output, add an id parameter in the URL:
GET /virtual_machines/:virtual_machine_id/vm_stats/:vm_stats_id.xml
GET /virtual_machines/:virtual_machine_id/vm_stats/:vm_stats_id.json
GET /virtual_machines/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 /virtual_machines/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_hourly_stats type="array"> <vm_hourly_stat> <vm_hourly_stat> <created_at type="datetime">2011-08-09T12:00:10Z</created_at> <currency_code>USD</currency_code> <id type="integer">8248</id> <stat_time type="datetime">2011-08-09T12:00:00Z</stat_time> <updated_at type="datetime">2011-08-09T12:00:10Z</updated_at> <user_id type="integer">1</user_id> <virtual_machine_id type="integer">44</virtual_machine_id> <vm_billing_stat_id type="integer">100175</vm_billing_stat_id> <billing_stats> <disks type="array"> <disk> <id type="integer">2933</id> <costs type="array"> <cost> <value type="integer">5</value> <cost type="float">3.0</cost> <resource_name>disk_size</resource_name> </cost> </costs> <label>Disk#2933</label> </disk> <disk>...</disk> </disks> <network_interfaces type="array"> <network_interface> <id type="integer">2688</id> <costs type="array"> <cost> <value type="integer">1</value> <cost type="float">0.0</cost> <resource_name>ip_addresses</resource_name> </cost> <cost> <value type="integer">1.0</value> <cost type="float">100.0</cost> <resource_name>instance_package</resource_name> <resource_id>90</resource_id> </cost> <cost> <value type="integer">1.0</value> <cost type="float">0.0</cost> <resource_name>template_usage</resource_name> <resource_id>5</resource_id> </cost> <cost>...</cost> </costs> <label>eth0</label> </network_interface> </network_interfaces> <service_addons type="array"> <service_addon> <id type="integer">1</id> <costs type="array"> <cost> <value type="integer">1</value> <cost type="float">0.0</cost> <resource_name>service_addon</resource_name> </cost> </costs> <label>zaza_unix</label> </service_addon> </service_addons> <virtual_machines type="array"> <virtual_machine> <id type="integer">1701</id> <costs type="array"> <cost> <value type="integer">1</value> <cost type="float">0.0</cost> <resource_name>cpus</resource_name> </cost> </costs> <label>zaza_CP_3.2 (do not remove)</label> </virtual_machine> </virtual_machines> </billing_stats> <total_cost type="float">0.0</total_cost> <vm_resources_cost type="float">0.0</vm_resources_cost> <usage_cost type="float">0.0</usage_cost> </vm_hourly_stat> <vm_hourly_stat>...</vm_hourly_stat> </vm_hourly_stats>
Where:
created_at – the timestamp in DB when this record was created
currency_code - currency in which this virtual machine is charged within the bucket
id – the ID of the server hourly statistics. You can add this parameter to the request URL to get a shorter statistics output.
stat_time – the particular hour for which these statistics were generated
updated_at – the date when these statistics were updated
user_id - the ID of VS owner
virtual_machine_id - the ID of the VS
vm_billing_stat_id - billing statistics ID
billing_stats - an array of billing details for the resources used by this VM
When generating billing statistics, OnApp takes the last state of the VS during the hour. For example, if a VS was turned on at 6.15 and turned off at 6.59 it will be considered as being off for the whole hour and its resources will be billed according to the OFF prices set in the bucket. However, the VS's disk and network interface usage can still be billed in case the VS was on during that hour.
disks - an array of disks used by this VM with their billing details:
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:
value - the amount of resources used (GBs of disk size, Kbs of data read/writen, the number of reads/writes)
cost - the total due for the resource
resource_name - the resource in question. This can be disk_size, data_read, data_written, reads_completed and writes_completed
label - disk name used in UI
network_interfaces - an array of network interfaces used by this VM with their billing statistics:
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:
value - the amount of resources used by this network interface (the number of IPs, the port speed in Mb per second, the data sent and received in KBs )
cost - the total due for the resource
resource_name- the resource in question. This can be ip_addresses, rate, data_received and data_sent
label - network interface name used in OnApp
service_addons - an array of service add-ons assigned to this VS with their billing details:
id - service add-on ID
costs - an array of service add-on related resources with their total prices for the period specified in the stat-time parameter, where:
value - the amount of resources used by this service add-on (at the moment value will always be "1")
cost - the total due for the resource
resource_name - the resource in question
label - service add-on name used in OnApp
virtual_machine - an array of virtual machine billing details:
id - virtual server ID
costs- an array of VS resources with their total prices for the period specified in the stat-time parameter, where:
value - the amount of resources allocated to this VM. For the templates resource, this parameter means a template ID in database.
cost - the total due for this resource
resource_name - the resource in question. This can be cpu_shares, cpus, cpu_usage, cpu_time, memory, instance_package, and template_usage
resource_id - the ID for the instance_package and template_usage resources
label - the VS name
total_cost – the total amount of money owed for the VM 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 VM resources for the particular hour specified by stat_time parameter (memory, disks, templates)
usage_cost – the total due for VM usage for this particular hour specified by stat_time parameter (data sent/received, bandwidth, CPU usage)
Page History
v. 6.0
- added the resource_id parameter for the instance_package and template_usage resources
v. 5.3
- added the service _addons array of parameters