All Products
Search
Document Center

Container Registry:Create an event notification rule

Last Updated:Nov 13, 2024

Container Registry works with EventBridge to provide the event notification feature. If you want to receive notifications about status changes that occur during image replication, image building, image scans, delivery chain execution, or image signing, you can use the DingTalk, an HTTP gateway, or an HTTPS gateway.

Prerequisites

Precautions

  • The event notification feature is not available in the China East 1 Finance, China East 2 Finance, China South 1 Finance, China North 2 Ali Gov 1 and UK (London) regions of Container Registry.

  • The maximum number of event rules allowed for a region is 10. You can create up to 10 event rules in EventBridge and Container Registry separately. If the maximum number is reached, you can remove event rules that are no longer needed.

  • Only events within three days can be queried by event ID in EventBridge.

  • When you use DingTalk to send event notifications, each DingTalk chatbot can send a maximum of 20 messages to the group per minute due to the limits of DingTalk chatbots. If the number of event notifications exceeds 20, the DingTalk chatbot is throttled for 10 minutes.

  • After you create an event rule in Container Registry, you can modify the information of the event rule such as the notification type in EventBridge. For more information, see Modify event targets.

    Important

    If you modify an event rule in EventBridge, and then modify the event rule in Container Registry, the default event rule in Container Registry overwrites the event rule in EventBridge. For example, if you modify the event notification template in EventBridge, and then modify the effective scope of the event rule in Container Registry, the default event notification template in Container Registry overwrites the event notification template in EventBridge. The modification of the event notification template in EventBridge is not synchronized to Container Registry and does not take effect.

Step 1: Create a DingTalk chatbot

You need to perform this step only if you use DingTalk to send notifications.

  1. Open the DingTalk group chat to which you want to add a chatbot and click the 设置 icon in the upper-right corner.

  2. In the Group Settings panel, click Group Assistant.

  3. In the Group Assistant dialog box, click Add robot, and then click the 添加 icon next to Add robot.

  4. In the ChatBot dialog box, click Custom.

  5. In the Robot details dialog box, click Add.

  6. In the Add robot panel, specify the chatbot name, select Sign and Read and agree to "DingTalk Custom Robot Service Terms of Service", and then click Complete. Click Complete again.

  7. In the ChatBot dialog box, click the 设置 icon next to the created chatbot.

    In the Settings dialog box, copy the webhook address and signing key, and then click Complete.

Step 2: Create an event rule

  1. Log on to the Container Registry console.

  2. In the top navigation bar, select a region.

  3. In the left-side navigation pane, click Instances.

  4. On the Instances page, click the Enterprise Edition instance that you want to manage.

  5. In the left-side navigation pane of the instance details page, choose Instances > Event Notification.

  6. On the Event Rules tab, click Create Rule.

  7. In the Event Scope step, configure parameters and then click Next. The following table describes the parameters.

    Parameter

    Description

    Rule Name

    Specify the name of the event rule.

    Event Type

    Specify the type of the event that triggers event notifications. The following event types are supported:

    • cr:Artifact:SynchronizationCompleted: An image synchronization succeeds, fails, or is canceled.

    • cr:Artifact:BuildCompleted: An image build succeeds, fails, or is canceled.

    • cr:Artifact:ScanCompleted: An image scan succeeds or fails.

    • cr:Artifact:DeliveryChainCompleted: The processing of a delivery chain succeeds, fails, is canceled, or is denied.

    • cr:Artifact:SigningCompleted:: Image tagging succeeds or fails.

    In this example, the event type of image scan is used. Select "cr:Artifact:ScanCompleted The image is scanned" and then select Scanned.

    Effective scope

    Specify the effective scope of the event:

    • Instance: Set the regular expression for image tags. An event notification is triggered when an image tag in the Enterprise Edition instance meets the regular expression.

    • Namespace: Select a namespace and set the regular expression for image tags. An event notification is triggered when an image tag in the namespace meets the regular expression.

    • Repository: Select a namespace and a repository, and then set the regular expression for image tags. An event notification is triggered when an image tag in the image repository meets the regular expression.

  8. In the Event Notification step, configure the notification method and then click Save.

    You can select DingTalk, HTTP, or HTTPS as a notification method.

    • DingTalk: Set Notification Method to DingTalk, and then enter the webhook address and tagging key. In this example, the DingTalk notification method is used.

    • HTTP: Set Notification Method to HTTP and then enter the HTTP address.

    • HTTPS: Set Notification Method to HTTPS and then enter the HTTPS address.

    After an event rule is created in Container Registry, an event rule of the same name is automatically created in the default event bus of EventBridge. The event rule in EventBridge uses the default DingTalk notification template.

    After an image scan succeeds, the DingTalk group receives the following notification.

    钉钉

Related operations

This section describes how to view event traces.

  1. Log on to the Container Registry console.

  2. In the top navigation bar, select a region.

  3. In the left-side navigation pane, click Instances.

  4. On the Instances page, click the Enterprise Edition instance that you want to manage.

  5. In the left-side navigation pane of the instance details page, choose Instances > Event Notification.

  6. On the Event Notification page, click the Event History tab, and then click View Details in the Actions column that corresponds to the event ID.

  7. On the Query by Event ID tab of the EventBridge console, click Event Trace in the Actions column that corresponds to the event ID.

    In the Event Trace dialog box, view the information about receiving and delivering events.