Updated on 2024-06-12 GMT+08:00

Preparation

Download lts_cleanse.zip (including code file write_log.py of function A, code file lts_cleanse.py of function B, and dependency huaweicloudsdklts) and lts_cleanse.zip.sha256 to filter logs in real time.

Collecting and Storing Logs

  • Create two log groups, for example, test1206 and test-1121, on the LTS console. For details, see Creating a Log Group.
  • Create two log streams, for example, test-206 and test-1121, on the LTS console. For details, see Creating a Log Stream.
  • Create function A to write logs to test-206. For the sample code of this function, see the write_log.py file.
  • Create function B with an LTS trigger to receive logs from test-206, process the logs, and write the result to test-1121. For the sample code of this function, see the lts_cleanse.py file.
  • Configure an agent to collect logs from servers, such as ECSs, to a specified log group. For details, see Installing the ICAgent.
    Figure 1 Flowchart

Creating an Agency

  1. Log in to the IAM console.
  2. Choose Agencies from the navigation pane, and click Create Agency in the upper right corner, as shown in Figure 2.

    Figure 2 Creating an agency

  3. Configure the agency.

    • Agency Name: Enter LtsOperation.
    • Agency Type: Select Cloud service.
    • Cloud Service: Select FunctionGraph.
    • Validity Period: Select Unlimited.
    • Description: Describe the agency.

  4. Click Next. On the displayed page, search for LTS Administrator and Tenant Administrator in the search box on the right and select them, as shown in Figure 3.

    Figure 3 Selecting a permission

    LTS Administrator depends on Tenant Guest. When you select the former, the latter will also be selected.

  5. Click Next and select the application scope of the permission based on service requirements.