Log processing method and device, related equipment, storage medium and computer program product

By determining the controller according to the service type in the microservice system and generating logs, the problems of confusion and overwrite in log reporting are solved, and effective management of logs and accurate monitoring of resources are achieved.

CN120066889APending Publication Date: 2025-05-30CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510025671.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In the microservice system, the logs reported through existing log reporting schemes may be confusing and mutually covered, making it difficult to effectively manage resources.

Method used

By introducing a log processing method in the microservice system, the corresponding controller is determined according to the service type requested by the service, the business logic is executed and the log is generated. The controller of the front-end service sends a prelog to the first device before the business logic is executed, while the controller of the back-end service does not send a prelog. The first device stores the logs into the database or discards them according to the type of the log and the information contained in it to avoid log confusion.

Benefits of technology

It realizes effective management of logs in the microservice system, avoiding log confusion and mutual overwriting, so that resource management can be carried out accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066889A_ABST
    Figure CN120066889A_ABST
Patent Text Reader

Abstract

The invention discloses a log processing method and device, related equipment, a storage medium and a computer program product. The method comprises the following steps: receiving a service request; according to a service type requested by the service request, a corresponding controller is determined, and the service type requested by the service request at least comprises a front-end service or a back-end service; the controller corresponding to the front-end service at least can send the log to the first equipment before the business logic is executed; the controller corresponding to the back-end service cannot send the log to the first equipment before the business logic is executed; on the basis of the determined controller, service logic is executed, and a log is generated; the generated log is sent to a first device, the first device is at least used for collecting the log reported by the service in the micro-service system, and the type of the reported log comprises at least one of the following: a front log representing the execution of the service logic; representing a fine log in a business logic execution process; and a post-log representing that the execution of the business logic is completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and in particular, to a log processing method, apparatus, related device, storage medium, and computer program product. Background Art

[0002] A microservice system usually includes multiple services. Each service can execute the business logic corresponding to the service when receiving a request, and report the logs related to the service. The reported logs can be used to manage the resources of the microservice system.

[0003] However, the logs reported through the log reporting scheme in the related art may be chaotic and overwrite each other, which makes it difficult to perform effective resource management. Summary of the Invention

[0004] To solve the related technical problems, embodiments of this application provide a log processing method, apparatus, related device, storage medium, and computer program product.

[0005] The technical solution of the embodiments of this application is implemented as follows:

[0006] Embodiments of this application provide a log processing method, which is applied to a first service, and the first service belongs to a microservice system. The method includes:

[0007] Receiving a service request for requesting to execute the business logic corresponding to the first service;

[0008] Determining a corresponding controller according to the service type requested by the service request. The service type requested by the service request includes at least a front-end service or a back-end service. The controller corresponding to the front-end service can at least send a log to a first device before the business logic is executed. The controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed;

[0009] Based on the determined controller, executing the business logic and generating a log; sending the generated log to the first device. The generated log at least includes the identification information of the service request and the operation type of the first service. The first device is at least used to collect the logs reported by the services in the microservice system. The types of the reported logs include at least one of the following:

[0010] Pre-log indicating before the business logic is executed;

[0011] Fine-grained log indicating during the execution of the business logic;

[0012] Post-log indicating after the business logic is executed.

[0013] In the above solution, determining a corresponding controller according to the service type requested by the service request includes:

[0014] Determining a corresponding controller according to the Uniform Resource Locator (URL) of the service request.

[0015] In the above solution, when the service type requested by the service request includes a front-end service, based on the determined controller, executing business logic and generating a log includes:

[0016] Before executing the business logic, the determined controller obtains the identifier of the service request and the operation type of the first service through an annotation, and generates a first log, where the first log includes the identifier information of the service request and the operation type of the first service; the type of the first log includes a pre-log.

[0017] During the execution of the business logic, a second log is generated, where the second log includes the identifier information of the service request, the operation type of the first service, and resource-related information corresponding to the first request, and the type of the second log includes a detailed log.

[0018] After the execution of the business logic is completed, a third log is generated, where the third log includes the identifier information of the service request, the operation type of the first service, and the execution result of the business logic; the type of the third log includes a post-log.

[0019] In the above solution, when the service type requested by the service request includes a back-end service, based on the determined controller, executing business logic and generating a log includes:

[0020] During the execution of the business logic, a fourth log is generated, where the fourth log includes the identifier information of the service request, the operation type of the first service, and resource-related information corresponding to the first request, and the type of the fourth log includes a detailed log.

[0021] An embodiment of the present application further provides a log processing method, which is applied to a first device, and the first device is at least used to collect logs reported by services in a microservice system. The method includes:

[0022] Obtaining the logs reported by the first service, where the reported logs at least include the identifier information of the service request and the operation type of the first service, and the type of the logs includes at least one of the following:

[0023] A pre-log representing before the execution of the business logic;

[0024] Characterize the fine-grained logs during the execution of the business logic;

[0025] Characterize the post logs after the completion of the execution of the business logic;

[0026] According to the type of the log, the identification information of the service request, and the operation type of the first service, store the log in the database or discard the log.

[0027] In the above solution, when storing the log in the database or discarding the log according to the type of the log and the information contained in the log, one or more of the following are executed:

[0028] The log reported by the first service includes a first log. Determine that the type of the first log includes a pre-log, and store the first log in the database;

[0029] The log reported by the first service includes a second log. Determine that the type of the second log includes a fine-grained log, and the database includes the pre-log corresponding to the second log, and store the second log in the database;

[0030] The log reported by the first service includes a third log. Determine that the type of the third log includes a post-log, and store the third log in the database.

[0031] In the above solution, storing the log in the database or discarding the log according to the type of the log and the information contained in the log includes:

[0032] The log reported by the first service includes a fourth log. Determine that the type of the fourth log includes a fine-grained log, and the database does not include the pre-log corresponding to the fourth log, and discard the fourth log.

[0033] In the above solution, storing the log in the database includes:

[0034] Parse the log based on a preset template to obtain a parsing result;

[0035] Store the parsing result in the database.

[0036] An embodiment of the present application further provides a log processing device, which is set in a second device where at least the first service is deployed, and includes:

[0037] A receiving unit, configured to receive a service request, where the service request is used to request the execution of the business logic corresponding to the first service;

[0038] A determination unit, configured to determine a corresponding controller according to the service type requested by the service request, where the service type requested by the service request includes at least a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to a first device before the business logic is executed; the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed;

[0039] An execution unit, configured to execute business logic based on the determined controller and generate a log; send the generated log to the first device, where the generated log at least includes the identification information of the service request and the operation type of the first service, and the first device is at least used to collect the logs reported by the services in the microservice system, and the types of the reported logs include at least one of the following:

[0040] A pre-log representing before the business logic is executed;

[0041] A detailed log representing during the execution of the business logic;

[0042] A post-log representing after the business logic is executed.

[0043] An embodiment of the present application further provides a log processing device, which is set in the first device, and the first device is at least used to collect the logs reported by the services in the microservice system, including:

[0044] An acquisition unit, configured to acquire the log reported by the first service, where the reported log at least includes the identification information of the service request and the operation type of the first service, and the types of the log include at least one of the following:

[0045] A pre-log representing before the business logic is executed;

[0046] A detailed log representing during the execution of the business logic;

[0047] A post-log representing after the business logic is executed;

[0048] A processing unit, configured to store the log in a database or discard the log according to the type of the log, the identification information of the service request, and the operation type of the first service.

[0049] An embodiment of the present application further provides a second device, including: a first processor and a first memory for storing a computer program that can run on the processor,

