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 @ 2021-07-12 11:44  幻影黑子  阅读(243)  评论(0)    收藏  举报