steampipe plugin install aws

Table: aws_cost_by_service_usage_type_monthly - Query AWS Cost Explorer Service using SQL

The AWS Cost Explorer Service is a tool that enables you to view and analyze your costs and usage. You can explore your AWS costs using an interface that lets you observe both your costs and usage patterns. It includes features that allow you to dive deeper into your cost and usage data to identify trends, pinpoint cost drivers, and detect anomalies.

Table Usage Guide

The aws_cost_by_service_usage_type_monthly table in Steampipe provides you with information about the monthly cost data per service and usage type within AWS Cost Explorer Service. This table allows you, as a financial analyst or cloud cost manager, to query detailed cost data, including the service name, usage type, cost, and currency. You can utilize this table to gather insights on monthly AWS costs, such as cost per service, cost per usage type, and the total monthly cost. The schema outlines the various attributes of the cost data, including the service name, usage type, cost, and the currency used.

Amazon Cost Explorer helps you visualize, understand, and manage your AWS costs and usage. The aws_cost_by_service_usage_type_monthly table provides you with a simplified view of cost for services in your account (or all linked accounts when run against the organization master), summarized by month, for the last year.

Important Notes

Examples

Basic info

This query provides a comprehensive overview of your AWS service usage, allowing you to understand your monthly costs. By analyzing the cost and usage patterns, you can identify areas for potential cost savings and optimize your AWS utilization.

select
service,
usage_type,
period_start,
blended_cost_amount :: numeric :: money,
unblended_cost_amount :: numeric :: money,
amortized_cost_amount :: numeric :: money,
net_unblended_cost_amount :: numeric :: money,
net_amortized_cost_amount :: numeric :: money
from
aws_cost_by_service_usage_type_monthly
order by
service,
period_start;
select
service,
usage_type,
period_start,
cast(blended_cost_amount as decimal),
cast(unblended_cost_amount as decimal),
cast(amortized_cost_amount as decimal),
cast(net_unblended_cost_amount as decimal),
cast(net_amortized_cost_amount as decimal)
from
aws_cost_by_service_usage_type_monthly
order by
service,
period_start;

Min, Max, and average monthly unblended_cost_amount by service and usage type

Gain insights into your AWS service usage by evaluating the minimum, maximum, and average monthly costs associated with each service and usage type. This helps in better understanding of your cloud spending patterns and can guide cost optimization efforts.

select
service,
usage_type,
min(unblended_cost_amount) :: numeric :: money as min,
max(unblended_cost_amount) :: numeric :: money as max,
avg(unblended_cost_amount) :: numeric :: money as average
from
aws_cost_by_service_usage_type_monthly
group by
service,
usage_type
order by
service,
usage_type;
select
service,
usage_type,
min(cast(unblended_cost_amount as numeric)) as min,
max(cast(unblended_cost_amount as numeric)) as max,
avg(cast(unblended_cost_amount as numeric)) as average
from
aws_cost_by_service_usage_type_monthly
group by
service,
usage_type
order by
service,
usage_type;

Top 10 most expensive service usage type (by average monthly unblended_cost_amount)

Explore which services and usage types are the most costly on average per month, allowing for targeted cost reduction efforts. This analysis can help prioritize areas for cost optimization within your AWS services.

select
service,
usage_type,
sum(unblended_cost_amount) :: numeric :: money as sum,
avg(unblended_cost_amount) :: numeric :: money as average
from
aws_cost_by_service_usage_type_monthly
group by
service,
usage_type
order by
average desc
limit
10;
select
service,
usage_type,
sum(unblended_cost_amount) as sum,
avg(unblended_cost_amount) as average
from
aws_cost_by_service_usage_type_monthly
group by
service,
usage_type
order by
average desc
limit
10;

Top 10 most expensive service usage type (by total monthly unblended_cost_amount)

Discover the segments that are contributing the most to your monthly AWS costs. This query helps in identifying the top 10 service usage types that are incurring the highest costs, allowing you to better manage and optimize your resource usage.

select
service,
usage_type,
sum(unblended_cost_amount) :: numeric :: money as sum,
avg(unblended_cost_amount) :: numeric :: money as average
from
aws_cost_by_service_usage_type_monthly
group by
service,
usage_type
order by
sum desc
limit
10;
select
service,
usage_type,
sum(unblended_cost_amount) as sum,
avg(unblended_cost_amount) as average
from
aws_cost_by_service_usage_type_monthly
group by
service,
usage_type
order by
sum desc
limit
10;

Schema for aws_cost_by_service_usage_type_monthly

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
account_idtextThe AWS Account ID in which the resource is located.
amortized_cost_amountdouble precisionThis cost metric reflects the effective cost of the upfront and monthly reservation fees spread across the billing period. By default, Cost Explorer shows the fees for Reserved Instances as a spike on the day that you're charged, but if you choose to show costs as amortized costs, the costs are amortized over the billing period. This means that the costs are broken out into the effective daily rate. AWS estimates your amortized costs by combining your unblended costs with the amortized portion of your upfront and recurring reservation fees.
amortized_cost_unittextUnit type for amortized costs.
blended_cost_amountdouble precisionThis cost metric reflects the average cost of usage across the consolidated billing family. If you use the consolidated billing feature in AWS Organizations, you can view costs using blended rates.
blended_cost_unittextUnit type for blended costs.
estimatedbooleanWhether the result is estimated.
net_amortized_cost_amountdouble precisionThis cost metric amortizes the upfront and monthly reservation fees while including discounts such as RI volume discounts.
net_amortized_cost_unittextUnit type for net amortized costs.
net_unblended_cost_amountdouble precisionThis cost metric reflects the unblended cost after discounts.
net_unblended_cost_unittextUnit type for net unblended costs.
normalized_usage_amountdouble precisionThe amount of usage that you incurred, in normalized units, for size-flexible RIs. The NormalizedUsageAmount is equal to UsageAmount multiplied by NormalizationFactor.
normalized_usage_unittextUnit type for normalized usage.
partitiontextThe AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov).
period_endtimestamp with time zoneEnd timestamp for this cost metric.
period_starttimestamp with time zoneStart timestamp for this cost metric.
regiontextThe AWS Region in which the resource is located.
servicetext=, !=The name of the AWS service.
unblended_cost_amountdouble precisionUnblended costs represent your usage costs on the day they are charged to you. In finance terms, they represent your costs on a cash basis of accounting.
unblended_cost_unittextUnit type for unblended costs.
usage_quantity_amountdouble precisionThe amount of usage that you incurred. NOTE: If you return the UsageQuantity metric, the service aggregates all usage numbers without taking into account the units. For example, if you aggregate usageQuantity across all of Amazon EC2, the results aren't meaningful because Amazon EC2 compute hours and data transfer are measured in different units (for example, hours vs. GB).
usage_quantity_unittextUnit type for usage quantity.
usage_typetext=, !=The usage type of this metric.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws

You can pass the configuration to the command with the --config argument:

steampipe_export_aws --config '<your_config>' aws_cost_by_service_usage_type_monthly