Skip to content

Configuration Manual for the "Alibaba Cloud - Billing" Collector

Before reading this article, please first read:

Before using this collector, you must install the 'Integration Core Package' and its corresponding third-party dependency packages

To ensure data integrity, the billing date collected is current date - 2 days, i.e.: 2022-07-03 00:00:00 ~ 23:59:59. All data collected during this period corresponds to 2022-07-01. It is recommended that this script runs once daily.

The program has built-in duplicate collection prevention processing. If run multiple times within the same day, all subsequent executions after the first one will automatically skip.

1. Configuration Structure

This collector requires no configuration.

2. Data Reporting Format

After data synchronizes successfully, it can be viewed under the "Metrics" section of Guance and TrueWatch.

An example of the reported data is as follows:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "measurement": "cloud_bill",
  "tags": {
    "product_code": "ecs",
    "product_name": "Cloud Server ECS",
    "account_id"  : "1234xxxxxx999",
    "account_name": "xxxxx",
  },
  "fields": {
    "amount"        : 9419.23,
    "offical_amount": 18843.258604
  },
  "timestamp": 1657507021
}

Fields in tags and fields may change with subsequent updates

3. Statistical Explanation

Field Reported Field Alibaba Cloud API Return Field Description
Product Code product_code ProductCode
Product Name product_name ProductName
Account Name account_name AccountName
Account ID account_id AccountID
Original Price offical_amount PretaxGrossAmount Sum of PretaxGrossAmount for the same product code
Payable Amount amount PretaxAmount Sum of PretaxAmount for the same product code
Billing Date timestamp BillingDate

Data statistics granularity is Product Code: ProductCode; amounts for the same type of bill will be consolidated, refer specifically to the comparison between the original data from Alibaba Cloud API and the data aggregated by the script

To ensure complete data reporting, the date collected by the collector is two days prior, for example, if the collector runs on 2022-07-03, it collects data for 2022-07-01

For details about the Alibaba Cloud API interface, see the appendix for the 'Query Resource Consumption Records' interface address under Alibaba Cloud-Billing Management

Original Alibaba Cloud Billing Data

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[
  {
    "BillingDate"      : "2022-xx-xx",
    "ProductCode"      : "oss",
    "ProductName"      : "Block Storage",
    "PretaxAmount"     : 0.12,
    "PretaxGrossAmount": 0.22,
    "account_id"       : "1234xxxxxx999",
    "account_name"     : "xxxxx",
    "{other_fields}"   : "{omitted}"
  },
  {
    "BillingDate"      : "2022-xx-xx",
    "ProductCode"      : "oss",
    "ProductName"      : "Block Storage",
    "PretaxAmount"     : 0.22,
    "PretaxGrossAmount": 0.32,
    "account_id"       : "1234xxxxxx999",
    "account_name"     : "xxxxx",
    "{other_fields}"   : "{omitted}"
  },
  {
    "BillingDate"      : "2022-xx-xx",
    "ProductCode"      : "snapshot",
    "ProductName"      : "Block Storage",
    "account_id"       : "1234xxxxxx999",
    "account_name"     : "xxxxx",
    "PretaxAmount"     : 0.02,
    "PretaxGrossAmount": 0.02,
    "{other_fields}"   : "{omitted}"
  }
]

Aggregated by Script

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[
  {
    "measurement": "cloud_bill",
    "tags": {
      "product_code": "oss",
      "product_name": "Block Storage",
      "account_id"  : "1234xxxxxx999",
      "account_name": "xxxxx",
    },
    "fields": {
      "amount"        : 0.34,
      "offical_amount": 0.54,
      "account_id"    : "1234xxxxxx999",
      "account_name"  : "xxxxx",
    },
    "timestamp": 1657507021
  },
  {
    "measurement": "cloud_bill",
    "tags": {
      "product_code": "snapshot",
      "product_name": "Block Storage",
      "account_id"  : "1234xxxxxx999",
      "account_name": "xxxxx",
    },
    "fields": {
      "amount"        : 0.02,
      "offical_amount": 0.02
    },
    "timestamp": 1657507021
  }
]

Appendix

Alibaba Cloud - Billing Management «Query Instance Billing Service»