You can use Function Compute to deliver logs that you want to persist to Object Storage Service (OSS). You can view and analyze persisted logs based on your business requirements. This topic describes how to use Function Compute to deliver logs to OSS.

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. An OSS bucket in which logs can be persisted is created.
  • Function Compute is activated. To activate Function Compute, go to the Function Compute console.
    Note
    • You cannot deliver logs as a Security Token Service (STS) role. We recommend that you deliver logs with 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 log data.

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. 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. 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 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 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. Configure the Service Name and OSS Bucket parameters based on your business requirements, and click Next.

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

    Configure the parameters in the Select Trigger step
  6. Click Authorize to the right of Service Authentication.
    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 step, select one or more domain names that you want to associate with the Function Compute service and click Create.
    Select a domain name
  9. Click Done.
    Click Done

Disable Function Compute for log storage

To disable Function Compute for log storage, perform the following steps. You are no longer charged after Function Compute for log storage 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. 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.
      Disassociate domain names
    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 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 need from OSS buckets.

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