CN113282466A - Processing method of monitoring data of restful style interface and related equipment - Google Patents
Processing method of monitoring data of restful style interface and related equipment Download PDFInfo
- Publication number
- CN113282466A CN113282466A CN202110691637.XA CN202110691637A CN113282466A CN 113282466 A CN113282466 A CN 113282466A CN 202110691637 A CN202110691637 A CN 202110691637A CN 113282466 A CN113282466 A CN 113282466A
- Authority
- CN
- China
- Prior art keywords
- request
- interceptor
- target data
- style interface
- micrometer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3089—Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Mathematical Physics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the invention provides a processing method and related equipment for monitoring data of a restful style interface, wherein the method comprises the following steps: generating a custom interceptor by using an interceptor adapter arranged in a Spring frame; after the user-defined interceptor is added into a Spring frame container configuration class, injecting a Micrometer dependence into the user-defined interceptor; intercepting a request through the custom interceptor and acquiring parameters carried by the request; determining a corresponding restful style interface according to the parameters carried by the request, wherein the parameters carried by the request comprise the unique identifier of the restful style interface corresponding to the request; and acquiring target data to be monitored of the corresponding restful style interface through the Micrometer. The method provided by the embodiment of the invention can acquire the monitoring data of the specific restful style interface.
Description
Technical Field
The invention relates to the technical field of data monitoring, in particular to a processing method of monitoring data of a restful style interface and related equipment.
Background
The front-end and back-end services typically use Promethus, which is an open source system monitoring system, to obtain monitoring data for the interfaces. Promethus generally obtains monitoring data of an interface by accessing a program interface, imports the obtained monitoring data into a visualization tool, and displays the required monitoring data of the interface through the visualization tool. Where an interface refers to a reference type that defines an agreement. The members of the interface may include methods, attributes, indexers, and events, among others.
Representational State Transfer (REST) refers to a set of architectural constraints and principles. The constraints and principles proposed by REST mainly include the following three points. First, everything on the network can be abstracted into resources. Second, each resource has a unique resource identifier, and operations on the resource do not change these identifiers. Third, all operations are stateless. The interface satisfying the above three constraints and principles is called a restful style interface, and may also be called a restful interface.
Generally, when a user makes a request, the requested information generally includes three parts, first, a request method, a Uniform Resource Identifier (URI), a protocol, and a version of the protocol. Second, a request header, where the request header contains a lot of useful information about the client environment and the request body. Third, the request body, wherein the request body may contain the query string information submitted by the client.
For the restful style interface, because the requested information specifies the corresponding restful style interface, Promethus can only obtain the monitoring data of the unified interface at the outermost layer, but cannot obtain the monitoring data of the specific restful style interface.
Disclosure of Invention
The embodiment of the invention aims to provide a processing method and related equipment for monitoring data of a restful style interface, so as to obtain the monitoring data of the specific restful style interface. The specific technical scheme is as follows:
in a first aspect of the present invention, a method for processing monitoring data of a restful style interface is provided, including:
generating a custom interceptor by using an interceptor adapter arranged in a Spring frame;
after the user-defined interceptor is added into a Spring frame container configuration class, injecting a Micrometer dependence into the user-defined interceptor;
intercepting a request through the custom interceptor and acquiring parameters carried by the request;
determining a corresponding restful style interface according to the parameters carried by the request, wherein the parameters carried by the request comprise the unique identifier of the restful style interface corresponding to the request;
and acquiring target data to be monitored of the corresponding restful style interface through the Micrometer.
In a second aspect of the present invention, there is also provided a device for processing monitoring data of a restful style interface, including:
the generating module is used for generating a custom interceptor by using an interceptor adapter built in a Spring frame;
the dependence injection module is used for injecting the Micrometer dependence into the user-defined interceptor after the user-defined interceptor is added into the Spring framework container configuration class;
the first acquisition module is used for intercepting a request through the custom interceptor and acquiring parameters carried by the request;
a determining module, configured to determine a corresponding restful style interface according to a parameter carried by the request, where the parameter carried by the request includes a unique identifier of the restful style interface corresponding to the request;
and the second acquisition module is used for acquiring the corresponding target data to be monitored of the restful style interface through the Micrometer.
In another aspect of the present invention, an electronic device is further provided, which includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the steps of executing the processing method of the monitoring data of the restful style interface when executing the program stored in the memory.
In another aspect of the present invention, there is also provided a computer-readable storage medium, which stores instructions that, when executed on a computer, cause the computer to execute the method for processing monitoring data of any of the restful-style interfaces described above.
In yet another aspect of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to execute the method for processing monitoring data of any of the restful-style interfaces described above.
The method for processing the monitoring data of the restful style interface provided by the embodiment of the invention firstly generates and configures the user-defined interceptor in the Spring frame. And then intercepting a request through the custom interceptor and acquiring parameters of the request to determine a specific restful style interface corresponding to the request. And finally, adding a section at the position where the custom interceptor intercepts the request, starting a surrounding notice, and acquiring data of the restful style interface corresponding to the request by depending on the Micrometer injected into the custom interceptor. In the method, the user-defined interceptor intercepts the request, and the specific restful style interface corresponding to the request can be determined according to the parameters of the request, so that the monitoring data of the specific restful style interface can be acquired.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a schematic flowchart of a method for processing monitoring data of a restful-style interface according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of an information processing apparatus according to an embodiment of the present invention;
fig. 3 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a method for processing monitoring data of a restful style interface, including:
102, after the user-defined interceptor is added into a Spring frame container configuration class, injecting a Micrometer dependence into the user-defined interceptor;
and 105, acquiring target data to be monitored of the corresponding restful style interface through the Micrometer.
It should be understood that the Spring framework is a lightweight Control Inversion (IoC) and cut-Oriented Programming (AOP) container framework. Since the Spring framework contains and manages the configuration and lifecycle of application objects, it can be considered a container in this sense. Meanwhile, the Spring framework can be used as a framework to configure and combine simple components into complex application. Thus, in some embodiments, the Spring frame may also be referred to as a Spring or Spring container. IoC is one technique that may facilitate loose coupling. After the IoC technique is applied, other objects on which an object depends are passed in a passive manner, rather than the object creating or finding a dependent object itself, i.e., rather than the object finding a dependency from a container, the container actively passes the dependency to the object without waiting for the object to request it at object initialization. AOP is a technology for realizing the unified maintenance of program functions through a precompilation mode and a dynamic agent during running. AOP can realize the dynamic and uniform addition of functions to programs without modifying source codes through a pre-compiling mode and running a dynamic proxy thereof. For better understanding of the AOP technology, the concepts of connection point (Joint point), point of tangency (Pointcut), notification (Advice), and tangent plane (Aspect) involved in AOP should be understood. The connection points are understood to be points defined in a program, and a connection point may be considered to represent the execution of a method. The tangent point can be understood as a group of the connection points, and a group of the connection points are combined through a logical relationship or are collected through a wildcard, a regular expression and the like. The notification may be understood as an operation to be specifically performed by the connection point defined in the tangent point, and the types of the notification include a pre-notification, a post-notification, a return notification, an exception notification, and a surround notification. The tangent plane may be considered a collection of the tangent points and the notifications.
It should be understood that different components can be customized according to the needs of the user to realize different functions, and the customized components are added to the Spring framework and are uniformly managed by the Spring framework. Interceptors are used in AOPs to intercept and then join certain operations before or after a certain method or field is accessed. After the interceptor receives the request, the interceptor will intercept or pass the request. The interceptor intercepting the request means that the interceptor adds some operations before or after the request is processed; the interceptor passing through the request means that the interceptor does not join certain operations before or after the request is processed, which will be processed directly by the processor.
In a specific implementation, the step 101 of generating the custom interceptor by using the interceptor adapter built in the Spring framework may be understood as generating a custom interceptor by inheriting the interceptor adapter. Wherein the interceptor adaptor is an abstract class in a Spring framework. The class is a base for realizing information packaging by object-oriented programming, and is a user-defined reference data type, also called class type. Each class contains a description of the data and a set of functions that operate on the data or pass messages. Abstract classes are often used to characterize abstract concepts derived from the analysis and design of problem areas, and are abstractions of a series of concrete concepts that look different but are essentially the same. Since the custom interceptor is inherited from the interceptor adapter, the custom interceptor has the properties and methods of the interceptor adapter. The interceptor adapter comprises a pre-processing method (PreHandle) and a post-processing method (AfterCompletion), wherein the pre-processing method is called before the request is processed; the post-processing method is invoked after the request is processed. It should be understood that the pre-processing method and the post-processing method herein define the timing of the method call, and the corresponding specific operation of the method may be redefined according to the requirement. The custom interceptor inherits the pre-processing method and the post-processing method, and can rewrite the pre-processing method and the post-processing method according to requirements to realize the required functions.
It should be understood that after the custom interceptor is generated, in order to make the custom interceptor effective, the custom interceptor needs to be configured into a Spring framework configuration class. In a specific implementation, the adding the custom interceptor into the Spring framework container configuration class in step 102 may be understood as first generating a custom container configuration class, where the container configuration class may be understood as a class for adding components into a Spring container. And then, a WebMvcConfigurer interface is realized in a self-defined container configuration class, wherein the WebMvcConfigurer interface is a configuration mode in a Spring framework and is personalized and customized for the framework in a JavaBean form. Since the webmvcconfigurrer interface includes a method for adding an interceptor, the custom interceptor can be added to the Spring framework configuration class by implementing the method for adding an interceptor in the interface. It should be noted that, as can be seen from the definition of the interface, the members of the interface usually include methods, that is, the interface itself defines methods, but the interface cannot implement the methods, and needs to implement the methods of the interface by classes. Therefore, with the above configuration, the custom interceptor can be added into the Spring framework, so that the custom interceptor can introduce the object of Spring, and at this time, the custom interceptor can be considered to be effective.
It should be understood that the dependency injection can be considered as a specific implementation of the IoC technology, and refers to a Spring container dynamically injecting some dependency into an object during operation. In a specific implementation, the injecting the Micrometer dependency into the custom interceptor in step 102 may be understood that the custom interceptor needs to rely on the Micrometer to obtain target data to be monitored, and in order to implement the Micrometer in the custom interceptor, the Micrometer needs to be injected into the custom interceptor, so that the custom interceptor may invoke the Micrometer. In the process of injecting the Micrometer dependence into the custom interceptor, the Micrometer is initialized at the same time. It should be noted that the Micrometer is a measurement class library of monitoring indexes in a Spring framework, and can be used for acquiring and storing data of each monitoring index.
It should be understood that after steps 102 and 103 are performed, the custom interceptor is configured in the Spring framework. The following three situations can be realized by configuring the custom interceptor: in the first case, any request passes through the custom interceptor before being processed. In the second case, any request is processed through the custom interceptor. In a third case, either request passes through the custom interceptor both before and after being processed.
When a request enters the interceptor, the interceptor compares the path of the request with a preset path, and judges whether to intercept or release the request according to the comparison. Generally, the interception of a request by an interceptor is classified into the following three cases. In the first case the interceptor intercepts all requests. In the second case, the path preset in the interceptor is a released path, and in the case that the requested path belongs to said released path, the interceptor will release the request. In a third case, the path preset in the interceptor is an intercepted path, and in case that the path of the request belongs to the intercepted path, the interceptor will intercept the request. It should be noted that the path preset by the interceptor may include both an intercepted path and a released path, and the interceptor may be controlled to intercept only the request to be intercepted and/or release the request to be released by configuring the intercepted path and/or the released path corresponding to the interceptor.
For the custom interceptor, a user can define a path preset by the custom interceptor in the process of generating and configuring the custom interceptor according to requirements, so that the interceptor intercepts a corresponding request. When the custom interceptor intercepts the request, the custom interceptor will add a section for the request and the response at the position of intercepting the request and open the surrounding notice. Wherein the surround notification may be understood as a notification performed both before the connection point is made and after the connection point exits. After the user-defined request is intercepted, the pre-processing method can be called in the user-defined interceptor, at the moment, the pre-processing method is rewritten, and the operation of acquiring the parameters carried by the request can be executed by calling the pre-processing method.
According to the constraint conditions and principles proposed by REST, each resource has a unique resource identifier. Therefore, in order to locate the resource corresponding to the request, the unique resource identifier needs to be extracted from the parameter carried by the request, and the restful style interface corresponding to the request is determined through the unique resource identifier. The unique identifier refers to the unique Resource identifier, and the unique Resource identifier generally refers to a Uniform Resource Locator (URL), where the URL may be regarded as a subset of the URI, so that the URL may be obtained from the parameter carried by the request. And determining a specific restful style interface corresponding to the request according to the acquired URL, so that the restful style interface data corresponding to the request can be monitored.
It should be understood that the Micrometer is a measure class library of monitoring metrics. Specifically, the Micrometer includes a Meter and a meterregistration. The Meter is an interface for collecting a series of indicators about an application, and commonly used meters include a Timer (Timer), a Meter value (Gauge), a Counter (Counter), and the like. Wherein the timer is typically used to measure the distribution of execution times of code blocks of a short time; the meter value is generally used for recording a numerical value which can be changed instantly, such as CPU utilization rate, memory utilization rate and the like; the counter is generally used to obtain an index of the number of requests of the service, and the like, which is not decreased, and the counter only allows the data to be incremented by a fixed value. It should be noted that the above is an example of a commonly used Meter, the type of the Meter is not limited herein, and the data can be obtained by using the corresponding Meter according to different types of target data to be monitored. The meterregistration is generally used for creating a Meter and storing data collected by the Meter, and the meterregistration stores all data acquired by all meters. The acquisition of the target data to be monitored can therefore be considered to be carried out by meterregistration.
Since the Micrometer dependency is injected into the custom interceptor in the step 102, the custom interceptor can directly obtain the target data to be monitored of the corresponding restful style interface through the Micrometer.
In specific implementation, the step 101 and the step 102 are pre-configured for the Spring frame, the user-defined interceptor can be generated and configured in the Spring frame by executing the step 101 and the step 102, and each parameter of the user-defined interceptor is defined in the generating and configuring process, and corresponding operation can be executed according to requirements. After completing the steps 101 and 102, the custom interceptor can perform the steps 103, 104 and 105, thereby continuously intercepting the corresponding request while the system is running. Because the interfaces of the specific restful styles corresponding to different requests can be different, the custom interceptor can correspond to the interfaces of the different specific restful styles when intercepting different requests, and therefore the custom interceptor can acquire the monitoring data of the interfaces of the specific restful styles, and monitoring of the data of the interfaces of the specific restful styles is achieved.
The method for processing the monitoring data of the restful style interface provided by the embodiment of the invention firstly generates and configures the user-defined interceptor in the Spring frame. And then intercepting a request through the custom interceptor and acquiring parameters of the request to determine a specific restful style interface corresponding to the request. And finally, adding a section at the position where the custom interceptor intercepts the request, starting a surrounding notice, and acquiring data of the restful style interface corresponding to the request by depending on the Micrometer injected into the custom interceptor. In the method, the user-defined interceptor intercepts the request, and the specific restful style interface corresponding to the request can be determined according to the parameters of the request, so that the monitoring data of the specific restful style interface can be acquired.
Optionally, the step of obtaining target data to be monitored of the restful style interface through the Micrometer includes:
acquiring first target data of the restful style interface through the Micrometer before the request is processed;
acquiring second target data of the restful style interface through the Micrometer after the request is processed;
analyzing the first target data and the second target data to obtain the target data;
and recording the target data into the Micrometer.
It should be understood that the target data to be monitored includes at least one of: interface call times, interface response status codes, interface response times, request Uniform Resource Locators (URLs), and request types. It should be understood that the timing of acquiring data varies according to the type of target data to be monitored. Therefore, it is necessary to intercept the request and obtain the relevant data through the micro meter before and/or after the request is processed. For example, in the first case, the target data to be monitored includes the number of interface calls, and in order to obtain the number of interface calls, it is necessary to start an initial value of the number of calls by the counter before the request is processed, and continuously record the number of interface calls. In the second case, the target data to be monitored includes an interface response status code, and the interface response status code is generated after the request is processed, so that the request needs to be intercepted and the interface response status code needs to be acquired after the request is processed. In a third case, the target data to be monitored includes interface response time, and in order to obtain the interface response time, a timer in the micro meter needs to be started for starting timing before the request is processed, and the timing is finished after the request is processed, and corresponding data is obtained.
Generally, various target data of the interface are monitored in order to comprehensively grasp the operation condition of the interface. Therefore, it is necessary to obtain the data of the restful style interface, i.e. the first target data, through the Micrometer before processing the request, and obtain the data of the restful style interface, i.e. the second target data, through the Micrometer after processing the request.
It should be understood that although the first target data and the second target data acquired by Meter are stored in MeterRegistry, at this time only the corresponding values of all acquired data are stored in MeterRegistry, and the data itself is meaningless. Therefore, the data stored in meterregistration needs to be extracted as the data to be monitored by analyzing the first target data and the second target data. In one case, for example, when the data to be monitored is an interface response status code or a request type, the target data can be obtained only by extracting the data to be monitored from the first target data and the second target data and associating the data with the corresponding data type. In another case, for example, when the data to be monitored is interface call times or interface response time, the first target data and the second target data need to be analyzed to obtain corresponding data, and the obtained data is associated with a corresponding data type to obtain the target data.
It should be understood that entering the target data into the Micrometer means that the data stored in meterregistration has been extracted as the target data in the last step, and at this time, the extracted target data needs to be entered and stored in meterregistration.
In this embodiment, the custom interceptor intercepts the request before the request is processed and after the request is processed, and through the above setting, the data generated before the request is processed or the data generated after the request is processed may be acquired. Therefore, by the method provided by the embodiment, the method can acquire data of more types of restful style interfaces.
Optionally, after the step of obtaining, by the Micrometer, target data to be monitored of the corresponding restful style interface, the method further includes:
outputting the target data recorded in the Micrometer to Promethus;
outputting the target data to a visualization tool through the Promethus.
It should be understood that the Micrometer is already configured in the Spring frame, and the Micrometer is provided with an interface that can expose data to Promethus, so that Promethus can extract the required target data from the Micrometer directly through the exposed interface. The target data are all stored in a Micrometer, and Promethus can only extract specific types of the target data when extracting the target data. The target data recorded in the Micrometer is output to Promethus and then stored in Promethus.
It should be understood that the visualization tool may visually present the target data by way of a chart or the like, wherein the type of the visualization tool is not limited herein. For example, Grafana is a cross-platform open-source metric analysis and visualization tool, and data of Promethus can be output to Grafana, where data is queried and presented using a query language supported by Promethus.
It should be understood that when the Promethus outputs the target data to the visualization tool, part of the target data may be output according to actual needs.
In this embodiment, the target data acquired by the micro meter may be output to Promethus, and unified monitoring and management are performed through Promethus. Meanwhile, the Promethus can output the target data to a visualization tool, and the visualization tool displays the result of the target data in a chart mode according to the requirements of a user, so that the target data is more visual and clear, the user can better master the operation condition of each interface according to the target data, and the operation condition of the application can be adjusted.
Optionally, before the step of intercepting the request by the custom interceptor and acquiring the parameters carried by the request, the method further includes:
appointing a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
after the custom interceptor receives the request, judging whether the path of the request belongs to the preset path;
and if the path of the request belongs to the preset path, intercepting the request through the custom interceptor.
It should be understood that the controller is generally configured to accept a request from a user, and search for content from the database and return the content to the user or update the request from the user to the database according to parameters carried in the request. Typically, a plurality of such controllers are contained in a Spring framework, and a plurality of methods are contained in any one of the controllers. Generally, any one of the methods in the controller has a corresponding parameter, and if a request needs to call a certain method, the path of the request contains the parameter corresponding to the method. The step of designating the controller corresponding to the custom interceptor may be understood as that paths including parameters corresponding to the method may be regarded as paths corresponding to the method, the paths corresponding to the methods included in the controller are paths corresponding to the controller, and the step of designating the controller corresponding to the custom interceptor means that the paths corresponding to the controller are preset as intercepted paths.
And after the custom interceptor receives the request, comparing the path of the request with a preset path. If the request calls the method in the designated interceptor, the path of the request comprises corresponding parameters corresponding to the method, the path of the request belongs to the preset path, and at this time, the custom interceptor intercepts the request, otherwise, the request is released. By designating the controller corresponding to the custom interceptor, the custom interceptor can only intercept the request for calling the method in the controller.
It should be understood that, in an embodiment, according to actual requirements, there may be a plurality of controllers corresponding to the designated custom interceptors. Further, in another embodiment, a part of methods in the controller corresponding to the custom interceptor may be specified.
In this embodiment, through appointing the controller that self-defined interceptor corresponds, can be right the interception scope of self-defined interceptor sets up, makes the self-defined interceptor only intercepts the call object for predetermineeing the request of controller, thereby has improved the work efficiency of self-defined interceptor.
Referring to fig. 2, fig. 2 is a structural diagram of a device 300 for processing monitoring data of a restful style interface according to an embodiment of the present invention.
a generating module 201, configured to generate a custom interceptor using an interceptor adapter built in a Spring framework;
the dependence injection module 202 is used for injecting the Micrometer dependence into the custom interceptor after the custom interceptor is added into the Spring framework container configuration class;
a first obtaining module 203, configured to intercept a request through the custom interceptor and obtain a parameter carried by the request;
a determining module 204, configured to determine a corresponding restful style interface according to a parameter carried by the request, where the parameter carried by the request includes a unique identifier of the restful style interface corresponding to the request;
a second obtaining module 205, configured to obtain, by using the Micrometer, target data to be monitored of the corresponding restful style interface.
Optionally, the second obtaining module 205 includes:
a first obtaining unit, configured to obtain, by the Micrometer, first target data of the restful-style interface before processing the request;
the second acquisition unit is used for acquiring second target data of the restful style interface through the Micrometer after the request is processed;
an analysis unit, configured to analyze the first target data and the second target data to obtain the target data;
and the recording unit is used for recording the target data into the Micrometer.
Optionally, the processing device 200 for monitoring data of the restful style interface further includes:
the first output module is used for outputting the target data recorded in the Micrometer to Promethus;
a second output module for outputting the target data to a visualization tool through the Promethus.
Optionally, the processing device 200 for monitoring data of the restful style interface further includes:
the assigning module is used for assigning a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
the judging module is used for judging whether the path of the request belongs to the preset path or not after the custom interceptor receives the request;
and the intercepting module is used for intercepting the request through the custom interceptor if the path of the request belongs to the preset path.
The embodiment of the present invention further provides an electronic device, as shown in fig. 3, which includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, where the processor 301, the communication interface 302, and the memory 303 complete mutual communication through the communication bus 304,
a memory 303 for storing a computer program;
the processor 301, when executing the program stored in the memory 303, implements the following steps:
generating a custom interceptor by using an interceptor adapter arranged in a Spring frame;
after the user-defined interceptor is added into a Spring frame container configuration class, injecting a Micrometer dependence into the user-defined interceptor;
intercepting a request through the custom interceptor and acquiring parameters carried by the request;
determining a corresponding restful style interface according to the parameters carried by the request, wherein the parameters carried by the request comprise the unique identifier of the restful style interface corresponding to the request;
and acquiring target data to be monitored of the corresponding restful style interface through the Micrometer.
Optionally, the step of obtaining target data to be monitored of the restful style interface through the Micrometer includes:
acquiring first target data of the restful style interface through the Micrometer before the request is processed;
acquiring second target data of the restful style interface through the Micrometer after the request is processed;
analyzing the first target data and the second target data to obtain the target data;
and recording the target data into the Micrometer.
Optionally, after the step of obtaining, by the Micrometer, target data to be monitored of the corresponding restful style interface, the method further includes:
outputting the target data recorded in the Micrometer to Promethus;
outputting the target data to a visualization tool through the Promethus.
Optionally, before the step of intercepting the request by the custom interceptor and acquiring the parameters carried by the request, the method further includes:
appointing a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
after the custom interceptor receives the request, judging whether the path of the request belongs to the preset path;
and if the path of the request belongs to the preset path, intercepting the request through the custom interceptor.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, which stores instructions that, when executed on a computer, cause the computer to execute the method for processing monitoring data of the restful-style interface described in any of the above embodiments.
In a further embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method for processing monitoring data of a restful style interface as described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.
Claims (10)
1. A processing method for monitoring data of a restful style interface is characterized by comprising the following steps:
generating a custom interceptor by using an interceptor adapter arranged in a Spring frame;
after the user-defined interceptor is added into a Spring frame container configuration class, injecting a Micrometer dependence into the user-defined interceptor;
intercepting a request through the custom interceptor and acquiring parameters carried by the request;
determining a corresponding restful style interface according to the parameters carried by the request, wherein the parameters carried by the request comprise the unique identifier of the restful style interface corresponding to the request;
and acquiring target data to be monitored of the corresponding restful style interface through the Micrometer.
2. The method as claimed in claim 1, wherein the step of obtaining target data to be monitored of the restful style interface through the Micrometer comprises:
acquiring first target data of the restful style interface through the Micrometer before the request is processed;
acquiring second target data of the restful style interface through the Micrometer after the request is processed;
analyzing the first target data and the second target data to obtain the target data;
and recording the target data into the Micrometer.
3. The method according to claim 1, wherein after the step of obtaining the target data to be monitored of the corresponding restful style interface through the Micrometer, the method further comprises:
outputting the target data recorded in the Micrometer to Promethus;
outputting the target data to a visualization tool through the Promethus.
4. The method according to claim 1, wherein before the steps of intercepting the request by the custom interceptor and obtaining the parameters carried by the request, the method further comprises:
appointing a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
after the custom interceptor receives the request, judging whether the path of the request belongs to the preset path;
and if the path of the request belongs to the preset path, intercepting the request through the custom interceptor.
5. A device for processing monitoring data of a restful style interface, comprising:
the generating module is used for generating a custom interceptor by using an interceptor adapter built in a Spring frame;
the dependence injection module is used for injecting the Micrometer dependence into the user-defined interceptor after the user-defined interceptor is added into the Spring framework container configuration class;
the first acquisition module is used for intercepting a request through the custom interceptor and acquiring parameters carried by the request;
a determining module, configured to determine a corresponding restful style interface according to a parameter carried by the request, where the parameter carried by the request includes a unique identifier of the restful style interface corresponding to the request;
and the second acquisition module is used for acquiring the corresponding target data to be monitored of the restful style interface through the Micrometer.
6. The apparatus for processing monitoring data of restful style interface according to claim 5, wherein the second obtaining module comprises:
a first obtaining unit, configured to obtain, by the Micrometer, first target data of the restful-style interface before processing the request;
the second acquisition unit is used for acquiring second target data of the restful style interface through the Micrometer after the request is processed;
an analysis unit, configured to analyze the first target data and the second target data to obtain the target data;
and the recording unit is used for recording the target data into the Micrometer.
7. The apparatus for processing monitoring data of restful style interface as claimed in claim 5, wherein the apparatus for processing monitoring data of restful style interface further comprises:
the first output module is used for outputting the target data recorded in the Micrometer to Promethus;
a second output module for outputting the target data to a visualization tool through the Promethus.
8. The apparatus for processing monitoring data of restful style interface as claimed in claim 5, wherein the apparatus for processing monitoring data of restful style interface further comprises:
the assigning module is used for assigning a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
the judging module is used for judging whether the path of the request belongs to the preset path or not after the custom interceptor receives the request;
and the intercepting module is used for intercepting the request through the custom interceptor if the path of the request belongs to the preset path.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 4 when executing a program stored in the memory.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110691637.XA CN113282466B (en) | 2021-06-22 | 2021-06-22 | Method for processing monitoring data of restful-style interface and related equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110691637.XA CN113282466B (en) | 2021-06-22 | 2021-06-22 | Method for processing monitoring data of restful-style interface and related equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113282466A true CN113282466A (en) | 2021-08-20 |
CN113282466B CN113282466B (en) | 2023-09-15 |
Family
ID=77285234
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110691637.XA Active CN113282466B (en) | 2021-06-22 | 2021-06-22 | Method for processing monitoring data of restful-style interface and related equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113282466B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030163602A1 (en) * | 1999-10-11 | 2003-08-28 | Brett Edward Johnson | System and method for intercepting, instrumenting and characterizing usage of an application programming interface |
US20130074101A1 (en) * | 2011-09-15 | 2013-03-21 | Oracle International Corporation | System and method for supporting a server-side event model in a distributed data grid |
US20150074670A1 (en) * | 2013-09-10 | 2015-03-12 | Vmware, Inc. | Method and system for distributed processing of http requests |
CN109271331A (en) * | 2018-08-20 | 2019-01-25 | 平安普惠企业管理有限公司 | Generation method, device, computer equipment and the storage medium of log |
US10719374B1 (en) * | 2019-09-17 | 2020-07-21 | Capital One Services, Llc | Application programming interface generator using database metadata |
CN112231379A (en) * | 2020-10-16 | 2021-01-15 | 苏州浪潮智能科技有限公司 | API audit method, device, device and storage medium based on microservice architecture |
CN112597486A (en) * | 2020-12-24 | 2021-04-02 | 广东广宇科技发展有限公司 | Method for preventing repeated access to Restful API based on Spring |
CN112685032A (en) * | 2020-12-31 | 2021-04-20 | 北京赛思信安技术股份有限公司 | Dynamic api visualization generation method based on spring boot frame |
-
2021
- 2021-06-22 CN CN202110691637.XA patent/CN113282466B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030163602A1 (en) * | 1999-10-11 | 2003-08-28 | Brett Edward Johnson | System and method for intercepting, instrumenting and characterizing usage of an application programming interface |
US20130074101A1 (en) * | 2011-09-15 | 2013-03-21 | Oracle International Corporation | System and method for supporting a server-side event model in a distributed data grid |
US20150074670A1 (en) * | 2013-09-10 | 2015-03-12 | Vmware, Inc. | Method and system for distributed processing of http requests |
CN109271331A (en) * | 2018-08-20 | 2019-01-25 | 平安普惠企业管理有限公司 | Generation method, device, computer equipment and the storage medium of log |
US10719374B1 (en) * | 2019-09-17 | 2020-07-21 | Capital One Services, Llc | Application programming interface generator using database metadata |
CN112231379A (en) * | 2020-10-16 | 2021-01-15 | 苏州浪潮智能科技有限公司 | API audit method, device, device and storage medium based on microservice architecture |
CN112597486A (en) * | 2020-12-24 | 2021-04-02 | 广东广宇科技发展有限公司 | Method for preventing repeated access to Restful API based on Spring |
CN112685032A (en) * | 2020-12-31 | 2021-04-20 | 北京赛思信安技术股份有限公司 | Dynamic api visualization generation method based on spring boot frame |
Also Published As
Publication number | Publication date |
---|---|
CN113282466B (en) | 2023-09-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108664613B (en) | Data query method and device, computer equipment and storage medium | |
CN107329888B (en) | Smart contract operation code coverage calculation method and system | |
WO2020238597A1 (en) | Hadoop-based data updating method, device, system and medium | |
WO2012167267A2 (en) | Building information tracking system and method of use | |
CN112905323B (en) | Data processing method, device, electronic equipment and storage medium | |
CN111522728A (en) | Method for generating automatic test case, electronic device and readable storage medium | |
CN114116065A (en) | Method and device for acquiring topological graph data object and electronic equipment | |
CN114490246B (en) | A monitoring method, device, electronic device and storage medium | |
CN104423968A (en) | Method of designing business logic, server performing the same and storage medium storing the same | |
CN104184826A (en) | Multi-data-center storage environment managing method and system | |
CN107330031B (en) | Data storage method and device and electronic equipment | |
CN115357590A (en) | Recording method and device for data change, electronic device and storage medium | |
US20140006000A1 (en) | Built-in response time analytics for business applications | |
WO2023049520A1 (en) | Advanced agent instrumentation for opentelemetry implementations | |
CN112597105B (en) | File association object processing method, server device and storage medium | |
CN114238129A (en) | Method, apparatus, device and storage medium for generating interface data | |
CN105184156A (en) | Security threat management method and system | |
CN116955140A (en) | SDK test method, device, equipment and storage medium | |
CN110413496B (en) | Method for realizing componentized collection of electronic license operation data | |
US11556839B1 (en) | Auditing system for machine learning decision system | |
CN110309062A (en) | Use case generation method, device, electronic device and storage medium | |
Moser et al. | Event driven monitoring for service composition infrastructures | |
CN108243238B (en) | Method and device for acquiring performance data | |
CN114281549A (en) | Data processing method and device | |
CN118747164A (en) | A log-based risk management method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |