Skip to content

Cloud Account Billing Inspection

Background

Cloud account billing inspection helps users manage budget warnings for cloud services, abnormal cost warnings, predict cost situations, and provides users with visualization capabilities. It supports multi-dimensional visualization of cloud service resource consumption.

Prerequisites

  1. Offline deployment of self-built DataFlux Func
  2. Enable the Script Market in DataFlux Func from TrueWatch
  3. Create an API Key for operations in the "Management / API Key Management" section of TrueWatch
  4. In the self-built DataFlux Func, install the "Self-built Inspection Core Package", "Algorithm Library", and "Self-built Inspection (Billing)" via the "Script Market"
  5. Install and enable “Integration (Huawei Cloud - Billing Collection)”, “Integration (Alibaba Cloud - Billing Collection)”, “Integration (Tencent Cloud - Billing Collection)” via the Script Market, ensuring data collection spans over 15 days
  6. Write a self-built inspection processing function in the self-built DataFlux Func
  7. Through "Management / Automatic Trigger Configuration" in the self-built DataFlux Func, create an automatic trigger configuration for the written function

If considering using a cloud server for offline deployment of DataFlux Func, please ensure it is deployed with the currently used TrueWatch SaaS in the same operator and region

Configure Inspection

Create a new script set in the self-built DataFlux Func to enable cloud account billing inspection configuration

Python
 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
33
34
35
36
37
38
from guance_monitor__register import self_hosted_monitor
from guance_monitor__runner import Runner
import guance_monitor_billing__main as main

# Account Configuration
API_KEY_ID  = 'xxxxx'
API_KEY     = 'xxxx'

'''
Task configuration parameters should use:
@DFF.API('Cloud Account Billing Inspection', fixed_crontab='0 0 * * *', timeout=900)

fixed_crontab: Fixed execution frequency "once daily"
timeout: Task execution timeout duration, controlled within 15 minutes
'''

# Cloud billing configuration, no modification required by user
@self_hosted_monitor(API_KEY_ID, API_KEY)
@DFF.API('Cloud Account Billing Inspection', fixed_crontab='0 0 * * *', timeout=900)
def run(configs=None):
    '''
    configs : List type
    configs = [
        {
            "account_id": "10000000",    # Account ID
            "budget": 20000,             # Billing budget, numeric type
            "cloud_provider": "aliyun"   # Cloud provider name, optional parameters aliyun, huaweicloud, tencentcloud
        },
        ...
    ]
    '''
    # Cloud billing detector configuration
    checkers = [
        main.CloudChecker(configs=configs),
    ]

    # Execute cloud asset detector
    Runner(checkers, debug=False).run()

Enable Inspection

After configuring the inspection in DataFlux Func, you can test it by selecting and running the run() method directly on the page. After publishing, you can view and configure it under "Management / Scheduled Tasks" in DataFlux Func.

View Events

Intelligent Inspection uses smart algorithms to identify anomalies in cloud asset costs and budget metrics, such as sudden changes in cloud asset costs. For any anomalies detected, Intelligent Inspection generates corresponding events, which can then be viewed in the "Event Center".

Once the appropriate cloud provider accounts and monthly budgets are configured, the cloud account billing inspection will generate two types of events upon detecting anomalies to assist in troubleshooting error information.

Event Details

  • Event Overview: Describes the object and content of the anomaly inspection event
  • Cost Analysis: View the consumption trend of the current anomalous cloud account over the past 30 days

    • Anomaly Range: The start and end time of the anomaly interval from intelligent inspection data
  • Consumption Amount Ranking: View the ranking of product expenses for the current cloud account

  • Cost Prediction: Predict the remaining date's consumption amount for the current month for the cloud account

    • Confidence Interval: The accuracy range of the predicted trend line
  • Monthly Budget: The proportion of current account costs to the monthly budget

Common Issues

1. How to configure the detection frequency of the cloud account billing inspection

  • In the self-built DataFlux Func, when writing the self-built inspection processing function, add fixed_crontab='0 0 * * *', timeout=900 in the decorator, and then configure it under "Management / Automatic Trigger Configuration".

2. How to view the related Metrics Sets collected by the cloud account billing inspection

Metrics Set: cloud_bill

3. Under what circumstances will cloud account billing inspection events be generated

Using the total cost of specified cloud provider products as the entry point, events are triggered when there are significant changes in the cost information or when the total cost exceeds the configured budget, generating inspection events for root cause analysis.

  • Tracking Threshold: If the current period's cost increases by more than 100% year-over-year and quarter-over-quarter
  • Tracking Budget: When the monthly cost total exceeds the set budget

4. During the inspection process, previously normal scripts encounter abnormal errors

Please update the referenced script sets in the Script Market of DataFlux Func. You can view the update records of the Script Market through the Change Log to facilitate timely updates to the scripts.