You can use the alerting feature of Simple Log Service to monitor the resource usage of Simple Log Service resources in real time. This topic describes common examples of alert rules for fees and resource usage.
Entry points to alerts
Log on to the Simple Log Service console.
In the Log Application section, click the Business Analysis tab and then click Cost Manager.
Use one of the following methods to create an alert rule:
Method 1: Directly create an alert rule.
In the left-side navigation pane of the Cost Manager page, click Alerts to go to the Alert Center page. On the page that appears, click Create Alert.
Method 2: Save a query statement as an alert rule.
In the left-side navigation pane of the Cost Manager page, click Custom Analysis to go to the query and analysis page. On the page that appears, enter a query statement, set the query time range to yesterday, and then click Save As Alert.
Examples of alert rules for bills
You can set the query time range of a query statement to yesterday because bill data is synchronized on a T+1 basis. Bills of multiple cloud services are generated by day. Therefore, you must set the check frequency to a fixed interval of one day for an alert rule. The following section provides common examples of alert rules for fees and resource usage for reference. For more information, see Create an alert rule in Simple Log Service.
Create an alert rule for the total fee of the previous day
You can use the following query statement to create an alert rule for the total fee of the previous day. In the alert rule, set the Time Range parameter to Yesterday, set the Trigger Condition parameter to data matches the expression, and then enter the "cost" > Alert threshold
expression.
* | select
sum(PretaxAmount) as cost
FROM instance_bill
Create an alert rule for the total fee of a cloud service of the previous day
You can use the following query statement to create an alert rule for the total fee of a cloud service of the previous day. In the following code, set ProductCode to the code of the cloud service that you want to monitor. In the alert rule, set the Time Range parameter to Yesterday, set the Trigger Condition parameter to data matches the expression, and then enter the "cost" > Alert threshold
expression.
* | select
sum(PretaxAmount) as cost
FROM instance_bill
where
ProductCode = '${ProductCode}'
Create an alert rule for the total resource usage of a cloud service of the previous day
You can use the following query statement to create an alert rule for the total resource usage of a cloud service of the previous day. In the following code, set ProductCode to the code of the cloud service that you want to monitor and set BillingItem to a billable item that you want to monitor. In this example, BillingItem is set to Storage. In the alert rule, set the Time Range parameter to Yesterday, set the Trigger Condition parameter to data matches the expression, and then enter the "Usage" > Alert threshold
expression.
* | select
sum(Usage) as Usage
FROM instance_bill
where
ProductCode = 'sls'
and BillingItem like '%Storage%'
Create an alert rule for the resource usage of an instance for a cloud service of the previous day
You can use the following query statement to create an alert rule for the resource usage of an instance for a cloud service of the previous day. In the following code, set ProductCode to the code of the cloud service that you want to monitor, set BillingItem to a billable item that you want to monitor, and then set InstanceId to the resource of an instance for a cloud service that you want to monitor. In this example, BillingItem is set to Storage and InstanceId is set to a Simple Log Service project. In the alert rule, set the Time Range parameter to Yesterday, set the Trigger Condition parameter to data matches the expression, and then enter the "Usage" > Alert threshold
expression.
* | select
sum(Usage) as Usage
FROM instance_bill
where
ProductCode = 'sls'
and BillingItem like '%Storage%'
and InstanceId like '%project%'
Create an interval-valued comparison alert rule for fees
You can use the following query statement to create an interval-valued comparison alert rule for the fees of a cloud service. In the alert rule, set the Time Range parameter to Yesterday, set the Trigger Condition parameter to data matches the expression, and then enter the "Increased by" > Alert threshold
expression.
* |
SELECT
diff [1] AS "Fees of the previous day",
diff [2] AS "Fees of the 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
)
)