[0050] wherein, when the first processor is used to run the computer program, it executes the steps of any of the above methods on the second device side where at least the first service is deployed.

[0051] An embodiment of the present application further provides a first device, including: a second processor and a second memory for storing a computer program that can run on the processor,

[0052] wherein, when the second processor is used to run the computer program, it executes the steps of any of the above methods on the first device side.

[0053] An embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of any of the above methods on the second device side where at least the first service is deployed, or implements the steps of any of the above methods on the first device side.

[0054] An embodiment of the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the steps of any of the above methods on the second device side where at least the first service is deployed, or implements the steps of any of the above methods on the first device side.

[0055] The log processing method, device, related equipment, storage medium and computer program product provided by the embodiments of this application. A first service receives a service request. The first service belongs to a microservice system, and the service request is used to request the execution of the business logic corresponding to the first service. According to the service type requested by the service request, a corresponding controller is determined. The service types requested by the service request include at least a front-end service and a back-end service. The controller corresponding to the front-end service can at least send a log to a first device before the execution of the business logic. The controller corresponding to the back-end service cannot send a log to the first device before the execution of the business logic. Based on the determined controller, the business logic is executed and a log is generated. The generated log is sent to the first device. The generated log at least includes the identification information of the service request and the operation type of the first service. The first device is at least used to collect the logs reported by the services in the microservice system. The types of the reported logs include at least one of the following: pre-log indicating before the execution of the business logic; fine-grained log indicating during the execution of the business logic; post-log indicating after the execution of the business logic is completed. At the same time, the first device obtains the log reported by the first service, and according to the type of the log and the information included in the log, stores the log in the database or discards the log. In the solution provided by the embodiments of this application, after the first service receives the service request, it can determine the service type requested by the service request, and then select the corresponding controller according to the requested service type to execute the business logic. For example, when the requested service type includes a front-end service, that is, when the first service determines that it belongs to a front-end service directly called by an external request, the first service can execute the business logic based on the controller corresponding to the front-end service and send a pre-log to the first device before executing the business logic. Another example is when the requested service type includes a back-end service, that is, when the first service determines that it belongs to a back-end service called by an internal request initiated by other services, the first service can execute the business logic based on the controller corresponding to the back-end request and does not send a pre-log to the first device before executing the business logic. Among them, the log at least includes the identification information of the service request and the operation type of the first service. Correspondingly, when the first device receives the log reported by the service, it can determine whether to store the log in the database according to the type of the log and the identification information of the service request and the operation type of the service included in the log.For example, when the type of the log includes the pre-log, it can be considered that the log belongs to the log sent by the front-end service, and the first device can directly store the log in the database. For another example, when the type of the log does not include the pre-log, the first device can use the identification information of the service request included in the log and the operation type of the service to determine whether the database contains the pre-log corresponding to the log. When the database contains the pre-log corresponding to the log, the first device can determine that the log belongs to the log sent by the front-end service and store the log in the database. When the database does not contain the pre-log corresponding to the log, the first device can determine that the log belongs to the log sent by the back-end service and discard the log. In this way, the first device can ensure that only the logs sent by the front-end service are stored in the database, and the situation where the logs stored in the database are chaotic and overwrite each other can be avoided, so that accurate resource management can be achieved by using the logs in the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a schematic structural diagram of a related technology using the Aspect-Oriented Programming (AOP) technology;

[0057] Figure 2 It is a schematic flowchart of the first log processing method according to an embodiment of the present application;

[0058] Figure 3 It is a schematic flowchart of the second log processing method according to an embodiment of the present application;

[0059] Figure 4 It is a schematic flowchart of the third log processing method according to an embodiment of the present application;

[0060] Figure 5 It is a schematic flowchart of a refined log processing method for a private cloud in an application example of the present application;

[0061] Figure 6 It is a schematic structural diagram of a log processing device according to an embodiment of the present application;

[0062] Figure 7 It is a schematic structural diagram of another log processing device according to an embodiment of the present application;

[0063] Figure 8 It is a schematic structural diagram of a second device according to an embodiment of the present application;

[0064] Figure 9 It is a schematic structural diagram of a first device according to an embodiment of the present application;

[0065] Figure 10 It is a schematic structural diagram of a log processing system according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0066] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments.

[0067] A microservices system usually includes multiple services (which can also be understood as microservices). Different services can be used to execute different business logics, and the execution of each service is independent of each other. Therefore, the microservices system has the advantages of high scalability and high fault tolerance. Specifically, the development and deployment of the microservices system can usually be carried out on architectures such as Spring Boot.

[0068] In the related art, the AOP technology (which can also be understood as the AOP programming paradigm) can be used to implement the recording of user operation logs for each service (hereinafter simply referred to as logs), so that the resource usage in the microservices system can be determined by using the recorded logs, and more effective resource management can be achieved.

[0069] Specifically, a service may include concerns that are not directly related to the core business logic (which can also be understood as the main business logic), such as log recording, transaction management, performance monitoring, etc. The AOP technology can be used to separate the operations related to the cross-cutting concerns in the service from the business logic and encapsulate the operations related to the cross-cutting concerns into independent modules (which can also be understood as aspects). In this way, when it is necessary to execute the operations related to the cross-cutting concerns, the module corresponding to the cross-cutting concern can be reused, and there is no need to repeatedly write the same code, reducing code redundancy and improving the maintainability and extensibility of the code.

[0070] When using AOP to implement log recording, as Figure 1 shown, a custom annotation can be defined first during service development (specifically, it can include descriptive information, such as log levels, etc.), and the annotation of the custom annotation can be added to the interface where log recording is required (which can also be understood as the interface to be intercepted). Then, an AOP interceptor class is created to intercept the business logic at the interface annotated with the custom annotation and execute the method of the custom annotation (i.e., log recording). In this way, when the logic is executed, when it runs to the interface annotated with the custom annotation, it is intercepted and the corresponding log recording logic of the interceptor is executed (which can also be understood as intercepting with this custom annotation as the pointcut), so as to generate the corresponding log; after the log is generated, the log generated in the interceptor can be extracted and written into the database for subsequent resource management operations.

[0071] Specifically, a log annotation can be added to the controller of the service (which can also be understood as the controller file). In this way, when the service receives a request to execute the business logic (which can also be understood as a service request), when the business logic is executed based on the controller with the log annotation added, the interceptor can be triggered and the corresponding log can be generated.

[0072] As the business develops, the number of services in the microservices system is increasing, and the services are frequently called. Specifically, when the gateway service in the microservices system receives a request from outside the system (which can also be understood as an external request), it will route the request to the corresponding service to execute the business logic corresponding to the service. At this time, this service can be called the front-end service. During the process of executing the business logic of the front-end service, it may be necessary to call other services. At this time, the front-end service can send a request to other services to call other services to execute the corresponding business logic. At this time, the other services called by the front-end service can be called the back-end services. Of course, the back-end service can also continue to call other back-end services to jointly complete the business. In this process, the called services can form a call chain according to the call order. The first service on the call chain belongs to the front-end service, and the other services on the call chain belong to the back-end services.

[0073] When performing resource management on the microservices system, the logs reported by the front-end services are mainly considered, and the logs reported by the back-end services do not need to be considered. However, in the log reporting scheme in the related art, each service will perform log reporting when receiving internal requests and external requests (which can also be understood as each service will reuse the log recording interface). Therefore, for each external request, multiple services' reported logs can be obtained, and there may be situations of log chaos and mutual overwriting, resulting in difficulty in using the logs for effective resource management (which can also be understood as the logs being unavailable).

