img

MyPerf4J做接口监控以及可视化

旁观者 1年前 ⋅ 1560 阅读

一.使用MyPerf4J

1.下载MyPerf4J-ASM解压

下载地址:https://github.com/LinShunKang/Objects/tree/master/zips

2.修改MyPerf4J.properties

#应用名称
AppName=Application

#MetricsProcessor类型
#0:以标准格式化结构输出到stdout.log 
#1:以标准格式化结构输出到磁盘
#2:以InfluxDB LineProtocol格式输出到磁盘
MetricsProcessorType=2

#配置各个Metrics 日志的文件路径,可配置成相同路径
MethodMetricsFile=/home/tax/logs/MyPerf4J/method_metrics.log
ClassMetricsFile=/home/tax/logs/MyPerf4J/class_metrics.log
GCMetricsFile=/home/tax/logs/MyPerf4J/gc_metrics.log
MemMetricsFile=/home/tax/logs/MyPerf4J/memory_metrics.log
BufPoolMetricsFile=/home/tax/logs/MyPerf4J/buf_pool_metrics
ThreadMetricsFile=/home/tax/logs/MyPerf4J/thread_metrics.log
FileDescMetricsFile=/home/tax/logs/MyPerf4J/file_desc_metrics.log
CompilationMetricsFile=/home/tax/logs/MyPerf4J/compilation_metrics.log

#配置方法指标的采集周期,单位为ms,最小1s,最大600s
MethodMilliTimeSlice=10000

#配置 JVM 指标的采集周期,单位为ms,最小1s,最大600s
JvmMilliTimeSlice=1000

#需要监控的package,可配置多个,用英文';'分隔
IncludePackages=com.zhijiu.taxmodule.controller

#是否展示方法参数类型
ShowMethodParams=true

3.接入使用

-javaagent:/{path}/MyPerf4J-ASM-2.10.0.jar -DMyPerf4JPropFile=/{path}/MyPerf4J.properties

二.可视化

1.安装influxdb

a.新建/etc/yum.repos.d/influxdb.repo

[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key

b.yum install influxdb

c.vim /etc/profile

 export INFLUXDB_CONFIG_PATH=/etc/influxdb/influxdb.conf

d.端口修改vim /etc/influxdb/influxdb.conf

e.启动

2.安装telegraf

a. 修改配置vim /etc/telegraf/telegraf.conf

logfile = "/var/log/telegraf/telegraf.log"

[[outputs.influxdb]]

[[inputs.tail]]

b.启动

3.安装Grafana

a.新建/etc/yum.repos.d/grafana.repo

[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

b.yum install grafana

c.启动:

systemctl daemon-reload

service grafana-server start

d.访问地址:

http://ip:3000 

admin/admin

e.添加DB

f.添加JVM -> 8787

g.添加Method ->7766

注意事项:

1.DB的database对应

2.Grafana配置

参考MyPerf4J安装配置及可视化页面


全部评论: 0

    我有话说: