Connecting SCF Logs to CLS

Last updated: 2020-12-31 14:14:55

    Overview

    When SCF is used for function computation, a large number of function execution logs will be generated. You can view and search for logs generated in the last 15 days in the SCF Console.
    If you need to store, deliver, or consume logs in a persistent manner and monitor and set alarms on log content, you can deliver logs to the Tencent Cloud Log Service (CLS) platform as shown below:

    Prerequisites

    Before using the SCF real-time log service, you need to activate CLS first.

    Directions

    Creating logset and log topic

    Log in to the CLS Console and create a logset and log topic. This document uses the creation of the SCF-test log set and log topic in Guangzhou as an example as shown below:

    Note:

    For the logset region, please select the region where the SCF service is located. Cross-region log push is not supported currently.

    Configuring CLS

    1. Log in to the SCF Console and select Function Service on the left sidebar.
    2. Select the SCF region and namespace at the top of the page and click the function name in the list for which to collect logs in real time.
    3. On the "Function configuration" page, click Edit in the top-right corner as shown below:
    4. In "Log Delivery", click "Enable" and select the logset and log topic already created for this function. This document uses SCF-test as an example as shown below:
    5. Click Save to connect to the CLS platform.

    Enabling index

    Note:

    Log retrieval depends on the index configuration of the log topic. Please enable the index as instructed below:

    1. Log in to the CLS Console and select Log Sets on the left sidebar.
    2. Click the ID of a created logset to enter the "Basic Info" page.
    3. Select Manage to the right of the log topic row to enter the "Basic Info" page of the log topic.
    4. On the "Basic Info" page of the log topic, click Index Configuration as shown below:
    5. Click Edit in the top-right corner, enable "Key-Value Index", and add "Field Name" and "Field Type" according to the following table.

      Note:

      For functions configured with CLS, to ensure the display effect of the logs in the SCF Console, please toggle on "Enable Statistics" for the field in the key-value index configuration as shown below:

      Field Name Field Type
      SCF_FunctionName text
      SCF_Namespace text
      SCF_StartTime long
      SCF_LogTime long
      SCF_RequestId text
      SCF_Duration long
      SCF_Alias text
      SCF_Qualifier text
      SCF_MemUsage double
      SCF_Level text
      SCF_Message text
      SCF_Type text
      SCF_StatusCode long

    For more information on other features such as real-time log search, delivery, and consumption, please see the CLS documentation. These features can be used in the CLS Console directly.

    Note:

    Before using the real-time search feature, please make sure that your SCF log service has been connected to the CLS platform and the index has been enabled for the log topic to be searched.

    1. Log in to the CLS Console and select Log Search on the left sidebar.
    2. On the "Search and Analysis" page, select the desired log topic and time and enter the search syntax in the input box. This document uses START as an example.
      The search syntax supports keyword search, fuzzy search, range search, and other search methods. For more information, please see Legacy CLS Search Syntax.
    3. Click Search and Analysis to view real-time log information.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help