[0074] Based on this, in various embodiments of the present application, after receiving a service request, the first service can determine the service type requested by the service request, and then select the corresponding controller according to the requested service type to execute the business logic. For example, when the requested service type includes a front-end service, that is, when the first service determines that it belongs to a front-end service directly called by an external request, the first service can execute the business logic based on the controller corresponding to the front-end service, and send a pre-log to the first device before executing the business logic; for another example, when the requested service type includes a back-end service, that is, when the first service determines that it belongs to a back-end service called by an internal request initiated by another service, the first service can execute the business logic based on the controller corresponding to the back-end request, and does not send a pre-log to the first device before executing the business logic, where the log at least includes the identification information of the service request and the operation type of the first service. Correspondingly, when the first device receives the log reported by the service, it can determine whether to store the log in the database according to the type of the log, and the identification information of the service request and the operation type of the service included in the log. For example, when the type of the log includes a pre-log, it can be considered that the log belongs to the log sent by the front-end service, and the first device can directly store the log in the database; for another example, when the type of the log does not include a pre-log, the first device can use the identification information of the service request and the operation type of the service included in the log to determine whether the database contains the pre-log corresponding to the log. When the database contains the pre-log corresponding to the log, the first device can determine that the log belongs to the log sent by the front-end service and store the log in the database; when the database does not contain the pre-log corresponding to the log, the first device can determine that the log belongs to the log sent by the back-end service and discard the log. In this way, the first device can ensure that only the logs sent by the front-end service are stored in the database, and can avoid the situation that the logs stored in the database are chaotic and overwrite each other, so as to realize accurate resource management using the logs in the database.

[0075] An embodiment of the present application provides a log processing method, which is applied to a first service, and the first service belongs to a microservice system, such as Figure 2 shown, the method includes:

[0076] Step 201: Receive a service request, where the service request is used to request the execution of the business logic corresponding to the first service;

[0077] Step 202: Determine a corresponding controller according to the service type requested by the service request, where the service type requested by the service request includes at least a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to the first device before the business logic is executed; the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed;

[0078] Step 203: Based on the determined controller, execute the business logic and generate a log; send the generated log to the first device, where the generated log at least includes the identification information of the service request and the operation type of the first service, and the first device is at least used to collect logs reported by services in the microservice system, and the types of the reported logs include at least one of the following:

[0079] Represents the pre-log before the business logic is executed;

[0080] Represents detailed logs during the execution of business logic;

[0081] Post-log indicating the completion of business logic execution.

[0082] Here, in actual application, the microservice system may include a microservice system using the Spring Boot architecture. The first service can also be understood as one of the multiple services included in the microservice system. The first service can also be called a microservice. The embodiment of the present application does not limit the name of the first service or the microservice system as long as its function is realized.

[0083] The first service may be deployed on an electronic device (such as a server, etc.), and the electronic device on which the first service is deployed is referred to as a second device. The operations performed by the first service below may also be understood as operations performed by the second device on which the first service is deployed.

[0084] In actual application, after entering the microservice system, all external requests are usually processed by the gateway service first. The gateway service can generate a corresponding identifier according to the request, that is, a request identifier (such as a request ID, which can be expressed as requestID in English). The request identifier is used to uniquely identify the request in the microservice system. Exemplarily, the request identifier may include: gateway and a 32-bit random universally unique identifier (UUID), such as gatewaybbf988a45a504df693bdf1806f2ddf92.

[0085] After generating the request identifier, the gateway service can route the external request and the request identifier to the front-end service corresponding to the external request, and call the front-end service to execute the corresponding business logic. At this time, the external request can also be understood as a service request for the front-end service.

[0086] After receiving the service request, the front-end service can execute the business logic corresponding to the front-end service and carry the request identifier in the context of each thread executing the business logic. During the execution of the business logic, the front-end service can, according to the needs of the business logic, call other back-end services to execute the corresponding business logic.

[0087] Specifically, the front-end service can send a service request for the back-end service to the back-end service to be called, so as to request the back-end service to execute the corresponding business logic. Among them, the service request for calling the back-end service can include a Hypertext Transfer Protocol (HTTP) request, and the HTTP request can carry the request identifier. In this way, the call chain for the request corresponding to the request identifier (that is, the call relationship between the front-end request corresponding to the request identifier and all back-end requests) can be determined.

[0088] In practical applications, the front-end request can send the HTTP request to the back-end request through the URL, and the header of the HTTP request can carry the request identifier.

[0089] In practical applications, by adding request-related information to the URL, each service can, after receiving the URL, determine whether the request corresponding to the URL belongs to an external request routed by the gateway service (which can also be understood as a front-end request) or a request for internal call within the microservice system (which can also be understood as a back-end internal service request).

[0090] Based on this, for the first service in the microservice system, in one embodiment, the first service can determine the service type requested by the service request according to the URL of the service request. Among them, the service type requested by the service request can include a front-end service or a back-end service. That is to say, the first service can determine whether it is called as a front-end service or a back-end service itself according to the request-related information included in the URL.

[0091] Specifically, when a service within the microservice system calls the first service, it can add " / backend / " to the virtual directory part of the URL corresponding to the service request. In this way, after receiving the URL of the service request, the first service can determine the service type requested by the service request according to whether the URL contains " / backend / ".

[0092] Exemplarily, assume that the service request includes a request related to creating a cloud host. When the service type requested by the service request includes a front-end service, the URL of the service request may include:

[0093] http: / / ip:port / v1 / instance;

[0094] When the service type requested by the service request includes a back-end service, the URL of the service request may include:

[0095] http: / / ip:port / v1 / backend / instance.

[0096] In this way, the first service can determine the service type of the first service according to the URL of the service request, that is, whether it is called as a front-end service or a back-end service. When the service type of the first service includes a front-end service, the first service can report logs for subsequent resource management using the reported logs; at the same time, when the service type of the first service includes a back-end service, the first service can refrain from reporting logs to avoid overwriting the logs reported by the front-end service corresponding to the first service, causing log chaos and making it difficult to perform effective resource management.

[0097] Based on this, in the first service, multiple different controllers can be set for different service types, and the log annotations added in different controllers are different. Therefore, the first service can select an appropriate controller according to the service type, so as to trigger an interceptor at the log annotation position in the selected controller, thereby implementing a log reporting method suitable for the service type.

[0098] Specifically, in one embodiment, the specific implementation of step 202 may include:

[0099] Determine the corresponding controller according to the URL of the service request.

[0100] Among them, the controllers of the first service may include the controller corresponding to the front-end service and the controller corresponding to the back-end service. When the URL of the service request indicates that the service type requested by the service request includes a front-end service, the first service can determine to execute the business logic based on the controller corresponding to the front-end service; when the URL of the service request indicates that the service type requested by the service request includes a back-end service, the first service can determine to execute the business logic based on the controller corresponding to the back-end service.

[0101] In the related art, when the business logic is executed based on the controller and the log is generated and reported, log annotations are usually added at the position before the execution of the business logic and at the position after the execution of the business logic, so as to generate the pre-log before the execution of the business logic and the post-log after the execution of the business logic, and then the generated pre-log and post-log can be reported. Among them, the pre-log can include the operation type, the operator, the operation time, and the operation parameters; the post-log can include the operation type, the operator, the operation time, the operation parameters, and the operation result.

