27
Application Performance Management Getting Started Issue 01 Date 2019-06-20 HUAWEI TECHNOLOGIES CO., LTD.

Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Application Performance Management

Getting Started

Issue 01

Date 2019-06-20

HUAWEI TECHNOLOGIES CO., LTD.

Page 2: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Copyright © Huawei Technologies Co., Ltd. 2020. All rights reserved.

No part of this document may be reproduced or transmitted in any form or by any means without priorwritten consent of Huawei Technologies Co., Ltd. Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei andthe customer. All or part of the products, services and features described in this document may not bewithin the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,information, and recommendations in this document are provided "AS IS" without warranties, guaranteesor representations of any kind, either express or implied.

The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. i

Page 3: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Contents

1 Subscribing to APM and Buying a Package.......................................................................1

2 Monitoring Java Applications............................................................................................... 52.1 VM Applications....................................................................................................................................................................... 52.1.1 Connecting an ECS Application to APM.......................................................................................................................52.1.2 Connecting a Non-HUAWEI CLOUD Host Application to APM........................................................................... 92.2 Containerized Applications................................................................................................................................................ 142.2.1 Connecting a HUAWEI CLOUD Containerized Application to APM.................................................................142.2.2 Connecting a Native Docker Application to APM.................................................................................................. 172.3 Connecting a Deployment Application to APM......................................................................................................... 20

Application Performance ManagementGetting Started Contents

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. ii

Page 4: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

1 Subscribing to APM and Buying aPackage

If you use Application Performance Management (APM) for the first time,subscribe to it first. The basic edition is used by default. It provides limitedfunctions and applies to trial scenarios. You can switch editions and purchasepackages as required. Professional, enterprise, and platinum editions of probeproducts, and professional edition of mesh products are available. For moreinformation, see APM Pricing Details.

Subscription and Purchase Process

Registering an AccountRegister a cloud account.

Application Performance ManagementGetting Started 1 Subscribing to APM and Buying a Package

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 1

Page 5: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Subscribing to APM

Step 1 Log in to the management console.

Step 2 Choose Service List > Management & Deployment > Application PerformanceManagement.

Step 3 Click Free opening.● After the subscription, click Experience for Free. Then, connect your

applications to APM for monitoring according to Monitoring JavaApplications and use the functions supported in the basic edition.

● If the basic edition does not meet your service requirements, switch to anadvanced edition according to Switching Editions.

----End

Switching EditionsIf an APM edition cannot meet your requirements, switch to a more advancededition. You can also switch from an advanced version to an earlier version onlyonce a month.

Step 1 On the Dashboard page of the APM console, click Switch Edition.

Step 2 On the page that is displayed, select the product type and specifications.

Application Performance ManagementGetting Started 1 Subscribing to APM and Buying a Package

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 2

Page 6: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Step 3 After learning the functions supported by the desired edition, click Change Now.● If you purchase a package and switch to a new edition, the number of probes

in the purchased package is automatically converted to that under the newedition.

● If you do not purchase any package and switch to a new edition, you will bebilled on a pay-per-use basis.

----End

Buying a PackageIf you need to use APM for a long period of time, purchase a package so that youcan use more functions and save more.

Step 1 On the Dashboard page of the APM console, click Buy Package.

Application Performance ManagementGetting Started 1 Subscribing to APM and Buying a Package

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 3

Page 7: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Step 2 On the displayed page, specify Region, Product Type, Package Type,Specifications, and Required Duration.

● Product Type: Mesh products are applicable to applications deployed inclusters of Istio mesh. Probe products are applicable to common applications,such as those deployed on VMs.

● Package Type: The functions supported by each package are different. Fordetails, see Package Details.

● Specifications: indicates the number of probe instances in a package. Anapplication process requires a probe. You can select specifications based onthe total number of service processes. After a resource package expires, youwill be billed on a pay-per-use basis for the resources used. If your account isin arrears, probes will no longer report data, affecting APM functions. Formore information, see Renewal Details.

Step 3 Click Pay Now to buy the package.

After buying the package, connect your applications to APM for monitoringaccording to Monitoring Java Applications.

----End

Application Performance ManagementGetting Started 1 Subscribing to APM and Buying a Package

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 4

Page 8: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

2 Monitoring Java Applications

2.1 VM Applications

2.1.1 Connecting an ECS Application to APMIf your application is deployed on an Elastic Cloud Server (ECS), learn ApplicationPerformance Management (APM) based on the following procedure. This sectiondescribes how to connect a Java application on an ECS server to APM formonitoring.

Prerequisites● You have purchased an ECS server.● The ECS server meets the requirements in Supported OSs.● The ECS server meets the requirements in Supported Java Types.● The time and time zone of the local browser are consistent with those of the

ECS server.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 5

Page 9: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Procedure

Step 1: Subscribe to APMSee Subscribing to APM and Buying a Package.

Step 2: Install the ICAgent1. Obtain an Access Key ID/Secret Access Key (AK/SK).2. Log in to the APM console.3. In the navigation pane, choose Agent > Management.4. Click Install ICAgent. On the page that is displayed, set Host to HUAWEI

CLOUD host and OS to Linux.5. Select the Obtain AK/SK installation mode, enter the obtained AK/SK in the

text box to generate the ICAgent installation command, and click CopyCommand.

NO TE

Ensure that the AK/SK are correct. Otherwise, the ICAgent cannot be installed.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 6

Page 10: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

6. Remotely log in to the ECS server as the root user and run the precedingcommand to install the ICAgent.When the message "ICAgent install success" is displayed, the ICAgent issuccessfully installed in the /opt/oss/servicemgr/ directory.

(Optional) Step 3: Modify PermissionsIf you start the program as a non-root user, run the following commands tomodify the permissions on the probe file and output directory before enablingapplication monitoring:

chmod -R 777 /opt/oss/servicemgr/ICAgent/pinpoint/mkdir -p /paas-apm/collectors/pinpointchmod -R 777 /paas-apm

Step 4: Configure the Application Startup Script and Restart the Application1. On the ECS server, if you do not use Tomcat to start the service, perform the

following operations:

a. Add the configuration items in the following table to the place below thejava keyword in the Java application startup script to ensure that the Javaapplication can be monitored by APM.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 7

Page 11: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Table 2-1 Configuration items to be added

Parameter Description

-javaagent JAR package that collection probes depend onThe fixed value is /opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar.

-Dapm_application Application name.The value must be 1 to 64 characters startingwith a letter or an underscore (_). Onlylowercase letters, digits, hyphens (-), andunderscores are allowed.

-Dapm_tier Application microservice name.The value must be 1 to 64 characters startingwith a letter or an underscore (_). Onlylowercase letters, digits, hyphens (-), andunderscores are allowed.

Example of the modified startup script

The following shows an example startup script of the Vmall applicationwith the vmall-dao-service and vmall-user-service services. You need toconfigure your script as required.

▪ Original startup script:java -Xmx512m -jar /root/testdemo/ecommerce-persistence-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_dao.yml > dao.log 2>&1 &java -Xmx512m -jar /root/testdemo/ecommerce-user-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_userservice.yml > user.log 2>&1 &

▪ Modified startup script (differences are in bold):java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-dao-service -Xmx512m -jar /root/testdemo/ecommerce-persistence-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_dao.yml > dao.log 2>&1 &java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-user-service -Xmx512m -jar /root/testdemo/ecommerce-user-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_userservice.yml > user.log 2>&1 &

b. Execute the modified application startup script to enable applicationmonitoring.

2. On the ECS server, if you use Tomcat to start the service, perform thefollowing operations:

a. Go to the bin directory of Tomcat.

b. Copy the following content to the catalina.sh file.JAVA_OPTS="$JAVA_OPTS -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=xxx -Dapm_tier=xxx"

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 8

Page 12: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

NO TE

1. Note that -Dapm_application -Dapm_tier needs to be configured based onTable 2-1.

c. Execute the modified application startup script to enable applicationmonitoring.

Step 5: Manage the Application on APMThree minutes after the application is started, its data will be displayed on theAPM console. You can log in to the APM console and optimize applicationperformance through topology and tracing. For details, see APM User Guide.

2.1.2 Connecting a Non-HUAWEI CLOUD Host Application toAPM

Application Performance Management (APM) supports data access in the hybridcloud scenario. When your application is deployed on a non-HUAWEI CLOUD host,you can connect it to APM for monitoring through a jump server. This sectiondescribes how to connect a Java application on a non-HUAWEI CLOUD host toAPM for monitoring.

Prerequisites● In the hybrid cloud scenario, monitoring data needs to be forwarded to APM

through a jump server. Therefore, you need to purchase an Elastic CloudServer (ECS) as a jump server.

● The ECS server meets the requirements in Supported OSs and supports theAMD64 processor architecture.

● The server has been bound to an Elastic IP Address (EIP). For details, seeAssigning an EIP and Binding It to an ECS.

● The time and time zone of the local browser are consistent with those of theECS server.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 9

Page 13: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Procedure

Step 1: Subscribe to APMSee Subscribing to APM and Buying a Package.

Step 2: Install the ICAgentBefore installing the ICAgent on a non-HUAWEI CLOUD host, purchase an ECSserver from HUAWEI CLOUD as a jump server and perform the followingoperations:

NO TE

You are advised to use CentOS 6.5 64bit or later images. The minimum specification is1vCPUs | 1GB and the recommended one is 2vCPUs | 4GB.

Step 1 Log in to an ECS server and modify its security group rule.

1. On the ECS details page, click the Security Groups tab.2. On the security group page, click a security group name and then click

Modify Security Group Rule.3. On the security group details page, click the Inbound Rules tab and then

click Add Rule. On the page that is displayed, add a security group rule basedon Table 2-2.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 10

Page 14: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Table 2-2 Security group rule

Direction Protocol Port Description

Inbound TCP 8149, 8102, 8923,30200, 30201, and80

List of ports onthe jump serverto which theICAgent sendsdata

NO TE

Enable ports 8149, 8102, 8923, 30200, 30201, and 80 in the inbound direction of thesecurity group to ensure normal data communication between the non-HUAWEICLOUD host and the jump server.

Step 2 In the navigation pane, choose Agent > Management.

Step 3 Select Other: user-defined nodes, click Install ICAgent, and set Host to Non-HUAWEI CLOUD host.

Step 4 Enable forwarding ports on the jump server.

1. As shown in Figure 2-1, enter the private IP address of the jump server andgenerate a forwarding command.

Figure 2-1 Private IP address of the jump server

NO TE

The private IP address of the jump server refers to the internal IP address of theVirtual Private Cloud (VPC) where the jump server locates.

2. Click Copy Command.3. Log in to the jump server as the root user, and run the SSH Tunnel

command:ssh -f -N -L {ECS IP address}:8149:{ELB IP address}:8149 -L {ECS IP address}:8102:{ELB IP address}:8102 -L {ECS IP address}:8923:{ELB IP address}:8923 -L {ECS IP address}:30200:{ELB IP address}:30200 -L {ECS IP address}:30201:{ELB IP address}:30201 -L {ECS IP address}:80:icagent-{Region}.obs.{Region}.myhuaweicloud.com:80 {ECS IP address}

Enter the password of the root user as prompted.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 11

Page 15: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

4. Run the netstat -lnp | grep ssh command to check whether correspondingports are being listened to. If the results in Figure 2-2 are returned, TCP portsare enabled.

Figure 2-2 Verification results of TCP ports

NO TE

– Enter http://ECS IP address in the address bar of the browser. If the access issuccessful, the security group rule has taken effect.

– If the jump server is powered off and then restarted, run the command in Step 4.3again.

Step 5 Obtain an Access Key ID/Secret Access Key (AK/SK).

Step 6 Generate the ICAgent installation command and copy it.

1. As shown in Figure 2-3, enter the AK, SK, DC, and Connection IP to generatethe ICAgent installation command.

Figure 2-3 Obtaining the AK/SK

NO TE

– Ensure that the AK/SK are correct. Otherwise, the ICAgent cannot be installed.– DC: Custom a DC name for querying hosts more easily.– Connection IP: For EIP connection, use the EIP of the jump server. For VPC peer

connection, use the internal IP address of the VPC where the jump server locates.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 12

Page 16: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

2. Then, click Copy Command.

Step 7 Use a remote login tool to log in to the server where the ICAgent is to be installedas the root user and run the preceding command to install the ICAgent.

