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.
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:
|
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.
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.