[0102] However, for the microservice system, the refinement degree of the information included in the above-mentioned pre-log and post-log is insufficient, so it is difficult to perform refined resource management. For example, when the service request includes a request related to creating a cloud host, according to the above-generated pre-log and post-log, it is impossible to determine information such as the identifier of the cloud host (such as the cloud host ID), the cloud host name, the application system to which the cloud host belongs, the combination to which the cloud host belongs, and the business network protocol (IP, Internet Protocol) of the cloud host; for another example, due to the different dimensions of the operation resources in the cloud platform (that is, the cloud platform related to the microservice system), when the service request includes a request related to batch deleting cloud hosts, the operation of deleting each cloud host will be regarded as a black box operation, that is, the resource changes related to deleting each cloud host will not be recorded in the pre-log and post-log; for another example, when the service request includes a request related to deleting a single cloud host, the operations related to the block and floating IP bound to the cloud host will be regarded as black box operations, that is, the resource changes of resources such as the floating IP and the block bound to the cloud host will not be recorded in the pre-log and post-log. It can be seen that in the pre-log and post-log, the refinement degree of the log record is insufficient. Especially when the business logic executed by the service operates on large-grained resources, the operation conditions of small-grained resources are not recorded.

[0103] Based on this, a custom log annotation can be added to the service layer code that executes the business logic, and a corresponding interceptor class can be created to record the detailed resource-related information (such as the above-mentioned small-grained resource changes, etc.) corresponding to the service request in the log during the execution of the business logic. Among them, the resource-related information corresponding to the service request can be set according to the actual service request and the business logic of the service. This application embodiment does not make a limit on this. The log that records (can also be understood as includes) the resource-related information can be called a fine log.

[0104] In actual application, when executing business logic based on the controller corresponding to the front-end service, the service layer code with the above-mentioned log annotation can be called. In this way, when executing the logic related to the service layer code, that is, during the execution of business logic, fine-grained logs can be generated and the fine-grained logs can be reported.

[0105] When executing business logic based on the controller corresponding to the back-end service, in order to avoid log chaos, the service layer code without the above-mentioned log annotation should be called, so that during the execution of the logic, no fine-grained logs are generated and no fine-grained logs are reported. However, this requires writing two sets of service layer code in the first service, which will increase the code complexity and occupy more resources.

[0106] Based on this, the first service can choose to reuse the same service layer code. That is to say, when executing business logic based on the controller corresponding to the back-end service, the service layer code with the above-mentioned log annotation is also called. In this way, during the execution of business logic, fine-grained logs are also generated and the fine-grained logs are reported, thereby saving code complexity and reducing resource occupancy. At the same time, when the first service generates any logs (including pre-log, fine-grained log, post-log), the service request identification information and the operation type of the first service are at least included in the log. In this case, when the first service belongs to the back-end service, the first service will report the fine-grained log. At this time, the device receiving the fine-grained log can determine according to the service request identification information and the operation type of the first service included in the fine-grained log that the pre-log corresponding to the fine-grained log has not been received before, and further determine that the fine-grained log belongs to the log reported by the back-end service, so that the fine-grained log can be discarded (that is, not stored in the database), avoiding the situation of log chaos and mutual overwriting in the database (it can also be understood as ensuring the stability of the log), and accurate resource management can be realized by using the logs in the database. Here, the device receiving the log is hereinafter referred to as the first device, which may specifically include a remote dictionary server (Redis, Remote Dictionary Server), etc., and the embodiments of the present application do not limit this.

[0107] As can be seen from the above description, when the service type requested by the service request includes a front-end service, the first service can execute the business logic based on the controller corresponding to the front-end service, generate front-end logs, back-end logs, and detailed logs, and report the generated logs. That is to say, in one embodiment, before the first service executes the business logic, the determined controller obtains the identifier of the service request and the operation type of the first service through annotations, and generates a first log, which includes the identifier information of the service request and the operation type of the first service; the type of the first log includes a pre-log;

[0108] During the execution of the business logic, a second log is generated, which includes the identifier information of the service request, the operation type of the first service, and the resource-related information corresponding to the first request. The type of the second log includes a detailed log;

[0109] After the business logic is executed, a third log is generated, which includes the identifier information of the service request, the operation type of the first service, and the execution result of the business logic. The type of the third log includes a post-log.

[0110] Of course, when the service type requested by the service request includes a back-end service, the first service can execute the business logic based on the controller corresponding to the front-end service, generate detailed logs, and report the detailed logs. That is to say, in one embodiment, during the execution of the business logic by the first service, a fourth log is generated, which includes the identifier information of the service request, the operation type of the first service, and the resource-related information corresponding to the first request. The type of the fourth log includes a detailed log.

[0111] Correspondingly, an embodiment of the present application further provides a log processing method, which is applied to a first device. The first device is at least used to collect the logs reported by services in a microservice system, as Figure 3 shown. The method includes:

[0112] Step 301: Obtain the logs reported by the first service. The reported logs at least include the identifier information of the service request and the operation type of the first service. The type of the logs includes at least one of the following:

[0113] A pre-log representing before the execution of the business logic;

[0114] A detailed log representing during the execution of the business logic;

[0115] A post-log representing after the execution of the business logic is completed;

[0116] Step 302: Store the log in a database or discard the log according to the type of the log, the identification information of the service request, and the operation type of the first service.

[0117] Here, in practical applications, the services in the microservice system can generate logs based on the above method on the first service side and report the logs to the first device. The first device may include Redis or other devices. When the first device includes other devices, the first device can periodically pull logs from Redis to obtain the logs reported by the services in the microservice system. Among them, the period for the first device to pull logs can be set according to actual needs, such as 3 minutes, etc., and the embodiments of the present application do not limit this.

[0118] After the first device obtains the logs reported by the first service, it can determine the type of the logs according to the information contained in the logs.

[0119] When the type of the log includes a pre-log, since only the front-end service will report the pre-log, the first device can determine that the log belongs to the log reported by the front-end service and can store it in the database. That is to say, in one embodiment, the logs reported by the first service include first logs. When the first device determines that the type of the first logs includes pre-logs, the first logs are stored in the database.

[0120] When the type of the log includes a post-log, since only the front-end service will report the post-log, the first device can determine that the log belongs to the log reported by the front-end service and can store it in the database. That is to say, in one embodiment, the logs reported by the first service include third logs. When the first device determines that the type of the third logs includes post-logs, the third logs are stored in the database.

[0121] When the type of the log includes a fine-grained log, since both the front-end service and the back-end service report fine-grained logs, the first device can use the identification information of the service request included in the fine-grained log and the operation type of the first service to perform a match in the database. When a corresponding pre-log is matched, the first device can determine that the log belongs to the log reported by the front-end service and can store it in the database. That is, in one embodiment, the log reported by the first service includes a second log. The first device determines that the type of the second log includes a fine-grained log, and the database includes the pre-log corresponding to the second log, and stores the second log in the database. Correspondingly, when no corresponding pre-log is matched, the first device can determine that the log belongs to the log reported by the back-end service and can discard the fine-grained log to avoid log overwriting and ensure the stability of the logs in the database. That is, in one embodiment, the log reported by the first service includes a fourth log. The first device determines that the type of the fourth log includes a fine-grained log, and the database does not include the pre-log corresponding to the fourth log, and discards the fourth log.

[0122] In practical applications, to ensure the readability of the logs, the first device can parse the logs based on a preset template to obtain highly readable log data (which can also be understood as the parsing result) after parsing, and store the parsed log data in the database.

[0123] Based on this, in one embodiment, the storing the log in the database includes:

[0124] Parsing the log based on a preset template to obtain a parsing result;

[0125] Storing the parsing result in the database.

