跳转至

采集器「阿里云-账单(实例维度)」配置手册

阅读本文前,请先阅读:

使用本采集器前,必须安装「观测云集成 Core 核心包」及其配套的第三方依赖包

为了保证数据的完整性,所采集的账单数据为采集日期前一天的数据

1. 配置结构

本采集器无需配置

2. 数据上报格式

数据正常同步后,可以在观测云的「云账单查看器」中查看数据。

上报的数据示例如下:

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
{
    "category": "cloud_billing",
    "fields": {
      "amount": 0.12,
      "cash_amount": 0.0,
      "coupon_amount": 0.0,
      "credit_amount": 0.0,
      "message": "{\"BillingDate\": \"2024-11-10\", \"BillingItem\": \"\", \"BillingType\": \"\\u5176\\u5b83\", \"CommodityCode\": \"slb_intl\", \"CostUnit\": \"\\u672a\\u5206\\u914d\", \"Currency\": \"USD\", \"DeductedByCoupons\": 0.0, \"DeductedByResourcePackage\": \"\", \"InstanceConfig\": \"\\u53ef\\u7528\\u533a\\u7c7b\\u578b:\\u591a\\u53ef\\u7528\\u533a;\\u5b9e\\u4f8b\\u7c7b\\u578b:\\u516c\\u7f51;\\u5730\\u57df:\\u65b0\\u52a0\\u5761;\\u5b9e\\u4f8b\\u8ba1\\u8d39\\u65b9\\u5f0f:\\u6309\\u4f7f\\u7528\\u91cf\\u8ba1\\u8d39;\\u516c\\u7f51\\u6d41\\u91cf\\u8d39:\\u6309\\u4f7f\\u7528\\u6d41\\u91cf\\u8ba1\\u8d39GB;yundun_service:\\u5f00\\u901a;\\u5b9e\\u4f8b\\u8d39:\\u662f;\\u5bb9\\u91cf\\u5355\\u4f4d:1;\\u8ba1\\u8d39\\u5468\\u671f:\\u6309\\u5c0f\\u65f6;IP\\u7248\\u672c:IPv4;\\u5907\\u53ef\\u7528\\u533a:ap-southeast-1c;\\u8ba1\\u8d39\\u9879:\\u914d\\u7f6e\\u8d39\\u7528+\\u6d41\\u91cf\\u8d39\\u7528;\\u4e3b\\u53ef\\u7528\\u533a:ap-southeast-1b\", \"InstanceID\": \"lb-gs5v2g2irfujv93hr3k0l\", \"InstanceSpec\": \"slb.s3.large\", \"InternetIP\": \"47.245.99.230\", \"IntranetIP\": \"\", \"InvoiceDiscount\": 0.0774, \"Item\": \"PayAsYouGoBill\", \"ListPrice\": \"\", \"ListPriceUnit\": \"\", \"NickName\": \"fileshow\", \"OwnerID\": \"5451716195367166\", \"PipCode\": \"slb\", \"PretaxAmount\": 0.12, \"PretaxGrossAmount\": 0.258, \"ProductCode\": \"slb\", \"ProductDetail\": \"\\u4f20\\u7edf\\u578b\\u8d1f\\u8f7d\\u5747\\u8861 (\\u6309\\u91cf\\u4ed8\\u8d39) \\u56fd\\u9645\\u7ad9\", \"ProductName\": \"\\u8d1f\\u8f7d\\u5747\\u8861\", \"ProductType\": \"\", \"Region\": \"\\u65b0\\u52a0\\u5761\", \"ResourceGroup\": \"default resource group\", \"ServicePeriod\": \"86400\", \"ServicePeriodUnit\": \"\\u79d2\", \"SubscriptionType\": \"PayAsYouGo\", \"Tag\": \"\", \"Usage\": \"\", \"UsageUnit\": \"\", \"Zone\": \"ap-southeast-1b\"}",
      "offical_amount": 0.258,
      "stored_card_amount": 0.0
    },
    "measurement": "cloud_billing",
    "tags": {
      "account_id": "5539882238131171",
      "account_name": "guance-intl@guance.com",
      "billing_date": "2024-11-10",
      "billing_id": "a202af3e367140098dbf703e4c4e772642930c009b2e26051962dd14477c4417",
      "billing_timestamp": "1731254399",
      "cost_unit": "未分配",
      "instance_id": "lb-gs5v2g2irfujv93hr3k0l",
      "name": "lb-gs5v2g2irfujv93hr3k0l",
      "product_code": "slb",
      "product_name": "负载均衡",
      "region_id": "新加坡",
      "subscription_type": "PayAsYouGo",
      "zone": "ap-southeast-1b"
    },
    "timestamp": 1731254399
  }

