The built-in Java 8 runtime of Function Compute supports integration with Application Real-Time Monitoring Service (ARMS). Custom runtimes for Java 8, Java 11, and Java 17 also support the ARMS extension. This topic describes how to integrate the ARMS agent into a custom runtime function.
Before you start, make sure:
Your function memory is greater than 512 MB. ARMS consumes approximately 300 MB of memory.
ARMS is in the same region as your function. Cross-region monitoring is not supported.
Monitoring capabilities
After integrating ARMS, you can monitor your functions with the following capabilities:
| Capability | What you can do |
|---|---|
| Instance-level observability | View CPU, memory, and request metrics for each function instance |
| Tracing | Inspect call relationships between your function and upstream and downstream components such as databases and message queues |
| Java virtual machine (JVM) metrics | Track garbage collection (GC) counts, heap usage, and thread stack information |
| Code-level profiling | Identify slow methods and exceptions at the code level |
| Application security | Protect your application against unknown vulnerabilities using Runtime Application Self-Protection (RASP) technology |
For a full overview of ARMS, see What is ARMS?
Prerequisites
Before you begin, ensure that you have:
A function using a custom runtime (Java 8, Java 11, or Java 17). See Create a function
ARMS activated. See Activate and upgrade ARMS
Function memory set to greater than 512 MB
How it works
ARMS integrates into a custom runtime as an internal extension. The ARMS agent is delivered as a public layer. A bootstrap script injects the agent into your Java application at startup, and two environment variables pass the license key and enable the extension.
Connect a custom runtime to ARMS
Step 1: Add the ARMS agent layer
Function Compute provides public layers with ARMS agents for each supported Java version.
| Java version | Compatible runtime | Layer ARN |
|---|---|---|
| Java 11 / Java 8 | Custom runtimes | acs:fc:{region}:official:layers/ArmsAgent273x/versions/1 |
| Java 17 | Custom runtimes | acs:fc:{region}:official:layers/ArmsAgent273x_JDK17/versions/1 |
Replace {region} with your function's region ID (for example, cn-hangzhou).
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select the region where your function resides. On the Functions page, click the function you want to configure.
On the function details page, click the Configurations tab.
Click Modify next to Advanced Settings. In the Advanced Settings panel, expand Layers and click + Add Layer > Add Public Layer.
Select the layer that matches your Java version and click OK.
Step 2: Set environment variables
In the Advanced Settings panel, expand Environment Variables and set the following:
| Environment variable | Value | Description |
|---|---|---|
FC_EXTENSION_ARMS | true | Enables the ARMS extension |
FC_EXTENSIONS_ARMS_LICENSE_KEY | Your license key | Passes your ARMS license key to the agent. See Obtain a license key |
After a function invocation completes, the instance stays active for 10 seconds to let the ARMS agent finish reporting logs. Fees continue to accrue during this period at the same rate as during invocation. See Billing.
Step 3: Create a bootstrap script
Create a file named bootstrap in your function's code directory using WebIDE, then make it executable by running chmod +x bootstrap in the terminal.
The following script shows a complete example. All ARMS agent parameters are injected as JVM arguments when the environment variable FC_EXTENSIONS_ARMS_LICENSE_KEY is present.
#!/bin/bash
set -eo pipefail
# 1. Set the ARMS application name. Defaults to FC:{FunctionName}.
appName="FC:Custom_Java_Arms_Demo"
if [ -n "${FC_FUNCTION_NAME}" ]; then
appName="FC:${FC_FUNCTION_NAME}"
fi
echo "appName: ${appName}"
params=" "
# 2. Inject ARMS agent parameters if the license key is configured.
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` "
# Path to the ARMS agent JAR in the public layer
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
# 3. Start the application with the ARMS parameters.
echo "params: ${params}"
exec java $params \
-Dserver.port=9000 \
-jar /code/target/demo-0.0.1-SNAPSHOT.jarThe script passes three JVM arguments required by ARMS:
| Parameter | Description |
|---|---|
-javaagent | Path to the ARMS agent JAR. When using the public layer, this is always /opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar |
-Darms.licenseKey | Your ARMS license key, read from the FC_EXTENSIONS_ARMS_LICENSE_KEY environment variable |
-Darms.appName | The application name shown in the ARMS console. Defaults to FC:{FunctionName} |
Step 4: Deploy
Click Deploy in WebIDE to apply the code changes. After the function restarts, the ARMS agent starts collecting monitoring data.
Verify the integration
After deploying, invoke your function at least once, then verify the integration in the ARMS console:
Log on to the ARMS console.
In the left-side navigation pane, choose Application Monitoring > Applications.
Look for an application named
FC:{FunctionName}(for example,FC:my-java-function). If it appears in the list, the integration is successful.
For details on reading monitoring data, see Application overview.
Billing
Enabling the ARMS extension introduces two cost considerations:
ARMS charges: Fees apply for ARMS application monitoring. See Billing overview.
Post-invocation freeze: After each invocation completes, the instance remains active for 10 seconds while the ARMS agent reports logs. Function Compute charges apply during this period at the standard invocation rate.