Subscribe, query, and analyze billing data

更新时间:
复制 MD 格式

In Costs, you can subscribe to various types of billing data, including billing item details, split item details, and cost details. Costs delivers the data to MaxCompute based on your subscription rules. You can then use the Data Analysis feature in DataWorks to query and analyze this data, and create visual cards and reports. You can also share these cards and reports with other users.

Background

Before you subscribe to and analyze your billing data, familiarize yourself with the following products:

  • Costs: Provides a comprehensive suite of financial management capabilities for your cloud resources, allowing you to view bills and perform cost analysis.

  • DataWorks and MaxCompute:

    DataWorks, built on big data engines like MaxCompute, lets you perform online analysis with SQL Query (Previous Version) and Data Profiling, edit and share data, and save query results as visual cards to quickly generate data reports. After you subscribe to your billing data, Costs synchronizes it to a specified MaxCompute table. You can then use the Data Analysis feature in DataWorks to analyze your Alibaba Cloud bill.

Billing

Subscribing to, querying, and analyzing billing data incurs the following costs:

  • Storage costs (charged by MaxCompute): Your billing data is stored in MaxCompute tables, which incurs storage costs. For more information, see Billing items and pricing.

  • Compute costs (charged by MaxCompute): Running SQL statements in Data Analysis incurs compute costs. For more information, see Billing items and pricing.

  • Card and report costs (charged by DataWorks): If you save query results as cards or reports, additional costs are incurred. DataWorks provides a free usage quota. Once you exceed the quota, you are charged based on the number of cards and reports you have. For more information, see advanced analytics billing.

Limitations

  • This feature is only available in the new version of the Costs console. To switch, click the Experience New Version button in the left-side navigation pane of the Costs console.

    Note

    If you cannot switch to the new version in the Costs console, submit a ticket to request access.

  • The bill analysis tool in Costs can only be activated in one region. For example, if you have activated it in the China (Shanghai) region, you cannot subscribe to billing data in any other region.

Create a bill subscription

  1. Log on to the Costs console. In the left-side navigation pane, choose Price > Bills > Bill Subscription.

  2. On the Bill Subscription page, click the Create Bill Subscription button.

  3. On the page that appears, click the MaxCompute tab and configure the parameters.

    Note

    The Alibaba Cloud bill details on the Data Analysis page include only the data you have subscribed to and stored in MaxCompute.

    • Configure delivery: The system automatically checks whether the required products are activated. If they are, you only need to configure the subscription content and billing cycle.

      Parameter

      Description

      Activate Products

      Checks if the service-linked role is authorized.

      Checks if DataWorks and MaxCompute are activated.

      Note

      If the role is not authorized or the products are not activated, see Activate required products and authorize the service-linked role.

      Select Subscription Content

      You can subscribe to billing item details, split item details, and cost details.

      Select Billing Cycle

      Select the starting month for the bill subscription. You can select bills from the last six months.

    • Delivery rule: A full data export for the previous day is delivered daily before 18:00. The complete dataset is delivered again at 18:00 on the 3rd of the following month. You can distinguish between them by the partition name, such as ds=delivery_month or version=delivery_time.

  4. After configuring the parameters, click Create to complete the bill subscription for MaxCompute.

Note

When you create the environment from Costs with one click, the system automatically creates a MaxCompute project and a DataWorks workspace named bill_<primary_account_UID>, and creates the corresponding data source.

View and analyze bill details in DataWorks

Access Alibaba Cloud bills

  1. Go to the SQL Query page.

    Log on to the DataWorks console. In the target region, click Data Analysis and Service > DataAnalysis in the left-side navigation pane. Click Go to DataAnalysis to open the Data Analysis page. In the left-side navigation pane, click SQL Query.

  2. On the SQL Query page, click the image icon to the right of the search box, and add Alibaba Cloud Bill Data from the Recommended Directory tab to the file directory on the left.

  3. Click the image icon to the right of the Alibaba Cloud Bill Data directory to go to the Alibaba Cloud Bill Data page. A message appears, indicating that the data subscription incurs MaxCompute storage costs and requires primary account permissions. The MaxCompute table names for the three types of billing data are billing_item_detail_for_billing_period, split_item_detail_for_billing_period, and cost_item_detail_for_billing_period. Their initial status is "Not Subscribed". Click Go to Subscribe at the bottom of the page to subscribe to the data.

    • On the Alibaba Cloud Bill Data page, click a bill name under the Bill Name column to view its details page, which shows Details, Basic information, Partition Information, and View Sample SQL.

      Note

      The details for Alibaba Cloud bills are displayed even before you subscribe. This allows you to understand the data structure of tables for billing item details, split item details, and cost details.

    • On the Alibaba Cloud Bill Data page, hover over View Sample SQL in the Operation column and select a predefined SQL example from Data Analysis to quickly generate an SQL query.

Query Alibaba Cloud bill data

