ECS bill analysis

更新时间:
复制 MD 格式

This topic describes how to use the ECS Instance Bill Analysis report, provides common cost analysis examples, and explains how to configure alerts for ECS traffic usage.

ECS instance bill analysis report

In Cost Manager, open the ECS Instance Bill Analysis report to view an overview of your ECS bills.

The ECS Instance Bill Analysis report includes four metric cards: Yesterday's cost, This month's cost, Total instances (30 days), and Average instance cost. It also features a Weekly cost trend bar chart with a corresponding details table.

Custom ECS cost analysis

In Cost Manager, you can write custom queries in the Custom Analysis section.

Example 1: Calculate ECS instance costs

The following query calculates the cost for each ECS instance. In the query results, region is the region of the instance, and cost is the corresponding cost.

* | select
  instanceId, region,
  sum(PretaxAmount) as cost
FROM  instance_bill
where
  productcode = 'ecs'
group by
  instanceId,region

Example 2: Daily cost breakdown for a single instance

The following query returns the daily cost for each billing item of a single instance. Replace ${instanceId} with your actual instance ID.

* | select
  date_trunc('day', __time__) as t,
  billingItem,
  sum(PretaxAmount) as cost
FROM  instance_bill
where
  productcode = 'ecs'
  and instanceId = '${instanceId}'
group by
  t,
  billingItem
order by
  t

ECS traffic usage alert

In the left navigation pane, select Alerts to view all alerts for the Cost Manager project. You can configure alerts to automatically monitor your daily costs or usage. The following example shows how to create an alert that triggers when the outbound traffic from a single instance on the previous day exceeds a specified threshold.

  1. In the left-side navigation pane, click Alerts. On the Alert Center page, click Create Alert.

  2. On the Create Alert page, configure the Check Frequency, Query Statistics, and Trigger Condition. For other parameters, see Configuration Description.

    Configure the following query to check the outbound traffic for each instance from the previous day. Because bill data is synchronized on a T+1 basis, set the query time range to Yesterday. Since SLS bill data is generated daily, you must set the check frequency to a fixed interval of 1 day. Set the trigger condition to data matches the expression and the matching condition that the Traffic value is greater than your alert threshold. This example uses an alert threshold of 10.

    * | select
      instanceId,
      sum(Usage) as "Traffic"
    FROM  instance_bill
    where
      productcode = 'ecs'
    	and billingItem = 'outbound traffic'
    group by
      instanceId

    In the advanced settings for query statistics, set Type to Logstore and select aliyun_bill for the Logstore. Set dedicated SQL to Off. After you finish configuring the query, click Confirm.

  3. After you configure the alert, you can view the alert trigger records on the alert dashboard.