All Products
Search
Document Center

CDN:Use Function Compute to deliver logs

Last Updated:Mar 07, 2024

You can use Function Compute to deliver logs. When Alibaba Cloud CDN generates new offline logs, Function Compute triggers a preset function to deliver the logs to Object Storage Service (OSS) in an automatic and serverless manner. This way, you can store and archive logs in a secure, efficient, and stable manner without manual intervention or additional O&M costs. You can focus on your business without worrying about the collection, storage, and management of logs. This improves overall operational efficiency and reduces O&M costs.

Prerequisites

Before you use Function Compute to deliver logs to OSS, make sure that the following requirements are met:

  • OSS is activated. To activate OSS, go to the OSS product page. Then, you can create an OSS bucket to store the logs.

  • Function Compute is activated. To activate Function Compute, log on to the Function Compute console.

    Note
    • You cannot deliver logs by using a Security Token Service (STS) role. We recommend that you deliver logs by using an Alibaba Cloud account or as a RAM user.

    • Log on to the Function Compute console and use an existing Function Compute service to deliver logs.

Background information

  • Alibaba Cloud CDN allows you to use Function Compute to deliver logs to OSS. When you enable this feature, the system creates the AliyunCDNEventNotificationRole service-linked role and assigns the role to Alibaba Cloud CDN. Then, Alibaba Cloud CDN assumes this role to access Function Compute and automate log delivery.

  • Alibaba Cloud CDN is integrated with Function Compute. This allows you to configure functions for common CDN events and filter events by parameter. For example, you can filter events by domain name to collect data from specific domain names. After Alibaba Cloud CDN receives events that meet the filter conditions, it automatically calls functions to process the events and deliver logs to OSS.

Scenarios

The log storage feature of Alibaba Cloud CDN retains log data for 30 days free of charge. To persist log data, you can deliver log data to OSS. This facilitates log storage and analytics.

Billing rules

You are not charged by Alibaba Cloud CDN when you use Function Compute to deliver logs. You are charged by OSS and Function Compute based on the following rules:

  • For more information about the pricing of OSS, visit the OSS pricing page.

  • Function Compute resources are consumed during the log delivery process. Function Compute provides a free quota each month. You are charged for Function Compute resources that exceed the free quota. For more information about Function Compute pricing, see Function Compute billing methods.

Enable Function Compute for log storage

  1. Log on to the Alibaba Cloud CDN console.

  2. In the left-side navigation pane, choose Logs > Offline Logs.

  3. Click the Function Compute for Log Storage tab.

  4. Click Activate Log Storage.

  5. Configure the Service Name and OSS Bucket parameters based on your business requirements, and click Next.

    To perform the next step, select I understand and agree that fees will be incurred by Function Compute after I activate Log Storage.

    选择触发器

  6. Click Authorize to the right of Service Authorization.

    On the Role Templates page, configure the Policy Name parameter. Then, click Confirm Authorization Policy to grant Function Compute the permissions to write data to OSS and execute functions.

  7. Click Authorize to the right of Trigger Role.

    On the Role Templates page, click Confirm Authorization Policy to grant Alibaba Cloud CDN the permissions to access Function Compute.

  8. In the Select Domains section, select one or more domain names that you want to associate with Function Compute and click Create.

    选择域名

  9. Click Done.

    完成

Disable Function Compute for log storage

To disable Function Compute for log storage, perform the following steps. After you disable Function Compute for log storage, you are no longer charged.

  1. In the Alibaba Cloud CDN console, disassociate the Function Compute service from all domain names.

    1. Log on to the Alibaba Cloud CDN console.

    2. In the left-side navigation pane, choose Logs > Offline Logs.

    3. Click the Function Compute for Log Storage tab.

    4. Click Bind Domains in the Actions column. In the dialog box that appears, select the domain names that you want to disassociate in the right-side list and click 按钮.

      取消

    5. Click OK.

  2. Optional. Delete the function and service in the Function Compute console.

    Note

    When you enable Function Compute for log storage, a function and a service are created or an existing function and an existing service are used. When you disable Function Compute for log storage, you can delete the function and the service to clear the settings.

  3. Delete log data from the OSS bucket in the OSS console.

    Note

    You are charged for the storage of log data in OSS buckets. We recommend that you delete the log data that you no longer require from OSS buckets.

    For information about how to delete log data from an OSS bucket, see Delete buckets.