On the Alibaba Cloud Bill Data page or the Sample SQL tab of a bill's details page, you can generate an SQL query file and edit the SQL to query your bills. The following steps show how to generate a temporary SQL query file from the Sample SQL tab to analyze bills.

  1. On the Alibaba Cloud Bill Data page, click a bill name under the Bill Name column to go to its details page.

  2. On the details page for billing item details, switch to the View Sample SQL tab. You can see two examples provided by Data Analysis, each with SQL Code and a Sample Card.

  3. On the View Sample SQL tab, click Generate SQL File for Query to generate a temporary SQL Query (Previous Version) file. Run the sample SQL to view the query results.

    The page includes two billing item examples: Example 1 queries summary information (payable amount, list price, savings plan deduction, discount, and coupon deduction). Example 2 queries the payable amount for each product and billing item, showing the top 10 items by payable amount in descending order.

Note

In SQL Query, you can also write your own SQL code based on the bill details to perform custom queries.

Create billing cards and reports

After the SQL query completes, you can generate cards and reports from the results. The following sections describe how to do this.

Generate billing cards

After the query completes, click the image icon on the left side of the results pane. A visual chart is generated from the results. If the default chart does not meet your needs, click the image icon in the upper-right corner of the chart to open the chart editor.

  1. In the chart editor, click Style Settings on the right to configure Global Settings, Change Chart, and adjust the Chart Style.

  2. After adjusting the chart, click Data Settings on the left side of the editor to adjust the chart's axis data and how the data is displayed.

  3. You can edit the title on the chart as needed. When you are finished, click Save in the upper-right corner to return to the SQL query results page.

  4. On the SQL query results page, click the Save button in the upper-right corner of the chart to save the adjusted chart as a card.

    Note

    If the default chart meets your needs, you can directly save it as a card by clicking the Save button in the upper-right corner.

After a card is saved, click the image icon in the left-side navigation pane to go to the Cards page. Here, you can view your saved cards and perform actions such as sharing. For more information, see Visual cards.

Create billing reports

After you save the chart generated from the SQL query results as a card, you can click the image icon in the left-side navigation pane to go to the Reports page and use the card to create a report.

  1. In the upper-right corner, click Create Report. In the dialog box that appears, select the cards you want to add and click Determine.

  2. On the report creation page, build your data report.

  3. After completing the settings, click the Create button in the upper-right corner to create the report.

Afterward, you can view all the reports you have created on the Report page. In the upper-right corner of a report, in addition to the options to Share and Preview the report, you can also click the image icon to Edit, Copy, or Delete the report.

Create a billing spreadsheet

After an SQL query is complete, you can select Export > Spreadsheet on the right side of the results pane to generate and navigate to a spreadsheet created from the query results. After you save the spreadsheet, you can click the image icon in the left-side navigation pane to go to the Spreadsheet page and view your saved spreadsheets.

Create a bill data profile

When you configure Data Profiling for your bills, you can create a data profile based on a bill. This section describes how to create one.

  1. On the SQL Query page, click the Alibaba Cloud Bills directory to expand the added bill directory.

  2. Select the bill for which you want to create a data profile, hover over the image icon, and select Data Insight from the menu to create a new data profile.

    In the Create Data Insight Task dialog box, configure the Work space, Data Source Type, Data Source Name, Table Name, Partition, Field, and Data Range parameters. Click Start Data Insight to create the data profile.

Note

If you have not yet enabled advanced analytics, click Try Now as prompted on the page.

More operations: Unsubscribe

You can unsubscribe from your Alibaba Cloud bill subscriptions. Note the following when you unsubscribe:

  • Unsubscribing from billing data does not automatically delete the physical tables synchronized to your MaxCompute project.

  • Whether you unsubscribe from billing data or manually delete the physical tables in your MaxCompute project, the corresponding billing data table information in the Data Analysis directory remains visible.

    Note

    This information remains visible in DataWorks to help you understand your billing data structure.

Appendix: Activate products and authorize the service-linked role

If you have not activated DataWorks and MaxCompute when creating a bill subscription, follow the instructions in the Costs UI to activate MaxCompute and DataWorks with one click, complete the related authorization, and prepare the analysis environment.

  1. Activate the required products.

    DataWorks and MaxCompute must be activated in the selected region. If they are not activated, click Activate on the Create Bill Subscription page to go to the product purchase page and activate them as prompted.

    Note

    The bill analysis tool in Costs can only be activated in one region. For example, if you have activated it in the China (Shanghai) region, you cannot subscribe to billing data in any other region.

  2. Authorize the service-linked role.

    You need to grant Costs the AliyunServiceRoleForBssOpenApi service-linked role. This role allows Costs to access your MaxCompute and DataWorks resources and query the list of authorized projects in MaxCompute to synchronize and analyze billing data. For more information about authorization, see Costs service-linked role.

  3. Prepare the analysis environment.

    Before subscribing, you must also prepare a storage and analysis environment by creating a MaxCompute project for storing and computing billing data, and a DataWorks workspace and data source for querying it. The platform can complete these tasks for you in about 2 minutes.

    Note
    • The logged-in account must be one of the following:

      • An Alibaba Cloud primary account.

      • A RAM user with the AdministratorAccess policy. For more information about authorization, see Create and authorize a RAM user.

    • When you create the environment with one click in the Costs UI, the system automatically creates a MaxCompute project, a DataWorks workspace named bill_<primary_account_UID>, and the corresponding data source.