跳转至

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

阅读本文前,请先阅读:

使用本采集器前,必须安装「观测云集成 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
[
  {
    "measurement": "cloud_billing_by_instance",
    "tags": {
      "name"                : "b65dd0c5e43e433xxxxxxxxxxf5e226din02",
      "cloud_provider"      : "huaweicloud",
      "billing_date"        : "2022-xx-xx",
      "billing_timestamp"   : "1662957294",
      "billing_account_id"  : "1e1fed9816xxxxxxxxxxx285140c83",
      "billing_account_name": "1e1fed9816xxxxxxxxxxx285140c83",
      "billing_product_code": "dds",
      "billing_product_name": "文档数据库服务"
    },
    "fields": {
      "billing_amount"        : 11.11,
      "billing_offical_amount": 11.11468938
    },

    "timestamp": 1662957294
  }
]

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

3. 字段说明

上报字段 API 返回字段 API 字段含义 说明
产品代码 billing_product_code cloud_service_type 云服务类型编码 cloud_service_type截取所得
如:"hws.service.type.vpc" —> "vpc"
产品名称 billing_product_name cloud_service_type_name 云服务类型名称
原价 billing_official_amount official_amount 官网价,华为云商品在官网上未叠加应用商务折扣、促销折扣等优惠的销售价格。 official_amount累加所得
实付金额 billing_amount amount 用户使用云服务享受折扣优惠后需要支付的费用金额,包括现金券和储值卡和代金券金额,精确到小数点后 2 位。 amount累加所得
账期 billing_date bill_date 资源消费记录的日期。格式:YYYY-MM-DD
账期 billing_timestamp 资源消费记录的日期(时间戳)
消费者 ID billing_account_id customer_id 资源消费的消费者 ID
消费者名称 billing_account_name customer_id 资源消费的消费者 ID
实例 ID name resource_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
[
  {
    "measurement": "cloud_billing_by_instance",
    "tags": {
      "billing_date"        : "2022-08-11",
      "billing_timestamp"   : "1662957294",
      "cloud_provider"      : "huaweicloud",
      "name"                : "b65dd0c5e43e433xxxxxxxxxxf5e226din02",
      "billing_product_code": "dds",
      "billing_product_name": "文档数据库服务",
      "billing_account_id"  : "1e1fed9816xxxxxxxxxxx285140c83",
      "billing_account_name": "1e1fed9816xxxxxxxxxxx285140c83"
    },
    "fields": {
      "billing_amount"        : 0.18,
      "billing_offical_amount": 0.18168888
    },
    "timestamp": 1662957294
  }
]

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

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

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "measurement": "cloud_billing_by_instance",
  "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_by_instance",
  "tags": {
    "instance_id": "i-001",
    "region_id"  : "xxxxx",
    "{其他字段}" : "{略}"
  },
  "fields": {
    "{指标}": "{指标值}"
  }
}

X. 附录

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

请参考华为云官方文档: