> For the complete documentation index, see [llms.txt](https://docs.acecloud.ai/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acecloud.ai/knowledge-base/functions/how-to-monitor-functions-and-view-logs.md).

# How to Monitor Functions and View Logs?

AceCloud Functions provides **Insights** and **Logs** to help you monitor function activity, review execution details, and troubleshoot issues.

Use **Insights** to review function performance and activity and use **Logs** to investigate individual function executions and errors.

### **Before you begin**

Make sure that:

* You have created and deployed a function.
* The function has been invoked at least once if you want to review its execution activity.
* You have access to the project containing the function.

### **Open a Function**

1. Log in to the **AceCloud** portal.
2. Select the required **Project** and **Region**.
3. Go to **Functions > Overview**.
4. Select the function you want to monitor.

The function page provides access to the function's configuration, versions, **Insights**, and **Logs**.

## **View Function Insights**

Select the **Insights** tab to monitor the function's activity and performance.

Use Insights to understand how the function is performing after deployment and invocation.

Review the available metrics to identify:

* Function activity
* Request or invocation behavior
* Execution performance
* Errors or failed executions

Use these metrics to identify unusual behavior, such as increased execution time or a higher number of failed requests.

**Note:** The exact metrics displayed in Insights depend on the function activity and the monitoring information available for the function.

#### Using the Insights dashboard

Use the version dropdown to view All versions or select an individual version, such as draft or v1.

Choose a time range using the available presets (15m, 30m, 1h, 1d, or 7d), or select a custom date-and-time range. Use the refresh control to refresh the displayed data.

The dashboard displays these charts:

• Invocations — shows invocation activity over time (Calls/s).

• Active Instances — shows the number of active instances over time, with versions distinguished in the chart legend.

• Avg Duration (ms) — shows average execution duration in milliseconds. The chart may show “No metrics in this time range” when data is unavailable for the selected period.

• Errors & Status Codes — shows request rates grouped by 2xx, 4xx, and 5xx status-code classes.

**Example: Insights dashboard**

**Example: selecting a function version**

## **View Function Logs**

Select the **Logs** tab to view logs generated while the function executes.

Logs are useful when you need to:

Understand what happened during an invocation.

* Identify application errors.
* Troubleshoot unexpected responses.
* Trace a request through the function.
* Investigate failed executions.

The platform associates logs with the function invocation so that you can correlate a log entry with a specific request.

Use the controls at the top of the Logs tab to narrow the entries:

• Request ID — enter or paste a request ID to locate log entries for a specific invocation.

• Version — choose All versions or filter logs to a specific version.

• Show lines — select how many log lines to display; the example shows 100 lines.

• Time range — choose a preset (15m, 30m, 1h, 1d, or 3d) or set a custom date-and-time range, then use refresh to reload the results.

• Log table — review Time, Request ID, Version, Type, Level, and Message for each entry.

• Live tail — enable Live tail to follow new log entries as they arrive. While following live, the time-range controls are disabled.

**Example: Logs tab with filters and log entries**

**Example: Live tail enabled**

### **Use the Request ID to Trace an Invocation**

Each function invocation has a unique **request ID**.

The request ID is available in the x-acefaas-request-id response header. The same ID is available to the function through the runtime context and is attached to the logs generated for that invocation.

You can use the request ID to trace a request from the client response to the corresponding function logs.

For example, a Python function can access the request ID using:

context.request\_id

Node.js:

context.requestId

Go:

ctx.RequestID

If a request fails, first note its request ID and then use it to locate the corresponding log entries.

## **Add Logs to a Function**

You can add application logs to your function to record important events during execution.

Use the logging mechanism provided by the selected runtime.

#### **Python**

You can use:

print("Processing request")

or Python's logging functionality.

#### **Node.js**

You can use:

console.log("Processing request")

#### **Go**

Use the logger available through the function context.

The platform automatically associates function logs with the corresponding function invocation and request ID.

#### **Recommended logging**

Include useful information such as:

* Processing stages
* Important application events
* Validation failures
* External service failures
* Processing results
* Error details

Avoid logging passwords, access tokens, API keys, or other sensitive information.

## **Control Log Levels**

Ace Functions supports the following log levels:

* DEBUG
* INFO
* WARN
* ERROR

The default log level is INFO. DEBUG messages are not captured unless the function is configured to allow the DEBUG level.

Use DEBUG logging when you need additional information while troubleshooting a function.

For normal production operation, use an appropriate level so that logs remain useful without generating unnecessary output.

## **Troubleshoot Function Errors Using Logs**

If a function returns an unexpected response:

1. Note the **request ID** from the response.
2. Open the function in the AceCloud portal.
3. Select **Logs**.
4. Locate the logs associated with the request ID.
5. Review the log entries generated during the invocation.
6. Identify the error or processing step that caused the failure.
7. Update the function code or configuration as required.
8. Test the function again.

The request ID is particularly useful because the same ID is associated with the response and the captured log lines for that invocation.

## **Understand Common Invocation Errors**

Logs can help identify the cause of common invocation failures.

| **Status** | **Description**                                                      |
| ---------- | -------------------------------------------------------------------- |
| **400**    | The request body could not be read by the platform.                  |
| **413**    | The request body exceeds the platform's **10 MiB** limit.            |
| **500**    | The handler failed or returned a value that could not be serialized. |
| **504**    | The function exceeded its configured execution timeout.              |

These errors can be generated by the platform before the handler completes, so use the request ID to correlate the error with the available logs.

### **Troubleshoot a 400 Error**

A 400 response can occur when the platform cannot read the request body, such as when the client disconnects during an upload.

If the request never reaches the handler, there may be no application-level error to fix in the function code.

Check:

1. The request body.
2. The request content type.
3. Whether the client completed the upload.
4. The request ID and corresponding logs.

### **Troubleshoot a 413 Error**

A 413 response indicates that the request body exceeds the platform's **10 MiB** limit.

This limit is enforced before the request reaches the function handler and cannot be increased for an individual function.

For larger payloads, consider splitting the request or using a different approach for transferring the data.

### **Troubleshoot a 500 Error**

A 500 response can occur when:

* The Python or Node.js handler throws an exception.
* The Go handler returns a non-nil error.
* The function returns a value that cannot be serialized as JSON.

Use the request ID to locate the corresponding logs and identify the error.

For additional debugging information, you can enable:

ACEFAAS\_DEBUG=true

This adds stack-trace and error details to 500 responses.

**Warning:** Use detailed debugging carefully, particularly in production environments, because error details can expose implementation information.

### **Troubleshoot a 504 Error**

A 504 response indicates that the function exceeded its configured timeout.

Check the function's **Timeout** configuration and the execution logs to determine where the function is spending its time.

If the function genuinely requires more time, increase the configured timeout within the platform's supported limit. Otherwise, optimize the function so that it completes within the configured execution time.

## **Use Logs for Application Debugging**

For more effective troubleshooting, add logs around important processing steps.

For example:

Request received\
↓\
Request validated\
↓\
Data processed\
↓\
External service called\
↓\
Response generated

If an invocation fails after External service called, you can focus your investigation on that part of the function.

Avoid writing sensitive information to logs. Use identifiers, status values, or other non-sensitive information when you need to trace an operation.

## **Configure Log Retention**

You can control how long function logs are retained through the function's **Log retention** setting.

To update the setting:

1. Open the function.
2. Click **Actions > Edit**.
3. Open **Advanced Settings**.
4. Update **Log retention**.
5. Save the changes.

Choose a retention period that provides enough history for troubleshooting and operational monitoring.
