Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Actuator components in SpringBoot to realize system Monitoring

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how SpringBoot configures Actuator components to achieve system monitoring". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to configure Actuator components for SpringBoot to achieve system monitoring" can help you solve the problem.

A brief introduction to Actuator

Monitoring classification

Actuator provides Rest interface to display monitoring information.

Interfaces are divided into three categories:

Application configuration class: get application configuration, environment variables, automation configuration reports and other configuration class information related to SpringBoot applications loaded in the application.

Metrics class: get the metrics used for monitoring during the running of the application, such as memory information, thread pool information, HTTP request statistics, etc.

Operation control class: provides operation class functions such as closing the application.

II. Integration with SpringBoot2.0

1. The core relies on Jar package org.springframework.boot spring-boot-starter-actuator2, Yml configuration file # Port server: port: 8016spring: application: # Application name name: node16-boot-actuatormanagement: endpoints: web: exposure: # Open all monitoring points include: "*" # Custom monitoring path monitor # default: http://localhost:8016/actuator/* # after configuration: http://localhost : 8016 app monitorUniverse * base-path: / monitor endpoint: health: show-details: always shutdown: # disable SpringBoot enabled: true through the specified interface # you can customize the port # server: # port: 808 describe the basic information of the project info: app: name: node16-boot-actuator port: 8016 version: 1.0.0 author: cicada Detailed explanation of monitoring interface

1. Info interface

Basic project information configured in the Yml file

Path: http://localhost:8016/monitor/info output: {"app": {"name": "node16-boot-actuator", "port": 8016, "version": "1.0.0", "author": "cicada"} 2, Health interface

Health is mainly used to check the running status of applications.

Path: http://localhost:8016/monitor/health output: {"status": "UP", "details": {"diskSpace": {"status": "UP", "details": {"total": 185496236032, "free": 140944084992 "threshold": 10485760} 3, Beans interface

Shows the type of bean, singleton multiple instances, aliases, full path of the class, dependency Jar, and so on.

Path: http://localhost:8016/monitor/beans output: {"contexts": {"node16-boot-actuator": {"beans": {"endpointCachingOperationInvokerAdvisor": {"aliases": [], "scope": "singleton", "type": "org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor" "resource": "class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.class]", "dependencies": ["environment"]} 4, Conditions interface

See under what conditions the configuration is valid, or why the automatic configuration is invalid.

Path: http://localhost:8016/monitor/conditions output: {"contexts": {"node16-boot-actuator": {"positiveMatches": {"AuditAutoConfiguration#auditListener": [{"condition": "OnBeanCondition", "message": "@ ConditionalOnMissingBean"}],}} 5, HeapDump API

Automatically generate a heap dump file HeapDump for Jvm, which can be opened using the monitoring tool VisualVM to view memory snapshots.

Path: http://localhost:8016/monitor/heapdump6, Mappings API

Describe the mapping relationship between URI path and controller

Path: http://localhost:8016/monitor/mappings output: {"contexts": {"node16-boot-actuator": {"mappings": {"dispatcherServlets": {"dispatcherServlet": [{"handler": "Actuator web endpoint 'auditevents'" "predicate": "{GET / monitor/auditevents | | application/json]}" Details: {"handlerMethod": {"className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.Operat" name ":" handle " "descriptor": "Ljavax/servlet/http/HttpServletRequest Ljava/util/Map;) Ljava/lang/Object "}," requestMappingConditions ": {" consumes ": []," headers ": []," methods ": [" GET "] "params": [], "patterns": ["/ monitor/auditevents"], "produces": [{"mediaType": "application/vnd.spring-boot.actuator.v2+json" "negated": false}, {"mediaType": "application/json" "negated": false}]} 7, ThreadDump interface

Show the thread name, thread ID, whether to wait for the lock, thread status, thread lock and other related information.

Path: http://localhost:8016/monitor/threaddump output: {"threads": [{"threadName": "DestroyJavaVM", "threadId": 34, "blockedTime":-1, "blockedCount": 0, "waitedTime":-1, "waitedCount": 0, "lockName": null, "lockOwnerId":-1, "lockOwnerName": null "inNative": false, "suspended": false, "threadState": "RUNNABLE", "stackTrace": [], "lockedMonitors": [], "lockedSynchronizers": [], "lockInfo": null}]} 8, ShutDown interface

Gracefully close the Spring Boot application. Only POST requests are supported by default.

Path: http://localhost:8016/monitor/shutdown 's content on "how to configure Actuator components for system monitoring in SpringBoot" ends here. Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report