SystemUsageData

NOTE: This page and it's notifications may be out of date. The full list of legacy notifications can be found in the nova.rpc.LegacyValidatingNotifier code. Nova has moved to sending versioned notifications which are described in the developer documentation here: http://docs.openstack.org/developer/nova/notifications.html#versioned-notifications

Summary
Nova administrators want data on system usage for billing, chargeback, or monitoring purposes.

Release Note
System usage data is emitted from Nova in the form of usage events from Nova's NotificationSystem. The notification system can be configured to emit events either through nova's logging facility, or send them to a series of AMQP queues (one per notification priority). System usages are emitted as notification events with the INFO priority. Different types of usage events are distinguished via the notifications' event_type, which is a hierarchical dotted string such as compute.instance.create, which allows usages to be easily grouped for aggregation. Usage notifications can be immediate, created when a specific increment of usage occurs (such as creation of an instance) or periodic, generated by a periodic task, like a cron job, and covering usage for a certain period of time. Besides the standard Nova Notification priority, notification timestamp, and event_type, usage notifications contain a payload of data that will vary depending on the event_type. This is presented as a json-formatted hash of key-value pairs. Some of the keys, such as tenant_id will always be present in any usage notification, others will be data relevent to that event_type (For example, instance related notifications will contain data describing the instance.)

For more indepth examples see NotificationEventExamples.

An external application (https://github.com/rackerlabs/yagi) is available that can read notifications from AMQP queues and provide an Atom API. This application generates Atom feeds of the notifications, and can publish feeds via PubSubHubbub (PSH) for efficient distribution of data to subscribers.

Rationale
As a systems integrator, we need the ability for 3rd party systems to query usage information from Nova to determine how to charge customers for use of the platform.

Enterprise customers also need the ability to determine usage data, though for different reasons. For example, a cloud administrator may want to determine VMs that have not been used in several month so that they can be reclaimed and the resources reallocated. Some IT departments may implement a quota system for their users.

Note that Nova itself should not be concerned with billing, but it needs to present a feed of usage data that an external application could use to aggregate the billing data for a requested time period.

User stories

 * 1) As a systems integrator, I need to retrieve usage data so that I can properly bill my customers.
 * 2) As a systems integrator or enterprise cloud administrator, I want to monitor usage data over time so that I can optimize the utilization of my resources.
 * 3) As an business or agency that supports multiple projects, I need to account for the resources consumed by each project so that I can properly meet accounting and budget standards.
 * 4) As a systems integrator, I need to provide usage data to multiple third-party systems without building custom interfaces to each one so that I can efficiently utilize my manpower.

Assumptions
Usage data can be aggregated by Tenant ID (as defined in the openstack-accounting blueprint).(i.e. Tenant ID is always present)

There is a billing system that is not a part of OpenStack. Invoicing, billing, and customer management are handled externally to OpenStack/Nova. Nova only has knowledge of an "tenant ID" (as per the openstack-accounting blueprint).

The Tenant ID is the same as the tenant id concept in Keystone, and is known internally to Nova as the "Project ID".

If Nova is installed in multiple regions (aka "zones"), usage data will not span zones; even if the same tenant ID is used in multiple zones, that data must be aggregated external to Nova.

Design and Implementation
There are two events generated for every activity. Previously, events were only generated on activity completion, but now there is an event when the activity starts and, as before, when the activity ends. These are marked as 'compute.instance. .start' and 'compute.instance. .end'. The '.end' event is the same as the event previously expected.

Event Types and Payload data:
A sample of most Nova events (with scrubbed values) is available here: http://paste.openstack.org/show/54140/

