跳转至

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

阅读本文前,请先阅读:

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

为了保证数据的完整性,所采集的的账单日期为当前日期前一天,例如:2022-07-03 00:00:00 ~ 23:59:59 期间采集的都是 2022-07-02 的数据

当前账单数据采集仅统计部分产品,产品缩写列表:dcs, dds, ecs, elb, obs, rds, vpc

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
[
  {
    "measurement": "cloud_billing",
    "tags": {
      "billing_id"    : "anvxfafakjflxxxxxxx",
      "cloud_provider"      : "huaweicloud",
      "billing_date"        : "2022-xx-xx",
      "instance_id"   : "b65dd0c5e43e433xxxxxxxxxxf5e226din02",
      "region_id"   : "cn-hangzhu-1",
      "account_id"  : "1e1fed9816xxxxxxxxxxx285140c83",
      "account_name": "1e1fed9816xxxxxxxxxxx285140c83",
      "product_code": "dds",
      "product_name": "文档数据库服务"
    },
    "fields": {
      "amount"        : 11.11,
      "offical_amount": 11.11468938
    },

    "timestamp": 1662957294
  }
]

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

3. 字段说明

上报字段 API 返回字段 API 字段含义 说明
账单 ID billing_id 账单唯一 ID
产品代码 product_code cloud_service_type 云服务类型编码 cloud_service_type截取所得
如:"hws.service.type.vpc" —> "vpc"
产品名称 product_name cloud_service_type_name 云服务类型名称
原价 official_amount official_amount 官网价,华为云商品在官网上未叠加应用商务折扣、促销折扣等优惠的销售价格。 official_amount累加所得
实付金额 amount amount 用户使用云服务享受折扣优惠后需要支付的费用金额,包括现金券和储值卡和代金券金额,精确到小数点后 2 位。 amount累加所得
现金支付金额 cash_amount cash_amount 现金支付金额
信用额度支付金额 credit_amount credit_amount 信用额度支付金额
代金券支付金额 coupon_amount coupon_amount 代金券支付金额
现金券支付金额 flexipurchase_coupon_amount flexipurchase_coupon_amount 现金券支付金额
奖励金支付金额 bonus_amount bonus_amount 奖励金支付金额(用于现网客户未使用完的奖励金)
储值卡支付金额 stored_card_amount stored_card_amount 储值卡支付金额
欠费金额 debt_amount debt_amount 欠费金额
欠费核销金额 adjustment_amount adjustment_amount 欠费核销金额
账期 billing_date bill_date 资源消费记录的日期。格式:YYYY-MM-DD
地域 region_id region 地域 ID
实例 ID instance_id resource_id 实例 ID
消费者 ID account_id customer_id 资源消费的消费者 ID
消费者名称 account_name customer_id 资源消费的消费者 ID

脚本每次运行时数据统计颗粒度为 资源(实例)id:resource_id;相同实例的账单消费金额会合并计算,具体可以查看下面华为云 API 原始数据脚本汇总后的数据对比

华为云 API 接口原始数据

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
[
  {
    "cloud_service_type_name": "文档数据库服务",
    "resource_type_name"     : "DDS集群",
    "effective_time"         : "2022-08-11T10:00:00Z",
    "expire_time"            : "2022-08-11T10:06:05Z",
    "resource_id"            : "b65dd0c5e43e433e86d747af7f5e226din02",
    "resource_name"          : "dds-f652",
    "official_amount"        : 0.06975555,
    "amount"                 : 0.06,
    "product_id"             : "00301-327271-0--0",
    "product_name"           : "通用型集群II|config.large.2|2vCPUs|4GB 按需",
    "product_spec_desc"      : "通用型集群II|config.large.2|2vCPUs|4GB",
    "{其他字段}"             : "{略}"
  },
  {
    "cloud_service_type_name": "文档数据库服务",
    "resource_type_name"     : "DDS集群",
    "effective_time"         : "2022-08-11T10:00:00Z",
    "expire_time"            : "2022-08-11T10:06:05Z",
    "resource_id"            : "b65dd0c5e43e433e86d747af7f5e226din02",
    "resource_name"          : "dds-f652",
    "official_amount"        : 0.11193333,
    "amount"                 : 0.11,
    "product_id"             : "00301-327217-0--0",
    "product_name"           : "通用型集群II|mongos.medium.4|1vCPUs|4GB 按需",
    "product_spec_desc"      : "通用型集群II|mongos.medium.4|1vCPUs|4GB",
    "{其他字段}"             : "{略}"
  }
]