When the message "ICAgent install success" is displayed, the ICAgent issuccessfully installed in the /opt/oss/servicemgr/ directory. After the ICAgent issuccessfully installed, choose Agent > Management to view the ICAgent status.

----End

(Optional) Step 3: Modify PermissionsIf you start the program as a non-root user, run the following commands tomodify the permissions on the probe file and output directory before enablingapplication monitoring:

chmod -R 777 /opt/oss/servicemgr/ICAgent/pinpoint/mkdir -p /paas-apm/collectors/pinpointchmod -R 777 /paas-apm

Step 4: Enable Application MonitoringConfigure the application startup script to enable application monitoring. TheICAgent obtains the application data from the Java probe, and then reports thedata to APM to ensure that the Java application is monitored. The following showsan example of the VMall application with the vmall-dao-service and vmall-user-service services.

Table 2-3 Configuration description

Parameter Description

-javaagent JAR package that collection probes depend onThe fixed value is /opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar.

-Dapm_application Application name.The value must be 1 to 64 characters starting with aletter or an underscore (_). Only lowercase letters,digits, hyphens (-), and underscores are allowed.

-Dapm_tier Application microservice name.The value must be 1 to 64 characters starting with aletter or an underscore (_). Only lowercase letters,digits, hyphens (-), and underscores are allowed.

Step 1 Configure the startup script of the Java application based on Table 2-3.

Original startup script:java -Xmx512m -jar /root/testdemo/ecommerce-persistence-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_dao.yml > dao.log 2>&1 &java -Xmx512m -jar /root/testdemo/ecommerce-user-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_userservice.yml > user.log 2>&1 &

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 13

Page 17: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Modified startup script:

java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-dao-service -Xmx512m -jar /root/testdemo/ecommerce-persistence-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_dao.yml > dao.log 2>&1 &java -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-user-service -Xmx512m -jar /root/testdemo/ecommerce-user-service-0.0.1-SNAPSHOT.jar --spring.config.location=file:/root/testdemo/application_userservice.yml > user.log 2>&1 &

Step 2 Execute the application startup script to enable application monitoring.

----End

Step 5: Manage the Application on APMThree minutes after the application is started, its data will be displayed on theAPM console. You can log in to the APM console and optimize applicationperformance through topology and tracing. For details, see APM User Guide.

2.2 Containerized Applications

2.2.1 Connecting a HUAWEI CLOUD Containerized Applicationto APM

If your containerized application has been deployed on the cloud, learnApplication Performance Management (APM) based on the following procedure.This section describes how to connect a Java application on a container service toAPM through the Pinpoint probe.

Prerequisites● You have subscribed to Cloud Container Engine (CCE) and ServiceStage.● You have deployed Java applications on CCE and ServiceStage.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 14

Page 18: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Procedure

Step 1: Subscribe to APMSee Subscribing to APM and Buying a Package.

Step 2: Enable Application MonitoringYou need to perform operations based on application deployment modes.Currently, APM supports application deployment through:

● ServiceStage. For details, see ServiceStage Mode.● CCE. For details, see CCE Mode.

ServiceStage ModeServiceStage is a one-stop DevOps platform service oriented for enterprises anddevelopers. If you select the probe when using ServiceStage to create a cluster,APM is automatically connected to the application.

Figure 2-4 Selecting the Java probe when creating an application

Figure 2-5 Selecting the Java probe

CCE ModeCCE provides containerized application management. If you select the probe whencreating or upgrading an application, the APM collection probe is installed on theapplication.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 15

Page 19: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Figure 2-6 Selecting the Java probe when creating an application

Figure 2-7 Selecting the Java probe

Figure 2-8 Selecting the probe when upgrading an application

Step 3: Manage the Application on APM

Three minutes after the application is started, its data will be displayed on theAPM console. You can log in to the APM console and optimize applicationperformance through topology and tracing. For details, see APM User Guide.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 16

Page 20: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

2.2.2 Connecting a Native Docker Application to APMIf you have a Java application image, you can add the parameters required by theJava probe to the native Docker startup command. In this case, by starting theimage, you can connect the Java application to Application PerformanceManagement (APM), and then view application data on the topology andtransaction pages.

Prerequisite

You have deployed a Java application in Docker.

Procedure

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 17

Page 21: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Step 1: Subscribe to APMSee Subscribing to APM and Buying a Package.

Step 2: Install the ICAgent1. Obtain an Access Key ID/Secret Access Key (AK/SK).2. Log in to the APM console.3. In the navigation pane, choose Agent > Management.4. Click Install ICAgent. On the page that is displayed, set Host to HUAWEI

CLOUD host and OS to Linux.5. Select the Obtain AK/SK installation mode, enter the obtained AK/SK in the

text box to generate the ICAgent installation command, and click CopyCommand.

NO TE

Ensure that the AK/SK are correct. Otherwise, the ICAgent cannot be installed.

6. Remotely log in to the Elastic Cloud Server (ECS) server as the root user andrun the preceding command to install the ICAgent.When the message "ICAgent install success" is displayed, the ICAgent issuccessfully installed in the /opt/oss/servicemgr/ directory.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 18

Page 22: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

(Optional) Step 3: Modify Permissions

If you start the program as a non-root user, run the following commands tomodify the permissions on the probe file and output directory before enablingapplication monitoring:

chmod -R 777 /opt/oss/servicemgr/ICAgent/pinpoint/mkdir -p /opt/apm-container chmod -R 777 /opt/apm-container

Step 4: Start an Image

Add the parameters required by the Java probe to the native Docker startupcommand, and adjust the application and service names as required. Thefollowing shows an example of the VMall application with the vmall-dao-serviceservice.

1. Modify the Docker startup script.

Example

Original startup command:docker run -p 8080:8080 demo:latest

Modified startup command:docker run -e JAVA_TOOL_OPTIONS="-javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_application=vmall -Dapm_tier=vmall-dao-service -Dapm_container=true" -v /opt/apm-container:/paas-apm/collectors/pinpoint -v /opt/oss/servicemgr/ICAgent/pinpoint:/opt/oss/servicemgr/ICAgent/pinpoint -p 8080:8080 demo:latest

2. Run the docker run command to start the image, so that the Dockerapplication can be connected to the APM console.

Step 5: Manage the Application on APM

Three minutes after the application is started, its data will be displayed on theAPM console. You can log in to the APM console and optimize applicationperformance through topology and tracing. For details, see APM User Guide.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 19

Page 23: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

2.3 Connecting a Deployment Application to APMDeployment is a workload that does not store any data or status. If you havedeployed a Deployment application using Cloud Container Engine (CCE) or open-source Kubernetes, you can execute the configuration script to connect theapplication to Application Performance Management (APM) and view its data onthe topology and transaction pages.

Prerequisites● You have connected an Elastic Cloud Server (ECS) to a cluster by running the

kubectl command. For details, see Connecting to the Kubernetes ClusterUsing kubectl.

● You have deployed an application using CCE or open-source Kubernetes.

Procedure

Step 1: Subscribe to APM

See Subscribing to APM and Buying a Package.

Step 2: Install the ICAgentNO TE

If the ICAgent is bound to CCE, skip this step.

1. Obtain an Access Key ID/Secret Access Key (AK/SK).2. Log in to the APM console.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 20

Page 24: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

3. In the navigation pane, choose Agent > Management.4. Click Install ICAgent. On the page that is displayed, set Host to HUAWEI

CLOUD host and OS to Linux.5. Select the Obtain AK/SK installation mode, enter the obtained AK/SK in the

text box to generate the ICAgent installation command, and click CopyCommand.

NO TE

Ensure that the AK/SK are correct. Otherwise, the ICAgent cannot be installed.

6. Remotely log in to the ECS server as the root user and run the precedingcommand to install the ICAgent.When the message "ICAgent install success" is displayed, the ICAgent issuccessfully installed in the /opt/oss/servicemgr/ directory.

(Optional) Step 3: Modify PermissionsIf you start the program as a non-root user, run the following commands tomodify the permissions on the probe file and output directory before enablingapplication monitoring:

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 21

Page 25: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

chmod -R 777 /opt/oss/servicemgr/ICAgent/pinpoint/mkdir -p /opt/apm-container chmod -R 777 /opt/apm-container

Step 4: Enable Application Monitoring1. On the ECS or CCE, configure the startup script of the Deployment.

Specifically, add the following information in bold to the YAML file.Run the following command to edit the YAML file:vi xxx.yaml

xxx indicates the name of the description file customized when you create theDeployment application. The following provides an example. For moreinformation on deployments, see Kubernetes documents.kind: Deployment apiVersion: apps/v1 metadata: name: user-service namespace: default selfLink: /apis/apps/v1/namespaces/default/deployments/user-service uid: b231788d-9abd-11e8-80a5-fa163e3a2cc7 resourceVersion: '50972062' generation: 13 creationTimestamp: '2018-08-08T03:46:56Z' labels: app: user-service stack-name: auto-test annotations: deployment.kubernetes.io/revision: '5' description: '' enable: true spec: replicas: 1 selector: matchLabels: app: user-service template: metadata: creationTimestamp: null labels: app: user-service enable: true spec: #External mount directory of the container, including the data output path and Java probe package path. volumes: - name: paas-apm hostPath: path: /opt/apm-container - name: pinpoint-pkg hostPath: path: /opt/oss/servicemgr/ICAgent/pinpoint containers: - name: user-service image: '100.125.0.198:20202/zhyyy/user-service:v1' ports: - containerPort: 8080 protocol: TCP env: - name: PAAS_APP_NAME # Workload name (service name). value: user-service - name: PAAS_NAMESPACE #CCE cluster namespace. For a non-CCE cluster, this parameter is left blank. value: default - name: PAAS_PROJECT_ID #Tenant's project ID.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 22

Page 26: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

value: d698369a975645bfb35f8437d11c5a12 - name: PAAS_CLUSTER_ID #CCE cluster ID, which can be queried by pressing F12 on the CCE console. For a non-CCE cluster, this parameter is left blank. value: 89b49857-5433-11e8-941c-0255ac101f3e - name: PAAS_POD_ID valueFrom: fieldRef: fieldPath: metadata.uid - name: PAAS_MONITORING_GROUP # Application name (monitoring group). You are advised to set the same application name for the services that fulfill the same function. value: shoppingmall - name: JAVA_TOOL_OPTIONS value: -javaagent:/opt/oss/servicemgr/ICAgent/pinpoint/pinpoint-bootstrap.jar -Dapm_container=true resources: {} #Internal mount directory of the container, including the data output path and Java probe package path. volumeMounts: - name: paas-apm mountPath: /paas-apm/collectors/pinpoint - name: pinpoint-pkg mountPath: /opt/oss/servicemgr/ICAgent/pinpoint

terminationMessagePath: /dev/termination-log terminationMessagePolicy: File imagePullPolicy: Always restartPolicy: Always terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst securityContext: {} schedulerName: default-scheduler strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 1 revisionHistoryLimit: 10 progressDeadlineSeconds: 600 status: observedGeneration: 13 replicas: 1 updatedReplicas: 1 readyReplicas: 1 availableReplicas: 1 conditions: - type: Progressing status: 'True' lastUpdateTime: '2018-09-02T13:25:46Z' lastTransitionTime: '2018-08-08T03:46:56Z' reason: NewReplicaSetAvailable message: ReplicaSet "user-service-f584f46b7" has successfully progressed. - type: Available status: 'True' lastUpdateTime: '2018-12-21T11:01:33Z' lastTransitionTime: '2018-12-21T11:01:33Z' reason: MinimumReplicasAvailable message: Deployment has minimum availability.

2. Restart the application using the modified script, and enable applicationperformance monitoring.

Step 5: Manage the Application on APMThree minutes after the application is started, its data will be displayed on theAPM console. You can log in to the APM console and optimize applicationperformance through topology and tracing. For details, see APM User Guide.

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 23

Page 27: Getting Started - Huawei · Getting Started 1 Subscribing to APM and Buying a Package 2019-06-20 4. 2 Monitoring Java Applications 2.1 Connecting an ECS Application to APM 2.2 Connecting

Application Performance ManagementGetting Started 2 Monitoring Java Applications

Issue 01 (2019-06-20) Copyright © Huawei Technologies Co., Ltd. 24