All Products
Search
Document Center

Function Compute:Context and log format

Last Updated:Apr 01, 2026

When building a custom runtime, Function Compute passes context and execution metadata to your runtime through HTTP request headers. This page describes those headers and the log formats your runtime receives.

Request headers

Function Compute automatically generates a set of common request headers and sends them to your custom runtime on every invocation. Both event functions and HTTP functions receive these headers.

To call other Alibaba Cloud services from your function code, use the temporary credentials in the x-fc-access-key-id, x-fc-access-key-secret, and x-fc-security-token headers. If you are migrating an existing application to Function Compute, you can ignore most of these headers.
HeaderDescriptionExample
x-fc-request-idThe unique ID for this invocation.a9e64a3c-1234-5678-abcd-ef0123456789
x-fc-access-key-idThe temporary AccessKey ID. Function Compute calls AssumeRole to get this value after you configure a role for the function.STS.NaXxxx
x-fc-access-key-secretThe temporary AccessKey secret, obtained the same way as x-fc-access-key-id.7jXxxx
x-fc-security-tokenThe temporary security token, obtained the same way as x-fc-access-key-id.CAIS...
x-fc-function-handlerThe handler of the function. In a custom runtime or Custom Container runtime, this value is ignored — set it to any string.index.handler
x-fc-function-memoryThe maximum memory the function is allowed to use.512
x-fc-regionThe region where the function runs.cn-hangzhou
x-fc-account-idThe account ID of the function owner.123456789012
x-fc-qualifierThe service version or alias specified when invoking the function. For details, see Use versions and aliases to implement canary release.LATEST or myAlias
x-fc-version-idThe specific service version specified at invocation.1
x-fc-function-nameThe name of the function.my-function
x-fc-service-logprojectThe Simple Log Service (SLS) log project configured for the service the function belongs to.my-log-project
x-fc-service-logstoreThe Simple Log Service Logstore configured for the service the function belongs to.my-logstore
x-fc-control-pathThe request type. See the table below for valid values./invoke

x-fc-control-path values

ValueMeaning
/invokeAn event function invocation.
/http-invokeAn HTTP function invocation. Function Compute adds common headers containing the request path, body, and original headers, forwards the request to your runtime, then forwards the response headers and body back to the client.
/initializeThe Initializer hook call. Function Compute sends this request the first time it creates a runtime environment. Like a class constructor, the Initializer hook runs only once in the lifetime of a container.
Important

x-fc-security-token is not supported in Custom Runtime (Debian 11). To get temporary credentials in that environment, read the ALIBABA_CLOUD_ACCESS_KEY_ID, ALIBABA_CLOUD_ACCESS_KEY_SECRET, and ALIBABA_CLOUD_SECURITY_TOKEN environment variables instead. For details, see Configure environment variables.

Log formats

Application logs (stdout)

Enable the logging feature when creating a Function Compute service. All output written to stdout in your custom runtime is automatically collected in the Simple Log Service Logstore you configure. For setup instructions, see Configure the logging feature.

Execution logs (x-fc-log-result)

This log type applies to runtimes other than custom runtimes and Custom Container runtimes. If the invocation request includes the header x-fc-log-type: Tail, the response includes an x-fc-log-result header containing the function's execution logs. Each log entry is capped at 4 KB. View these logs in the function invocation results in the Function Compute console.

The API for specifying the log level varies by programming language. For language-specific details, see Basics.

What's next