When you run Java functions on Function Compute, you need visibility into application performance, distributed traces, and JVM health. Application Real-Time Monitoring Service (ARMS) integrates with Function Compute as an internal extension, giving you:
Instance-level observability
Distributed tracing
Java Virtual Machine (JVM) metrics
Code-level profiling
Application security insights
The following steps show how to add the ARMS agent to a custom runtime function.
The ARMS agent consumes approximately 300 MB of memory at runtime. Make sure your function has at least 512 MB of memory allocated. The 10-second post-invocation freeze window required for data reporting is billed at the standard invocation rate. For details, see Function Compute billing.
Supported runtimes and requirements
| Requirement | Details |
|---|---|
| Runtime | Custom runtime with Java 8, Java 11, or Java 17. The built-in Java 8 runtime is also supported. |
| JDK version | Must be supported by ARMS Application Monitoring. See Java components and frameworks supported by ARMS. |
| Heap memory | Greater than 256 MB |
| Function memory | At least 512 MB (ARMS consumes ~300 MB) |
| Region | ARMS and Function Compute must be in the same region. Cross-region monitoring is not supported. |
To create a function with a custom runtime, see Create a function.
Step 1: Get a license key
Call the DescribeTraceLicenseKey API operation in OpenAPI Explorer to retrieve your ARMS license key. Save this key for use in Step 3.
Step 2: Add the ARMS agent layer
Function Compute provides official common layers that bundle the ARMS agent for each supported Java version.
| Java version | Compatible runtime | Common layer ARN |
|---|---|---|
| Java 8 / Java 11 | Custom runtimes | acs:fc:{region}:official:layers/ArmsAgent273x/versions/2 |
| Java 17 | Custom runtimes | acs:fc:{region}:official:layers/ArmsAgent273x_JDK17/versions/1 |
Replace {region} with the region ID of your function, such as cn-hangzhou.
To add the layer in the Function Compute console:
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click the target function.
On the function details page, click the Configurations tab.
In the left-side navigation pane, click Layers, then click Modify.
In the Layers panel, choose + Add Layer > Add Official Common Layer, and select the ARMS agent layer that matches your Java version.
Step 3: Configure environment variables
Set the following environment variables for your function:
| Variable | Value | Description |
|---|---|---|
FC_EXTENSION_ARMS | true | Enables the ARMS extension in Function Compute. |
FC_EXTENSIONS_ARMS_LICENSE_KEY | Your ARMS license key | Authenticates the ARMS agent. Get this key from Step 1. |
Setting FC_EXTENSION_ARMS=true causes the function instance to freeze 10 seconds after each invocation completes. This gives the ARMS agent time to report collected data. Billing continues at the standard rate during this 10-second window. For details, see Function Compute billing.
To set these variables in the Function Compute console:
On the function details page, click the Configurations tab.
In the left-side navigation pane, click Environment Variables, then click Modify.
Add
FC_EXTENSION_ARMS=trueandFC_EXTENSIONS_ARMS_LICENSE_KEY=<your-license-key>.
For more details, see Configure environment variables.
Step 4: Create a bootstrap script
The ARMS agent attaches to your Java process through JVM startup parameters. Create a bootstrap file to pass these parameters when the function starts.
The following table describes the required JVM parameters:
| Parameter | Description |
|---|---|
-javaagent:/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar | Path to the ARMS agent JAR provided by the common layer. |
-Darms.licenseKey=${FC_EXTENSIONS_ARMS_LICENSE_KEY} | ARMS license key, read from the environment variable set in Step 3. |
-Darms.appName=${appName} | Application name as it appears in the ARMS console. Defaults to FC:{FunctionName}. |
-Dfc.instanceId=$HOSTNAME@`hostname -i` | Unique identifier for the function instance. |
Example bootstrap script:
#!/bin/bash
set -eo pipefail
# Set the ARMS application name.
# Defaults to FC:{FunctionName} if the FC_FUNCTION_NAME variable exists.
appName="FC:Custom_Java_Arms_Demo"
if [ -n "${FC_FUNCTION_NAME}" ]; then
appName="FC:${FC_FUNCTION_NAME}"
fi
echo "appName: ${appName}"
params=" "
# Build the ARMS JVM parameters.
if [[ -n "${FC_EXTENSIONS_ARMS_LICENSE_KEY}" ]]; then
echo "FC_EXTENSIONS_ARMS_LICENSE_KEY: ${FC_EXTENSIONS_ARMS_LICENSE_KEY}"
params+="-Dfc.instanceId=$HOSTNAME@`hostname -i` "
params+="-javaagent:/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar "
params+="-Darms.licenseKey=${FC_EXTENSIONS_ARMS_LICENSE_KEY} "
params+="-Darms.appName=${appName} "
else
echo "The environment FC_EXTENSIONS_ARMS_LICENSE_KEY does not exist, please set the FC_EXTENSIONS_ARMS_LICENSE_KEY environment!"
exit 1
fi
# Launch the application. Replace the JAR path with your own.
echo "params: ${params}"
exec java $params \
-Dserver.port=9000 \
-jar /code/target/demo-0.0.1-SNAPSHOT.jarReplace /code/target/demo-0.0.1-SNAPSHOT.jar with the path to your application JAR file.
Deploy the bootstrap file
In the WebIDE on the function code page, create a file named
bootstrapwith the content above.Open the terminal in WebIDE and run
chmod +x bootstrapto make the file executable.Click Deploy.
For more details, see Use a bootstrap script as startup commands.
Step 5: Verify the integration
After deployment, invoke the function at least once to trigger data collection, then confirm that ARMS is receiving data:
Log on to the ARMS console.
In the left-side navigation pane, choose Application Monitoring > Applications.
Find the application whose name matches the
appNamevalue from your bootstrap script. The default isFC:{FunctionName}.Click the application name to view traces, JVM metrics, and other monitoring data.
For details on the monitoring dashboard, see Application overview.
Billing
ARMS integration with Function Compute incurs charges from two services:
| Service | Charge | Details |
|---|---|---|
| ARMS | Application monitoring fees | ARMS billing overview |
| Function Compute | 10-second post-invocation freeze window, billed at the standard invocation rate | Function Compute billing |