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

Prerequisites

Install the ARMS application monitoring agent

Install ARMS application monitoring components ack-arms-pilot.

  1. Log on to the Alibaba Cloud Container Service for Kubernetes console.
  2. In the left-side navigation pane, choose Market > Application catalog On the right of the page, click ack-arms-pilot .
  3. On the app catalog-ack-arms-pilot page, select the target cluster in the create pane, and click create .

Authorize Alibaba Cloud Container Service for Kubernetes

Use the following steps to authorize Alibaba Cloud Container Service for Kubernetes to access ARMS resources.

  1. Log on to the container service console.
  2. In the left-side navigation pane, choose clusters . On the clusters page, find the target cluster, and click actions in the details column.
    Manage Cluster
  3. On the cluster information page of the target cluster, click the cluster resources tab. Click the link on the right of the Worker RAM role .
    Worker RAM Link
  4. On the RAM roles page of the RAM console, click the policy name on the permissions tab.
  5. On the policy document tab, click modify policy document , add the following content to the policy document section, and then click OK .
    
            { "Action": "arms:*", "Resource": "*", "Effect": "Allow" } 
          
    Modify RAM Authorization

Enable ARMS application monitoring for Java applications

The following steps demonstrate how to enable ARMS application monitoring for a new application or an existing application.

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

  1. In the Alibaba Cloud Container Service for Kubernetes console, choose clusters from the left-side navigation pane. On the clusters page, find the target cluster, and click actions in the application management column.
  2. On the deployments page, click create from template in the upper-right corner.
  3. On the create from template page, select a sample template , and in template (YAML format), add the following annotations to the spectimtemplatewithmetadata section:
    Note Replace <your-deployment-name> with your application name.
    
            annotations: armsPilotAutoEnable: "on" armsPilotCreateAppName: "<your-deployment-name>" 
          
    YAML Example

    The following YAML template shows how to create an application and enable ARMS application monitoring 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
    ---
    

To enable ARMS application monitoring for an existing application, perform the following steps.

  1. In the Alibaba Cloud Container Service for Kubernetes console, choose clusters from the left-side navigation pane. On the clusters page, find the target cluster, and click actions in the application management column.
  2. On the stateless or stateful page, Select More > View Yaml in the actions column for the target application.View YAML
  3. In the edit YAML dialog box, add the following annotations to the speckettemplatewithmetadata section and then click update .
    Note Replace <your-deployment-name> with your application name.
    
            annotations: armsPilotAutoEnable: "on" armsPilotCreateAppName: "<your-deployment-name>" 
          

Execution result

On the Deployments or StatefulSets tab, ARMS Console appears in the Actions column of the application.

ARMS Console Button
Note If you cannot find ARMS Console in the Actions column, check whether you have authorized Container Service to access ARMS.

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, click Applications in the Actions column corresponding to the cluster that contains the Java application from which you want to uninstall the ARMS agent.
  3. In the left-side navigation pane, select Releases.
  4. On the Helm tab, select the release name arms-pilot of the ARMS agent, and click Delete in the Actions column.
  5. In the Delete dialog box, click OK.
  6. Restart your business pod.

Change the application name

You can change the application name without restarting the application or reinstalling the agent. For example, if you forget to change the sample name Java-Demo to a custom name, you can edit the armsPilotCreateAppName parameter in the Deployment application and then restart the pod. For more information, see How can I change the name of a Java application that is deployed in a Container Service for Kubernetes cluster?