springboot2.0集成javamelody應用監測

javamelody是一款監測java應用,支持獲取如cpu,內存,線程數,http訪問,sql等數據。css

支持metrics,提供接口供其餘第三方抓取。java

1.官方提供了springboot2.0的集成方案。git

pom文件增長以下依賴github

<dependency>
    <groupId>net.bull.javamelody</groupId>
    <artifactId>javamelody-spring-boot-starter</artifactId>
    <version>1.74.0</version>
</dependency>

2.經過其餘方式集成web

pom文件增長以下依賴spring

<!-- javamelody-core -->
<dependency>
	<groupId>net.bull.javamelody</groupId>
	<artifactId>javamelody-core</artifactId>
	<version>1.74.0</version>
</dependency>

新增以下類sql

https://github.com/javamelody/javamelody/blob/without-spring-boot-starter/javamelody-for-spring-boot/src/main/java/hello/JavaMelodyConfiguration.javaspringboot

 

以後訪問地址:http://127.0.0.1:8080/monitoring便可ide

如需個性化配置spring-boot

# 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

相關文章
相關標籤/搜索