You can use Function Compute to deliver logs to Object Storage Service (OSS) where the logs can be persisted. You can view and analyze persisted logs based on business requirements. This topic describes how to use Function Compute to deliver logs to OSS.

Prerequisites

Make sure that the following prerequisites are met before you can use Function Compute to deliver logs:

  • OSS is activated. You can activate OSS on the OSS product page and create an OSS bucket where logs can be stored.
  • Function Compute is activated. You can activate Function Compute in the Function Compute console.
    Note Log on to the Function Compute console and use an existing Function Compute service to deliver log data.

Background information

  • Alibaba Cloud CDN allows you to use Function Compute to deliver logs to OSS. When you enable this feature, the service-linked role AliyunCDNEventNotificationRole is automatically created and assigned to Alibaba Cloud CDN. Alibaba Cloud CDN can assume 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 events and filter events by parameter such as domain name. This way, data can be collected from specific domain names. After Alibaba Cloud CDN receives events that meet the filter conditions, it automatically calls functions to process the events and delivers the log entries 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

The log storage feature is free of charge. OSS and Function Compute are billed based on the following rules:

  • For more information about the billing rules of OSS, see OSS pricing.
  • Function Compute resources are consumed during the log delivery process. Function Compute provides a free quota each month. You are charged for the Function Compute resources that exceed the free quota. For more information, 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. Set Service Name and OSS Bucket based on your business requirements, and click Next.

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

    Set the parameters in the Select Trigger step
  6. Click Authorize next to Service Authentication.
    On the Resource Access Management page, set Policy Name and click Confirm Authorization Policy. This grants Function Compute permissions to write data to OSS and execute functions.
  7. Click Authorize next to Trigger Role.
    On the Resource Access Management page, click Confirm Authorization Policy. This grants Alibaba Cloud CDN permissions to access Function Compute.
  8. In the Select Domains section, select one or more domain names to be associated with the Function Compute service and click Create.
    Select a domain name
  9. Click OK.
    Click OK

Disable Function Compute for log storage

To disable Function Compute for log storage, perform the following steps. Function Compute for log storage is no longer billed after it is disabled.

  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. On the Offline Logs page, 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 Button.
    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 exiting service are used. When you disable Function Compute for log storage, you can delete the function and service to clear the settings.
  3. Delete log data from the OSS bucket in the OSS console.
    Note You are charged for log data that is stored in OSS buckets. We recommend that you delete log data that is no longer needed.

    For more information about how to delete an OSS bucket, see Delete buckets.