Use Application Real-Time Monitoring Service (ARMS) to monitor applications in a generic Kubernetes environment. You can monitor application topology, API calls, track abnormal and slow transactions, and perform SQL analysis. This topic describes how to connect a Java application in a generic Kubernetes environment to ARMS.
If you use a Kubernetes cluster provided by Container Service for Kubernetes (ACK), this topic does not apply. To connect an ACK cluster to ARMS, see Install the Java agent for Container Service for Kubernetes (ACK) and Container Compute Service (ACS) using the ack-onepilot component.
Prerequisites
Your Kubernetes cluster must be version 1.18 or later.
If your Kubernetes cluster is not deployed on Alibaba Cloud, ensure that it can connect to the internet. Alternatively, you can connect the cluster to an Alibaba Cloud VPC using services such as Cloud Enterprise Network (CEN).
Check your JDK version. For more information, see Supported JDK versions.
Ensure the maximum heap memory for the process is greater than 256 MB.
Option 1 (Recommended): Connect to ARMS through a registered ACK cluster
Advantages of using a registered ACK cluster:
More efficient operations and maintenance (O&M) support.
Access to more extension capabilities of ACK clusters, such as monitoring, logging, backup and recovery, security, and elastic cloud resources. For more information, see Overview of registered clusters.
Connect the Kubernetes cluster to ACK One. For more information, see Create a registered cluster in ACK One.
Install the ack-onepilot component for the registered cluster. For more information, see Connect Application Real-Time Monitoring Service (ARMS) to a registered cluster.
Option 2: Connect directly to ARMS
This method does not use an ACK registered cluster. After integration, information related to containers, such as CPU, memory, disk, and network, cannot be correlated and displayed. This means that on the Application Instance page, only container environment data collected by the ARMS agent is displayed, and you cannot view container data obtained from Prometheus probes by integrating with Managed Service for Prometheus. For more information, see Java application instance monitoring.
Step 1: Install Helm 3
Step 2: Install the agent
ARMS Application Monitoring supports connecting both stateless (deployment) and stateful (StatefulSet) applications. The connection method is the same for both. This section shows how to connect a stateless (deployment) application as an example.
Run the following
wgetcommand to download the ack-onepilot installation package.wget 'https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ack-onepilot-5.1.1.tgz'Run the following command to decompress the ack-onepilot installation package.
tar xvf ack-onepilot-5.1.1.tgzEdit the values.yaml file in the installation package. Modify the following parameters as needed, and then save the file.
registry: registry-__ACK_REGION_ID__.ack.aliyuncs.com/acs/ cluster_id: __ACK_CLUSTER_ID__ accessKey: __ACCESSKEY__ accessKeySecret: __ACCESSKEY_SECRET__ uid: "__ACK_UID__" region_id: __ACK_REGION_ID__registry: The registry address of the ack-onepilot image.cluster_id: A custom ID for the Kubernetes cluster. This ID must be unique. The recommended format is<uid>-<clusterid>.accessKeyandaccessKeySecret: The AccessKey ID and AccessKey secret of your Alibaba Cloud account. To obtain them, see Create an AccessKey.ImportantMake sure the Alibaba Cloud account has the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions.
If you are using a Resource Access Management (RAM) user, make sure the RAM user also has the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions. For more information, see Manage RAM user permissions.
For better security, you can hide the AccessKey ID and AccessKey secret using a Kubernetes Secret. For more information, see Option 2: Import the AccessKey ID and AccessKey secret using a Kubernetes Secret.
uid: The ID of your Alibaba Cloud account. You can find the ID by moving the mouse pointer over your profile picture in the upper-right corner of the Alibaba Cloud Management Console.region_id: The ID of the Alibaba Cloud region. For a list of regions where Application Monitoring is available, see Available regions.
NoteIf the destination cluster is an edge cluster, add the nodeSelector annotation to schedule the ack-onepilot component to the cloud. This ensures that ack-onepilot works correctly.
kind: Deployment apiVersion: apps/v1 metadata: name: xxx namespace: xxx spec: template: spec: nodeSelector: # Replace with your actual node selector. alibabacloud.com/is-edge-worker: "false"Run the following command to install ack-onepilot.
Run this command outside the ack-onepilot installation package directory.
helm3 upgrade --install ack-onepilot ack-onepilot --namespace ack-onepilot --create-namespace
Step 3: Modify the application's YAML file
Run the following command to view the YAML file of the destination stateless (deployment) application.
kubectl get deployment {deployment_name} -o yamlNoteIf you do not know the
{deployment_name}, run the following command to view all stateless (deployment) applications. Find the destination application in the output, and then view its YAML file.kubectl get deployments --all-namespaceRun the following command to start editing the YAML file of the destination stateless (deployment) application.
kubectl edit deployment {deployment_name} -o yamlIn the YAML file, add the following content under the spec.template.metadata level.
labels: armsPilotAutoEnable: "on" armsPilotCreateAppName: "<your-deployment-name>" # Replace <your-deployment-name> with your application name. aliyun.com/app-language: javaNoteFor information about Application Security, see What is Application Security
For information about the billing rules of Application Security, see Billing.
To create a new stateless (deployment) application in a Kubernetes environment and connect it to ARMS, the complete YAML file for the application is as follows:
After you save the configuration, the application automatically restarts for the changes to take effect.
After 2 to 5 minutes, if your application appears on the page in the ARMS console and data is reported, the connection is successful.