The new Cost Manager stores data in a Tablestore instance to ensure data accuracy and real-time performance. The new Cost Manager automatically performs a full update every day. This topic describes how to use the new Cost Manager.
Entry point
On the Business Analysis tab in the Log Application section, click Cost Manager.
Syntax overview
Syntax
The dedicated Tablestore table of the new Cost Manager is associated with the dedicated Logstore of Cost Manage as an external table. You can query bill data only by using the external table.
Search statement: Only an asterisk (*) can be specified before a vertical bar (|).
Analytic statement: The name of the dedicated external table is instance_bill. All search conditions must be specified in a WHERE clause. Example:
* | select xxx from instance_bill where xxx group by xxx limit xxx
The following sample query statement is executed to query the daily expenses of Log Service:
* |
select
date_trunc('day', __time__) as day,
sum(PretaxAmount) as cost
FROM instance_bill
where
productcode = 'sls'
group by
day
Example 1: Query aggregated data
The following example shows how to obtain the total amount of expenses of Log Service:
Query statement
* | select sum(PretaxAmount) as cost FROM instance_bill where productcode = 'sls'
Query and analysis result
Example 2: Query data by group
The following example shows how to obtain the expenses of Log Service for each service:
Query statement
* | select productcode, sum(PretaxAmount) as cost FROM instance_bill group by productcode
Query and analysis result
Example 3: Perform comparative analysis
The following example shows how to compare the expenses of the current month with the expenses of the previous month by service:
Query statement
* | SELECT diff [1] AS "Expenses of this month", diff [2] AS "Expenses of the previous month", diff [3] * 100 -100 as "Increased by (%)" FROM ( SELECT compare(amount, 604800) as diff FROM ( SELECT sum(PretaxAmount) AS amount FROM instance_bill ) )
Query and analysis result
Example 4: Analyze the billable items of a service
The following example shows how to query the expenses and usage of each billable item in Log Service:
Query statement
* | SELECT BillingItem, sum(PretaxAmount) AS "Expense", sum(Usage) as "Usage" FROM instance_bill where productcode = 'sls' GROUP by BillingItem
Query and analysis result
Example 5: Analyze data by instance
The following example shows how to query the expenses of each instance in Log Service:
Query statement
* | SELECT InstanceID, sum(PretaxAmount) AS "Expense" FROM instance_bill where productcode = 'sls' GROUP by InstanceID
Query and analysis result
Example 6: Join external tables to query data
The following example shows how to query bill data by joining the instance_bill table with a custom external table.
In this example, a custom external table named instance_name_table is used. The custom table is used to map the instanceName field to the data in the instance_bill table based on the instanceID field.
Query statement
* | with t1 as ( select InstanceID, sum(PretaxAmount) as PretaxAmount FROM instance_bill ), t2 as ( select InstanceID, InstanceName FROM instance_name_table ) select t1.InstanceID, t1.PretaxAmount, t2.InstanceName FROM t1 left join t2 on t1.InstanceID = t2.InstanceID
Bill data
Field | Description | Example |
BillingDate | The billing cycle. | 2022-11-06 |
BillingItem | The billable item. | Number of other requests |
BillingType | The billing method. | Others |
CostUnit | The cost center. | Not Allocated |
Currency | The currency. | CNY |
DeductedByCashCoupons | The fee that is offset by using coupons. | 0.0 |
DeductedByCoupons | The fee that is offset by using vouchers. | 0.0 |
DeductedByPrepaidCard | The fee that is offset by using stored-value cards. | 0.0 |
DeductedByResourcePackage | The fee that is offset by using resource plans. | 0 |
InstanceConfig | The configurations of the instance. | None |
InstanceID | The ID of the instance. | me-east-1%3Bstandard |
InstanceSpec | The type of the instance. | None |
InternetIP | The public IP address. | None |
IntranetIP | The internal IP address. | None |
InvoiceDiscount | The savings. | 0.001 |
Item | The type of the bill. Valid values:
| PayAsYouGoBill |
ListPrice | The unit price. | 1.020000 |
ListPriceUnit | The unit. | USD per 10 thousand requests |
NickName | The alias of the instance. | test |
OutstandingAmount | The unsettled amount. | 0.0 |
OwnerID | Account ID | 12***3212 |
PaymentAmount | The fee that is paid in cash. | 0.0 |
PretaxAmount | The actual amount of fees. | 0.0 |
PretaxGrossAmount | The original price. | 0.005 |
ProductCode | The service code. | oss |
ProductDetail | The service details. | OSS |
ProductName | The service name. | Object Storage Service |
ProductType | The service type. | None |
Region | The region. | China (Shanghai) |
ResourceGroup | The resource group. | None |
ServicePeriod | The validity period. | 10800 |
SubscriptionType | The billing method. Valid values:
| PayAsYouGo |
Tag | The tag. | None |
Usage | The usage. | 0.005000 |
UsageUnit | The usage unit. | 10 thousand requests |
Zone | The zone. | cn-shanghai-b |