[0126] Here, in practical applications, a corresponding preset template can be set in advance based on the operation type of the service. That is, the preset template corresponds to the operation type. The first device can use the operation type of the first service to determine the corresponding preset template and parse the log based on the determined template.

[0127] In practical applications, the preset template can include a readable log template or a single resource template. Among them, the readable log template is used to convert the operations recorded in the log into highly readable text so as to understand the operation content corresponding to the log during subsequent resource management; the single resource template is used to separately record the operation details corresponding to each resource in the fine-grained log so as to perform resource management subsequently.

[0128] Exemplarily, assume that the operation type of the first service includes deleting a cloud host, and the log includes a fine-grained log, and the specific content is shown in Table 1:

[0129] Attribute Name Event ID (instanceid) requestId Event Name (instanceName) Operation Name Floating IP (floatingIp) Floating IP Floating IP ID (floatingIpId) ID of the Floating IP Volume ID (volumeId) Block Storage ID Volume Name (volumeName) Block Storage Name User Name (username) User Name User ID (userId) User ID Log Operation Type (logaction) Operation Name Request ID (requestId) requestId

[0130] Table 1

[0131] At this time, the first device can determine that the preset template corresponding to the deleted cloud host includes a readable log template: "{username} deletes the cloud host: {instanceName}, and deletes the floating IP: {floatingIp}, block storage: {volumeName}"; and a single resource template: "{resource type}, {resource id}, {resource name}, {requestId}, {username}, {userId}", where {} represents a placeholder. Then the first device can use the determined template, combined with java reflection technology, to obtain the attribute information in the log, and replace the placeholders in the template to obtain a readable log parsed by the readable log template, and three single resource logs parsed by the single resource template (one readable log and three single resource logs can also be understood as the above-mentioned parsing results), where the three single resource logs are respectively associated with the resources of the cloud host, floating IP, and block storage.

[0132] The present application also provides a log processing method, such as Figure 4 As shown, the method includes:

[0133] Step 401: A second device at least having a first service deployed thereon receives a service request, where the service request is used to request execution of a business logic corresponding to the first service, and the first service belongs to a microservice system;

[0134] Step 402: the second device determines a corresponding controller according to the service type requested by the service request, where the service type requested by the service request at least includes a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to the first device before the business logic is executed; the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed;

[0135] Step 403: The second device executes the business logic based on the determined controller and generates a log; sends the generated log to the first device, where the generated log includes at least the identification information of the service request and the operation type of the first service. The first device is at least used to collect logs reported by services in the microservice system, and the types of the reported logs include at least one of the following:

[0136] Represents the pre-log before the business logic is executed;

[0137] Represents detailed logs during the execution of business logic;

[0138] Post - log indicating the completion of business logic execution;

[0139] Step 404: The first device obtains the logs reported by the first service;

[0140] Step 405: The first device stores the logs in the database or discards the logs according to the type of the logs, the identification information of the service request, and the operation type of the first service.

[0141] Here, it should be noted that: The specific processing procedures of the second device and the first device have been described in detail above and will not be elaborated here.

[0142] The log processing method provided by the embodiment of this application is as follows: The first service receives a service request. The first service belongs to a microservice system, and the service request is used to request the execution of the business logic corresponding to the first service. According to the service type requested by the service request, the corresponding controller is determined. The service types requested by the service request at least include a front-end service and a back-end service. The controller corresponding to the front-end service can at least send a log to the first device before the execution of the business logic. The controller corresponding to the back-end service cannot send a log to the first device before the execution of the business logic. Based on the determined controller, the business logic is executed and a log is generated. The generated log is sent to the first device. The generated log at least includes the identification information of the service request and the operation type of the first service. The first device is at least used to collect the logs reported by the services in the microservice system. The types of the reported logs include at least one of the following: pre-log indicating before the execution of the business logic; fine-grained log indicating during the execution of the business logic; post-log indicating after the execution of the business logic is completed. At the same time, the first device obtains the log reported by the first service, and according to the type of the log and the information included in the log, stores the log in the database or discards the log. In the solution provided by the embodiment of this application, after the first service receives the service request, it can determine the service type requested by the service request, and then select the corresponding controller according to the requested service type to execute the business logic. For example, when the requested service type includes a front-end service, that is, when the first service determines that it belongs to a front-end service directly called by an external request, the first service can execute the business logic based on the controller corresponding to the front-end service and send a pre-log to the first device before the execution of the business logic. Another example is that when the requested service type includes a back-end service, that is, when the first service determines that it belongs to a back-end service called by an internal request initiated by other services, the first service can execute the business logic based on the controller corresponding to the back-end request and does not send a pre-log to the first device before the execution of the business logic. Among them, the log at least includes the identification information of the service request and the operation type of the first service. Correspondingly, when the first device receives the log reported by the service, it can determine whether to store the log in the database according to the type of the log and the identification information of the service request and the operation type of the service included in the log.For example, when the type of the log includes a pre-log, it can be considered that the log belongs to the log sent by the front-end service, and the first device can directly store the log in the database. For another example, when the type of the log does not include a pre-log, the first device can use the identification information of the service request included in the log and the operation type of the service to determine whether the database contains the pre-log corresponding to the log. When the database contains the pre-log corresponding to the log, the first device can determine that the log belongs to the log sent by the front-end service and store the log in the database. When the database does not contain the pre-log corresponding to the log, the first device can determine that the log belongs to the log sent by the back-end service and discard the log. In this way, the first device can ensure that only the logs sent by the front-end service are stored in the database, and the situation of chaos and mutual overwriting of the logs stored in the database can be avoided, so that accurate resource management can be realized by using the logs in the database.

[0143] The following further describes the present application in detail with application examples.

[0144] To solve the problem of mutual overwriting of the logs of multiple business services (i.e., the above-mentioned multiple services) in the microservice system (which can also be understood as log records), and the problem of incomplete records of small-grained resources in the logs, the application example of the present application proposes a method for processing refined logs in a private cloud to achieve refined log records for all resources and ensure the stability and accuracy of the logs. As Figure 5 shown, it includes the following steps:

[0145] Step 501: The gateway service of the microservice system processes an external request; during the process of the gateway service processing the external request, a globally unique request ID (requestId) can be generated as the unique identifier of the external request, and the external request and the requestId are routed to Service A;

[0146] Specifically, the request sent by the gateway service to Service A can be called a front-end request, and the URL of the front-end request includes the requestId.

[0147] Step 502: After receiving the front-end request, Service A executes the business logic corresponding to the front-end service based on the controller corresponding to the front-end service; among them, the controller corresponding to the front-end service in Service A is added with a log annotation, and the code of the service layer corresponding to Service A is also added with a log annotation, and the context of the process of executing the business logic carries the requestId;

[0148] When Service A executes the business logic, it generates front-end logs, refined logs, and back-end logs, and sends the generated logs to Redis.

[0149] Specifically, before executing the business logic, the service first reads the requestId (i.e., the identification information of the above service request) and the enumerated value of the operation type of Service A (i.e., the operation type of the above first service, hereinafter referred to as the operation type of Service A) through the log annotation in the controller, and reports the requestId and the operation type of Service A as the pre-log to Redis; during the process of Service A executing the business logic, the service queries information such as the identification, name, resource pool to which it belongs, and the corresponding tenant of the operation resource through the log annotation of the service layer code, and assembles the queried information, the requestId, and the operation type of Service A into a refined log (i.e., the above-mentioned fine log) and sends it to Redis; after Service A finishes executing the business logic, it can capture the execution result of the business logic through the log annotation in the controller, and form a post-log (which can also be called a post-result log) with the execution result of the business logic, the requestId, and the operation type of Service A and send it to Redis.

