Last updated: 2020-07-17 14:49:11

    Overview

    When Serverless Cloud Function (SCF) is used for function computing, a high number of function execution logs are generated. As connected to Tencent Cloud CLS, SCF can collect function execution logs and push them to CLS in real time. CLS supports multiple log operations, such as search, shipping, and consumption.

    Directions

    1. Log in to the CLS Console, and create a logset and a log topic. Set the region of the logset to the same as that of the SCF. Currently, cross-region log pushing is not supported. For more information, see Creating a logset and a log topic.

    2. To search for logs, you need to enable index manually. If you have done so, skip Steps 2-5.
      Log in to the CLS Console, and click Logset. Select the logset you want, and click Manage* under the Operation column to enter the logset details page.

    3. Select the Index Configuration tab.

    4. Click Edit, toggle on Index Status, Full-Text Index and Key-Value Index, and then add key-value indexes.

    5. Once completed, click Save.

      For more operations, such as real-time log search, log shipping and consumption, log in to the CLS Console. For more features, see CLS Overview.

      SCF log fields

      Field Meaning Type
      SCF_RequestId Request ID text
      SCF_Namespace Namespace text
      SCF_FunctionName Function name text
      SCF_Qualifier Version text
      SCF_StartTime Start time long
      SCF_Message Log content text
      SCF_Level Log level text
      SCF_Index Log line No. long
      SCF_Alias Function alias text
    6. Log in to the SCF Console. Click Function Service in the left sidebar to enter the functions list page.

    7. Click the name of the function for real-time log collection, after which the Function Configuration page is displayed. In the upper-right corner, click Edit to edit the function information.

    8. Configure the logset and log topic created in Step 1 for the function service, then click Save.

    Log Search Examples

    Before using the real-time search feature, make sure that your SCF logs are connected to CLS and that index is enabled for the log topic to be searched. If index is not enabled, see Enabling Index.

    1. Log in to the CLS Console, and click Log Search in the left sidebar to enter the log search page.
    2. Select the time range and log topic before using the search box. The search syntax supports searching by keyword, fuzzy match, and scope. For more information, see Syntax and Rules.
    3. Now, click Search Analysis to begin searching for logs.
      Example 1: SCF_StartTime:1583233118007 searches for logs with a timestamp 1583233118007.

      Example 2: SCF_Index:2 searches for logs matching an index of 2.

    Was this page helpful?

    Was this page helpful?

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