You can create a Log Service (SLS) trigger to integrate SLS and Function Compute so that the generation of a log can trigger a function to process the log. This topic describes how to create an SLS trigger in the Function Compute console.

Prerequisites

Create a trigger

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Service/Function.
  4. Find the target function in the target service and click the name of the function.
  5. Click the Triggers tab. On the tab, click Create Trigger.
    create_trigger
  6. In the Create Trigger dialog box, enter the related information and click OK.
    Parameter Description
    Trigger Type Select Log Service (Log).
    Trigger Name Enter the name of a custom trigger.
    Version/Alias Enter the version of the trigger. Default value: LATEST. For more information, see Introduction.
    Log Project Name Select an existing SLS project.
    Logstore Name Select an existing Logstore. The current trigger regularly subscribes to data in the Logstore and sends the data to Function Compute for custom processing.
    Trigger Log Select an existing Logstore to store the logs that are generated when the SLS trigger triggers the function.
    Invocation Interval Enter the time interval at which the SLS trigger triggers the function.

    Valid values: 3 to 600. Unit: seconds.

    Retry Count Enter the maximum number of retries allowed for a single trigger operation.

    Valid values: 0 to 100.

    Function Configuration If you want to pass in a custom parameter, configure the custom parameter in this field. This parameter will be passed in to the function as the Parameter field of event of the function.

    The default value is empty ({}).

    Role Operation
    1. Select Quick Authorize from the drop-down list.
    2. Click Authorize.
    3. On the page that appears, click Confirm Authorization Policy.

    The trigger role is AliyunLogETLRole.

    You can view the created trigger in the trigger list.create_trigger_result

What to do next

  1. Write a function
  2. Debug a function