[0150] Exemplarily, assume that Service A is related to deleting a cloud host. At this time, the attribute list of the pre-log can be represented as Table 2, the attribute list of the refined log can be represented as Table 1, and the attribute list of the post-log can be represented as Table 3.

[0151] Attribute Name Remark requestId requestId Unique Identifier of the Request Call Chain logaction Operation Name Delete Cloud Host, Create Cloud Host, etc.

[0152] Table 2

[0153] Attribute Name Remark requestId requestId Unique Identifier of the Request Call Chain logaction Operation Name Delete Cloud Host, Create Cloud Host, etc. result Operation Result Success or Failure

[0154] Table 3

[0155] During the process of Service A executing the business logic, it may send a back-end internal service request to Service B to call Service B, and then execute step 503, where the back-end internal service request contains the requestId.

[0156] Step 503: After receiving the back-end internal service request, Service B executes the business logic corresponding to Service B based on the controller corresponding to the back-end service; among them, the controller corresponding to the front-end service in Service B does not add a log annotation, the service layer code corresponding to Service B adds a log annotation, and the context of the process of executing the business logic carries the requestId;

[0157] When Service B executes the business logic, it generates a refined log and sends the generated log to Redis; then it executes step 504.

[0158] Step 504: The log processing module pulls the Redis logs regularly (for example, every 3 minutes); then for each pulled log, step 505 is executed;

[0159] Step 505: The log processing module determines the type of the log;

[0160] If the type of the log includes pre-log or post-log, directly store the log in the database; or, if the type of the log includes refined log, execute step 506;

[0161] Step 506: The log processing module uses the requestId included in the log and the operation type of the service to query whether there is a pre-log corresponding to the log in the database, and obtains the query result;

[0162] If the query result indicates that there is no pre-log corresponding to the log, directly discard the log; or, if the query result indicates that there is a pre-log corresponding to the log, execute step 507;

[0163] Step 507: The log processing module determines a log template according to the operation type of the service corresponding to the log, and uses the determined log template to parse the refined log into a user-readable log (i.e., the above-readable log) and all resource operation logs involved in the operation (i.e., the above single-resource log), and stores the parsed user-readable log and all resource operation logs involved in the operation in the database.

[0164] The solution provided by the application example of the present application proposes a new refined log management model, innovatively introduces the controller layer, and combines it with the requestId to ensure the uniqueness of the logs in the whole link, greatly improving the reuse rate of the backend code, effectively reducing the interface rewriting caused by recording business logs, improving the interface reuse rate, preventing the situation of log duplication and coverage confusion, and ensuring the stability and accuracy of user logs; at the same time, a log (such as a complex operation log of private cloud resources) parsing method is proposed, which first decouples the log type (which can also be understood as identifying the logs generated in different stages, such as pre-logs, post-logs, refined logs), and then performs log template matching according to the log operation type, and separates the readable complex logs and single-resource data, solving the problem of recording the full life cycle logs of resources with different dimensions and different granularities.

[0165] To implement the method provided by the second device side with at least the first service deployed in the embodiments of the present application, the embodiments of the present application also provide a log processing device, which is set on the second device, as Figure 6 shown, the device includes:

[0166] A receiving unit 601, configured to receive a service request for requesting to execute the business logic corresponding to the first service, where the first service belongs to a microservice system;

[0167] A determining unit 602, configured to determine a corresponding controller according to the service type requested by the service request, where the service type requested by the service request includes at least a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to a first device before the business logic is executed; the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed;

[0168] An execution unit 603, configured to execute the business logic based on the determined controller and generate a log; send the generated log to the first device, where the generated log at least includes the identification information of the service request and the operation type of the first service, and the first device is at least used to collect the logs reported by the services in the microservice system, and the types of the reported logs include at least one of the following:

[0169] A pre-log representing before the business logic is executed;

[0170] A fine-grained log representing during the execution of the business logic;

[0171] A post-log representing after the business logic is executed.

[0172] Wherein, in one embodiment, the determining unit 602 is specifically configured to:

[0173] Determine a corresponding controller according to the URL of the service request.

[0174] In one embodiment, when the service type requested by the service request includes a front-end service, the execution unit 603 is specifically configured to:

[0175] Before the business logic is executed, the determined controller obtains the identification of the service request and the operation type of the first service through an annotation and generates a first log, where the first log includes the identification information of the service request and the operation type of the first service; the type of the first log includes a pre-log;

[0176] During the execution of the business logic, a second log is generated, where the second log includes the identification information of the service request, the operation type of the first service, and the resource-related information corresponding to the first request, and the type of the second log includes a fine-grained log;

[0177] After the business logic is executed, a third log is generated. The third log includes the identification information of the service request, the operation type of the first service, and the execution result of the business logic. The type of the third log includes a post log.

[0178] In one embodiment, when the service type requested by the service request includes a backend service, the execution unit 603 is specifically configured to:

[0179] During the execution of the business logic, a fourth log is generated. The fourth log includes the identification information of the service request, the operation type of the first service, and the resource-related information corresponding to the first request. The type of the fourth log includes a detailed log.

[0180] In practical applications, the receiving unit 601 can be implemented by a communication interface in the log processing device, the determining unit 602 can be implemented by a processor in the log processing device, and the execution unit 603 can be implemented by a processor in the log processing device in combination with the communication interface.

[0181] To implement the method on the first device side in the embodiments of the present application, the embodiments of the present application further provide a log processing device, which is disposed on the first device. The first device is at least used to collect the logs reported by services in the microservice system, such as Figure 7 As shown, the device includes:

[0182] An obtaining unit 701, configured to obtain the logs reported by the first service. The reported logs at least include the identification information of the service request and the operation type of the first service. The type of the logs includes at least one of the following:

[0183] A pre log representing before the execution of the business logic;

[0184] A detailed log representing during the execution of the business logic;

[0185] A post log representing after the execution of the business logic is completed;

[0186] A processing unit 702, configured to store the logs in a database or discard the logs according to the type of the logs, the identification information of the service request, and the operation type of the first service.

[0187] Wherein, in one embodiment, the processing unit 702 is specifically configured to execute one or more of the following items:

[0188] The logs reported by the first service include a first log. Determine that the type of the first log includes a pre log, and store the first log in the database;

[0189] The log reported by the first service includes a second log. When it is determined that the type of the second log includes a fine-grained log and the database includes the pre-log corresponding to the second log, the second log is stored in the database;

[0190] The log reported by the first service includes a third log. When it is determined that the type of the third log includes a post-log, the third log is stored in the database.

[0191] In one embodiment, the processing unit 702 is specifically configured to:

[0192] The log reported by the first service includes a fourth log. When it is determined that the type of the fourth log includes a fine-grained log and the database does not include the pre-log corresponding to the fourth log, the fourth log is discarded.

[0193] In one embodiment, the processing unit 702 is specifically configured to:

[0194] Parse the log based on a preset template to obtain a parsing result;

[0195] Store the parsing result in the database.

[0196] In practical applications, the obtaining unit 701 can be implemented by a communication interface in the log processing device, and the processing unit 702 can be implemented by a processor in the log processing device.

