Simple Log Service provides the dynamic recipient feature. This feature allows you to configure dynamic recipients for alert notifications by using webhooks.
Scenarios
You can create users or user groups in the Simple Log Service alerting system and specify them in an action policy to receive alert notifications. However, this method may not meet the needs of certain special scenarios, such as the following:
Connect to third-party user management systems: Some enterprises have self-managed user management systems. In such cases, the updates of user information in the user management systems cannot be synchronized to the alerting system of Simple Log Service in real time. The organization structure of an enterprise varies based on the users and user groups that are created in the enterprise. Therefore, the user and user group models provided by Simple Log Service are not applicable to all enterprises.
Send alert notifications to dynamic recipients: If your system has multiple services and alert notifications for each service need to be sent to different recipients, you must configure multiple action groups by using the dynamic distribution mechanism of action policies, which increases maintenance costs.
How it works
In the preceding scenarios, you can use the dynamic recipient feature to specify the recipients of alert notifications. If you use the dynamic recipient feature, you must specify a webhook URL. Before Simple Log Service sends an alert notification, Simple Log Service calls the webhook. Then, the webhook service returns information about the recipients of alert notification. This way, you do not need to maintain recipients in the alerting system of Simple Log Service.
Dynamic recipients
Static recipients
Configure dynamic recipients
When you create an action policy, set the Recipient Type parameter to Dynamic Recipient. Then, configure the other parameters. The following table describes the parameters. For more information, see Create an action policy. 
Parameter | Description |
Recipient Type | Select Dynamic Recipient. |
Recipient Callback URL | Enter the webhook URL. For more information, see Webhook specifications. The webhook URL has the following limits:
Important The webhook for dynamic recipients is called in the same manner as a webhook for alert notifications. If you want to configure access control for a webhook, configure an IP address whitelist or an HTTP request header. For more information, see How do I verify access permissions? |
Request Header | Enter the request header that must be added when Simple Log Service sends a request to the specified webhook URL. By default, the Content-Type: application/json request header is added. If you set the Content-Type parameter to a different value, the request header does not take effect. |
Webhook specifications
Request information
Request method: POST
Request header:
A custom request header.
Default request header: Content-Type: application/json.
Sample request:
The value of the alerts field is an array of alerts that are merged into a set. Up to 10 alerts can be included in an alert set. For more information, see Variables in alert templates (new version). After your webhook service receives the request, the webhook service determines recipients based on the request and returns information about the recipients to Simple Log Service.
{ "alerts": [ { "alert_id": "test-alert-1", // Alert unique identity "alert_instance_id": "jid-**********-a578-441e-8d25-42e92aef506c", // Instance ID "alert_name": "Test Alert 1", // Alert rule name "alert_time": 1646808904, // Current evaluation time "alert_type": "sls_alert", // Alert type "aliuid": "123****3424", // Alibaba Cloud account ID // Annotation information "annotations": { "desc": "Test alert triggered", // Description "title": "Test Title" // Annotation }, // Data that triggered the alert "fire_results": [ {"message": "error occurs"} ], "fire_results_count": 1, // Total number of data entries that triggered the alert "fire_time": 1646808904, // First trigger time // Tag information "labels": { "app": "nginx", // Application tag "env": "prod", // Environment tag "team": "sre" // Responsible team }, "next_eval_interval": 60, // Next evaluation interval (seconds) "project": "demo-alert", // Project to which the alert rule belongs "region": "cn-hangzhou", // Region ID "resolve_time": 0, // Alert recovery time (If the alert status is firing, the value is 0. If the alert status is resolved, the value is the specific recovery time.) "severity": 8, // Alert severity (10: critical; 8: high; 6: medium; 4: low; 2: report only) "status": "firing" // Alert status (firing: alert triggered; resolved: recovery notification) } ] }
Response information
Status code: 200
Response header: The Content-Type: application/json response header must be included.
Sample response:
{ "receivers": [{ "code": "86", "phone": "137****34", "email": "****@example.com" }] }Field
Type
Required
Description
code
string
No
If the response does not contain this field, Simple Log Service uses the default code 86.
phone
string
No
This field is valid only if you set the Notification Method parameter to SMS Message, Voice Call, DingTalk, or Enterprise WeChat. If you set the Notification Method parameter to Email, ignore this field.
email
string
No
This field is valid only if you set the Notification Method parameter to Email. If you set the Notification Method parameter to a different value, ignore this field.