All Products
Search
Document Center

Function Compute:Context and log format

Last Updated:May 07, 2025

In custom runtimes, the common request headers and log headers contain the context information and execution logs that can be used to customize your runtimes.

Common request headers in Function Compute

The following table describes the common request headers that a custom runtime may receive from Function Compute. If you want to access other Alibaba Cloud services, you may need to use the request headers that specify a temporary AccessKey pair. If you want to migrate existing applications to Function Compute, ignore the following information.

Note
  • Both event functions and HTTP functions contain common request headers.

  • Common request headers are automatically generated by Function Compute. They contain the basic information about a function such as relevant permissions.

Header

Description

x-fc-request-id

The request ID.

x-fc-access-key-id

The temporary AccessKey ID.

x-fc-access-key-secret

The temporary AccessKey secret.

x-fc-security-token

The temporary security token.

x-fc-function-handler

The handler of the function. If the runtime is a function, such as a function that runs in a custom runtime or a Custom Container runtime, this parameter is ignored and can be set to a random string.

x-fc-function-memory

The maximum memory that a function can use.

x-fc-region

The region where the function resides.

x-fc-account-id

The ID of the function owner.

x-fc-qualifier

The service version or alias that you specify when you invoke a function. For more information, see Use versions and aliases to implement canary release.

x-fc-version-id

The service version that you specify when you invoke a function.

x-fc-function-name

The name of the function.

x-fc-service-logproject

The Simple Log Service project that is configured for the service to which a function belongs.

x-fc-service-logstore

The Simple Log Service Logstore that is configured for the service to which a function belongs.

x-fc-control-path

The request type of a function.

For a custom runtime or a Custom Container runtime, this parameter indicates whether the function is invoked through an HTTP request or triggered by an event. Valid values:

  • /invoke: The request is used to invoke an event function.

  • /http-invoke: /http-invoke: The request is sent to invoke an HTTP function. Function Compute adds common headers to your request, which contains the information about the request path, request body, and request headers. Then Function Compute forwards the request to a custom runtime or a Custom Container runtime and forwards the returned response headers and body to the client.

  • /initialize: The request that is automatically initiated by Function Compute to call an Initializer hook the first time you create a runtime environment. Similar to a class constructor, an Initializer hook is invoked only once in the lifecycle of a container.

Important

For security reasons, x-fc-security-token is no longer supported in Custom Runtime (Debian11). If you still need temporary permission information, you can obtain the temporary permission information by using the ALIBABA_CLOUD_ACCESS_KEY_ID, ALIBABA_CLOUD_ACCESS_KEY_SECRET, and ALIBABA_CLOUD_SECURITY_TOKEN environment variables. For more information, see Configure environment variables.

Function log formats

We recommend that you enable the logging feature when you create a service in Function Compute. This way, all logs that are printed to stdout in a custom runtime are automatically collected in your specified project of Simple Log Service. For more information, see Configure the logging feature.

If Function Compute invokes a function in a runtime that is not a custom runtime or a Custom Container and the request header contains x-fc-log-type = "Tail", the response that contains the x-fc-log-result header is the log that the system generates when the system invokes the function. The maximum size of a log is 4 KB. You can view the log in the results of the function invocation in the Function Compute console.

Note

The API you can call to specify the log level varies based on the programming language. For more information, see Basics.

References

  • For more information about functions in custom runtimes, see Overview.

  • For more information about cold starts in a custom runtime and how to configure HTTP servers, see Principles.

  • For more information about how to invoke functions in a custom runtime, see Web functions.

  • For more information about how to implement lifecycle hooks for function instances in a custom runtime, see Lifecycle hooks for function instances.