springboot real-time monitoring springboot-starter-actuator package

Real-time monitoring of java project many ways, this article is mainly about monitoring springboot framework.
springboot frame, carrying the monitoring actuator, the jar package can be incorporated in the pom, the following

1.引入jar
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Great changes after version 2.0, I used here is 2.0.2

2. Start to access the project
HTTP: // localhost: 8081 / WebProject / Actuator / Health
HTTP: // localhost: 8081 / WebProject / Actuator / info

If you want a personalized url that in application.propertie
added to the configuration file
management.endpoints.web.base-path = / jiankong
then you can visit
http: // localhost: 8081 / webproject / jiankong / health

3.actuator offers many api (known as: nodes)
by default only open health, info two nodes
if all you need to expose the configuration file to continue adding
management.endpoints.web.exposure.include = *
where health approach is not display of specific content, such as the need to
continue joining configuration
management.endpoint.health.show-details = always

Specific methods and return content can refer to the API
GET / autoconfig view usage automatically configured to true 
GET / configprops view the configuration properties, including the default configuration to true 
GET / Beans view a list of bean and its relationship to true 
GET / print thread stack dump to true 
GET / env View All environment variables to true 
GET / env / {name} view specific variable values to true 
GET / health Check application health indicators false 
GET / info view information about false 
GET / mappings View all url mapped to true 
GET / metrics view the application of basic indicators to true 
GET / metrics / {name} view specific targets true 
the POST / closing the shutdown applications true 
the GET / view the trace substantially true tracking information 

4. Common methods specific indicators of view / metrics / {name}
HTTP: // localhost: 8081 / WebProject / Actuator / metrics / http.server.requests
HTTP: // localhost: 8081 / WebProject / Actuator / metrics / JVM. memory.used
HTTP: // localhost: 8081 / WebProject / Actuator / metrics / jvm.threads.peak


And the like, specifically by name / metrics obtained,
wherein http.server.requests url is monitored all the requests, the number, time and the like.
So if we need to monitor for individual focus controller, respectively, it ~ ~

5. monitoring respectively, the controller needs to do something in
the above comment on RequestMapping @Timed (value = "list.base", = longTask to true)
value can be used on this mapping.
This @Timed annotations are micrometer-core-1.0.3-sources.jar the springboot used to monitor itself.
When visited the controller can call attention ~ have not received the request if the request is less than the list.base of
http: // localhost: 8081 / webproject / actuator / metrics / list.base

{
    "availableTags":[
        {
            "tag":"exception",
            "values":["None"]
        },
        {
            "tag":"method",
            "values":["POST"]
        },
        {
            "tag":"uri",
            "values":["/ListDataBase","root"]
        },
        {
            "tag":"status",
            "values":["200"]
        }
    ],
    "measurements":[
        {
            "statistic":"ACTIVE_TASKS",
            "value":0
        },
        {
            "statistic":"DURATION",
            "value":0
        },
        {
            "statistic":"COUNT",
            "value":1
        },
        {
            "statistic":"TOTAL_TIME",
            "value":0.306317164
        },
        {
            "statistic":"MAX",
            "value":0.306317164
        }
    ],
    "name":"list.base"
}

If you are interested in more research. . . Official website API
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-endpoints

Guess you like

Origin www.cnblogs.com/jpfss/p/11936048.html