Simple Log Service provides built-in alert rule templates for Scheduled SQL. Use these templates to monitor Scheduled SQL jobs and receive alert notifications through DingTalk or other channels.
Prerequisites
A Scheduled SQL job is created.
-
To import data from a Logstore to another Logstore, Create a Scheduled SQL task for Logstore-to-Logstore data import.
-
To import data from a Logstore to a Metricstore, Create a scheduled SQL job to import Logstore data to a Metricstore.
-
To import data between Metricstores, Import data between MetricStores using Scheduled SQL.
Step 1: Enable service logs for job operations
Log on to the Simple Log Service console.
-
In the Projects section, click the project that contains the Scheduled SQL job.
Select the project that contains the Scheduled SQL job.
-
In the upper-left corner of the page that appears, click the
icon. -
Open the service log configuration panel for job operational logs.
-
If you have not enabled detailed logs for the Project, on the Service Log tab, click Enable Detailed Logs.
-
If you have already enabled detailed logs for the Project, on the Service Log tab, click the
icon.
-
-
Configure the following parameters and click OK.
Parameter
Description
Job Operational Logs
Enabling the Job Operational Logs switch creates a Logstore named internal-diagnostic_log in the specified project. This Logstore stores operational and error logs for Scheduled SQL jobs, MaxCompute data shipping, and OSS data shipping. For more information, see Scheduled SQL job operational logs.
Log Storage Location
Select a project to store the operational logs. Valid values:
-
Automatic Creation (Recommended)
-
Current Project
-
Other projects in the same region as the current project
If a Scheduled SQL job fails, you can view the error logs in the internal-diagnostic_log Logstore of the specified project. The log topic is scheduled_sql_alert, stored in the __topic__ field.
-
Step 2: Configure an action policy
Log on to the Simple Log Service console.
-
Go to the Action Policy page.
-
In the Projects section, click a project.
-
In the left-side navigation pane, click Alerts.
-
Select .
-
-
Find the action policy named sls.app.scheduled_sql.builtin and click Modify.
To create a custom action policy, see Action policies.
-
In the Edit Action Policy panel, change the Request URL to the webhook URL of your DingTalk chatbot. Keep the default settings for other options.
To obtain the webhook URL of a DingTalk chatbot, see DingTalk-Custom. For other notification methods, see Notification channels.
-
Click Confirm.
Step 3: Create an alert rule
Simple Log Service provides the following built-in alert rule templates. Both templates use similar parameters. This example uses the ScheduledSQL Delay Monitor template.
-
ScheduledSQL Error Monitor: Scans data at 5-minute intervals. An alert is triggered when an error is detected in a Scheduled SQL job.
-
ScheduledSQL Delay Monitor: Scans data at 5-minute intervals. An alert is triggered when the latency of a Scheduled SQL job exceeds a threshold.
Log on to the Simple Log Service console.
-
In the Projects section, click the project that contains the internal-diagnostic_log Logstore.
Select the project that contains the internal-diagnostic_log Logstore.
-
In the left-side navigation pane, click Alerts.
-
On the Alert Rules tab, click the arrow icon next to Create Alert
. -
Click Create from Template.
-
In the Create from Template panel, click SLS Scheduled SQL.
-
Click ScheduledSQL Delay Monitor.
-
Configure the parameters of the alert rule.
-
To monitor a specific project or adjust the trigger threshold, configure parameters as described in Create an alert rule. Otherwise, keep the default settings.
-
If you created a new action policy in Step 2, you need to configure it in .
-
-
After the alert rule is created, it appears in the Alert Rules list with a status of Running.