tags、fields 中的字段可能会随后续更新有所变动

3. 字段说明

上报字段 API 返回字段 API 字段含义
账单 ID billing_id 账单唯一 ID
产品代码 product_code ProductCode 产品代码
产品名称 product_name ProductName 产品名称
原价 official_amount PretaxGrossAmount 官网价
实付金额 amount PretaxAmount 用户支付价格
信用额度退款金额 credit_amount AdjustAmount 信用额度退款抵扣
代金券金额 coupon_amount DeductedByCashCoupons 代金券抵扣
储值卡金额 stored_card_amount DeductedByPrepaidCard 储值卡抵扣。
现金支付金额 cash_amount CashAmount 现金支付(不包含信用额度退款抵扣)。
实例ID instance_id InstanceID 实例ID
账期 billing_date 资源消费记录的日期。格式:YYYYMMDD
账期 timestamp 资源消费记录的日期(时间戳)
财务单元 cost_unit AliyunCostUnit 财务单元
地域 region_id AliyunRegion 地域
可用区 zone AliyunZone 可用区
订阅类型 subscription_type AliyunSubscriptionType 订阅类型
账号名称 account_name BillAccountName 账号名称
账号 ID account_id BillAccountID 账号 ID

4. 与自定义对象采集器联动

当同一个 DataFlux Func 中运行了其他自定义对象采集器(如 ECS、RDS)时,本采集器会自动根据 InstanceID 字段尝试匹配自定义对象中的 tags.name 字段。当成功匹配后,会将所匹配的自定义对象 tags 中除 name 以外的字段加入到账单数据的 tags 中。

假设账单采集到的原始数据如下:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
  "measurement": "cloud_billing",
  "tags": {
    "product_code": "ecs",
    "product_name": "云服务器 ECS",
    "name"                : "i-xxxxxxxx",
    "billing_date"        : "20220909",
    "cloud_provider"      : "aliyun",
    "account_id"  : "xxxxx",
    "account_name": "xxxxx"
  },
  "fields": {
    "amount"        : 9419.23,
    "offical_amount": 18843.258604
  },
  "timestamp": 1657507021
}

同时,阿里云 ECS 采集器采集到的自定义对象数据如下:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "measurement": "aliyun_ecs",
  "tags": {
    "account_name": "xxxxxx",
    "account_id"  : "xxxxxx",
    "name"                : "i-xxxxxxxx",
    "InstanceId"          : "i-xxxxxxxx",
    "RegionId"            : "cn-hangzhou",
    "{其他字段}"          : "{略}"
  },
  "fields": {
    "{其他字段}": "{略}"
  }
}

那么,最终上报的账单数据如下:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
"measurement": "cloud_billing",
  "tags": {
    "account_id"  : "xxxxx",
    "account_name": "xxxxx",
    "instance_id"          : "i-xxxxxxxx",
    "region_id"            : "cn-hangzhou",
    "product_code": "ecs",
    "product_name": "云服务器 ECS",
    "name"                : "i-xxxxxxxx",
    "billing_date"        : "20220909",
    "cloud_prvider"       : "aliyun",
    "{其他字段}"          : "{略}"
  },
  "fields": {
    "amount"        : 9419.23,
    "offical_amount": 18843.258604
  },
  "timestamp": 1657507021
}

附录

阿里云-账单管理「查询实例账单服务」