zoukankan      html  css  js  c++  java
  • 【SpringBoot/Actuator】给SpringBoot程序添加Actuator监控管理

    注意:本例针对SpringBoot v2.5.4版本写成,不保证在其它版本的效果。

    例程:

     https://files.cnblogs.com/files/heyang78/redisCache_actuator_210925.rar

    给应用程序添加Actuator的支持不难,只要遵循以下步骤:

    1.在pom.xml中添加对Actuator的支持

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>

    2.在appication.yml中开启Actuator端点

    #application.yml
    server:
        servlet: 
            context-path: /myapp
    management: 
        endpoints: 
            web: 
                exposure: 
                    include: '*'
    spring:
        profiles:
            active: dev

    注意,上面我设置app的上下文路径是/myapp,那么Actuator的地址就是http://localhost:port/myapp/actuator/healt或info或matrics之类,总之记住context-path在app路径及actuator路径之上就好。Actuator是可以设置自己的根路径和端口的,如果不设,它会和控制器共享同样的根路径和端口。

    3.启动application,在控制台能发现actutor已经被激活了。

    2021-09-25 14:29:19.536  ...: Root WebApplicationContext: initialization completed in 2399 ms
    2021-09-25 14:29:20.662  ...: Exposing 13 endpoint(s) beneath base path '/actuator'
    2021-09-25 14:29:20.767  ... : Tomcat started on port(s): 8080 (http) with context path '/myapp'

    4.在浏览器地址栏输入http://localhost:8080/myapp/actuator/health,出现以下画面就对了。

     

    END

  • 相关阅读:
    1265 四点共面
    1003 阶乘后面0的数量
    1080 两个数的平方和
    1090 3个数和为0
    1087 1 10 100 1000
    1082 与7无关的数
    OpenLayers工作原理
    CI(持续集成)CD(持续交付)
    打包命令
    文件与目录管理重点
  • 原文地址:https://www.cnblogs.com/heyang78/p/15334402.html
Copyright © 2011-2022 走看看