Updated on 2023-10-27 GMT+08:00

Building a Program

Download fss_examples_logstore_warning.zip to create an alarm log extraction function from scratch.

Creating a Function

Create a function by uploading the sample code package to extract logs. Select the Python 2.7 runtime and the agency LtsOperation created in Creating an Agency. For details about how to create a function, see Creating an Event Function.

This function performs Base64 decoding on received log event data, extracts alarm logs containing keyword WRN, WARN, ERR, or ERROR, and then stores the extracted logs in the specified OBS bucket. Set log extraction conditions based on the content of your service logs.

Setting Environment Variables

On the Configuration tab page of the preceding function, set environment variables to pass the bucket address, bucket name, and object name, as shown in Table 1.

Table 1 Environment variables

Environment Variable

Description

obs_address

OBS endpoint. To obtain the OBS endpoint, see Regions and Endpoints.

obs_store_bucket

Name of the destination bucket for storing logs.

obs_store_objName

Name of the target file for storing logs.

SMN_Topic

SMN topic.

region

Name of your region. To obtain the region name, see Regions and Endpoints.

Set the environment variables by following the procedure in Environment Variables.