In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Section 2 (learn from me Spring Cloud (Finchley version)-02-Building distributed applications) said:
The app has no monitoring, no drawing board, and no indicators. In this era when Growth Hack is gradually becoming mainstream, how dare you come out and hang out without a Dashboard to visualize the system pressure, QPS, CPU, memory, and the number of daily active users?
In this section, we will solve this problem.
Spring Boot Actuator is an official monitoring component provided by Spring Boot. You can integrate Spring Boot Actuator simply by adding the following dependencies to the project.
Org.springframework.boot spring-boot-starter-actuator monitoring endpoint
Actuator provides us with a number of monitoring endpoints, as shown in the following table.
Endpoints (Spring Boot 2.x) describe whether HTTP methods are sensitive (Spring Boot 1.x) conditions display autoconfiguration information GET is autoconfigbeans display application context all Spring beanGET is beansconfigprops display all @ ConfigurationProperties configuration properties list GET is configpropsdump display thread activity snapshot GET is dumpenv display environment variables, including system environment variables and application environment variables GET is the health indicator of the envhealth display application, values are provided by the implementation class of HealthIndicator The results include UP, DOWN, OUT_OF_SERVICE and UNKNOWN;. If you want to view details, you need to configure: management.endpoint.health.show-detailsGET No healthinfo displays the information of the application. You can use the info.* attribute to customize the data exposed by the info endpoint GET No infomappings display all URL paths GET is mappingsmetrics display application metric information GET is metrics
Table-Spring Boot Actuator common endpoints and descriptions
Simply access the http://{ip}:{port}/actuator/{endpoint} endpoint to monitor the health of the application.
Test 1:/health Endpoint
After integrating Actuator for the microservice-simple-provider-user service written earlier, let's do some tests:
The following results can be obtained by visiting:
{"status": "UP"} Test 2:/health endpoint display details
Display details for the / health endpoint configuration:
Management: endpoint: health: # whether to show health check details show-details: always
If you visit again, you can get the following results:
{"status": "UP", "details": {"db": {"status": "UP", "details": {"database": "H2", "hello": 1}}, "diskSpace": {"status": "UP" "details": {"total": 250790436864, "free": 43443773440, "threshold": 10485760}
As you can see, the / health endpoint shows the health of the DB and the health of the disk.
Test 3: expose sensitive paths
By default, sensitive paths are not exposed. To expose (take metrics as an example), you need to add a configuration:
Management: endpoints: web: exposure: # expose metrics endpoints. To expose multiple endpoints, separate them with; to expose all endpoints, use'* 'include: metrics
Visit:, you can get results similar to the following
{"names": ["jvm.memory.max", "http.server.requests", "jdbc.connections.active", "process.files.max", "jvm.gc.memory.promoted", "tomcat.cache.hit", "system.load.average.1m", "tomcat.cache.access", "jvm.memory.used", "jvm.gc.max.data.size", "jdbc.connections.max", "jdbc.connections.min" "jvm.gc.pause", "jvm.memory.committed", "system.cpu.count", "logback.events", "tomcat.global.sent", "jvm.buffer.memory.used", "tomcat.sessions.created", "jvm.threads.daemon", "system.cpu.usage", "jvm.gc.memory.allocated", "tomcat.global.request.max", "hikaricp.connections.idle", "hikaricp.connections.pending", "tomcat.global.request" "tomcat.sessions.expired", "hikaricp.connections", "jvm.threads.live", "jvm.threads.peak", "tomcat.global.received", "hikaricp.connections.active", "hikaricp.connections.creation", "process.uptime", "tomcat.sessions.rejected", "process.cpu.usage", "tomcat.threads.config.max", "jvm.classes.loaded", "hikaricp.connections.max", "hikaricp.connections.min" "jvm.classes.unloaded", "tomcat.global.error", "tomcat.sessions.active.current", "tomcat.sessions.alive.max", "jvm.gc.live.data.size", "tomcat.servlet.request.max", "hikaricp.connections.usage", "tomcat.threads.current", "tomcat.servlet.request", "hikaricp.connections.timeout", "process.files.open", "jvm.buffer.count", "jvm.buffer.total.capacity" "tomcat.sessions.active.max", "hikaricp.connections.acquire", "tomcat.threads.busy", "process.start.time", "tomcat.servlet.error"]}
Visit the http://localhost:8000/actuator/metrics/{name}, {name} list as above to view the currently applied metrics. For example, access: you can view the maximum memory that can be managed by JVM. The result is similar to the following:
{"name": "jvm.memory.max", "description": "The maximum amount of memory in bytes that can be used for memory management", "baseUnit": "bytes", "measurements": [{"statistic": "VALUE", "value": 5.597298687 billion}], "availableTags": [{"tag": "area", "values": ["heap" "nonheap"]}, {"tag": "id", "values": ["Compressed Class Space", "PS Survivor Space", "PS Old Gen", "Metaspace", "PS Eden Space", "Code Cache"]}]} TIPS
To expose all monitoring endpoints can be configured:
Management:endpoints: web: exposure: include: for more information on the differences between Spring Boot 1.x and 2.x endpoints, see: expand Reading
If we can graphically display the text data of the Actuator endpoint, we can achieve a relatively low-level "Growth Hack"! There is already such a tool in the open source world, Spring Boot Admin, with the following interface. Those who are interested can go to learn about it.
Note that because Actuator itself is a component of Spring Boot, it is not the focus of this tutorial (in fact, the author does not want to write this section, but later will continue to use these endpoints, and Spring Cloud has also made some additions on the basis of these endpoints, so it is still necessary to introduce them), so this section only gives a relatively simple introduction to Actuator, and readers can tap the other capabilities of Actuator. Can also continue to follow this official account, after the completion of this series, the author will remove the underwear of Actuator, in-depth introduction of those things that Spring Boot monitoring. Matching code
GitHub:
Https://github.com/eacdy/spring-cloud-study/tree/master/2018-Finchley/microservice-simple-provider-userhttps://github.com/eacdy/spring-cloud-study/tree/master/2018-Finchley/microservice-simple-consumer-movie
Gitee:
Https://gitee.com/itmuch/spring-cloud-study/tree/master/2018-Finchley/microservice-simple-provider-userhttps://gitee.com/itmuch/spring-cloud-study/tree/master/2018-Finchley/microservice-simple-consumer-movie
Original: http://www.itmuch.com/spring-cloud/finchley-3/, reproduced, please state the source.
Practical information sharing
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.