compute.instance.create.{start,error,end}:

 * Usage notification upon creation of a new instance.
 * tenant_id: Tenant ID that owns the this instance (string)
 * user_id: User ID that owns this instance (string)
 * instance_id: Nova instance ID of this instance (string)
 * instance_type: Name of the instance type ('flavor') of this instance. (string)
 * instance_type_id: Nova ID for instance type ('flavor') of this instance. (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor. (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image URL (from Glance) that this instance was created from. (string)
 * state: Current state of instance. (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)
 * message: High-level message describing the notification. If the event type is "create.error", it will contain error details.

compute.instance.delete.start/.end:

 * Usage notification upon deletion of an instance.
 * tenant_id: Tenant ID that  owns the this instance (string)
 * user_id: User ID that  owns this instance (string)
 * instance_id: Nova  instance ID of this instance (string)
 * instance_type: Name of  the instance type ('flavor') of this instance. (string)
 * instance_type_id: Nova ID for instance type ('flavor') of this instance. (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor. (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image URL (from Glance) that this instance was created from.  (string)
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

compute.instance.rebuild.start/.end:

 * Usage notification upon rebuild of instance.
 * tenant_id: Tenant ID that  owns the this instance (string)
 * user_id: User ID that  owns this instance (string)
 * instance_id:  Nova  instance ID of this instance (string)
 * instance_type: Name of  the instance type ('flavor') of this instance. (string)
 * instance_type_id: Nova ID for instance type ('flavor') of this instance. (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor. (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image  URL (from Glance) that this instance is being rebuilt from.  (string)
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

compute.instance.resize.prep.start/.end:

 * Usage notification when a resize/migrate of an instance is begun.
 * tenant_id: Tenant ID that  owns the this instance (string)
 * user_id: User ID that  owns this instance (string)
 * instance_id:  Nova  instance ID of this instance (string)
 * instance_type: Name of  the current (before resize) instance type ('flavor') of this instance. (string)
 * instance_type_id: Nova ID for current (before resize) instance type ('flavor') of this instance. (string)
 * new_instance_type: Name of  the new (after  resize) instance type ('flavor') of this instance. (string)
 * new_instance_type_id: Nova ID for new (after  resize) instance type ('flavor') of this instance. (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor. (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image  URL (from Glance) that this instance was  created from.  (string)
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

compute.instance.resize.confirm.start/.end:

 * Usage notification when a resize/migration of an instance has been confirmed by the user.
 * tenant_id: Tenant ID that  owns the this instance (string)
 * user_id: User ID that  owns this instance (string)
 * instance_id: Nova  instance ID of this instance (string)
 * instance_type: Name of  the current instance type ('flavor') of this instance. (i.e. the one it has been resized to.) (string)
 * instance_type_id: Nova ID for the current instance type ('flavor') of this instance. (i.e. the one it has been resized to.) (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor. (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image URL (from Glance) that this instance was created from.  (string)
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

compute.instance.resize.revert.start/.end:

 * Usage notification when a resize/migration of an instance has been reverted by the user.
 * tenant_id: Tenant ID that  owns the this instance (string)
 * user_id: User ID that  owns this instance (string)
 * instance_id:  Nova  instance ID of this instance (string)
 * instance_type: Name of  the current instance type ('flavor') of this instance. (i.e. the one it has been reverted back to.) (string)
 * instance_type_id: Nova ID  for the current instance type ('flavor') of this instance. (i.e. the one it has been reverted back to.) (string)
 * display_name: User  selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor. (string, formatted  "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image  URL (from Glance) that this instance was  created from.  (string)
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

compute.instance.exists:
There is no .start/.end event for this activity ... just the 'compute.instance.exists' event.


 * Periodic usage notification generated by the instance-usage-audit cron job. These usages are generated for each instance that was active during the specified audit period.
 * tenant_id:  Tenant ID that owns the this instance (string)
 * user_id: User ID that owns this instance  (string)
 * instance_id: Nova  instance ID of this instance (string)
 * instance_type:  Name of the instance type ('flavor') of this instance. (string)
 * instance_type_id: Nova ID for instance type ('flavor') of this instance. (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor.  (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image URL (from Glance) that this  instance was created from. (string)
 * image_meta: Dictionary of key-value pairs representing metadata from the image the instance was built from.
 * audit_period_begining: Timestamp of beginning of audit period. (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * audit_period_ending: Timestamp of end of audit period. (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * bandwidth: Hash listing bandwidth used for each network this instance is connected to. Keys will be network labels, values will be hashes containing the keys 'bw_in', and 'bw_out', listing the incoming, and outgoing bandwith, respectively,  used by that instance, on that network, for that audit period.  Bandwith is reported in bytes.
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

compute.instance.update:
This event is generated whenever the VM or task state of the server changes; for example, when the server moves from BUILDING to either ACTIVE or ERROR.

This notification is disabled by default.

To enable notifications when the VM state changes, set configuration flag "notify_on_state_change" to "vm_state".

To enable notifications when either VM state or task state changes, set configuration flag "notify_on_state_change" to "vm_and_task_state".


 * tenant_id:  Tenant ID that owns the this instance (string)
 * user_id: User ID that owns this instance  (string)
 * instance_id: Nova  instance ID of this instance (string)
 * instance_type:  Name of the instance type ('flavor') of this instance. (string)
 * instance_type_id: Nova ID for instance type ('flavor') of this instance. (string)
 * display_name: User selected display name for instance.
 * created_at: Timestamp for when this instance's record was created in Nova (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor.  (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * image_ref_url: Image URL (from Glance) that this  instance was created from. (string)
 * image_metadata: array of key-value pairs representing the metadata from the image from which the instance was built (array)
 * audit_period_begining: Timestamp of beginning of audit period. (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * audit_period_ending: Timestamp of end of audit period. (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * bandwidth: Hash listing bandwidth used for each network this instance is connected to. Keys will be network labels, values will be hashes containing the keys 'bw_in', and 'bw_out', listing the incoming, and outgoing bandwith, respectively,  used by that instance, on that network, for that audit period.  Bandwith is reported in bytes.
 * old_state: Prior state of instance.  (string, such as 'active' or 'deleted')
 * state: Current state of instance.  (string, such as 'active' or 'deleted')
 * state_description: Additional human readable description of current state of instance.
 * fixed_ips: list of ip addresses formatted like [{"floating_ips": [], "meta": {}, "type": "fixed", "version": 4, "address": "10.0.0.9", "label": "public"}] assigned to instance.
 * memory_mb: memory allocation for this instance (in mb)
 * disk_gb: disk allocation for this instance (in gb)

volume.create.start/.end:

 * Usage notification upon creation of a new volume.
 * tenant_id:  Tenant ID that owns the this volume (string)
 * user_id: User ID that owns this volume  (string)
 * volume_id: Nova volume ID of this volume (string)
 * volume_type:  Name of the volume type of this volume. (string)
 * display_name: User selected display name for volume.
 * created_at: Timestamp for when this volume's record was created in Nova (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor.  (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * status: Current status of volume.  (string, such as 'available' or 'attached')
 * size: size of disk allocation for this volume.
 * snapshot_id: Nova id of the volume snapshot.

volume.delete.start/.end:

 * Usage notification upon deletion of a volume.
 * tenant_id:  Tenant ID that owns the this volume (string)
 * user_id: User ID that owns this volume  (string)
 * volume_id: Nova volume ID of this volume (string)
 * volume_type:  Name of the volume type of this volume. (string)
 * display_name: User selected display name for volume.
 * created_at: Timestamp for when this volume's record was created in Nova (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor.  (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * status: Current status of volume.  (string, such as 'available' or 'attached')
 * size: size of disk allocation for this volume.
 * snapshot_id: Nova id of the volume snapshot.

volume.usage:
There is no .start/.end event for this activity ... just the 'volume.usage' event.


 * Periodic usage notification generated by the volume-usage-audit cron job. These usages are generated for each volume that was active during the specified audit period.
 * tenant_id:  Tenant ID that owns the this volume (string)
 * user_id: User ID that owns this volume  (string)
 * volume_id: Nova volume ID of this volume (string)
 * volume_type:  Name of the volume type of this volume. (string)
 * display_name: User selected display name for volume.
 * created_at: Timestamp for when this volume's record was created in Nova (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * launched_at: Timestamp for when this instance was last launched by hypervisor.  (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * audit_period_begining: Timestamp of beginning of audit period. (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * audit_period_ending: Timestamp of end of audit period. (string, formatted "YYYY-MM-DD  hh:mm:ss.ssssss")
 * status: Current status of volume.  (string, such as 'available' or 'attached')
 * size: size of disk allocation for this volume.
 * snapshot_id: Nova id of the volume snapshot.

servergroup.create:
There is no .start/.end event for this activity ... just the 'servergroup.create' event.


 * Create notification for server group.
 * server_group_id:  ID of the server group which was just created  (string)
 * name: Name of the server group which was just created  (string)

servergroup.delete:
There is no .start/.end event for this activity ... just the 'servergroup.delete' event.


 * Delete notification for the server group
 * server_group_id:  ID of the server group which was deleted (string)

servergroup.update:
There is no .start/.end event for this activity ... just the 'servergroup.update' event.


 * Update notification for the server group.
 * server_group_id:  ID of the server group which was just updated (string)
 * members: New members of the server group which was just updated  (string)

servergroup.addmember:
There is no .start/.end event for this activity ... just the 'servergroup.addmember' event.


 * Add member notification for the server group.
 * server_group_id:  ID of the server group which was just added some new members (string)
 * instance_uuids: Instance UUIDs that were just added to the server group  (string)

orchestration.stack.{create,update,delete,suspend,resume}.{start,error,end}:
Usage notification upon stack action and state changes.


 * tenant_id: Tenant ID that owns the this stack (string)
 * user_id: User name of the user that owns this instance (string) (DEPRECATED: please use user_identity or  username)
 * user_identity: User ID that owns this instance (string)
 * username: user name of the user that owns this instance (string)
 * stack_identity: Heat stack ID (arn) (string)
 * stack_name: User selected display name for the stack.
 * created_at: Timestamp for when this stack's record was created in Heat (string, formatted "YYYY-MM-DD hh:mm:ss.ssssss")
 * state: Current state of stack. (string, such as 'CREATE_COMPLETE' or 'DELETE_COMPLETE')
 * state_reason: The reason for the about status. (string)
 * outputs: list of outputs from the template (list of dicts)
 * parameters: list of user provided parameters (list of dicts)

orchestration.autoscaling.{start,error,end}:
Notifications when auto-scaling occurs, in addition to the information above :


 * adjustment_type : ChangeInCapacity|ExactCapacity|PercentChangeInCapacity (String)
 * groupname : The unique name of the GroupInstance (ie as1-WebServerGroup-nsdsvnlxzmdk) (String)
 * capacity : Number of member in the group (Integer)
 * adjustment : Size of adjustment, scale-down if negative (Integer)

additional events
These are generated for operations monitoring/profiling purposes and shouldn't directly affect usage/billing. They all follow the same signature as the above calls. Some of these notifications may be called from the above operations (for example, shutdown from delete).