The built-in Java 8 runtime of Function Compute supports integration with Application Real-Time Monitoring Service (ARMS). Custom runtimes of Java 8, Java 11, and Java 17 also support the ARMS extension. This topic describes how to connect a custom runtime to ARMS.
Background
Function Compute can be seamlessly integrated with ARMS. You can use ARMS to monitor and track functions and obtain relevant features and information, such as instance-level observability, tracing information, Java virtual machine (JVM) metrics, code-level profiling information, and application security information. For more information, see What is ARMS?
Feature | Description |
Instance-level observability | You can view various metrics for instances, such as metrics that are related to CPU, memory, and requests. |
Tracing | The ARMS agent automatically obtains topological relationships between functions and upstream and downstream components and related metrics. You can view the information about the components such as databases and message queues in the ARMS console. |
JVM metrics | The ARMS agent automatically obtains JVM applications. You can view the monitoring information of the JVM applications in the ARMS console, such as the number of garbage collections (GCs), heap information, and thread stack information. |
Code-level profiling information | You can view code-level profiling information of function execution, such as the amount of time consumed by each method and exceptions. |
Based on Runtime Application Self-Protection (RASP) technology, the application security feature can provide powerful security protection for applications, and resist attacks on most unknown vulnerabilities. |
Connect a custom runtime to ARMS
You can integrate ARMS into a custom runtime as an internal extension. The following section describes how to connect a custom runtime to ARMS.
Use a public layer to obtain ARMS agents
Function Compute uses common layers to provide ARMS agents that support Java 8, Java 11, and Java 17.
Java version | Compatible runtime | Common layer ARN |
Java 11/Java 8 | Custom runtimes | acs:fc:{region}:official:layers/ArmsAgent273x/versions/2 |
Java 17 | Custom runtimes | acs:fc:{region}:official:layers/ArmsAgent273x_JDK17/versions/1 |
Use a bootstrap script to start an application
To use ARMS, you must add three startup parameters. We recommend that you use a script to perform startup for simplicity. You can use WebIDE to create a bootstrap file on the function code page and configure executable permissions for the file by running the chmod +x bootstrap
command in the terminal. The following sample code provides an example:
#!/bin/bash
set -eo pipefail
#1. Specify a name for the ARMS application.
appName="FC:Custom_Java_Arms_Demo"
if [ -n "${FC_FUNCTION_NAME}" ]; then
appName="FC:${FC_FUNCTION_NAME}"
fi
echo "appName: ${appName}"
params=" "
#2. Add ARMS 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` "
# Use the ARMS program path in public layers.
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. Launch the application.
echo "params: ${params}"
exec java $params \
-Dserver.port=9000 \
-jar /code/target/demo-0.0.1-SNAPSHOT.jar
The following items describe the details of the sample code:
Specify a name for the ARMS application. The default value is
FC:{FunctionName}
.Add ARMS parameters.
javaagent
: the path of the ARMS program. If a public layer of an ARMS agent is used, the path is/opt/ArmsAgent/arms-bootstrap-1.7.0-SNAPSHOT.jar
.Darms.licenseKey
: the license key information. In this example, the license key is obtained from environment variables. For more information about how to obtain a license key, see Obtain a license key.Darms.appName
: the name of the ARMS application. Use your actual ARMS application name.
Configure environment variables
Configure the environment variable
FC_EXTENSIONS_ARMS_LICENSE_KEY=xxxx
. Set the value to the license key. For more information about how to obtain the license key, see Obtain a license key.Set the environment variable
FC_EXTENSION_ARMS=true
.After the environment variable is added, the function instance is frozen 10 seconds after a function invocation is completed. This ensures that the ARMS agent can report logs as expected.
ImportantAfter an invocation is complete, fees continue to generate before the instance is frozen based on the same billing rules during the invocation. For more information, see Billing.
Prerequisites
A function in a custom runtime (Java 8, Java 11, or Java 17) is created. For more information, see Create a function.
ARMS is activated. For more information, see Activate ARMS.
Procedure
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 function that you want to manage.
On the function details page, click the Configurations tab.
In the left-side navigation pane, click Layers. On the page that appears, click Modify. In the Layers panel, choose to add an ARMS agent layer that is compatible with your Java runtime.
In the left-side navigation pane, click Environment Variables. On the page that appears, click Modify to configure the following environment variables:
FC_EXTENSION_ARMS=true
andFC_EXTENSIONS_ARMS_LICENSE_KEY=xxxx
For more information, see Configure environment variables.
In the WebIDE of the function code page, create a bootstrap file and click Deploy.
For more information, see Use a Bootstrap script as startup commands.
After you update the configurations and deploy the code, the function is added to ARMS for high-performance management. You are charged for using ARMS. For more information, see Overview.
If you want to view monitoring information after your function is connected to ARMS, make sure that ARMS resides in the same region as your function.
Make sure that the memory size of your function is greater than 512 MB because ARMS consumes approximately 300 MB of memory.
Check the execution result of an HTTP job
After you connect a function to ARMS, you can view the function in the ARMS console.
You can also log on to the ARMS console. In the left-side navigation pane, choose . Click the name of the desired application to view the monitoring information. For more information, see Overview.
appName
indicates the name of the target application in the Bootstrap script. The default value is FC:{FunctionName}
.