码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot学习之SpringBoot执行器

时间:2017-12-20 22:03:49      阅读:428      评论:0      收藏:0      [点我收藏+]

标签:content   height   端口   gif   heap dump   使用   shu   port   file   

    在以往的分布式开发当中,各个服务节点的监控必不可少。监控包含有很多方面,比如说:内存占用情况,节点是否健康等。在spring-boot会给我们提供相关资源监控叫做spring-boot-actuator通过执行器可以帮我管理和监控生产环境下的应用服务。

 一。添加SpringBoot执行器的依赖

   添加gradle配置依赖:

技术分享图片
dependencies {
    compile(‘org.springframework.boot:spring-boot-starter-actuator‘)
}
View Code

 

 二。关于SpringBoot的端点

   端点:可用于监控应用与应用进行交互,springboot包含很多内置内置端点。tips:参考官网的

IDDescriptionSensitive Default

actuator

Provides a hypermedia-based “discovery page” for the other endpoints. Requires Spring HATEOAS to be on the classpath.

true

auditevents

Exposes audit events information for the current application.

true

autoconfig

Displays an auto-configuration report showing all auto-configuration candidates and the reason why they ‘were’ or ‘were not’ applied.

true

beans

Displays a complete list of all the Spring beans in your application.

true

configprops

Displays a collated list of all @ConfigurationProperties.

true

dump

Performs a thread dump.

true

env

Exposes properties from Spring’s ConfigurableEnvironment.

true

flyway

Shows any Flyway database migrations that have been applied.

true

health

Shows application health information (when the application is secure, a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated).

false

info

Displays arbitrary application info.

false

loggers

Shows and modifies the configuration of loggers in the application.

true

liquibase

Shows any Liquibase database migrations that have been applied.

true

metrics

Shows ‘metrics’ information for the current application.

true

mappings

Displays a collated list of all @RequestMapping paths.

true

shutdown

Allows the application to be gracefully shutdown (not enabled by default).

true

trace

Displays trace information (by default the last 100 HTTP requests).

true

如果使用spring-mvc时,我们可以访问以下节点:

IDDescriptionSensitive Default

docs

Displays documentation, including example requests and responses, for the Actuator’s endpoints. Requires spring-boot-actuator-docs to be on the classpath.

false

heapdump

Returns a GZip compressed hprof heap dump file.

true

jolokia

Exposes JMX beans over HTTP (when Jolokia is on the classpath).

true

logfile

Returns the contents of the logfile (if logging.file or logging.path properties have been set). Supports the use of the HTTP Range header to retrieve part of the log file’s content.

true

有几点要补充说明一下:

  1).如果需要访问health端点,那么请在映射中访问http://xxxxx:xxxx/health.

      2) 并不是所有端点都可以访问,在上述表格中如果Sensitive(是否敏感)的值如果为true,则访问会报401错误,不过好在在spring-boot配置文件中可以设置相关端点的敏感值,比如说:endpoints.env.sensitive=false

  3) 关于保护敏感端点,首先我们要添加对spring-security的依赖,并设置进行安全验证的用户名,密码以及角色,如果不使用spring-security就要慎重考虑暴露端口的端点了

    

技术分享图片
security.user.name=xxxx
security.user.password=xxxx
management.security.role=xxxx
View Code

SpringBoot学习之SpringBoot执行器

标签:content   height   端口   gif   heap dump   使用   shu   port   file   

原文地址:http://www.cnblogs.com/niechen/p/8072722.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!