Help Center/ FunctionGraph/ User Guide/ Viewing Metrics and Configuring Alarms/ Configuring and Viewing Function Invocation Logs
Updated on 2025-08-19 GMT+08:00

Configuring and Viewing Function Invocation Logs

FunctionGraph is interconnected with LTS, allowing you to view function logs without the need for any configurations.

On the FunctionGraph console, view function logs in the following ways:

  • Viewing logs on the execution result page

    After creating a function, test it and view test logs on the execution result page. For details, see Debugging Functions Online.

    The execution result page displays a maximum of 2 KB logs. To view more logs of the function, go to the Logs tab page.

  • Viewing logs on the Logs tab page

    On the function details page, choose Monitoring > Logs to query log information. For details, see Using LTS to Manage Function Logs.

Configuring Log Groups and Log Streams, and Viewing Function Logs

You can bind a log group and log stream to a function to store its invocation logs. By default, the logs are stored in the log stream automatically created for the function. For details, see Using LTS to Manage Function Logs.

Procedure

  1. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the name of the desired function.
  3. Choose Configuration > Log, and configure log collection according to Table 1.

    Table 1 Log configuration parameters

    Parameter

    Description

    Collect Logs

    Enabled by default in FunctionGraph V2. This feature is unavailable for FunctionGraph V1.

    Log Group

    Select a log group for the function. The default log group functiongraph.log.group.xxx cannot be selected. For details about how to create a log group, see Managing Log Groups.

    By default, the log group (starting with functiongraph) automatically generated by FunctionGraph is selected.

    Log Stream

    Select a log stream in the specified log group. For details about how to create a log group, see Managing Log Streams.

    By default, the log stream (starting with the function name) automatically generated for the function is selected.

  4. Click Save.

    You can change the log stream if needed.

  5. Click the Code tab and click Test to execute the function.
  6. After the function is executed, choose Monitoring > Logs to view the function logs.

    • As shown in Figure 1, logs of the function are generated in the specified log group and log stream.
    • If no custom log group and log stream are specified, the default log group (starting with functiongraph) and log stream are displayed.
      Figure 1 Viewing function logs
    • The following figure shows two successful requests. The request at the bottom took 13.100 ms, including the cold start time. The request at the top took only 1.671 ms, because no cold start was involved.
      Figure 2 Request

Log Tag

You can configure tags to report logs to LTS when a function is executed. You can filter function logs by tag.

  1. When creating a function, you can click Collect Logs in the Advanced Settings area to add log tags. If the function has been created, go to 2.
  2. On the function details page, choose Configuration > Logs, enable Collect Logs, and select a log group and log stream.
  3. Click Add, enter the tag key and value, and click Save. A maximum of 10 tags can be added.

    Table 2 Log tag description

    Parameter

    Description

    Tag key

    Cannot be left blank. The value can contain a maximum of 64 characters, including only digits, letters, underscores (_), and hyphens (-).

    Tag value

    Figure 3 Adding a log tag

  4. Click the Code tab, configure the test event, and click Test. Wait until the function execution is complete.
  5. Choose Monitoring > Logs. On the Request List page, view the function request records. (Log reporting may be delayed. Please wait for a few minutes.)
  6. Log in to the LTS console. In the navigation pane, choose Log Management. Set the filter criteria to search for the log group and stream. Click the log stream name to go to the details page.

    Figure 4 Searching for a log stream

  7. On the log stream details page, click Log Settings. On the Index Settings panel, click Add Field to add the log tag key added to the function. For details about how to set indexes, see Configuring Log Indexing. Click OK.
  8. Return to the log stream details page, enter the log tag key and value configured for the function in the search box to view the matched logs.

Using LTS to Manage Function Logs

You can enable LTS to better manage function logs. After you enable LTS, FunctionGraph automatically creates a log group starting with functiongraph. When you create a function, a log stream starting with the function name is generated.

You can also bind a log group and log stream to a function to store its invocation logs. For details, see Configuring Log Groups and Log Streams, and Viewing Function Logs.

Constraints:

  • By default, 20 log streams are created, which cannot be customized. On the Logs tab page of the function, press F12 to find out the log stream ID of the query API, and then locate the corresponding log stream ID in LTS.

  • Deleting a function log group by mistake on the LTS console will not be detected by FunctionGraph, and the historical log data can no longer be retrieved. To use a log group, modify the function description and save the changes. A new log group will be created.
  • Max. 10 MB logs can be retained for common instances during initialization. When this limit is reached, the latest logs replace the old ones.
  1. Enable LTS.

    On the Logs tab, click Enable. The Logs page is displayed. Click Collect Logs.

    Figure 5 Enabling logging

  2. Set filter criteria.

    • Request List: Filter requests by request ID, result (success or failure), duration, actual memory or cause (initialization failed, load failed, system error, timed out, out of memory, out of disk space, or code error).

      Before using query fields, configure them in LTS. For details, see Configuring Log Filtering Fields for a Function.

    • Request Log: Filter logs by keyword, request ID, or instance ID.
    Table 3 Invocation result

    Result

    Description

    Execution successful

    Log printed when a function is successfully executed.

    Execution failed

    Log printed when a function fails to be executed due to invocation timeout, memory or disk threshold exceeded, or code errors.

    To view the logs about invocation timeout, select Invocation timed out from the drop-down list. The methods for viewing the other three types of logs are the same.

    Table 4 Cause analysis

    Possible Cause

    Description

    Initialization failed

    Log printed when the function initialization fails.

    Load failed

    Log generated when the runtime fails to load your function file.

    System error

    Internal error.

    Invocation timed out

    Log printed when the function invocation period is longer than the preset limit.

    Memory threshold exceeded

    Log printed when the function memory size exceeds the preset limit.

    Disk threshold exceeded

    Log printed when the disk size exceeds the preset limit.

    Code error

    Log printed when a code error occurs.

    • You can view logs of the last hour, last day, last 3 days, or a custom time period.
    • To manage function logs, go to the LTS console.

  3. Use log analysis.

    On the Log Analysis tab page, you can configure log filtering fields for functions by referring to Configuring Log Filtering Fields for a Function. For details about how to analyze logs on LTS, see Searching and Analyzing Logs.

Configuring Log Filtering Fields for a Function

The log query function of FunctionGraph supports multiple filtering fields. First, perform the following steps:

  1. Return to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
  2. Click the name of a function.
  3. Click Monitoring. On the Logs tab page, click the Log Analysis tab to analyze logs using LTS on the FunctionGraph console.
  4. Click Log Settings on the right. On the Index Settings page, click Auto Configure. Wait until the backend automatically configures all fields.

    Figure 6 Log settings

  5. After the automatic configuration is complete, change the type of the memory and duration fields to float. Then check whether the errorType field exists, if it does not exist, manually add it, as shown in Figure 7.

    Figure 7 Configuring field information

  6. Click OK. Return to the Monitoring > Logs > Request List tab page of the function to use related fields to filter information.

Downloading Logs

Constraints:

  • A maximum of 5,000 logs can be downloaded at a time. When querying logs, select a proper time range to avoid log loss.
  • The timestamp of logs is in UTC.
  1. Choose Monitoring > Logs > Request Logs.
  2. Select a time range, and click Download Log.