All Products
Search
Document Center

Application Real-Time Monitoring Service:How to customize the mount path for a Java agent

Last Updated:Dec 29, 2025

Background

In a standard deployment, the ack-onepilot component specifies the mount path for a Java agent by injecting the JAVA_TOOL_OPTIONS environment variable. However, you may need to customize the agent mount path for specific scenarios, such as the following:

  • Centralized configuration management

    You can manage agent paths centrally using a Kubernetes ConfigMap to ensure configuration consistency across multiple environments.

  • Persistent storage requirements

    Enterprise security policies or O&M requirements may require storing probe files in a custom persistent volume (PVC).

Version dependencies

Customizing the Java agent mount path requires the following component versions:

Solution

Important

The ack-onepilot component is shared by Microservice Engine (MSE) and Application Real-Time Monitoring Service (ARMS). Therefore, this procedure also applies to MSE service administration applications.

  1. Add the disableJavaToolOptionsInjection annotation to Kubernetes workloads, such as deployments, that require a custom-mounted Java agent.

    After you add this annotation, the ack-onepilot component will not use the JAVA_TOOL_OPTIONS environment variable to automatically specify the agent mount path or other Java Virtual Machine (JVM) parameters.

    1. Run the following command to view the YAML file of the target deployment.

      kubectl get deployment YOUR_DEPLOYMENT_NAME -o yaml
      Note

      If you are unsure of the deployment name, you can run the following command to list all deployments. Find the target deployment in the results, and then view its YAML file.

      kubectl get deployments --all-namespaces
    2. You can edit the YAML file for the target stateless application (Deployment).

      kubectl edit deployment YOUR_DEPLOYMENT_NAME -o yaml
    3. In the YAML file, add the following content under `spec.template.metadata`.

      labels:
        armsPilotAutoEnable: "on"
        armsPilotCreateAppName: "<span class="var-span" contenteditable="true" data-var="YOUR_DEPLOYMENT_NAME">YOUR_DEPLOYMENT_NAME"</span> # Replace YOUR_DEPLOYMENT_NAME with your application name.
        disableJavaToolOptionsInjection: "true"            # To customize the Java agent mount path, set this to true.
  2. Add the mount path for the ARMS Java agent to your application startup script or Java startup command.

    The default mount path is /home/admin/.opt/AliyunJavaAgent/aliyun-java-agent.jar. Replace this path with your custom path.

    java -javaagent:/home/admin/.opt/AliyunJavaAgent/aliyun-java-agent.jar ... ... -jar xxx.jar

    Other information, such as the reporting region and license key, is injected by ack-onepilot through environment variables.