Built-in Java runtimes support ARMS extension
Connect built-in Java runtimes in Function Compute to Application Real-Time Monitoring Service (ARMS) for application-level monitoring, tracing, and profiling.
Currently, only the Java 8 and Java 11 runtimes are supported. If you use a custom runtime, see Custom runtime supports ARMS application monitoring extension.
How it works
ARMS application monitoring is an internal extension for Function Compute. To enable it, add a public layer that contains the ARMS agent and configure two environment variables: one to attach the agent to the Java Virtual Machine (JVM) and one to authenticate with your ARMS License Key. Once deployed, the ARMS agent collects monitoring data from your function instances and sends it to the ARMS backend in the same region.
After the integration is complete, you can monitor and trace your functions in ARMS. The following table describes the available capabilities.
| Feature | Description |
|---|---|
| Instance-level observability | View instance-level metrics such as CPU, memory, and request counts. |
| Tracing | Automatically discover topological relationships between functions and upstream or downstream components. View details for databases, message queues, and other dependencies in the ARMS console. |
| JVM metrics | Automatically collect JVM metrics such as garbage collection (GC) counts, heap usage, and thread stack details. |
| Code-level profiling information | View code-level profiling details such as method execution time and exceptions. |
| Application security | Uses Runtime Application Self-Protection (RASP) technology to defend applications against attacks that exploit most unknown vulnerabilities. |
For more information, see What is Application Real-Time Monitoring Service?.
Prerequisites
-
You have created an event function with a built-in runtime, and the runtime environment is Java 8 or Java 11. For more information, see Create an event function.
-
You have activated ARMS. For more information, see Activate ARMS.
-
The memory size of your function is greater than 512 MB. The ARMS agent consumes approximately 300 MB of memory at runtime.
-
ARMS must reside in the same region as your function. Otherwise, you cannot view monitoring information.
Procedure
Step 1: Add the ARMS agent layer
Function Compute provides ARMS agents that support the Java 8 and Java 11 runtimes. Both runtimes use the same public layer ARN.
| Runtime | Public layer ARN |
|---|---|
| java8 | acs:fc:{region}:official:layers/ArmsAgent4x/versions/1 |
| java11 | acs:fc:{region}:official:layers/ArmsAgent4x/versions/1 |
Replace {region} with the region where your function is deployed.
To add the layer:
-
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 configuration page, click the Configurations tab.
-
Click the Layers tab on the left side, and click Edit. In the Edit Function Layer panel, select +Add Layer > Add Layer By ARN, and add the ArmsAgent layer that is compatible with the selected Java language. Replace the value of
{region}in the ARN with your region, and click Deploy.
Step 2: Set environment variables
Set the following two environment variables for your function:
-
JAVA_TOOL_OPTIONS: Set to-javaagent:/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jarto attach the ARMS agent to the JVM at startup. This JAR file is provided by the public layer. -
FC_EXTENSIONS_ARMS_LICENSE_KEY: Set to your ARMS License Key. To obtain the License Key, see Obtain License Key information.
{
"FC_EXTENSIONS_ARMS_LICENSE_KEY": "xxx",
"JAVA_TOOL_OPTIONS": "-javaagent:/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar"
}
To set the environment variables:
-
In the left-side navigation pane, click the Environment Variables tab, and click Edit. Add the following environment variables, then deploy your changes: For more information, see Set environment variables.
-
JAVA_TOOL_OPTIONS=-javaagent:/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar -
FC_EXTENSIONS_ARMS_LICENSE_KEY=yourLicenseKey
-
-
After you update the configurations and deploy the code, the function is added to ARMS for monitoring. You are charged for using ARMS. For more information, see Billing overview.
-
Make sure that the memory size of your function is greater than 512 MB because the ARMS agent consumes approximately 300 MB of memory. For details, see Prerequisites.
-
Between the completion of an invocation and the freezing of the instance, fees continue to accrue based on the same billing rules as during the invocation. For more information, see Product Billing.
Verification
After you connect a function to ARMS, verify that monitoring data appears in the ARMS console:
-
Log on to the ARMS console.
-
In the left-side navigation pane, choose Application Monitoring > Applications.
-
Click the name of the target application to view detailed monitoring information.
If your function appears in the application list and displays metrics such as request counts and response times, the ARMS integration is working correctly.
For more information about the monitoring data available, see Application overview.
Troubleshooting
If monitoring data does not appear in the ARMS console after you connect your function, check the following:
| Issue | Solution |
|---|---|
| Function and ARMS are in different regions | ARMS must be in the same region as your function. Verify the region in both the Function Compute and ARMS consoles. |
| Incorrect License Key | Verify that the value of FC_EXTENSIONS_ARMS_LICENSE_KEY matches the License Key shown in the ARMS console. See Obtain License Key information. |
| Incorrect JAVA_TOOL_OPTIONS value | Verify that the path in JAVA_TOOL_OPTIONS exactly matches -javaagent:/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar. |
| Insufficient memory | Increase the function memory to greater than 512 MB. The ARMS agent requires approximately 300 MB. |
| Layer not added or wrong ARN | Verify that the ArmsAgent layer is listed in your function's layer configuration and that the {region} placeholder is replaced with your actual region. |
| Data display delay | After the first invocation, monitoring data may take a few minutes to appear in the ARMS console. Invoke the function and wait before checking. |