Actuator

1、添加Actuator监控

pom

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.gcz</groupId>
    <artifactId>monitorTest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- springboot应用 -->
    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.3.0.RELEASE</version>
    </parent>

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

        <!-- 使用热部署 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- hibernate验证框架 -->
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.0.17.Final</version>
            <scope>compile</scope>
        </dependency>

        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!-- hutool -->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.5.9</version>
        </dependency>

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

    <!-- 指定springboot仓库位置 -->
    <repositories>
        <repository>
            <id>milestones</id>
            <name>Spring Milestones</name>
            <url>http://code.yhsperp.com:8081/nexus/repository/maven-public/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>
复制代码

2、properties

复制代码
#actuator管理端口

management.server.port=8888

#修改访问根路径  2.0之前默认是/   2.0默认是 /actuator  可以通过这个属性值修改

management.endpoints.web.base-path=/monitor

#开放所有节点  默认只开启了health、info两个节点

management.endpoints.web.exposure.include=*

#显示健康具体信息  默认不会显示详细信息

management.endpoint.health.show-details=always

#通过接口控制应用关闭
management.endpoint.shutdown.enabled=true
复制代码

3、特殊访问路径

/monitor

复制代码
{
    "_links": {
        "self": {
            "href": "http://127.0.0.1:8888/monitor",
            "templated": false
        },
        "beans": {
            "href": "http://127.0.0.1:8888/monitor/beans",
            "templated": false
        },
        "caches-cache": {
            "href": "http://127.0.0.1:8888/monitor/caches/{cache}",
            "templated": true
        },
        "caches": {
            "href": "http://127.0.0.1:8888/monitor/caches",
            "templated": false
        },
        "health": {
            "href": "http://127.0.0.1:8888/monitor/health",
            "templated": false
        },
        "health-path": {
            "href": "http://127.0.0.1:8888/monitor/health/{*path}",
            "templated": true
        },
        "info": {
            "href": "http://127.0.0.1:8888/monitor/info",
            "templated": false
        },
        "conditions": {
            "href": "http://127.0.0.1:8888/monitor/conditions",
            "templated": false
        },
        "shutdown": {
            "href": "http://127.0.0.1:8888/monitor/shutdown",
            "templated": false
        },
        "configprops": {
            "href": "http://127.0.0.1:8888/monitor/configprops",
            "templated": false
        },
        "env": {
            "href": "http://127.0.0.1:8888/monitor/env",
            "templated": false
        },
        "env-toMatch": {
            "href": "http://127.0.0.1:8888/monitor/env/{toMatch}",
            "templated": true
        },
        "loggers": {
            "href": "http://127.0.0.1:8888/monitor/loggers",
            "templated": false
        },
        "loggers-name": {
            "href": "http://127.0.0.1:8888/monitor/loggers/{name}",
            "templated": true
        },
        "heapdump": {
            "href": "http://127.0.0.1:8888/monitor/heapdump",
            "templated": false
        },
        "threaddump": {
            "href": "http://127.0.0.1:8888/monitor/threaddump",
            "templated": false
        },
        "metrics": {
            "href": "http://127.0.0.1:8888/monitor/metrics",
            "templated": false
        },
        "metrics-requiredMetricName": {
            "href": "http://127.0.0.1:8888/monitor/metrics/{requiredMetricName}",
            "templated": true
        },
        "scheduledtasks": {
            "href": "http://127.0.0.1:8888/monitor/scheduledtasks",
            "templated": false
        },
        "mappings": {
            "href": "http://127.0.0.1:8888/monitor/mappings",
            "templated": false
        }
    }
}
复制代码

 

posted @   幻影黑子  阅读(232)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示