脚本汇总后

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
 {
    "category": "cloud_billing",
    "fields": {
      "adjustment_amount": 0.0,
      "amount": 105.0,
      "bonus_amount": 0.0,
      "cash_amount": 105.0,
      "coupon_amount": 0.0,
      "credit_amount": 0.0,
      "debt_amount": 0.0,
      "flexipurchase_coupon_amount": 0.0,
      "message": "{\"adjustment_amount\": null, \"az_code_infos\": [], \"bill_date\": null, \"bill_type\": 8, \"bonus_amount\": 0.0, \"cash_amount\": 105.0, \"charge_mode\": 1, \"cloud_service_type\": \"hws.service.type.elb\", \"cloud_service_type_name\": \"\\u5f39\\u6027\\u8d1f\\u8f7d\\u5747\\u8861\", \"consume_amount\": 105.0, \"coupon_amount\": 0.0, \"credit_amount\": 0.0, \"customer_id\": \"f000ee4d7327428da2f53a081e7109bd\", \"cycle\": \"2024-11\", \"debt_amount\": 0.0, \"discount_amount\": 45.0, \"effective_time\": null, \"enterprise_project_id\": \"0\", \"enterprise_project_name\": \"default\", \"expire_time\": null, \"flexipurchase_coupon_amount\": 0.0, \"id\": \"68caa614-409e-4147-ae5b-a412ace1d49c_1\", \"measure_id\": 1, \"official_amount\": 150.0, \"parent_resource_id\": null, \"payer_account_id\": \"f000ee4d7327428da2f53a081e7109bd\", \"period_type\": 20, \"pre_order_id\": null, \"product_spec_desc\": \"\\u5171\\u4eab\\u578b\\u5b9e\\u4f8b\\u6027\\u80fd\\u4fdd\\u969c\\u6a21\\u5f0f\", \"region\": \"cn-south-1\", \"region_name\": \"\\u534e\\u5357-\\u5e7f\\u5dde\", \"res_instance_id\": \"574387b2-fd11-4459-b966-54a7420d9ffb\", \"resource_Type_code\": \"hws.resource.type.elbv2\", \"resource_name\": \"kodo-nginx-elb\", \"resource_tag\": null, \"resource_type_name\": \"\\u5171\\u4eab\\u578b\\u8d1f\\u8f7d\\u5747\\u8861\", \"root_resource_id\": null, \"sku_code\": \"elbv2.basic.default\", \"stored_card_amount\": 0.0, \"sub_resource_id\": null, \"sub_resource_name\": null, \"sub_resource_type_code\": null, \"sub_resource_type_name\": null, \"sub_service_type_code\": null, \"sub_service_type_name\": null, \"trade_id\": \"CS2411070420BE132\"}",
      "offical_amount": 150.0,
      "stored_card_amount": 0.0
    },
    "measurement": "cloud_billing",
    "tags": {
      "account_id": "f000ee4d7327428da2f53a081e7109bd",
      "account_name": "f000ee4d7327428da2f53a081e7109bd",
      "billing_date": "2024-11-06",
      "billing_id": "8746f092d7353a56e987ac44abdc26655eed751296bd6361bf8e0a40977e5178",
      "billing_timestamp": "1730908799",
      "instance_id": "574387b2-fd11-4459-b966-54a7420d9ffb",
      "name": "574387b2-fd11-4459-b966-54a7420d9ffb",
      "product_code": "elb",
      "product_name": "弹性负载均衡",
      "region_id": "cn-south-1",
      "region_name": "华南-广州"
    },
    "timestamp": 1730908799
  }

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

当同一个 DataFlux Func 中运行了其他自定义对象采集器(如 EC2、RDS)时,本采集器会自动根据账单返回的resource_id字段尝试匹配自定义对象中的tags.name字段。 假设账单数据采集到的原始数据如下:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "measurement": "cloud_billing",
  "tags": {
    "instance_id": "i-001",
    "{其他字段}" : "{略}"
  },
  "fields": {
    "{指标}": "{指标值}"
  }
}

同时,华为云 EC2 采集器采集到的自定义对象数据如下:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "measurement": "huaweicloud_ec2",
  "tags": {
    "name"       : "i-001",
    "instance_id": "i-001",
    "region_id"  : "xxxxx",
    "{其他字段}" : "{略}"
  },
  "fields": {
    "{其他字段}": "{略}"
  }
}

当成功匹配后,会将所匹配的自定义对象tags中除name以外的字段加入到账单数据的tags中。 那么,最终上报的账单数据如下

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "measurement": "cloud_billing",
  "tags": {
    "instance_id": "i-001",
    "region_id"  : "xxxxx",
    "{其他字段}" : "{略}"
  },
  "fields": {
    "{指标}": "{指标值}"
  }
}

X. 附录

华为云-账单管理「查询资源消费记录」

请参考华为云官方文档: