Application Performance Management工具之pinpoint

1.背景知识

Application Performance Management是什么?

维基百科:

In the fields of information technology and systems management, Application Performance Management (APM) is the monitoring and management of performance and availability of software applications. APM strives to detect and diagnose complex application performance problems to maintain an expected level of service. APM is “the translation of IT metrics into business meaning ([i.e.] value).”

APM监控和管理软件应用的性能和可用性,探测和诊断复杂的应用性能问题。

APM 理论框架:

Application Performance Management工具之pinpoint_第1张图片

APM的鼻祖是Google Dapper

英文版paper: http://research.google.com/pubs/pub36356.html

中文翻译版: http://bigbully.github.io/Dapper-translation/

国外工具列表:

ZIPKIN: https://github.com/openzipkin/zipkin

pinpoint:https://github.com/naver/pinpoint

appdash: https://github.com/sourcegraph/appdash

国内工具列表:

阿里的鹰眼介绍: http://club.alibabatech.org/resource_detail.htm?topicId=102

点评的cat: https://github.com/dianping/cat

京东的hydra(不维护): https://github.com/odenny/hydra

还有个商业化的oneAPM。

本文以naver的pinpoint为例,搭建一套自己的APM平台。

2.pinpoint介绍

Pinpoint provides a solution to help analyze the overall structure of the system and how components within them are interconnected by tracing transactions across distributed applications.

Install agents without changing a single line of code

Minimal impact on performance (approximately 3% increase in resource usage)

Pinpoint能帮助分析整个系统架构,在分布式应用中通过追踪事务解释系统组件间是怎么进行连接的。

Pinpoint架构图:

Application Performance Management工具之pinpoint_第2张图片

Pinpoint由4部分组成:

1.Pinpoint Agent, 2. Pinpoint Collector, 3. HBase, 4.Pinpoint Web UI

其中2,4必须启web容器。

Pinpoint使用了字节码增强技术,在类加载时,注入到观察的应用Class文件中。

所以在启动应用时,必须设置-javaagent为Pinpoint的agent。

目前Pinpoint支持的模块:

JDK 6+

Tomcat 6/7/8, Jetty 8/9

Spring, Spring Boot

Apache HTTP Client 3.x/4.x, JDK HttpConnector, GoogleHttpClient, OkHttpClient, NingAsyncHttpClient

Thrift Client, Thrift Service

MySQL, Oracle, MSSQL, CUBRID, DBCP, POSTGRESQL

Arcus, Memcached, Redis

iBATIS, MyBatis

gson, Jackson, Json Lib

log4j, Logback

3.安装Pinpoint

因为Pinpoint依赖JDK6,7,8; 所以必须配置JDK6,7,8环境变量

在/etc/profile 添加:

JAVA_6_HOME="/data1/hugang/jdk1.6.0_45"
export JAVA_6_HOME
JAVA_7_HOME="/usr/local/jdk"
export JAVA_7_HOME
JAVA_8_HOME="/data1/hugang/jdk1.8.0_71"
export JAVA_8_HOME
#source /etc/profile

拷贝工程:

# git clone https://github.com/naver/pinpoint.git

本地安装:

# mvn install -Dmaven.test.skip=true

安装期间报错

报错info:

[ERROR] /data3/pinpoint/pinpoint-1.5.1/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/HbaseTemplate2.java:[303,22] error: cannot access CellScannable
[ERROR] /data3/pinpoint/pinpoint-1.5.1/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/PooledHTableFactory.java:[82,29] error: cannot access TableName

解决办法:

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/zookeeper-3.4.5-cdh5.4.0.jar -DgroupId=org.apache.zookeeper -DartifactId=zookeeper -Dversion=3.4.5-cdh5.4.0 -Dpackaging=jar -DcreateChecksum=true

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/mariaDB4j-2.1.3.jar -DgroupId=ch.vorburger.mariaDB4j -DartifactId=mariaDB4j -Dversion=2.1.3 -Dpackaging=jar -DcreateChecksum=true

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/hbase-client-1.0.0-cdh5.4.0.jar -DgroupId=org.apache.hbase -DartifactId=hbase-client -Dversion=1.0.0-cdh5.4.0 -Dpackaging=jar -DcreateChecksum=true

mvn install:install-file -Dfile=/data3/pinpoint/pinpoint-master/lib/hbase-0.90.3.jar -DgroupId=org.apache.hbase -DartifactId=hbase -Dversion=0.90.3 -Dpackaging=jar -DcreateChecksum=true

/data3/pinpoint/pinpoint-1.5.1/commons-hbase/pom.xml新增

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-core</artifactId>
    <version>1.2.1</version>
</dependency>

HBase可以自己安装,也可以直接使用工程的脚本(建议使用脚本):

Download & Start - Run quickstart/bin/start-hbase.sh

Initialize Tables - Run quickstart/bin/init-hbase.sh

部署Collector端:
将pinpoint-collector-1.5.1.war部署到你的web容器下,我的配置:/data3/tomcat8-Collector port:18080

部署Web UI端:
将pinpoint-web-1.5.1.war部署到你的web容器下,我的配置:/data3/tomcat8-Web port:28080

打开前端: http://10.210.228.50:28080

Application Performance Management工具之pinpoint_第3张图片

这时还没有被测试应用,本文以tomcat容器为例, 在bin/catalina.sh中添加:

#pinpoint agent路径
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/data1/hugang/pinpoint/pinpoint-agent-1.5.1/pinpoint-bootstrap-1.5.1.jar"
#被监控工程使用agent的标识号
CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.agentId=0000002"
#被监控工程名字
CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.applicationName=10.75.0.101_8086_自定义"

并且需修改pinpoint-agent的配置文件/data1/hugang/pinpoint/pinpoint-agent-1.5.1/pinpoint.config,指定pinpoint Collector的ip

profiler.collector.ip=10.210.228.50

启动被测试服务,访问该服务。

4.查看数据

这时查看Pinpoint web UI,左上下拉框选择你的应用:

4.1 trace 链路分析

圈中你想查看这次访问的链路信息,圈中右上访问时间散列图中的某个点(一个点代表一次访问)

Application Performance Management工具之pinpoint_第4张图片

Application Performance Management工具之pinpoint_第5张图片

4.2 性能数据

Application Performance Management工具之pinpoint_第6张图片

Application Performance Management工具之pinpoint_第7张图片

你可能感兴趣的:(性能,apm)