All Products
Search
Document Center

Logic Composer:Regularly export bills

Last Updated:Nov 09, 2023

This topic describes how to use Logic Composer to regularly export bills in an Alibaba Cloud account by calling the QueryBill operation of Alibaba Cloud to an RDS instance. You can export bills in multiple accounts.

Architecture

This architecture shows that you can use Logic Composer to call the billing API, obtain bill data, and write data to an RDS instance by using the MySQL connector provided by Logic Composer. You can analyze and display bills based on the data in the RDS database. You can use triggers of Logic Composer to automatically export the bill data to the RDS instance on a daily basis.

The following figure shows the overall architecture:

image

Preparations

Create an RDS instance. For more information, see Create an ApsaraDB RDS for MySQL instance.

When the instance is running, prepare the following information:

Create a workflow

  1. Log on to the Logic Composer console by using your Alibaba Cloud account. In the left-side navigation pane, click Workflows.

  2. Click Create Workflow. In the dialog box that appears, set the Workflow Name and Resource Group parameters and click OK. In the dialog box that appears, select Import Official Template.

  3. In the dialog box that appears, select Regularly export InstanceBill data to RDS. A workflow is created.

Configure the workflow

After the workflow is created, the Graphic View tab is displayed. You need to configure the database connector and grant Logic Composer permissions to call the billing API. After you grant permissions, Logic Composer can call the billing API and write data into the RDS instance. Logic Composer analyzes the template you import and lists all the operations on which you must grant permissions.

In the row of the database connector, click Create. In the sidebar that appears, enter the public endpoint, port number, database name, username, and password of the RDS instance.

In the row of Alibaba Cloud billing API operation, click Authorize. The Grant Role sidebar appears. Select AliyunBSSFullAccess.

After you complete all authorization operations, each item in the authorization list turns green. Click Continue to enter the Graphical View page.

Configure parameters

On the canvas page, you can configure running variables. For example, the SetTotalMonths node indicates the number of months in which data is imported. You can modify the settings based on your needs. Take another example. The template you import starts to import data on the first day of each month. You can modify the trigger settings to start data import at 04:00 every day. You only need to expand the Recurrence task node on the canvas and modify the related configurations.

Run a workflow

After you configure the parameters, click Save and click Run. Wait until the workflow is complete.

Note

If the amount of data is large, it takes some time to import the data. This is mainly determined by the amount of bill data in the account and the duration of writing data to the database.

Query execution results of the workflow

On the Execution Log tab, you can view the running records. If the status is Successful, the import is complete.

If the status is Failed, click the View button to check the details, such as whether the configurations of the database whitelist are valid or whether the API call fails. If an error occurs, you can adjust the parameters and run the workflow again. The template is also processed accordingly and the data is not imported repeatedly.