Log retrieval method and device for distributed system

By using trace identifiers and parent operation identifiers to determine the order in which log information is called in a distributed system, the problem of low log retrieval efficiency is solved, and efficient log location and retrieval are achieved.

CN114090514BActive Publication Date: 2026-03-17CHINA CONSTRUCTION BANK
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In distributed systems, due to the excessive and disorganized nature of logs, existing technologies struggle to efficiently locate the source of problems, resulting in low retrieval efficiency.

Method used

In response to a log retrieval request, the system uses a trace identifier to identify the corresponding log information in the stored log information, and uses the parent operation identifier and operation identifier to determine the order in which the log information is called, and then displays the log information in sequence.

Benefits of technology

It improves the efficiency of log retrieval, enabling technicians to quickly locate the problem point based on the log call order, reducing the storage of invalid logs and improving retrieval accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114090514B_ABST
    Figure CN114090514B_ABST
Patent Text Reader

Abstract

This application provides a log retrieval method and apparatus for a distributed system, relating to the field of data processing technology. The method includes: responding to a log retrieval request, determining, based on a tracking identifier corresponding to the log retrieval request, each log message corresponding to the tracking identifier in stored log messages; obtaining the calling order of each log message using a parent operation identifier and an operation identifier in each log message; and displaying the log messages sequentially according to the calling order. Thus, this application displays each log message corresponding to the log retrieval request sequentially according to the log calling order. This allows technicians to view logs according to the calling order, improving log retrieval efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a log retrieval method and apparatus for a distributed system. Background Technology

[0002] As distributed system business becomes increasingly complex, some critical business scenarios require the use of logs within the distributed system to locate problems when they encounter generation issues. However, due to the massive amount of logs in distributed systems, it is necessary to retrieve the required logs.

[0003] Existing log retrieval methods retrieve all logs corresponding to keywords. However, due to the large volume of logs and the disorganized nature of the information, it is difficult to pinpoint the source of the problem, resulting in low retrieval efficiency. Summary of the Invention

[0004] This application provides an exemplary embodiment of a log retrieval method for a distributed system, which improves log retrieval efficiency.

[0005] A first aspect of this application provides a log retrieval method for a distributed system, the method comprising:

[0006] In response to a log retrieval request, based on the tracking identifier corresponding to the log retrieval request, each log information corresponding to the tracking identifier is determined from the stored log information;

[0007] The order in which each log message is called is obtained by using the parent operation identifier and operation identifier in each log message;

[0008] The log information is displayed sequentially according to the order in which it is called.

[0009] In this embodiment, in response to a log retrieval request, based on the tracking identifier corresponding to the log retrieval request, the system determines the log information corresponding to the tracking identifier from the stored log information; and using the parent operation identifier and operation identifier in each log information, it obtains the calling order of each log information, and then displays the log information sequentially according to the calling order. Therefore, this embodiment can display the log information corresponding to the log retrieval request sequentially according to the log calling order, allowing technicians to view logs according to the calling order and improving log retrieval efficiency.

[0010] In one embodiment, obtaining the calling order of each log message using the parent operation identifier and operation identifier in each log message includes:

[0011] For any given log entry, the identifier in that log entry is compared with the parent operation identifier in other log entries.

[0012] If it is determined that there is a target log information whose parent operation identifier is the same as the operation identifier in the log information, then the calling order of the target log information is determined to be before the log information, and the log information is adjacent to it.

[0013] This embodiment compares the identifier in any given log message with the parent operation identifiers in other log messages. If a target log message is found to have a parent operation identifier identical to the operation identifier in the given log message, then the call order of the target log message is determined to be before the given log message, and the given log messages are adjacent. Therefore, by comparing the operation identifier of a log message with the parent operation identifiers in other log messages, the call order of each log message is obtained, improving the accuracy of the call order.

[0014] In one embodiment, before determining the log information corresponding to the tracking identifier from the stored log information based on the tracking identifier corresponding to the log retrieval request in response to the log retrieval request, the method further includes:

[0015] Upon receiving an external business call request, the external business call request is traced using an open distributed tracing algorithm to obtain tracing parameters for each microservice instance in the business request call chain. The tracing parameters include a tracing identifier and an operation identifier, and the business request call chain includes each microservice instance called by the external business call request.

