Retrieves cost and usage metrics for your account.
Table Specific Information
In order to use this view, the user must be authorized to use billing and cost services.
SelectThe following sections describe the server-side query capabilities; the component processes other parts of the query client-side, through collaborative query processing. You can turn off the client-side execution of the query by setting SupportEnhancedSQL to false.
Server-side filtering is not supported on metric columns, while it is supported on all the others. You can choose the metrics to be returned in the query.
Querying DimensionsDimensions are metadata that you can use to filter or group your results. This is the only view that supports GROUP BY server side.
Also, tags can be defined and used for filtering. Tags are retrieved dynamically.
Filtering on a Date Range
StartDate and EndDate have limitations from the API such that StartDate cannot be older than a year before the current date, while EndDate cannot be set to a value after the beginning of the next month (wrong values will be automatically corrected by the component). Both are required from the API, so if they are not specified in the query, values will be assigned to them as described below:
- Only StartDate is missing: StartDate will get a value of one year before the EndDate. Considering the limitations mentioned before, the value will be eventually corrected by the component.
- Only EndDate is missing: EndDate will get a value of one year after the StartDate. Considering the limitations mentioned before, the value will be eventually corrected by the component.
- Both are missing: EndDate will be set at the beginning of next month. StartDate will be set one year before the EndDate.
ExamplesThe default query retrieves all available metrics for the maximum date range -- the past year, including this month.
SELECT * FROM CostAndUsageBelow you can find examples of queries that will be solved server side:
SELECT * FROM CostAndUsage WHERE Service != 'Amazon Simple Storage Device' SELECT * FROM CostAndUsage WHERE StartDate = '2017-07-10' SELECT * FROM CostAndUsage WHERE Service = 'Amazon Simple Storage Device' AND StartDate = '01-01-2018' SELECT * FROM CostAndUsage WHERE Service = 'Amazon S3' OR Service = 'Amazon DynamoDB' SELECT * FROM CostAndUsage GROUP BY AZ
|Estimated||Boolean||Whether this result is estimated.|
|StartDate||Date||The start date for retrieving the dimension values.|
|EndDate||Date||The end date for retrieving the dimension values.|
|Granularity||String||Sets the AWS cost granularity to MONTHLY or DAILY. If Granularity isn't set, the response object doesn't include the Granularity, either MONTHLY or DAILY.|
|BlendedCost||String||Blended cost amount.|
|BlendedCostUnit||String||Blended cost unit.|
|UnblendedCost||String||Unblended cost amount.|
|UnblendedCostUnit||String||Unblended cost unit.|
|UsageQuantity||String||Usage quantity amount.|
|UsageQuantityUnit||String||Usage quantity unit.|
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
|AZ||String||The Availability Zone.|
|InstanceType||String||The type of EC2 instance.|
|LegalEntityName||String||The name of the organization that sells you AWS services, such as Amazon Web Services.|
|LinkedAccount||String||The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account.|
|Operation||String||The action performed. Examples include RunInstance and CreateBucket.|
|PurchaseType||String||The reservation type of the purchase to which this usage is related. Examples include On-Demand Instances and Standard Reserved Instances.|
|Region||String||The AWS Region.|
|Service||String||The AWS service such as Amazon DynamoDB.|
|UsageType||String||The type of usage. An example is DataTransfer-In-Bytes. The response for the GetDimensionValues operation includes a unit attribute. Examples include GB and Hrs.|
|UsageTypeGroup||String||The grouping of common usage types. An example is EC2: CloudWatch Alarms. The response for this operation includes a unit attribute.|
|RecordType||String||The different types of charges such as RI fees, usage costs, tax refunds, and credits.|
|OperatingSystem||String||The operating system. Examples are Windows or Linux.|
|Tenancy||String||The tenancy of a resource. Examples are shared or dedicated.|
|Scope||String||The scope of a Reserved Instance (RI). Values are regional or a single Availability Zone.|
|Platform||String||The EC2 operating system. Examples are Windows or Linux.|
|SubscriptionId||String||The subscription id.|
|DeploymentOption||String||The scope of Amazon Relational Database Service deployments. Valid values are SingleAZ and MultiAZ.|
|DatabaseEngine||String||The Amazon Relational Database Service database.|
|CacheEngine||String||The Amazon ElastiCache operating system. Examples are Windows or Linux.|