To monitor Go applications deployed in Container Service for Kubernetes (ACK) or Container Compute Service (ACS), you must install the ack-onepilot component and compile your Go binary file. You can then view monitoring data, such as application topology, interface calls, and database analysis, in the Application Real-Time Monitoring Service (ARMS) console. This topic describes how to install an agent for a Go application in Container Service for Kubernetes (ACK) or Container Compute Service (ACS).
The procedure for installing an agent is the same for Container Service for Kubernetes (ACK) and Container Compute Service (ACS). This topic uses an Container Service for Kubernetes (ACK) cluster as an example.
If you have questions about using the Go agent, contact us through our DingTalk group (ID: 159215000379).
Prerequisites
An ACK or ACS cluster is created.
ACK cluster: You can create an ACK managed cluster, ACK dedicated cluster, or ACK Serverless cluster, or a registered cluster, based on your business requirements.
ACS cluster: For information about how to create an ACS cluster, see Create an ACS cluster.
Create a namespace. This topic uses default as the namespace name. For more information, see Manage namespaces and quotas.
Check your compile-time operating system, architecture, Go version, and framework version. For more information, see Go components and frameworks supported by Application Monitoring.
Step 1: Grant ARMS resource access permissions
ACK managed cluster
If an ARMS Addon Token does not exist in your ACK managed cluster, you must manually grant the cluster access permissions to ARMS resources. If the token exists, you can skip to Step 4.
If a cluster has ARMS Addon Token, ARMS performs password-free authorization on the cluster. ARMS Addon Token may not exist in some ACK managed clusters. We recommend that you check whether an ACK managed cluster has ARMS Addon Token before you use ARMS to monitor applications in the cluster. If the cluster has no ARMS Addon Token, you must authorize the cluster to access ARMS.
ACK dedicated cluster/registered cluster
To monitor an application deployed in an ACK dedicated cluster or registered cluster, make sure that the AliyunARMSFullAccess and AliyunSTSAssumeRoleAccess permissions are granted to your Resouce Access Management (RAM) user.
After installing the ack-onepilot component, enter the AccessKey ID and AccessKey Secret of the account in the configuration file of ack-onepilot.
Method 1: Input in Hem
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the cluster you want to manage. In the left-side navigation pane of the page that appears, choose . Then, click Update next to ack-onepilot.
Replace
accessKeyandaccessKeySecretwith the AccessKey ID and AccessKey secret of the account and click OK.NoteThe AccessKey Secret is only visible during initial creation of an Alibaba Cloud AccessKey pair and cannot be retrieved afterward. This design mitigates leakage risks. Securely store the Secret immediately.

Restart the Deployment.
Method 2: Import through Kubernetes Secrets
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, click the cluster you want to manage. In the left-side navigation pane of the page that appears, choose .
Click Create. In the panel that appears, click Add and add the AccessKey ID and AccessKey Secret for ack-onepilot.
NoteThe AccessKey Secret is only visible during initial creation of an Alibaba Cloud AccessKey pair and cannot be retrieved afterward. This design mitigates leakage risks. Securely store the Secret immediately.

In the left-side navigation pane, choose . On the page that appears, click the ack-onepilot component. Generally, it is named ack-onepilot-ack-onepilot in the ack-onepilot namespace.
In the upper-right corner of the page that appears, click Edit.
Scroll down until you see the Environments section. Click Add, add the environment variables
ONE_PILOT_ACCESSKEYandONE_PILOT_ACCESSKEY_SECRET, reference the Secrets in Kubernetes Secrets, and click OK.
ASK/ECI cluster
To monitor applications in an ACK Serverless (ASK) cluster or applications in a Kubernetes cluster connected to Elastic Container Instance, you must first authorize the cluster to access ARMS on the Cloud Resource Access Authorization page. Then, restart all pods on which the ack-onepilot component is deployed.
Step 2: Install the ARMS agent helper (ack-onepilot)
Log on to the ACK console. On the Clusters page, click the name of the cluster.
In the navigation pane on the left, click Component Management. Then, search for ack-onepilot.
ImportantMake sure that the version of ack-onepilot is 3.2.0 or later.
Click Install on the ack-onepilot card.
NoteBy default, the ack-onepilot component supports 1,000 pods. For every additional 1,000 pods in the cluster, you must add 0.5 CPU cores and 512 MB memory for the component.
In the dialog box that appears, configure the parameters and click OK. We recommend that you use the default values.
NoteAfter you install ack-onepilot, you can upgrade, configure, or uninstall it on the Add-ons page.
Step 3: Compile the Golang application image
(Optional) If your project uses vendor-based compilation or includes the
-mod=vendorparameter at compile-time, check the following:Whether the go.mod file includes the google.golang.org/protobuf dependency, either directly or indirectly. If it does not, follow the instructions below:
Whether the
-mod=vendorparameter is added to the compile command. If it is not, add-mod=vendoraftergo build.
Use the
wgetcommand to download the instgo compile tool. Select the download address based on your compile environment and the region where your compile machine is located.Note that instgo automatically updates during compilation. Save instgo in a directory where the user who compiles the application has modification permissions.
NoteInstgo is a compile tool provided by ARMS for Golang applications. After you compile your Golang project with instgo, ARMS can start monitoring your application.
The compile tools downloaded from different regions are identical. If your public network can access the OSS address, you can directly use the public endpoint for China (Hangzhou) to obtain the tool for your operating system and architecture.
Grant execute permission to the compile tool.
Linux/Mac
# Grant the execute permission. chmod +x instgoWindows
No execute permission is required for Windows.
Obtain a license key and configure compile-time parameters.
ImportantIf you skip this step, instgo enters development mode and installs the latest version of the ARMS agent by default. If you plan to deploy your application in a production environment, we recommend that you configure the following parameter.
You can obtain the license key by calling the DescribeTraceLicenseKey OpenAPI operation.
On the DescribeTraceLicenseKey documentation page, click Debug, select a region, and then click Invoke to obtain the license key.

After you obtain the license key, use the
setcommand to configure the compile-time parameter.instgo set --licenseKey=${YourLicenseKey}
Add instgo as a prefix to your original compile command and run the command.
instgo go build {arg1} {arg2} {arg3}If you use go install to compile your project, you can also add instgo as a prefix to your original compile command.
Build an image using the binary file that you compiled in the previous step.
Step 4: Enable Application Monitoring for the Go application
The following YAML template shows how to create a stateless (Deployment) application and enable Application Monitoring for it:
Log on to the ACK console. In the left navigation pane, click Clusters.
At the top of the Clusters page, select the region and resource group where the target cluster is located, and click the name of the target cluster. In the navigation pane on the left, click Workloads. Then, select Deployments, StatefulSets, or DaemonSets.
Find the target application and choose .
To create a new application, click Create From YAML.
Add the following
labelsunder spec.template.metadata in the YAML file.labels: aliyun.com/app-language: golang # Required for Go applications. Specifies that this is a Go application. armsPilotAutoEnable: 'on' armsPilotCreateAppName: "<your-deployment-name>" # Replace <your-deployment-name> with your application name.
Click Update.
Execution result
After about one minute, check whether the Go application appears on the page in the ARMS console and whether data is reported. If so, the agent is successfully installed.

> Edit YAML