[0016] For any microservice instance in a distributed system, perform the following steps:

[0017] After receiving the internal business call request sent by the target microservice instance, the internal business call request is parsed to obtain the target operation identifier corresponding to the target microservice instance. The target microservice instance is the microservice instance that is located before and adjacent to the microservice instance in the business request call chain, and the internal business call request is obtained based on the external business call request.

[0018] The target operation identifier is determined as the parent operation identifier of the microservice instance;

[0019] Add the trace parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance.

[0020] In this embodiment, the operation identifier of the microservice instance that is located before and adjacent to the microservice instance in the business request call chain is determined as the parent operation identifier of the microservice instance itself. The tracking parameters, the first preset identifier, and the parent operation identifier of the microservice instance are added to the log information corresponding to the microservice instance. This ensures that during retrieval, the log information can be displayed according to the order of the log information based on the parent operation identifier.

[0021] In one embodiment, after receiving the internal business call request sent by the target microservice instance and before parsing the internal business call request, the method further includes:

[0022] It is determined that the microservice instance has a second preset identifier.

[0023] This embodiment parses internal business call requests sent by the target microservice instance only after determining that a first preset identifier exists in the microservice instance, obtaining the parent operation identifier, and adding the microservice instance's tracking parameters, the first preset identifier, and the parent operation identifier to the log information. This marks key microservice instances, ensuring that only log information for key microservice instances is recorded, reducing log search volume and improving log retrieval efficiency.

[0024] In one embodiment, after adding the trace parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance, the method further includes:

[0025] The log files corresponding to each microservice in the distributed system are periodically retrieved, and the log files corresponding to each microservice include log information of each microservice instance corresponding to the microservice.

[0026] For any given log file, iterate through each log entry in the log file;

[0027] For any log message that is traversed, if the first preset identifier exists in the log message, then the log message is stored.

[0028] This embodiment periodically retrieves log files corresponding to each microservice in the distributed system. Each microservice log file includes log information for each microservice instance. For any given log file, it iterates through all log entries. For any encountered log entry, if it contains the first preset identifier, it stores that log entry. This reduces the number of log entries and improves retrieval efficiency by storing only those containing the first preset identifier.

[0029] A second aspect of this application provides a log retrieval device for a distributed system, the device comprising:

[0030] The log information determination module is used to respond to a log retrieval request and, based on the tracking identifier corresponding to the log retrieval request, determine each log information corresponding to the tracking identifier from the stored log information.

[0031] The call order determination module is used to determine the call order of each log message by using the parent operation identifier and operation identifier in each log message;

[0032] The display module is used to display the log information sequentially according to the order in which the log information is called.

[0033] In one embodiment, the call order determination module is specifically used for:

[0034] For any given log entry, the identifier in that log entry is compared with the parent operation identifier in other log entries.

[0035] If it is determined that there is a target log information whose parent operation identifier is the same as the operation identifier in the log information, then the calling order of the target log information is determined to be before the log information, and the log information is adjacent to it.

[0036] In one embodiment, the apparatus further includes:

[0037] The tracing module, in response to a log retrieval request, before determining the log information corresponding to the tracing identifier in the stored log information based on the tracing identifier corresponding to the log retrieval request, after receiving an external business call request, uses an open distributed tracing algorithm to trace the external business call request and obtain tracing parameters for each microservice instance in the business request call chain; wherein, the tracing parameters include a tracing identifier and an operation identifier, and the business request call chain includes each microservice instance called by the external business call request;

[0038] The internal calling module is used to execute the following steps for any microservice instance in a distributed system:

[0039] After receiving the internal business call request sent by the target microservice instance, the internal business call request is parsed to obtain the operation identifier corresponding to the target microservice instance. The target microservice instance is the microservice instance that is located before and adjacent to the target microservice instance in the business request call chain, and the internal business call request is obtained based on the external business call request.

[0040] The target operation identifier is determined as the parent operation identifier of the microservice instance;

[0041] Add the trace parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance.

[0042] In one embodiment, the apparatus further includes:

[0043] The first preset identifier determination module is used to determine that the microservice instance has a second preset identifier after receiving the internal business call request sent by the target microservice instance and before parsing the internal business call request.

[0044] In one embodiment, the log information further includes a second preset identifier; the device further includes:

[0045] The log file acquisition module is used to periodically acquire the log files corresponding to each microservice in the distributed system after adding the tracking parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance. The log files corresponding to the microservice include the log information of each microservice instance corresponding to the microservice.

[0046] The traversal module is used to traverse each log message in any given log file.

[0047] The log information storage module is used to store any log information that has been traversed if the first preset identifier exists in the log information.

[0048] According to a third aspect of the embodiments of this application, an electronic device is provided, comprising:

[0049] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor; the instructions being executed by the at least one processor to enable the at least one processor to perform the method as described in the first aspect.

[0050] According to a fourth aspect provided in the embodiments of this application, a computer storage medium is provided, the computer storage medium storing a computer program for performing the method as described in the first aspect.

[0051] According to a fifth aspect of the present disclosure, a computer program product is provided, the computer program product including a computer program stored in a computer-readable storage medium, wherein at least one processor of the device reads from the computer-readable storage medium and executes the computer program, causing the device to perform the method described in the first aspect. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 This is one of the flowcharts illustrating a log retrieval method for a distributed system in one embodiment of this application;

[0054] Figure 2 This is a schematic diagram of a terminal interface according to an embodiment of this application;

[0055] Figure 3 This is a flowchart illustrating the process of determining the parent operation identifier of each log message according to one embodiment of this application;

[0056] Figure 4 This is a second flowchart illustrating a log retrieval method for a distributed system according to an embodiment of this application.

[0057] Figure 5 This application provides a log retrieval device for a distributed system according to one embodiment of the present application.

[0058] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0060] In the embodiments of this application, the term "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.

[0061] The application scenarios described in this application are for the purpose of more clearly illustrating the technical solutions of this application, and do not constitute a limitation on the technical solutions provided in this application. Those skilled in the art will understand that with the emergence of new application scenarios, the technical solutions provided in this application are also applicable to similar technical problems. In the description of this application, unless otherwise stated, "multiple" means two or more.

[0062] Existing log retrieval methods retrieve all logs corresponding to keywords. However, due to the large volume of logs and the disorganized nature of the information, it is difficult to pinpoint the source of the problem, resulting in low retrieval efficiency.

[0063] Therefore, this application provides a log retrieval method for a distributed system. In response to a log retrieval request, based on a tracking identifier corresponding to the log retrieval request, it determines the log information corresponding to the tracking identifier from the stored log information. Using the parent operation identifier and operation identifier in each log information, it obtains the calling order of each log information, and then displays the log information sequentially according to the calling order. Thus, in this embodiment, the log information corresponding to the log retrieval request can be displayed sequentially according to the log calling order. This allows technicians to view the logs according to the calling order, improving log retrieval efficiency. The financial data analysis scheme of this application will be described in detail below with reference to the accompanying drawings.

[0064] like Figure 1 The diagram shown is a flowchart of the log retrieval method for a distributed system in this application, which may include the following steps:

[0065] Step 101: In response to the log retrieval request, based on the tracking identifier corresponding to the log retrieval request, determine each log information corresponding to the tracking identifier in the stored log information;

[0066] The log retrieval request includes a tracking identifier.

[0067] Step 102: Use the parent operation identifier and operation identifier in each log message to obtain the calling order of each log message;

[0068] In one embodiment, the order in which log messages are invoked is obtained as follows:

[0069] For any log message, the identifier in the log message is compared with the parent operation identifier in other log messages. If it is determined that there is a target log message with the same parent operation identifier as the operation identifier in the log message, then the calling order of the target log message is determined to be before the log message, and the log messages are adjacent.

[0070] For example, the log information corresponding to the log retrieval request includes: Log Information 1, Log Information 2, Log Information 3, Log Information 4, and Log Information 5. If the operation identifier in Log Information 1 is the same as the parent operation identifier in Log Information 4, if the operation identifier in Log Information 4 is the same as the parent operation identifier in Log Information 3, and if the operation identifier in Log Information 3 is the same as the parent operation identifier in Log Information 2, then the order in which the log information is called is determined as: Log Information 1 → Log Information 4 → Log Information 3 → Log Information 2.

[0071] Step 103: Display the log information in sequence according to the order in which the log information is called.

[0072] like Figure 2 The image shown is a schematic diagram of the interface displaying various log information. Taking a mobile phone as an example, and using the previously mentioned log retrieval order as Log Message 1 → Log Message 4 → Log Message 3 → Log Message 2, this is an example. Figure 2 The system displays log information in the order in which they are accessed.

[0073] Therefore, in this embodiment, the log information corresponding to the log retrieval request can be displayed sequentially according to the order in which the logs are invoked. This allows technicians to view the logs according to the order in which they are invoked, improving log retrieval efficiency.

[0074] like Figure 3 The diagram shown illustrates the process for determining the parent operation identifier for each log entry, which may include the following steps:

[0075] Step 301: After receiving an external business call request, the external business call request is traced using an open distributed tracing algorithm to obtain the tracing parameters of each microservice instance in the business request call chain; wherein, the tracing parameters include tracing identifiers and operation identifiers, and the business request call chain includes each microservice instance called by the external business call request;

[0076] Step 302: For any microservice instance in the distributed system, perform the following steps: After receiving the internal business call request sent by the target microservice instance, parse the internal business call request to obtain the target operation identifier corresponding to the target microservice instance. The target microservice instance is the microservice instance that is located before the target microservice instance in the business request call chain and is adjacent to the target microservice instance. The internal business call request is obtained based on the external business call request.

[0077] To avoid storing a large amount of useless logs, in one embodiment, after receiving an internal business call request sent by the target micro-instance but before parsing the internal business call request, it is determined that the microservice instance has a second preset identifier.

[0078] If it is determined that the microservice instance does not have a second preset identifier, then the operation identifier of the target microservice instance is added to the internal business call request when the microservice instance sends an internal business call request to the next adjacent microservice instance.

[0079] For example, a microservice instance includes microservice instance 1, microservice instance 2, and microservice instance 3. Microservice instance 1 is the target microservice instance of microservice instance 2, and microservice instance 2 is the target microservice instance of microservice instance 3. After receiving an internal business call request from microservice instance 1, microservice instance 2 determines whether it has a second preset identifier. If it does, it parses the internal business call request. If it determines that microservice instance 2 does not have a second preset identifier, it adds the operation identifier of microservice instance 1 to the internal business request sent by microservice instance 2 to microservice instance 3. After receiving the internal business call request from microservice instance 2, if microservice instance 3 determines that it has a second preset identifier, it determines the operation identifier of microservice instance 1 as the parent operation identifier of microservice instance 3.

[0080] Step 303: Determine the target operation identifier as the parent operation identifier of the microservice instance;

[0081] Step 304: Add the trace parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance.

[0082] The tracking parameters include the parameter values, service name, hostname, and Internet Protocol address information of the preset method for internal business call requests.

[0083] In this embodiment, the tracking parameters, the first preset identifier, and the parent operation identifier are added to the log information corresponding to the microservice instance using MDC (Mapped Diagnostic Contexts) technology.

[0084] In order to store only critical logs, in one embodiment, log files corresponding to each microservice in the distributed system are periodically retrieved, wherein the log files corresponding to each microservice include log information of each microservice instance corresponding to the microservice; for any log file, each log information in the log file is traversed; for any traversed log information, if the log information contains the first preset identifier, the log information is stored.

[0085] For example, the log file corresponding to microservice 1 includes log information A for microservice instance 1, log information B for microservice instance 2, log information C for microservice instance 3, and log information D for microservice instance 4. If log information B and log information C contain a first preset identifier, while log information A and log information D do not contain the first preset identifier, then log information B and log information C are stored.

[0086] To further understand the technical solution of this application, the following is combined with... Figure 4 A detailed description of the log retrieval method for the distributed system in this application may include the following steps:

[0087] Step 401: After receiving an external business call request, the external business call request is traced using an open distributed tracing algorithm to obtain the tracing parameters of each microservice instance in the business request call chain; wherein, the tracing parameters include tracing identifiers and operation identifiers, and the business request call chain includes each microservice instance called by the external business call request;

[0088] Step 402: For any microservice instance in the distributed system, perform the following steps: After receiving the internal business call request sent by the target microservice instance, parse the internal business call request to obtain the target operation identifier corresponding to the target microservice instance. The target microservice instance is the microservice instance that is located before the target microservice instance in the business request call chain and is adjacent to the target microservice instance. The internal business call request is obtained based on the external business call request.

[0089] Step 403: Determine the target operation identifier as the parent operation identifier of the microservice instance;

[0090] Step 404: Add the trace parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance;

[0091] Step 405: Periodically obtain the log files corresponding to each microservice in the distributed system, wherein the log files corresponding to each microservice include log information of each microservice instance corresponding to the microservice;

[0092] Step 406: For any log file, iterate through each log entry in the log file;

[0093] Step 407: For any log message that is traversed, if the log message contains the first preset identifier, then store the log message;

[0094] Step 408: In response to the log retrieval request, based on the tracking identifier corresponding to the log retrieval request, determine each log information corresponding to the tracking identifier in the stored log information;

[0095] Step 409: Use the parent operation identifier and operation identifier in each log message to obtain the calling order of each log message;

[0096] Step 410: Display the log information in sequence according to the order in which the log information is called.

[0097] Based on the same inventive concept, the log retrieval method for a distributed system described above can also be implemented by a log retrieval device for a distributed system. The effect of this log retrieval device is similar to that of the aforementioned method, and will not be repeated here.

[0098] Figure 5 This is a schematic diagram of the structure of a log retrieval device for a distributed system according to an embodiment of this application.

[0099] like Figure 5 As shown, the log retrieval device 500 of the distributed system of this application may include a log information determination module 510, a call order determination module 520, and a display module 530.

[0100] The log information determination module 510 is used to respond to a log retrieval request and, based on the tracking identifier corresponding to the log retrieval request, determine each log information corresponding to the tracking identifier in the stored log information;

[0101] The call order determination module 520 is used to determine the call order of each log message by using the parent operation identifier and operation identifier in each log message;

[0102] The display module 530 is used to display the log information sequentially according to the order in which the log information is called.

[0103] In one embodiment, the call order determination module 520 is specifically used for:

[0104] For any given log entry, the identifier in that log entry is compared with the parent operation identifier in other log entries.

[0105] If it is determined that there is a target log information whose parent operation identifier is the same as the operation identifier in the log information, then the calling order of the target log information is determined to be before the log information, and the log information is adjacent to it.

[0106] In one embodiment, the apparatus further includes:

[0107] The tracing module 540 is configured to, in response to a log retrieval request, before determining the log information corresponding to the tracing identifier in the stored log information based on the tracing identifier corresponding to the log retrieval request, after receiving an external business call request, use an open distributed tracing algorithm to trace the external business call request and obtain tracing parameters for each microservice instance in the business request call chain; wherein, the tracing parameters include a tracing identifier and an operation identifier, and the business request call chain includes each microservice instance called by the external business call request;

[0108] Internal call module 550 is used to execute the following steps for any microservice instance in a distributed system:

[0109] After receiving the internal business call request sent by the target microservice instance, the internal business call request is parsed to obtain the target operation identifier of the target microservice instance. The target microservice instance is the microservice instance that is located before and adjacent to the microservice instance in the business request call chain, and the internal business call request is obtained based on the external business call request.

[0110] The target operation identifier is determined as the parent operation identifier of the microservice instance;

[0111] Add the trace parameters, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance.

[0112] In one embodiment, the apparatus further includes:

[0113] The first preset identifier determination module 560 is used to determine that the microservice instance has a second preset identifier after receiving the internal business call request sent by the target microservice instance and before parsing the internal business call request.

[0114] In one embodiment, the log information further includes a second preset identifier; the device further includes:

[0115] The log file acquisition module 570 is used to periodically acquire the log files corresponding to each microservice in the distributed system after adding the trace parameters of the microservice instance and the parent operation identifier to the log information corresponding to the microservice instance. The log files corresponding to the microservice include the log information of each microservice instance corresponding to the microservice.

[0116] The traversal module 580 is used to traverse each log message in any given log file.

[0117] The log information storage module 590 is used to store any log information that has been traversed if the first preset identifier exists in the log information.

[0118] After introducing a log retrieval method and apparatus for a distributed system according to an exemplary embodiment of this application, an electronic device according to another exemplary embodiment of this application will be introduced next.

[0119] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0120] In some possible implementations, the electronic device according to this application may include at least one processor and at least one computer storage medium. The computer storage medium stores program code that, when executed by the processor, causes the processor to perform the steps in the log retrieval method of the distributed system according to various exemplary embodiments of this application described above. For example, the processor may perform actions such as... Figure 1 Steps 101-103 are shown in the diagram.

[0121] The following reference Figure 6 To describe an electronic device 600 according to this embodiment of the present application. Figure 6 The electronic device 600 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0122] like Figure 6 As shown, the electronic device 600 is manifested in the form of a general electronic device. The components of the electronic device 600 may include, but are not limited to: at least one processor 601, at least one computer storage medium 602, and a bus 603 connecting different system components (including the computer storage medium 602 and the processor 601).

[0123] Bus 603 represents one or more of several bus structures, including a computer storage media bus or computer storage media controller, peripheral bus, processor, or local bus using any of the various bus structures.

[0124] Computer storage medium 602 may include readable media in the form of volatile computer storage media, such as random access computer storage medium (RAM) 621 and / or cache storage medium 622, and may further include read-only computer storage medium (ROM) 623.

[0125] The computer storage medium 602 may also include a program / utility 625 having a set (at least one) of program modules 624, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0126] Electronic device 600 can also communicate with one or more external devices 604 (e.g., keyboard, pointing device, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other electronic devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 605. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 606. As shown, network adapter 606 communicates with other modules used in electronic device 600 via bus 603. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0127] In some possible implementations, various aspects of the log retrieval method for a distributed system provided in this application can also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to cause the computer device to perform the steps in the log retrieval method for a distributed system according to the various exemplary embodiments of this application described above.

[0128] The program product may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access computer storage media (RAM), read-only computer storage media (ROM), erasable programmable read-only computer storage media (EPROM or flash memory), optical fibers, portable compact disk read-only computer storage media (CD-ROM), optical computer storage media, magnetic computer storage media, or any suitable combination thereof.

[0129] The log retrieval program product of the distributed system according to the embodiments of this application can be a portable compact disk read-only computer storage medium (CD-ROM) and include program code, and can run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0130] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0131] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0132] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's electronic device, partially on the user's device, as a standalone software package, partially on the user's electronic device and partially on a remote electronic device, or entirely on a remote electronic device or server. In cases involving remote electronic devices, the remote electronic device can be connected to the user's electronic device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external electronic device (e.g., via the Internet using an Internet service provider).

[0133] It should be noted that although several modules of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more modules described above can be embodied in one module. Conversely, the features and functions of one module described above can be further divided and embodied by multiple modules.

[0134] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0135] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk computer storage media, CD-ROMs, optical computer storage media, etc.) containing computer-usable program code.

[0136] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0137] These computer program instructions may also be stored in a computer-readable computer storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable computer storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0138] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0139] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A log retrieval method of a distributed system, characterized by, The method comprises: After receiving the external service call request, the external service call request is tracked and processed by using an open distributed tracking algorithm to obtain tracking parameters of each micro-service instance in a service request call link, wherein the tracking parameters comprise a tracking identifier, an operation identifier, a parameter value of a preset method of an internal service call request, a service name, a host name and Internet Protocol address information, and the service request call link comprises each micro-service instance called by the external service call request; For any one micro-service instance in the distributed system, the following steps are performed: After receiving the internal service call request sent by the target micro-service instance, the internal service call request is parsed to obtain a target operation identifier corresponding to the target micro-service instance, wherein the target micro-service instance is in front of the micro-service instance and adjacent to the micro-service instance in the service request call link, and the internal service call request is obtained based on the external service call request; The target operation identifier is determined as the parent operation identifier of the micro-service instance; The tracking parameters, the first preset identifier and the parent operation identifier of the micro-service instance are added to the log information corresponding to the micro-service instance; In response to a log retrieval request, based on a tracking identifier corresponding to the log retrieval request, each log information corresponding to the tracking identifier is determined in the stored log information; The calling order of each log information is obtained by using the parent operation identifier and the operation identifier in each log information. The calling order of each log information is obtained by using the parent operation identifier and the operation identifier in each log information.

2. The method of claim 1, wherein, The calling order of each log information is obtained by using the parent operation identifier and the operation identifier in each log information. The method further comprises: It is determined that the micro-service instance has a second preset identifier.

3. The method of claim 1, wherein, The method further comprises: Periodically obtain log files corresponding to each micro-service in the distributed system, wherein the log file corresponding to the micro-service comprises log information of each micro-service instance corresponding to the micro-service; 4. The method of claim 1, wherein, For any one log file, each log information in the log file is traversed; For any one of the traversed log information, if the first preset identifier exists in the log information, the log information is stored. The device comprises: ​ 5. A log retrieval apparatus of a distributed system, characterized by comprising: ​ The tracking module is configured to, in response to a log retrieval request, based on a tracking identifier corresponding to the log retrieval request, determine, before determining each log information corresponding to the tracking identifier among each stored log information, each microservice instance in a service request invocation link by tracking processing an external service invocation request using an open distributed tracking algorithm after the external service invocation request is received; wherein the tracking parameter includes a tracking identifier, an operation identifier, a parameter value of a preset method of an internal service invocation request, a service name, a host name, and Internet Protocol address information, and the service request invocation link includes each microservice instance invoked by the external service invocation request. The internal calling module is configured to, for any one microservice instance in the distributed system, perform the following steps: After receiving an internal service invocation request sent by a target microservice instance, the internal service invocation request is parsed to obtain a target operation identifier corresponding to the target microservice instance, wherein the target microservice instance is a microservice instance located in front of the microservice instance and adjacent to the microservice instance in the service request invocation link, and the internal service invocation request is obtained based on the external service invocation request; The target operation identifier is determined as a parent operation identifier of the microservice instance; The tracking parameter, the first preset identifier, and the parent operation identifier of the microservice instance are added to the log information corresponding to the microservice instance; The log information determination module is configured to, in response to a log retrieval request, based on a tracking identifier corresponding to the log retrieval request, determine each log information corresponding to the tracking identifier among each stored log information. The calling sequence determination module is configured to obtain the calling sequence of each log information by using the parent operation identifier and the operation identifier in each log information. The display module is configured to sequentially display the log information according to the calling sequence of the log information.

6. The apparatus of claim 5, wherein, The calling sequence determination module is specifically configured to: For any one log information, compare the identifier in the log information with the parent operation identifier in other log information; If it is determined that there is a target log information in which the parent operation identifier is the same as the operation identifier in the log information, it is determined that the calling sequence of the target log information is in front of the log information, and the log information is adjacent.

7. The apparatus of claim 5, wherein, The device further comprises: A first preset identifier determination module is configured to, after receiving the internal service invocation request sent by the target microservice instance and before parsing the internal service invocation request, determine that the microservice instance has a second preset identifier.

8. The apparatus of claim 5, wherein, The device further comprises: A log file acquisition module is configured to, after adding the tracking parameter, the first preset identifier, and the parent operation identifier of the microservice instance to the log information corresponding to the microservice instance, periodically acquire log files corresponding to each microservice in the distributed system, wherein the log file corresponding to the microservice includes the log information of each microservice instance corresponding to the microservice. The traversing module is configured to traverse each log information in the log file for any one log file; The log information storage module is configured to, for any one of the traversed log information, if the first preset identifier exists in the log information, store the log information.

9. An electronic device, comprising: The computer storage medium stores a computer program, and the computer program is used for executing the method according to any one of claims 1-4.

10. A computer storage medium, characterized in that, The computer program is executed by the processor to implement the method according to any one of claims 1-4.

11. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Distributed service tracking method, system, storage medium and electronic equipment

    CN108038145A