springboot2.x简单详细教程--高级篇幅之监控Actuator实战(第十八章)

一、SpringBoot2.x监控Actuator实战上集


    简介:讲解SpringBoot使用actuator监控配置和使用

    可用性:100%,99.9%

    1、介绍什么是actuator
        官方介绍:
            Spring Boot包含许多附加功能,可帮助您在将应用程序投入生产时监视和管理应用程序。 可   以选择使用HTTP端点或JMX来管理和监控您的应用程序,自动应用于审计,健康和指标收集;

        一句话:springboot提供用于监控和管理生产环境的模块(监控系统各种变化
        官方文档:https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/#production-ready
    2、加入依赖
        

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

    3、加入上述依赖后,访问几个url

   启动工程已经有映射的路径


  1)   /actuator/health :可以通过定时器访问这个路径,以监控系统状态


      2)


  3)

 http://localhost:8080/actuator

监控服务流程

二、SpringBoot2.x监控Actuator实战下集及生产环境建议(核心知识)


    简介:SpringBoot2.x监控Actuator实战下集及生产环境建议,SpringBoot新旧版本区别

    注意点: 网上的资料大多数没有讲到访问的前缀
    端点基础路径由 / 调整到 /actuator
            如:/info调整为/actuator/info 
                /actuator/xxx

1)旧版可以访问

    2)springboot新版需要加actuator的前缀

1、只能访问几个url

分析权限不够,需要配置获得更多权限

问题
        1)需要在配置文件中加入下列配置
            management.endpoints.web.exposure.include=*

启动工程

        2)官网说明:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-security-actuator
        
            原因:
                出于安全考虑除/ health和/ info之外的所有执行器默认都是禁用的。 management.endpoints.web.exposure.include属性可用于启用执行器
    2、建议
        在设置management.endpoints.web.exposure.include之前,请确保暴露的执行器不包含敏感信息和/
        或通过将其放置在防火墙进行控制,不对外进行使用

        禁用的端点将从应用程序上下文中完全删除。如果您只想更改端点所暴露的技术,请改用 include和exclude属性 。
        例子:
            开启全部:management.endpoints.web.exposure.include=*
            开启某个:management.endpoints.web.exposure.include=metrics
            关闭某个:management.endpoints.web.exposure.exclude=metrics

        或者用springadmin进行管理:客户端
            相关资料:https://www.cnblogs.com/ityouknow/p/8440455.html

        或者用自己编写脚本监控
        CPU、内存、磁盘、nginx的http响应状态码200,  404,  5xx 

         根据状态码数量报警等

    3、介绍常用的几个
        /health     查看应用健康指标
        /actuator/metrics    查看应用基本指标列表


        /actuator/metrics/{name}        通过上述列表,查看具体 查看具体指标


        /actuator/env        显示来自Spring的 ConfigurableEnvironment的属性    

猜你喜欢

转载自blog.csdn.net/jianchilu/article/details/84174192
今日推荐