Custom bill alert examples

更新时间:
复制 MD 格式

Simple Log Service allows you to create alert rules that monitor your fees and resource usage in real time. This topic provides common alert examples.

Entry points

  1. Log on to the Simple Log Service console.

  2. In the Log Application section, on the Business Analysis tab, click Cost Manager.

  3. Choose one of the following methods to configure an alert.

    • Method 1: Create an alert rule.

      On the Cost Manager page, click Alerts in the left-side navigation pane to go to the Alert Center page. Then, click Create Alert.

    • Method 2: Save a query statement as an alert.

      On the Cost Manager page, click Custom Analysis in the left-side navigation pane. On the query and analysis page, enter a query statement, set the time range to Yesterday, and then click Save as Alert.

      For example, you can use the following query statement: select sum(PretaxAmount) as cost FROM instance_bill.

Bill alert examples

Bill data is synchronized on a T+1 basis, so data for a given day becomes available the following day. Set the query time range to Yesterday and the check interval to one day. The following examples help you configure alerts for fees and usage.

Total fee for yesterday

Use the following query statement to alert on yesterday's total fee. Set the time range to Yesterday, the trigger condition to Data exists, and the trigger expression to "cost" > alert_threshold.

* | select
  sum(PretaxAmount) as cost
FROM  instance_bill

Single service total fee

Use the following query statement to alert on yesterday's total fee for a specific cloud service. In the WHERE clause, replace ${ProductCode} with the target service code. Set the time range to Yesterday, the trigger condition to Data exists, and the trigger expression to "cost" > alert_threshold.

* | select
  sum(PretaxAmount) as cost
FROM  instance_bill
where
  ProductCode = '${ProductCode}'

Service usage

Use the following query statement to alert on yesterday's usage of a specific billable item. In the WHERE clause, specify the ProductCode and BillingItem. This example monitors Simple Log Service (SLS) storage usage. Set the time range to Yesterday, the trigger condition to Data exists, and the trigger expression to "Usage" > alert_threshold.

* | select
  sum(Usage) as Usage
FROM  instance_bill
where
  ProductCode = 'sls'
  and BillingItem like '%storage%'

Single instance usage

Use the following query statement to alert on yesterday's usage of a specific instance. In the WHERE clause, specify the ProductCode, BillingItem, and InstanceId. This example monitors the storage usage of a single SLS project. Set the time range to Yesterday, the trigger condition to Data exists, and the trigger expression to "Usage" > alert_threshold.

* | select
  sum(Usage) as Usage
FROM  instance_bill
where
  ProductCode = 'sls'
  and BillingItem like '%storage%'
  and InstanceId like '%project%'

Day-over-day fee comparison

Use the following query statement to compare yesterday's fee against the previous day. Set the time range to Yesterday, the trigger condition to Data exists, and the trigger expression to "Increased by" > alert_threshold.

* |
SELECT
  diff [1] AS "Yesterday's Fee",
  diff [2] AS "Fee from Day Before Yesterday",
  diff [3] * 100 -100 as "Increased by"
FROM (
    SELECT
      compare(amount, 86400) as diff
    FROM (
        SELECT
          sum(PretaxAmount) AS amount
        FROM instance_bill
      )
  )