After you install the Application Real-Time Monitoring Service (ARMS) agent for a Java application that is deployed in Container Service for Kubernetes (ACK), ARMS starts to monitor the Java application. You can view the monitoring data of application topology, API requests, abnormal transactions, and slow transactions. This topic describes how to install the ARMS agent for a Java application that is deployed in ACK.

Prerequisites

Step 1: Install the ARMS agent

Install the ARMS agent that is named ack-arms-pilot.

  1. Log on to the ACK console.
  2. In the left-side navigation pane, choose Marketplace > App Catalog. On the Alibaba Cloud Apps tab, click ack-arms-pilot.
  3. In the Deploy section of the View Details page of ack-arms-pilot, select the cluster where the application to be monitored is deployed and click Create.

Step 2: Enable ARMS for a Java application

To enable ARMS when you create an application, perform the following steps:

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters. On the Clusters page, click Applications in the Actions column of the cluster where your application is deployed.
  2. On the Deployments page, click Create from YAML in the upper-right corner.
  3. On the page that appears, select a template from the Sample Template drop-down list, and add the following annotations to the spec > template > metadata section in the Template code editor.
    Note Replace <your-deployment-name> with the name of your application.
    annotations:
      armsPilotAutoEnable: "on"
      armsPilotCreateAppName: "<your-deployment-name>"                                
    YAML Example

    The following YAML template shows how to create a stateless application and enable ARMS for the application:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: arms-demo
    ---
    apiVersion: apps/v1beta1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: arms-springboot-demo
      namespace: arms-demo
      labels:
        app: arms-springboot-demo
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: arms-springboot-demo
      template:
        metadata:
          annotations:
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-demo"
          labels:
            app: arms-springboot-demo
        spec:
          containers:
            - resources:
                limits:
                  cpu: 0.5
              image: registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-springboot-demo:v0.1
              imagePullPolicy: Always
              name: arms-springboot-demo
              env:
                - name: SELF_INVOKE_SWITCH
                  value: "true"
                - name: COMPONENT_HOST
                  value: "arms-demo-component"
                - name: COMPONENT_PORT
                  value: "6666"
                - name: MYSQL_SERVICE_HOST
                  value: "arms-demo-mysql"
                - name: MYSQL_SERVICE_PORT
                  value: "3306"
    ---
    apiVersion: apps/v1beta1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: arms-springboot-demo-subcomponent
      namespace: arms-demo
      labels:
        app: arms-springboot-demo-subcomponent
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: arms-springboot-demo-subcomponent
      template:
        metadata:
          annotations:
            armsPilotAutoEnable: "on"
            armsPilotCreateAppName: "arms-k8s-demo-subcomponent"
          labels:
            app: arms-springboot-demo-subcomponent
        spec:
          containers:
            - resources:
                limits:
                  cpu: 0.5
              image: registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-springboot-demo:v0.1
              imagePullPolicy: Always
              name: arms-springboot-demo-subcomponent
              env:
                - name: SELF_INVOKE_SWITCH
                  value: "false"
                - name: MYSQL_SERVICE_HOST
                  value: "arms-demo-mysql"
                - name: MYSQL_SERVICE_PORT
                  value: "3306"
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        name: arms-demo-component
      name: arms-demo-component
      namespace: arms-demo
    spec:
      ports:
        # the port that this service should serve on
        - name: arms-demo-component-svc
          port: 6666
          targetPort: 8888
      # label keys and values that must match in order to receive traffic for this service
      selector:
        app: arms-springboot-demo-subcomponent
    ---
    apiVersion: apps/v1beta1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: arms-demo-mysql
      namespace: arms-demo
      labels:
        app: mysql
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mysql
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
            - resources:
                limits:
                  cpu: 0.5
              image: registry.cn-hangzhou.aliyuncs.com/arms-docker-repo/arms-demo-mysql:v0.1
              name: mysql
              ports:
                - containerPort: 3306
                  name: mysql
    ---
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        name: mysql
      name: arms-demo-mysql
      namespace: arms-demo
    spec:
      ports:
        # the port that this service should serve on
        - name: arms-mysql-svc
          port: 3306
          targetPort: 3306
      # label keys and values that must match in order to receive traffic for this service
      selector:
        app: mysql
    ---
    

Execution result

On the Deployments tab, find the application and check whether the ARMS Console button appears in the Actions column.

ARMS Console Button

Uninstall the ARMS agent

  1. Log on to the Alibaba Cloud Container Service for Kubernetes console.
  2. In the left-side navigation pane, click Clusters. On the Clusters page, find the cluster that contains the Java application from which you want to uninstall the ARMS agent and click Applications in the Actions column.
  3. In the left-side navigation pane, choose Applications > Helm.
  4. On the Helm tab, find the release named arms-pilot of the ARMS agent, and click Delete in the Actions column.
  5. In the Delete message, click OK.
  6. Restart your business pod.

FAQ

  • How do I change the name of an application?

    To change the name of an application, you must modify the armsPilotCreateAppName parameter in the Deployment application. For more information, see FAQ about application monitoring.

  • What can I do if the ARMS agent fails to be installed?

    Possible cause: The version of ack-arms-pilot is earlier than V1.30.

    Solution: Grant ACK the permissions to access ARMS. For more information, see FAQ about application monitoring.

  • How do I report data across regions?
    1. In the Deployment application that is deployed in the arms-pilot namespace of the ACK cluster, add the ARMS_REPORT_REGION environmental variable. The value must be an ID of the region where ARMS is available. For example, you can set the value to cn-hangzhou or cn-beijing.
    2. Restart the existing application or deploy a new application to report data across regions.
      Note After the environmental variable is added, all applications that are deployed in the cluster report data to the specified region.