spring项目健康检查

Actuator使用

maven依赖包

    org.springframework.boot
    spring-boot-starter-actuator

配置文件
management:
  endpoints:
    web:
      exposure:
        include: "*"
  server:
    port: 8080
    servlet:
      context-path: /
    ssl:
      enabled: false
  endpoint:
    health:
      show-details: always

“*”号代表启用所有的监控端点,可以单独启用,例如,health,info,metrics等。
“always”代表显示健康检查的详细信息。

启动并访问链接

http://xxxx/actuator

image.png

{
    "_links": {
        "self": {
            "href": "http://127.0.0.1:8111/actuator",
            "templated": false
        },
        "dubbo": {
            "href": "http://127.0.0.1:8111/actuator/dubbo",
            "templated": false
        },
        "dubbo-configs": {
            "href": "http://127.0.0.1:8111/actuator/dubbo/configs",
            "templated": false
        },
        "dubbo-properties": {
            "href": "http://127.0.0.1:8111/actuator/dubbo/properties",
            "templated": false
        },
        "auditevents": {
            "href": "http://127.0.0.1:8111/actuator/auditevents",
            "templated": false
        },
        "beans": {
            "href": "http://127.0.0.1:8111/actuator/beans",
            "templated": false
        },
        "health": {
            "href": "http://127.0.0.1:8111/actuator/health",
            "templated": false
        },
        "conditions": {
            "href": "http://127.0.0.1:8111/actuator/conditions",
            "templated": false
        },
        "configprops": {
            "href": "http://127.0.0.1:8111/actuator/configprops",
            "templated": false
        },
        "env": {
            "href": "http://127.0.0.1:8111/actuator/env",
            "templated": false
        },
        "env-toMatch": {
            "href": "http://127.0.0.1:8111/actuator/env/{toMatch}",
            "templated": true
        },
        "info": {
            "href": "http://127.0.0.1:8111/actuator/info",
            "templated": false
        },
        "loggers": {
            "href": "http://127.0.0.1:8111/actuator/loggers",
            "templated": false
        },
        "loggers-name": {
            "href": "http://127.0.0.1:8111/actuator/loggers/{name}",
            "templated": true
        },
        "heapdump": {
            "href": "http://127.0.0.1:8111/actuator/heapdump",
            "templated": false
        },
        "threaddump": {
            "href": "http://127.0.0.1:8111/actuator/threaddump",
            "templated": false
        },
        "metrics-requiredMetricName": {
            "href": "http://127.0.0.1:8111/actuator/metrics/{requiredMetricName}",
            "templated": true
        },
        "metrics": {
            "href": "http://127.0.0.1:8111/actuator/metrics",
            "templated": false
        },
        "scheduledtasks": {
            "href": "http://127.0.0.1:8111/actuator/scheduledtasks",
            "templated": false
        },
        "httptrace": {
            "href": "http://127.0.0.1:8111/actuator/httptrace",
            "templated": false
        },
        "mappings": {
            "href": "http://127.0.0.1:8111/actuator/mappings",
            "templated": false
        }
    }
}

/actuator/health用于查看状态

{
    "status": "UP",
    "details": {
        "dubbo": {
            "status": "UNKNOWN",
            "details": {
                "memory": {
                    "source": "management.health.dubbo.status.defaults",
                    "status": {
                        "level": "OK",
                        "message": "max:3618M,total:633M,used:391M,free:242M",
                        "description": null
                    }
                },
                "load": {
                    "source": "management.health.dubbo.status.defaults",
                    "status": {
                        "level": "UNKNOWN",
                        "message": "cpu:8",
                        "description": null
                    }
                }
            }
        },
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 148671901696,
                "free": 94233509888,
                "threshold": 10485760
            }
        },
        "mongo": {
            "status": "UP",
            "details": {
                "version": "4.0.9"
            }
        },
        "db": {
            "status": "UP",
            "details": {
                "database": "MySQL",
                "hello": 1
            }
        },
        "redis": {
            "status": "UP",
            "details": {
                "version": "4.0.14"
            }
        }
    }
}

/actuator/dubbo/properties用于查看dubbo具体配置信息

{
    "dubbo.application.name": "dra-service",
    "dubbo.protocol.name": "dubbo",
    "dubbo.protocol.port": 20880,
    "dubbo.protocol.threadpool": "fixed",
    "dubbo.protocol.threads": 100,
    "dubbo.provider.timeout": 30000,
    "dubbo.provider.version": "1.0.0",
    "dubbo.registry.address": "10.155.203.180:2181",
    "dubbo.registry.protocol": "zookeeper",
    "dubbo.scan.basePackages": "com.dtdream.dra.dataservice.service.impl"
}

你可能感兴趣的:(spring项目健康检查)