CN113282466B - Method for processing monitoring data of restful-style interface and related equipment - Google Patents
Method for processing monitoring data of restful-style interface and related equipment Download PDFInfo
- Publication number
- CN113282466B CN113282466B CN202110691637.XA CN202110691637A CN113282466B CN 113282466 B CN113282466 B CN 113282466B CN 202110691637 A CN202110691637 A CN 202110691637A CN 113282466 B CN113282466 B CN 113282466B
- Authority
- CN
- China
- Prior art keywords
- request
- restful
- target data
- interceptor
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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; CALCULATING OR 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; CALCULATING OR 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 method for processing monitoring data of a restful-style interface and related equipment, wherein the method comprises the following steps: generating a custom interceptor by using an interceptor adapter built in the Spring framework; after the custom interceptor is added into the Spring framework container configuration class, injecting Micrometer dependence into the custom 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 contain unique identifiers of the restful-style interfaces 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 method for processing monitoring data of a restful-style interface and related equipment.
Background
Currently, backend services generally use Promethus, which is an open-source system monitoring system, to obtain monitoring data of an interface. Prometa typically accesses the program interface to obtain the interface monitoring data, and imports the obtained monitoring data into the visualization tool, which exposes the desired interface monitoring data. Wherein the interface refers to a reference type defining an agreement. Members of the interface may include methods, attributes, indexers, and events, among others.
Representational state transfer (Representational State Transfer, REST) refers to a set of architectural constraints and principles. The constraint conditions and principles proposed by REST mainly include the following three points. First, everything on the network can be abstracted as a resource. Second, each resource has a unique resource identification, and manipulation of the resource does not change these identifications. Third, all operations are stateless. Interfaces that meet the above three constraints and principles are referred to as restful style interfaces, and may also be referred to as restful interfaces.
Typically when a user makes a request, the information of the request typically includes three parts, first, the request method, the uniform resource identifier (Uniform Resource Identifier, URI), the protocol, and the version of the protocol. Second, a request header, wherein the request header contains a number of useful information about the client environment and the request body. Third, the request text, which may contain the query string information submitted by the client.
For the restful interface, because the requested information designates the corresponding restful interface, the promethas can only acquire the monitoring data of the unified interface of the outermost layer, but cannot acquire the monitoring data of the specific restful interface.
Disclosure of Invention
The embodiment of the invention aims to provide a method and related equipment for processing monitoring data of a restful-style interface so as to acquire the monitoring data of a specific restful-style interface. The specific technical scheme is as follows:
in a first aspect of the present invention, there is provided a method for processing monitoring data of a restful-style interface, including:
generating a custom interceptor by using an interceptor adapter built in the Spring framework;
after the custom interceptor is added into the Spring framework container configuration class, injecting Micrometer dependence into the custom 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 contain unique identifiers of the restful-style interfaces 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 generation module is used for generating a custom interceptor by using an interceptor adapter built in the Spring framework;
the dependency injection module is used for injecting Micrometer dependency into the custom interceptor after the custom interceptor is added into the Spring framework container configuration class;
the first acquisition module is used for intercepting the request through the custom interceptor and acquiring parameters carried by the request;
the determining module is used for determining a corresponding restful-style interface according to the parameters carried by the request, wherein the parameters carried by the request contain the 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 yet another aspect of the present invention, there is also provided an electronic device including a processor, a communication interface, a memory, and a communication bus, wherein 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 step of executing the method for processing the monitoring data of the restful interface when executing the program stored in the memory.
In still another aspect of the implementation of the present invention, there is further provided a computer readable storage medium having instructions stored therein, which when executed on a computer, cause the computer to perform a method for processing monitoring data of any of the above-mentioned restful-style interfaces.
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 perform the method of processing monitoring data of a restful-style interface as described in any one of the above.
According to the method for processing the monitoring data of the restful interface, which is provided by the embodiment of the invention, firstly, the custom interceptor is generated and configured in the Spring framework. And then intercepting the 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 tangent plane at the position of the custom interceptor for intercepting the request, starting a surrounding notification, and acquiring data of a restful style interface corresponding to the request through relying on a Micrometer injected into the custom interceptor. In the method, the request is intercepted by the custom interceptor, and the specific restful interface corresponding to the request can be determined according to the parameter of the request, so that the monitoring data of the specific restful interface can be obtained.
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 flow chart of a method for processing monitoring data of a restful-style interface in an embodiment of the invention;
FIG. 2 is a schematic diagram of an information processing apparatus according to an embodiment of the present invention;
fig. 3 is a block diagram of an electronic device in an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying 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 interface, including:
step 101, generating a custom interceptor by using an interceptor adapter built in a Spring framework;
step 102, after adding the custom interceptor to a Spring framework container configuration class, injecting Micrometer dependencies into the custom interceptor;
step 103, intercepting the request through the custom interceptor and acquiring parameters carried by the request;
104, determining a corresponding restful-style interface according to the parameters carried by the request, wherein the parameters carried by the request contain unique identifiers of the restful-style interfaces corresponding to the request;
and 105, acquiring target data to be monitored of the corresponding restful-style interface through the Micrometer.
It should be appreciated that Spring frame is a lightweight control inversion (Inversion of Control, ioC) and tangential (Aspect-Oriented Programming, AOP) facing container frame. The Spring framework can be considered a kind of container in the sense that it contains and manages the configuration and lifecycle of application objects. Meanwhile, the Spring framework can be used as a framework to configure and combine simple components into complex applications. Thus, in some embodiments, a Spring frame may also be referred to as a Spring or Spring container. IoC is a technique that can promote loose coupling, among other things. After the IoC technique is applied, other objects on which an object depends are passed in a passive manner, rather than the object itself creating or looking for a dependent object, i.e., rather than the object looking for a dependency from a container, the container actively passes the dependency to it upon an unequal object request at object initialization. AOP is a technique that enables unified maintenance of program functions through precompiled means and dynamic agents during runtime. AOP can dynamically and uniformly add functions to a program by a precompiled mode and running a dynamic agent thereof under the condition of not modifying source code. For a better understanding of the AOP technique, the concepts of point of attachment (Point), point of tangency (Point), notification (Advice) and facet (Aspect) involved in AOP should be understood. The connection point may be understood as a point defined in a program, and a connection point may be considered to represent the execution of a method. The tangent point may be understood as a group of the connection points, and the connection points are combined by a logical relationship, or are concentrated by means of a wild-type, regular expression, or the like. The notification may be understood as an operation specifically to be performed by the connection point defined in the tangent point, and the type of the notification includes a pre-notification, a post-notification, a return notification, an exception notification, and a surround notification. The tangent plane may be considered as the set of the tangent point and the notification.
It should be understood that different components can be customized according to the requirements of the user to realize different functions, and the customized components are added into the Spring framework and are uniformly managed by the Spring framework. Interceptors are used in AOP to intercept a certain method or field before it is accessed and then join certain operations before or after it. After the interceptor receives the request, the interceptor intercepts or passes the request. Wherein the interceptor intercepting the request means that the interceptor may join certain operations before or after the request is processed; the interceptor passing a request means that the interceptor will not join certain operations before or after the request is processed, which will be processed directly by the processor.
In particular, the step 101 of generating a custom interceptor using an interceptor adapter built in a Spring framework may be understood as generating a custom interceptor by inheriting the interceptor adapter. Wherein the interceptor adapter is an abstract class in the Spring framework. Wherein, the class is the basis for realizing information encapsulation by the object-oriented programming, and the class is a type of reference data defined by users, which is also called class type. Each class contains a data description and a set of functions that operate on data or transfer messages. Abstract classes are often used to characterize abstractions that result from analyzing and designing the problem area, as abstractions to a series of seemingly different, but essentially identical concrete concepts. The custom interceptor has properties and methods of the interceptor adapter since the custom interceptor is inherited from the interceptor adapter. The interceptor adapter comprises a pre-processing method (PreHandle) and a post-processing method (AfterComposition), wherein the pre-processing method is called before a 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 time of the method call, and the specific operation corresponding to the method can be redefined according to the requirement. The customized 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 the requirements so as to realize the required functions.
It should be appreciated that after the custom interceptor is generated, the custom interceptor needs to be configured into a Spring framework configuration class in order for the custom interceptor to be effective. In particular, the adding of the custom interceptor to 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 to a Spring container. And then a WebMvcConfigururer interface is realized in the custom container configuration class, wherein the WebMvcConfigururer interface is a configuration mode in the Spring framework, and personalized customization is carried out on the framework in a JavaBean form. Because the webmvcc configuration interface comprises a method for adding the interceptor, the customized interceptor can be added into the Spring framework configuration class by realizing the method for adding the interceptor in the interface. It should be noted that, according to the definition of the interface, generally, the member of the interface includes a method, that is, the interface itself defines a method, but the interface cannot implement a method, and the method of the interface needs to be implemented by a class. Thus, with the above configuration, the custom interceptor can be added to the Spring framework, so the custom interceptor can introduce a Spring object, at which point the custom interceptor can be considered to be in effect.
It should be appreciated that the dependency injection may be considered a specific implementation of the IoC technique, referring to that the Spring container dynamically injects certain dependencies into the object during runtime. In particular, in the step 102, the step of injecting a Micrometer dependency into the custom interceptor may be understood that the custom interceptor needs to rely on the Micrometer to obtain the 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 call the Micrometer. In injecting Micrometer dependencies into the custom interceptor, this corresponds to initializing the Micrometer at the same time. It should be noted that, the Micrometer is a measurement class library of monitoring indexes in a Spring framework, and may be used to acquire and store data of each monitoring index.
It should be appreciated that after steps 102 and 103 are performed, the custom interceptor is already configured within the Spring framework. The following three cases can be realized by configuring the custom interceptor: in the first case, either request passes through the custom interceptor before being processed. In the second case, either request is processed and then passed 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. In general, 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 path of the request belongs to the released path, the interceptor will release the request. In the third case, the path preset in the interceptor is an intercepted path, and in the case that the path of the request belongs to the intercepted path, the interceptor intercepts the request. It should be noted that, the paths preset by the interceptor may include both an intercepted path and a released path, and by configuring the intercepted path and/or the released path corresponding to the interceptor, the interceptor may be controlled to intercept only the request to be intercepted and/or the request to be released.
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 corresponding requests. When the custom interceptor intercepts a request, the custom interceptor will increase the cut-planes for the request and response at the location where the request was intercepted and open a wrap-around notification. Wherein the surround notification may be understood as a notification performed both before the connection point is exited and after the connection point is exited. After the user-defined request is intercepted, the pre-processing method can be called in the user-defined interceptor, the pre-processing method is rewritten at the moment, 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. Wherein the unique identity refers to the unique resource identity and the unique resource identity is commonly referred to as a uniform resource locator (Uniform Resource Locator, URL), wherein the URL may be considered a subset of the URI and thus may be obtained from parameters 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 Micrometer is a library of metrics that monitors metrics. In particular, micrometer includes Meter and MeterRegistry. The Meter is an interface for collecting a series of indexes about an application, and commonly used meters include a Timer (Timer), a Gauge value (Gauge), a Counter (Counter), and the like. Wherein the timer is typically used to measure the distribution of execution times of short-time code blocks; the meter value is typically used to record a value that may change over time, such as CPU utilization, memory utilization, etc.; the counter is typically used to obtain an indication of only increasing or decreasing the number of requests for service, etc., and the counter only allows the data to increment by a fixed value. It should be noted that the foregoing is an illustration of a conventional Meter, and the types of the Meters are not limited herein, and the corresponding Meters may be used to obtain the data according to different types of the target data to be monitored. MeterRegistries are typically used to create a Meter and store data collected by the Meter, and will store all of the data acquired by all of the Meters. The acquisition of target data to be monitored can thus be considered to be effected by MeterRegistry.
Because the Micrometer dependency is already injected into the custom interceptor in the step 102, the custom interceptor may directly obtain the target data to be monitored of the corresponding restful-style interface through the Micrometer.
In a specific implementation, the step 101 and the step 102 are pre-configuring the Spring framework, the custom interceptor can be generated and configured in the Spring framework by executing the step 101 and the step 102, and each parameter of the custom interceptor is defined in the process of generating and configuring, so that corresponding operation can be executed according to requirements. After completing steps 101 and 102, the custom interceptor may perform steps 103, 104, and 105 to continually intercept the corresponding requests while the system is running. Because the specific restful-style interfaces corresponding to different requests can be different, the custom interceptor can correspond to the different specific restful-style interfaces when intercepting different requests, so that the custom interceptor can acquire the monitoring data of the specific restful-style interfaces, thereby realizing the monitoring of the data of the specific restful-style interfaces.
According to the method for processing the monitoring data of the restful interface, which is provided by the embodiment of the invention, firstly, the custom interceptor is generated and configured in the Spring framework. And then intercepting the 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 tangent plane at the position of the custom interceptor for intercepting the request, starting a surrounding notification, and acquiring data of a restful style interface corresponding to the request through relying on a Micrometer injected into the custom interceptor. In the method, the request is intercepted by the custom interceptor, and the specific restful interface corresponding to the request can be determined according to the parameter of the request, so that the monitoring data of the specific restful interface can be obtained.
Optionally, the step of obtaining, by the Micrometer, target data to be monitored of the restful interface includes:
acquiring first target data of the restful-style interface through the Micrometer before processing the request;
acquiring second target data of the restful-style interface through the Micrometer after processing the request;
analyzing the first target data and the second target data to obtain the target data;
and inputting the target data into the Micrometer.
It should be understood that the target data to be monitored includes at least one of the following: interface call times, interface response status code, interface response time, request uniform resource locator (Uniform Resource Locator, URL) and request type. It should be understood that the timing of acquiring the data is different depending on the type of the target data to be monitored. It is therefore necessary to intercept the request and obtain the relevant data by Micrometer before and/or after it has been processed, respectively. 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 the initial value of the number of interface 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, which is generated after the request is processed, so that it is necessary to intercept the request and acquire the interface response status code after the request is processed. In a third case, the target data to be monitored includes an interface response time, in order to obtain the interface response time, a timer in a Micrometer needs to be started for counting before the request is processed, and counting is ended after the request is processed and corresponding data is obtained.
In general, in order to master the operation condition of the interface in all aspects, various kinds of target data of the interface need to be monitored. Therefore, the data of the restful-style interface, namely the first target data, needs to be acquired through the Micrometer before the request is processed, and the data of the restful-style interface, namely the second target data, needs to be acquired through the Micrometer after the request is processed.
It should be understood that, although the first target data and the second target data acquired by the Meter are stored in the MeterRegistry, only the corresponding values of all the acquired data are stored in the MeterRegistry at this time, and the data itself is not given meaning. Therefore, it is necessary to extract the data stored in the metaregistry 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 the interface call number or the interface response time, the first target data and the second target data need to be analyzed to obtain corresponding data, and then the obtained data is associated with the 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 the metaregistry has been extracted as the target data in the previous step, and the extracted target data is then entered and stored in the metaregistry.
In this embodiment, the custom interceptor intercepts the request before the request is processed and after the request is processed, and through the above arrangement, the data generated before the request is processed may be obtained, or the data generated after the request is processed may be obtained. 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, the target data to be monitored of the corresponding restful-style interface, the method further includes:
outputting the target data recorded in the Micrometer to Prometa;
and outputting the target data to a visualization tool through the Prometa.
It should be appreciated that the Micrometer is already configured within the Spring framework and that the Micrometer is provided with an interface that exposes data to Promethus, so that Promethus can extract the desired target data directly from the Micrometer through the exposed interface. The target data are all stored in a Micrometer, and when the Prometa extracts the target data, only specific types of target data can be extracted. The target data recorded in the Micrometer is output to and stored in Prometa.
It should be understood that the visualization tool may intuitively display the target data by means of a chart or the like, wherein the kind of the visualization tool is not limited herein. For example, grafana is a cross-platform, open-source metric analysis and visualization tool, and data from promethas may be output to Grafana where it is configured to query and present the data using a promethas-supported query language.
It should be appreciated that when the promethas outputs the target data to the visualization tool, a portion of the target data may be output according to actual requirements.
In this embodiment, the target data acquired by the Micrometer may be output to promethas, and unified monitoring and management are performed by the promethas. Meanwhile, the Prometa can output the target data to the visualization tool, and the visualization tool displays the result of the target data in a chart mode according to the requirement of a user, so that the target data is more visual and clear, the user can conveniently master the operation condition of each interface according to the target data, and the operation condition of the application is adjusted.
Optionally, before the step of intercepting the request by the custom interceptor and obtaining the parameter carried by the request, the method further includes:
designating a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
after the user-defined 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 typically configured to accept a request from a user and to search for content from the database based on parameters carried in the request for return to the user or to update the user's request to the database. Typically, a Spring framework includes a plurality of such controllers, and a plurality of methods are included within any one of the controllers. Generally, any one of the methods in the controller has a corresponding parameter, and if a certain request needs to call a certain method, the path of the request contains the parameter corresponding to the method. The designating the controller corresponding to the custom interceptor may be understood that the paths including the parameters corresponding to the method may be considered as paths corresponding to the method, the paths corresponding to the method included in the controller are paths corresponding to the controller, and the designating the controller corresponding to the custom interceptor refers to presetting the paths corresponding to the controller as intercepted paths.
And after the user-defined interceptor receives the request, comparing the path of the request with a preset path. If the request calls a method in the specified interceptor, the path of the request contains corresponding parameters corresponding to the method, the path of the request belongs to the preset path, and the user-defined interceptor intercepts the request at the moment, otherwise, the request is released. By designating the controller corresponding to the custom interceptor, the custom interceptor can only intercept requests for calling the method in the controller.
It should be appreciated that in an embodiment, the controllers corresponding to the custom interceptors may be specified in multiple ways according to actual requirements. Further, in another embodiment, a portion of the methods in the controller corresponding to the custom interceptor may be specified.
In this embodiment, by designating a controller corresponding to the custom interceptor, the intercepting range of the custom interceptor may be set, so that the custom interceptor intercepts only a request of the controller whose calling object is preset, thereby improving the working efficiency of the custom interceptor.
Referring to fig. 2, fig. 2 is a block diagram of a processing apparatus 300 for monitoring data of a restful interface according to an embodiment of the present invention.
The processing device 200 of monitoring data of the restful interface includes:
a generating module 201, configured to generate a custom interceptor by using an interceptor adapter built in the Spring framework;
the dependency injection module 202 is configured to inject Micrometer dependencies into the custom interceptor after adding the custom interceptor into the Spring framework container configuration class;
the first obtaining module 203 is configured to intercept a request by using 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;
and a second obtaining module 205, configured to obtain, by using the Micrometer, target data to be monitored of the corresponding restful interface.
Optionally, the second obtaining module 205 includes:
the first acquisition unit is used for acquiring first target data of the restful-style interface through the Micrometer before processing the request;
the second obtaining unit is used for obtaining second target data of the restful-style interface through the Micrometer after the request is processed;
an analysis unit for analyzing the first target data and the second target data to obtain the target data;
and the input unit is used for inputting the target data into the Micrometer.
Optionally, the processing device 200 for monitoring data of the restful interface further includes:
the first output module is used for outputting the target data recorded in the Micrometer to Prometa;
and the second output module is used for outputting the target data to a visualization tool through the Prometa.
Optionally, the processing device 200 for monitoring data of the restful interface further includes:
the designating module is used for designating a controller corresponding to the customized interceptor, wherein the controller corresponds to a plurality of preset paths;
the judging module is used for judging whether the requested path belongs to the preset path or not after the user-defined interceptor receives the request;
and the interception 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, including 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 perform communication with each other through the communication bus 304,
a memory 303 for storing a computer program;
the processor 301 is configured to execute the program stored in the memory 303, and implement the following steps:
generating a custom interceptor by using an interceptor adapter built in the Spring framework;
after the custom interceptor is added into the Spring framework container configuration class, injecting Micrometer dependence into the custom 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 contain unique identifiers of the restful-style interfaces 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, by the Micrometer, target data to be monitored of the restful interface includes:
acquiring first target data of the restful-style interface through the Micrometer before processing the request;
acquiring second target data of the restful-style interface through the Micrometer after processing the request;
analyzing the first target data and the second target data to obtain the target data;
and inputting the target data into the Micrometer.
Optionally, after the step of obtaining, by the Micrometer, the target data to be monitored of the corresponding restful-style interface, the method further includes:
outputting the target data recorded in the Micrometer to Prometa;
and outputting the target data to a visualization tool through the Prometa.
Optionally, before the step of intercepting the request by the custom interceptor and obtaining the parameter carried by the request, the method further includes:
designating a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
after the user-defined 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 by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or 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 aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, where instructions are stored, when the computer readable storage medium runs on a computer, to cause the computer to execute the method for processing the monitoring data of the restful-style interface according to any one of the above embodiments.
In a further embodiment of the present invention, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of processing monitoring data of the restful-style interface of any of the above embodiments.
In the above embodiments, it may be implemented in whole or in part 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, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more 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)), etc.
It is noted that relational terms such as first and second, and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims (10)
1. A method for processing monitoring data of a restful-style interface, comprising the steps of:
generating a custom interceptor by using an interceptor adapter built in the Spring framework;
after the custom interceptor is added into the Spring framework container configuration class, injecting Micrometer dependence into the custom 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 contain unique identifiers of the restful-style interfaces corresponding to the request;
and acquiring target data to be monitored of the corresponding restful-style interface through the Micrometer.
2. The method according to claim 1, wherein the step of obtaining, by the Micrometer, target data to be monitored of the restful-style interface includes:
acquiring first target data of the restful-style interface through the Micrometer before processing the request;
acquiring second target data of the restful-style interface through the Micrometer after processing the request;
analyzing the first target data and the second target data to obtain the target data;
and inputting the target data into the Micrometer.
3. The method according to claim 1, wherein after the step of obtaining, by the Micrometer, target data to be monitored of the corresponding restful-style interface, the method further comprises:
outputting the target data recorded in the Micrometer to Prometa;
and outputting the target data to a visualization tool through the Prometa.
4. The method of claim 1, further comprising, prior to the step of intercepting a request by the custom interceptor and obtaining parameters carried by the request:
designating a controller corresponding to the custom interceptor, wherein the controller corresponds to a plurality of preset paths;
after the user-defined 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 generation module is used for generating a custom interceptor by using an interceptor adapter built in the Spring framework;
the dependency injection module is used for injecting Micrometer dependency into the custom interceptor after the custom interceptor is added into the Spring framework container configuration class;
the first acquisition module is used for intercepting the request through the custom interceptor and acquiring parameters carried by the request;
the determining module is used for determining a corresponding restful-style interface according to the parameters carried by the request, wherein the parameters carried by the request contain the 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 device for processing monitored data of a restful-style interface according to claim 5, wherein the second obtaining module comprises:
the first acquisition unit is used for acquiring first target data of the restful-style interface through the Micrometer before processing the request;
the second obtaining unit is used for obtaining second target data of the restful-style interface through the Micrometer after the request is processed;
an analysis unit for analyzing the first target data and the second target data to obtain the target data;
and the input unit is used for inputting the target data into the Micrometer.
7. The device for processing monitoring data of a restful-style interface according to claim 5, wherein the device for processing monitoring data of a restful-style interface further comprises:
the first output module is used for outputting the target data recorded in the Micrometer to Prometa;
and the second output module is used for outputting the target data to a visualization tool through the Prometa.
8. The device for processing monitoring data of a restful-style interface according to claim 5, wherein the device for processing monitoring data of a restful-style interface further comprises:
the designating module is used for designating a controller corresponding to the customized interceptor, wherein the controller corresponds to a plurality of preset paths;
the judging module is used for judging whether the requested path belongs to the preset path or not after the user-defined interceptor receives the request;
and the interception module is used for intercepting the request through the custom interceptor if the path of the request belongs to the preset path.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any 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 CN113282466A (en) | 2021-08-20 |
CN113282466B true 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 (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
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 (application program interface) auditing method, device, equipment and storage medium based on micro-service 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 |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7203946B2 (en) * | 1999-10-11 | 2007-04-10 | Hewlett-Packard Development Company, L.P. | System and method for intercepting, instrumenting and characterizing usage of an application programming interface |
US9348668B2 (en) * | 2011-09-15 | 2016-05-24 | Oracle International Corporation | System and method for supporting a server-side event model in a distributed data grid |
US9672071B2 (en) * | 2013-09-10 | 2017-06-06 | Vmware, Inc. | Method and system for distributed processing of HTTP requests |
-
2021
- 2021-06-22 CN CN202110691637.XA patent/CN113282466B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
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 (application program interface) auditing method, device, equipment and storage medium based on micro-service 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 |
---|---|
CN113282466A (en) | 2021-08-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11431753B2 (en) | Network-based permissioning system | |
US9210178B1 (en) | Mixed-mode authorization metadata manager for cloud computing environments | |
US20090106746A1 (en) | Application and database context for database application developers | |
Bockermann et al. | The streams framework | |
US11134085B2 (en) | Cloud least identity privilege and data access framework | |
US11902354B2 (en) | Cloud intelligence data model and framework | |
CN111143087A (en) | Interface calling method and device, storage medium and server | |
CN112905323B (en) | Data processing method, device, electronic equipment and storage medium | |
EP3204848B1 (en) | Real-time reporting based on instrumentation of software | |
CN104679500B (en) | Method and device for realizing automatic generation of entity class | |
US9442818B1 (en) | System and method for dynamic data collection | |
CN115357590A (en) | Recording method and device for data change, electronic device and storage medium | |
Moser et al. | Event driven monitoring for service composition infrastructures | |
US11556839B1 (en) | Auditing system for machine learning decision system | |
CN113282466B (en) | Method for processing monitoring data of restful-style interface and related equipment | |
JP4563403B2 (en) | Usage method and system in communication network | |
CN114238129A (en) | Method, device and equipment for generating interface data and storage medium | |
CN114281549A (en) | Data processing method and device | |
US9477821B2 (en) | Generic feature-licensing framework | |
CN112131257A (en) | Data query method and device | |
CN112579705A (en) | Metadata acquisition method and device, computer equipment and storage medium | |
KR102202923B1 (en) | Module specific tracing in a shared module environment | |
TWI754269B (en) | Method, apparatus and computer readable storage medium for data chain monitoring | |
CN113495747B (en) | Gray scale release method and device | |
Chen et al. | Analyzing execution path non-determinism of the Linux kernel in different scenarios |
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 |