Building a Program
You can download and use the alarm log extracting program package provided in this example.
Creating a Function
Create a function by uploading the sample code package to extract logs, as shown in Figure 1. For details, see Creating a 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.
|
Environment Variable |
Description |
|---|---|
|
obs_address |
OBS endpoint. To obtain the OBS endpoint, see Regions and Endpoints. For example, the OBS endpoint in North China is obs.cn-north-1.myhuaweicloud.com. |
|
obs_store_bucket |
Name of the target bucket for storing logs. |
|
obs_store_objName |
Name of the target file for storing logs. |
|
SMN_Topic |
SMN topic. |
Set the environment variables by following the procedure in Environment Variables.
Last Article: Preparation
Next Article: Adding an Event Source

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.