Amazon Elastic Compute Cloud
User Guide (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Subscribe to Your Spot Instance Data Feed

If you want to monitor your Spot Instance usage, you can subscribe to your Spot Instance data feed, which stores usage logs in Amazon Simple Storage Service (Amazon S3).

This section describes the data feed content and how to create the data feed for Spot Instances. You can create one data feed per account.

Spot Instance Data Feed Overview

To help you understand the charges for your Spot Instances, Amazon EC2 provides access to a data feed that details your Spot Instance usage and pricing. This data feed is sent to the Amazon S3 bucket of your choice.

To have a data feed delivered to an Amazon S3 bucket, you need to create a Spot Instances data feed subscription using the Amazon EC2 API. When you create this subscription, you can specify an Amazon S3 bucket to deliver the data feed files to, and a filename prefix to use to avoid collisions.

Data Feed Filename and Format

The Spot Instance data feed filename uses the following format (with the date and hour in UTC):

{Bucket}.s3.amazonaws.com/{Optional Prefix}/{AWS Account ID}.{YYYY}-{MM}-{DD}-{HH}.{n}.{Unique ID}.gz

For example, if your bucket name is myawsbucket, and you name your prefix myprefix, your filenames look similar to this:

myawsbucket.s3.amazonaws.com/myprefix/111122223333.2010-03-17-20.001.pwBdGTJG.gz

Data feed files arrive in your bucket typically once an hour and each hour of usage is typically covered in a single data file. These files are compressed (gzip) before delivery into your bucket. We can write multiple files for a given hour of usage where files are very large (for example, when file contents for the hour exceed 50 MB before compression).

Note

If you don't have a Spot Instance running during a certain hour, you won't receive a data feed file for that hour.

The Spot Instance data feed files are tab-delimited. Each line in the data file corresponds to one instance-hour. Each line contains the fields listed in the following table.

Field Description

Timestamp

The timestamp used to determine the price charged for this instance-hour.

UsageType

Indicates the type of usage and instance type being charged for. For m1.small Spot Instances, this field is set to "SpotUsage." For all other instance types, this field is set to "SpotUsage:{instance-type}," for example, “SpotUsage:c1.medium.”

Operation

Indicates the product being charged for. For Linux/UNIX Spot Instances, this field is set to “RunInstances.” For Microsoft Windows, this field is set to "RunInstances:0002." Spot usage is grouped according to Availability Zone.

InstanceID

The instance ID for the Spot Instance that generated this instance-hour.

MyBidID

The Spot Instance request ID for the request that generated this instance-hour.

MyMaxPrice

The maximum price specified for this Spot Instance request.

MarketPrice

The Spot price at the time specified in the Timestamp field.

Charge

The price charged for this instance-hour.

Version

The version included in the data feed filename for this record.

Preparing Amazon S3 for Data Feeds

When you subscribe to data feeds, you tell Amazon EC2 which bucket you want to store the data feed file in. Before you subscribe to the data feed, consider the following when choosing your S3 bucket:

  • You must have Amazon S3 FULL_CONTROL permission on the bucket you provide.

    If you're the bucket owner, you have this permission by default. If you're not the bucket owner, the bucket owner must grant your AWS account FULL_CONTROL permission.

  • When you create your data feed subscription, Amazon EC2 updates the designated bucket's ACL to allow read and write permissions for the AWS data feeds account.

  • Each data feed file has its own ACL (separate from the bucket's ACL).

    The bucket owner has FULL_CONTROL permission for the data files. The data feed account has read and write permission.

  • Removing the permissions for the data feed account does not disable the data feed.

    If you remove those permissions but don't disable the data feed (which you do with the control API), we reinstate those permissions the next time the data feeds account needs to write a data file to your bucket.

  • If you delete your data feed subscription, Amazon EC2 doesn't remove the read/write permissions for the data feed account on either the bucket or the data files.

    You must perform remove the read/write permissions yourself.

Subscribe to Your Spot Instance Data Feed

Command Line Tools

To subscribe to your Spot Instance data feed

  • Enter the following command:

    PROMPT>  ec2-create-spot-datafeed-subscription --bucket myawsbucket [--prefix prefix ]

    Amazon EC2 returns output similar to the following:

    SPOTDATAFEEDSUBSCRIPTION        111122223333    myawsbucket        prefix   Active

API

To subscribe to your Spot Instance data feed

  • Construct the following Query request.

    https://ec2.amazonaws.com/
    ?Action=CreateSpotDatafeedSubscription
    &Bucket=myawsbucket
    &Prefix=my-spot-subscription
    &...auth parameters...

    Following is an example response.

    <CreateSpotDatafeedSubscriptionResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
      <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
      <spotDatafeedSubscription>
            <ownerId>999988887777</ownerId>
            <bucket>myawsbucket</bucket>
            <prefix>my-spot-subscription</prefix>
            <state>Active</state>
            <fault>/</fault>
       </spotDatafeedSubscription>
    </CreateSpotDatafeedSubscriptionResponse>

Delete a Spot Instance Data Feed

Command Line Tools

To delete a Spot Instance data feed

  • To delete a data feed, enter the following command:

    PROMPT>  ec2-delete-spot-datafeed-subscription

    If the request is successful, the output is empty.

API

To delete a Spot Instance data feed

  • Construct the following Query request.

    https://ec2.amazonaws.com/
    ?Action=DeleteSpotDatafeedSubscription
    &...auth parameters...

    Following is an example response. It confirms that the subscription was deleted.

    <DeleteSpotDatafeedSubscriptionResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
       <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
       <return>true</return>
    </DeleteSpotDatafeedSubscriptionResponse>