[0197] It should be noted that: when the log processing device provided in the above embodiment performs log processing, only the above division of each program unit is used for illustration. In practical applications, the above processing can be allocated to different program units according to needs, that is, the internal structure of the device is divided into different program units to complete all or part of the above-described processing. In addition, the log processing device provided in the above embodiment and the log processing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0198] Based on the hardware implementation of the above program module, and in order to implement the method on the second device side of the embodiments of the present application, the embodiments of the present application further provide a second device. The second device is at least deployed with a first service, and the first service belongs to a microservice system. As Figure 8 shown, the second device 800 includes:

[0199] A first communication interface 801 capable of information interaction with the first device;

[0200] A first processor 802 connected to the first communication interface 801 to implement information interaction with the first device. When used to run a computer program, it executes the method provided by one or more technical solutions on the second device side described above;

[0201] A first memory 803, on which the computer program is stored.

[0202] Specifically, the first communication interface 801 is configured to:

[0203] Receive a service request for requesting to execute the business logic corresponding to the first service;

[0204] The first processor 802 is configured to:

[0205] According to the service type requested by the service request, determine the corresponding controller. The service types requested by the service request include at least a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to the first device before the business logic is executed; the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed; and based on the determined controller, execute the business logic and generate a log; send the generated log to the first device through the first communication interface 801. The generated log at least includes the identification information of the service request and the operation type of the first service. The first device is at least used to collect the logs reported by the services in the microservice system. The types of the reported logs include at least one of the following:

[0206] Pre-log indicating before the business logic is executed;

[0207] Fine-grained log indicating during the business logic is executed;

[0208] Post-log indicating after the business logic is executed.

[0209] Wherein, in one embodiment, the first processor 802 is specifically configured to:

[0210] Determine the corresponding controller according to the URL of the service request.

[0211] In one embodiment, when the service type requested by the service request includes a front-end service, the first processor 802 is specifically configured to:

[0212] Before the business logic is executed, the determined controller obtains the identification of the service request and the operation type of the first service through an annotation and generates a first log. The first log includes the identification information of the service request and the operation type of the first service; the type of the first log includes a pre-log;

[0213] During the execution of the business logic, a second log is generated. The second log includes the identification information of the service request, the operation type of the first service, and the resource-related information corresponding to the first request. The type of the second log includes a detailed log.

[0214] After the business logic is executed, a third log is generated. The third log includes the identification information of the service request, the operation type of the first service, and the execution result of the business logic. The type of the third log includes a post-log.

[0215] In an embodiment, when the service type requested by the service request includes a backend service, the first processor 802 is specifically configured to:

[0216] During the execution of the business logic, a fourth log is generated. The fourth log includes the identification information of the service request, the operation type of the first service, and the resource-related information corresponding to the first request. The type of the fourth log includes a detailed log.

[0217] It should be noted that the specific processing procedures of the first processor 802 and the first communication interface 801 can be understood with reference to the above method.

[0218] Of course, in actual application, each component in the second device 800 is coupled together through the bus system 804. It can be understood that the bus system 804 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 804 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear description, in Figure 8 all kinds of buses are labeled as the bus system 804.

[0219] The first memory 803 in the embodiment of the present application is used to store various types of data to support the operation of the second device 800. Examples of these data include: any computer program for operating on the second device 800.

[0220] The method disclosed in the embodiments of the present application can be applied to the first processor 802 or implemented by the first processor 802. The first processor 802 may be an integrated circuit chip with signal processing capabilities. During implementation, the steps of the above method can be completed by the integrated logic circuit in hardware or instructions in software form in the first processor 802. The above first processor 802 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The first processor 802 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. Combining the steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed and completed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, and this storage medium is located in the first memory 803. The first processor 802 reads the information in the first memory 803 and combines its hardware to complete the steps of the foregoing method.

[0221] In an exemplary embodiment, the second device 800 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontroller units (MCUs), microprocessors, or other electronic components for executing the foregoing method.

[0222] Based on the hardware implementation of the above program module, and in order to implement the method on the first device side in the embodiments of the present application, the embodiments of the present application further provide a first device. The first device is at least used to collect the logs reported by the services in the microservice system, such as Figure 9 As shown, this first device 900 includes:

[0223] A second communication interface 901 capable of interacting with a second device at least deploying a first service;

[0224] A second processor 902, connected to the second communication interface 901 to implement information interaction with a second device, and when running a computer program, executes the method provided by one or more of the above technical solutions on the first device side;

[0225] A second memory 903, where the computer program is stored on the second memory 903.

[0226] Specifically, the second communication interface 901 is used for:

[0227] Obtain logs reported by a first service, where the reported logs at least include identification information of a service request and an operation type of the first service, and the type of the logs includes at least one of the following:

[0228] A pre-log indicating before the execution of the business logic;

[0229] A detailed log indicating during the execution of the business logic;

[0230] A post-log indicating after the execution of the business logic is completed;

[0231] The second processor 902 is used for:

[0232] According to the type of the log, the identification information of the service request, and the operation type of the first service, store the log in a database or discard the log.

[0233] Wherein, in one embodiment, the second processor 902 is specifically used to execute one or more of the following:

[0234] The log reported by the first service includes a first log, determine that the type of the first log includes a pre-log, and store the first log in the database;

[0235] The log reported by the first service includes a second log, determine that the type of the second log includes a detailed log, and the database includes the pre-log corresponding to the second log, and store the second log in the database;

[0236] The log reported by the first service includes a third log, determine that the type of the third log includes a post-log, and store the third log in the database.

[0237] In one embodiment, the second processor 902 is specifically used for:

[0238] The log reported by the first service includes a fourth log, determine that the type of the fourth log includes a detailed log, and the database does not include the pre-log corresponding to the fourth log, and discard the fourth log.

[0239] In one embodiment, the second processor 902 is specifically used for:

[0240] Parse the log based on a preset template to obtain a parsing result;

[0241] Store the parsing result in a database.

[0242] It should be noted that: The specific processing procedures of the second processor 902 and the second communication interface 901 can be understood with reference to the above method.

[0243] Of course, in actual application, each component in the first device 900 is coupled together through the bus system 904. It can be understood that the bus system 904 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 904 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 9 all kinds of buses are labeled as the bus system 904.

[0244] The second memory 903 in the embodiments of the present application is used to store various types of data to support the operation of the first device 900. Examples of these data include: any computer program for operating on the first device 900.

[0245] The method disclosed in the above embodiments of the present application can be applied to the second processor 902 or implemented by the second processor 902. The second processor 902 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the second processor 902 or by instructions in the form of software. The above-mentioned second processor 902 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The second processor 902 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. Combining the steps of the method disclosed in the embodiments of the present application, it can be directly embodied as being executed and completed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, and this storage medium is located in the second memory 903. The second processor 902 reads the information in the second memory 903 and combines its hardware to complete the steps of the foregoing method.

[0246] In an exemplary embodiment, the first device 900 may be implemented by one or more ASICs, DSPs, PLDs, CPLDs, FPGAs, general-purpose processors, controllers, MCUs, Microprocessors, or other electronic components for executing the foregoing method.

[0247] It can be understood that the memories (the first memory 803 and the second memory 903) in the embodiments of the present application can be volatile memories or non-volatile memories, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM, Read Only Memory), a programmable read-only memory (PROM, Programmable Read-Only Memory), an erasable programmable read-only memory (EPROM, Erasable Programmable Read-Only Memory), an electrically erasable programmable read-only memory (EEPROM, Electrically Erasable Programmable Read-Only Memory), a ferromagnetic random access memory (FRAM, ferromagnetic random access memory), a flash memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM, Compact Disc Read-Only Memory); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM, Random Access Memory), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as a static random access memory (SRAM, Static Random Access Memory), a synchronous static random access memory (SSRAM, Synchronous Static Random Access Memory), a dynamic random access memory (DRAM, Dynamic Random Access Memory), a synchronous dynamic random access memory (SDRAM, Synchronous Dynamic Random Access Memory), a double data rate synchronous dynamic random access memory (DDR SDRAM, Double Data Rate Synchronous Dynamic Random Access Memory), an enhanced synchronous dynamic random access memory (ESDRAM, Enhanced Synchronous Dynamic Random Access Memory), a synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), a direct rambus random access memory (DRRAM, Direct Rambus Random Access Memory).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.

[0248] In an exemplary embodiment, the embodiments of the present application also provide a storage medium, namely a computer storage medium, specifically a computer-readable storage medium. For example, it includes a first memory 803 that stores a computer program. The above computer program can be executed by a first processor 802 of a second device 800 to complete the steps of the method on the second device side where at least the first service is deployed. Another example is a second memory 903 that stores a computer program. The above computer program can be executed by a second processor 902 of a first device 900 to complete the steps of the method on the first device side. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.

[0249] In an exemplary embodiment, the embodiments of the present application also provide a computer program product, including a computer program. The computer program can be executed by a first processor 802 of a second device 800 to complete the steps of the method on the second device side where at least the first service is deployed. Or, the computer program can be executed by a second processor 902 of a first device 900 to complete the steps of the method on the first device side.

[0250] To implement the method provided by the embodiments of the present application, the embodiments of the present application also provide a log processing system, as Figure 10 shown. The system includes: a second device 1001 and a first device 1002. The second device 1001 is at least deployed with a first service, and the first service belongs to a microservice system. The first device 1002 is at least used to collect the logs reported by the services in the microservice system.

[0251] Here, it should be noted that: the specific processing procedures of the second device 1001 and the first device 1002 have been described in detail above and will not be elaborated here.

[0252] It should be noted that: "first", "second", etc. are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence.

[0253] In addition, among the technical solutions described in the embodiments of the present application, they can be combined arbitrarily without conflict.

[0254] The above is only a preferred embodiment of the present application and is not used to limit the protection scope of the present application.

Claims

1. A log processing method, characterized in that: Applied to a first service, the first service belonging to a microservice system, the method includes: receiving a service request, wherein the service request is used to request execution of a business logic corresponding to the first service; Determine a corresponding controller controller according to the service type requested by the service request, where the service type requested by the service request includes at least a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to the first device before the business logic is executed; the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed; Based on the determined controller, execute the business logic and generate a log; send the generated log to the first device, where the generated log includes at least the identification information of the service request and the operation type of the first service, and the first device is at least used to collect the logs reported by the services in the microservice system, and the types of the reported logs include at least one of the following: Represents the pre-log before the business logic is executed; Represents detailed logs during the execution of business logic; Post-log indicating the completion of business logic execution.

2. The method according to claim 1, characterized in that The determining a corresponding controller according to the service type requested by the service request includes: According to the uniform resource locator URL of the service request, a corresponding controller is determined.

3. The method according to claim 1 or 2, characterized in that: In the case where the service type requested by the service request includes a front-end service, the controller based on the determination executes the business logic and generates a log, including: Before the business logic is executed, the determined controller obtains the identifier of the service request and the operation type of the first service through annotation, and generates a first log, wherein the first log includes the identifier information of the service request and the operation type of the first service; the type of the first log includes a pre-log; During the execution of the business logic, a second log is generated, wherein the second log includes identification information of the service request, an operation type of the first service, and resource-related information corresponding to the first request, and the type of the second log includes a detailed log; After the business logic is executed, a third log is generated, wherein the third log includes identification information of the service request, the operation type of the first service, and the execution result of the business logic; the type of the third log includes a post-log.

4. The method according to claim 1 or 2, characterized in that: In the case where the service type requested by the service request includes a backend service, the controller based on the determination executes the business logic and generates a log, including: During the execution of the business logic, a fourth log is generated, the fourth log including identification information of the service request, the operation type of the first service, and resource-related information corresponding to the first request, and the type of the fourth log includes a detailed log.

5. A log processing method, characterized in that: Applied to a first device, the first device is at least used to collect logs reported by services in a microservice system, and the method includes: Obtain a log reported by the first service, where the reported log includes at least identification information of the service request and an operation type of the first service, and the type of the log includes at least one of the following: Represents the pre-log before the business logic is executed; Represents detailed logs during the execution of business logic; Post-log that indicates the completion of business logic execution; According to the type of the log, the identification information of the service request, and the operation type of the first service, the log is stored in a database or discarded.

6. The method according to claim 5, characterized in that When storing the log into the database or discarding the log according to the type of the log and the information contained in the log, one or more of the following is performed: The log reported by the first service includes a first log, determining that a type of the first log includes a preceding log, and storing the first log in a database; The log reported by the first service includes a second log, determining that a type of the second log includes a detailed log, and that the database includes a preceding log corresponding to the second log, and storing the second log in the database; The log reported by the first service includes a third log, it is determined that a type of the third log includes a post-log, and the third log is stored in a database.

7. The method according to claim 5, characterized in that: The storing the log into a database or discarding the log according to the type of the log and the information contained in the log includes: The log reported by the first service includes a fourth log, it is determined that the type of the fourth log includes a fine log, and the database does not include a preceding log corresponding to the fourth log, and the fourth log is discarded.

8. The method according to any one of claims 5 to 7, characterized in that: The storing of logs into a database comprises: Parse the log based on a preset template to obtain a parsing result; The analysis results are stored in a database.

9. A log processing device, characterized in that: The second device is provided with at least a first service deployed thereon, including: A receiving unit, configured to receive a service request, wherein the service request is used to request execution of a business logic corresponding to the first service; A determination unit, configured to determine a corresponding controller according to a service type requested by the service request, wherein the service type requested by the service request includes at least a front-end service or a back-end service; the controller corresponding to the front-end service can at least send a log to the first device before the business logic is executed; and the controller corresponding to the back-end service cannot send a log to the first device before the business logic is executed; The execution unit is configured to execute the business logic based on the determined controller and generate a log; send the generated log to the first device, wherein the generated log includes at least the identification information of the service request and the operation type of the first service, and the first device is configured to collect logs reported by services in the microservice system, and the types of the reported logs include at least one of the following: Represents the pre-log before the business logic is executed; Represents detailed logs during the execution of business logic; Post-log indicating the completion of business logic execution.

10. A log processing device, characterized in that: Set on a first device, the first device is at least used to collect logs reported by services in the microservice system, including: An acquiring unit is configured to acquire a log reported by the first service, wherein the reported log includes at least identification information of the service request and an operation type of the first service, and the type of the log includes at least one of the following: Represents the pre-log before the business logic is executed; Represents detailed logs during the execution of business logic; Post-log that indicates the completion of business logic execution; The processing unit is used to store the log into a database or discard the log according to the type of the log, the identification information of the service request, and the operation type of the first service.

11. A second device, characterized in that: At least a first service is deployed, including: a first processor and a first memory for storing a computer program that can be run on the processor, Wherein, when the first processor is used to run the computer program, the steps of the method described in any one of claims 1 to 4 are executed.

12. A first device, characterized in that: include: a second processor and a second memory for storing a computer program executable on the processor, Wherein, when the second processor is used to run the computer program, the steps of the method described in any one of claims 5 to 8 are executed.

13. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 4, or implements the steps of the method according to any one of claims 5 to 8.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 4, or implements the steps of the method according to any one of claims 5 to 8.