Skip to content

Collector "Azure - Cloud Billing (Instance Level)" Configuration Manual

Before reading this document, please read:

Tip

Before using this collector, you must install the "Integration Core Package" and its accompanying third-party dependencies.

Tip

To ensure data integrity, the billing date collected is the day before the current date. For example: during 2022-07-03 00:00:00 ~ 23:59:59, the data collected is for 2022-07-02.

1. Configuration Structure

This collector requires no configuration and automatically retrieves the billing under the authorized subscription.

2. Data Reporting Format

After data is successfully synchronized, you can view the data in the "Cloud Billing Explorer" of TrueWatch.

An example of the reported data is as follows:

[
  {
    "category": "cloud_billing",
    "fields": {
      "amount": 0.000362931030000001,
      "message": "[0.000362931030000001, 0.000362931030000001, 20241126, \"func-resource\", \"/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc\", \"Storage\", \"us east\", \"ZP57-7TMW-BG7-PGB\", \"HM LU\", \"63a4a998-bd43-4cca-bd86-c4e7ed33a643\", \"Azure \\u8ba2\\u9605 1\", \"CNY\"]",
      "pre_tax_amount": 0.000362931030000001
    },
    "measurement": "cloud_billing",
    "tags": {
      "account_id": "ZP57-7TMW-BG7-PGB",
      "account_name": "HM LU",
      "billing_date": "2024-11-26",
      "billing_id": "2dcc4b206fe5b90a86540261b9aab7c103e7bff4204e2c54c022132cc7569b80",
      "billing_timestamp": "1732636799",
      "instance_id": "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc",
      "name": "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc",
      "product_code": "Storage",
      "product_name": "Storage",
      "region_id": "us east",
      "region_name": "us east",
      "resource_id": "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc",
      "subscription_id": "63a4a998-bd43-4cca-bd86-c4e7ed33a643",
      "subscription_name": "Azure subscription 1"
    },
    "timestamp": 1732636799
  }
]
Note

The fields in tags and fields may change with subsequent updates.

3. Field Description

Reported Field API Return Field API Field Meaning Description
Billing ID billing_id Unique ID of the bill
Product Code product_code ServiceName Cloud service type code
Product Name product_name ServiceName Cloud service type name
Actual Amount amount Cost User-paid amount including tax
Actual Amount (Excluding Tax) pre_tax_amount PreTaxCost User-paid amount excluding tax
Billing Period billing_date UsageDate Date of resource consumption record. Format: YYYYMMDD
Region ID region_id ResourceLocation Region ID
Region region_name ResourceLocation Region name
Instance ID instance_id ResourceId Instance ID / Resource ID
Consumer ID account_id BillingProfileId Billing profile ID, used to generate independent invoices.
Consumer Name account_name BillingProfileName Name of the billing profile, for user identification.
Subscription ID subscription_id SubscriptionId Unique identifier of the subscription, used to break down costs at the subscription level.
Subscription Name subscription_name SubscriptionName Friendly name of the subscription, for user identification of specific subscriptions.
Tip

The granularity of data statistics each time the script runs is Resource (Instance) ID: ResourceId; the billing consumption amounts of the same instance will be merged and calculated. For details, see the comparison between the Azure API Raw Data and the Script Aggregated Data below.

Azure API Raw Data

{
  "id": "subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/providers/Microsoft.CostManagement/query/3d4323d5-4408-4b3a-b81b-7f0b76679a7e",
  "name": "3d4323d5-4408-4b3a-b81b-7f0b76679a7e",
  "type": "Microsoft.CostManagement/query",
  "location": null,
  "sku": null,
  "eTag": null,
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "Cost",
        "type": "Number"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "ResourceId",
        "type": "String"
      },
      {
        "name": "ServiceName",
        "type": "String"
      },
      {
        "name": "ResourceLocation",
        "type": "String"
      },
      {
        "name": "BillingProfileId",
        "type": "String"
      },
      {
        "name": "BillingProfileName",
        "type": "String"
      },
      {
        "name": "SubscriptionId",
        "type": "String"
      },
      {
        "name": "SubscriptionName",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        0,
        0,
        20241001,
        "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/providers/microsoft.insights/pricings/metricsquery",
        "Azure Monitor",
        "us east",
        "ZP57-7TMW-BG7-PGB",
        "HM LU",
        "63a4a998-bd43-4cca-bd86-c4e7ed33a643",
        "Azure subscription 1",
        "CNY"
      ]
    ]
  }
}

Script Aggregated Data

[
  {
    "category": "cloud_billing",
    "fields": {
      "amount": 0.000362931030000001,
      "message": "[0.000362931030000001, 0.000362931030000001, 20241126, \"func-resource\", \"/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc\", \"Storage\", \"us east\", \"ZP57-7TMW-BG7-PGB\", \"HM LU\", \"63a4a998-bd43-4cca-bd86-c4e7ed33a643\", \"Azure \\u8ba2\\u9605 1\", \"CNY\"]",
      "pre_tax_amount": 0.000362931030000001
    },
    "measurement": "cloud_billing",
    "tags": {
      "account_id": "ZP57-7TMW-BG7-PGB",
      "account_name": "HM LU",
      "billing_date": "2024-11-26",
      "billing_id": "2dcc4b206fe5b90a86540261b9aab7c103e7bff4204e2c54c022132cc7569b80",
      "billing_timestamp": "1732636799",
      "instance_id": "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc",
      "name": "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc",
      "product_code": "Storage",
      "product_name": "Storage",
      "region_id": "us east",
      "region_name": "us east",
      "resource_id": "/subscriptions/63a4a998-bd43-4cca-bd86-c4e7ed33a643/resourcegroups/func-resource/providers/microsoft.storage/storageaccounts/dffunc",
      "subscription_id": "63a4a998-bd43-4cca-bd86-c4e7ed33a643",
      "subscription_name": "Azure subscription 1"
    },
    "timestamp": 1732636799
  }
]

X. Appendix

Azure - Billing Management "Query Resource Usage Records"

Please refer to the official Azure documentation: