javamelody是一款监测java应用,支持获取如cpu,内存,线程数,http访问,sql等数据。
支持metrics,提供接口供其他第三方抓取。
- Sending metrics to Graphite
- Sending metrics to InfluxDB
- Sending metrics to AWS CloudWatch
- Sending metrics to Datadog
- Sending metrics to StatsD
- Exposing metrics to Prometheus
- Exposing data as JMX MBeans
1.官方提供了springboot2.0的集成方案。
pom文件增加如下依赖
2.通过其他方式集成
pom文件增加如下依赖
新增如下类
之后访问地址:http://127.0.0.1:8080/monitoring即可
如需个性化配置
# Enable JavaMelody auto-configuration (optional, default: true) javamelody.enabled=true
Data source names to exclude from monitoring (optional, comma-separated)
javamelody.excluded-datasources=secretSource,topSecretSource
Enable monitoring of Spring services and controllers (optional, default: true)
javamelody.spring-monitoring-enabled=true
Initialization parameters for JavaMelody (optional)
See: https://github.com/javamelody/javamelody/wiki/UserGuide#6-optional-parameters
log http requests:
javamelody.init-parameters.log=true
to exclude images, css, fonts and js urls from the monitoring:
javamelody.init-parameters.url-exclude-pattern=(/webjars/.*|/css/.*|/images/.*|/fonts/.*|/js/.*)
to aggregate digits in http requests:
javamelody.init-parameters.http-transform-pattern: \d+
to add basic auth:
javamelody.init-parameters.authorized-users=admin:pwd
to change the default storage directory:
javamelody.init-parameters.storage-directory=/tmp/javamelody
to change the default "/monitoring" path:
javamelody.init-parameters.monitoring-path=/admin/performance
如图所示,可以查看cpu,内存等
http请求等
支持主动执行垃圾回收以及dump文件
参照:https://github.com/javamelody/javamelody/wiki/SpringBootStarter