An event-based cloud log cutting method
By setting up probes in cloud services and dividing log events, the problem of noise impact and computing resource requirements in large-scale cloud service log analysis is solved, and efficient and accurate log analysis is achieved.
Patent Information
- Application Number
- CN202111146695.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-09-28
AI Technical Summary
Existing technologies are easily affected by noise when processing logs of large-scale cloud services, are difficult to obtain event characteristics, and require a large amount of computing resources, resulting in low log analysis efficiency.
The event-based cloud log cutting method is used to collect process call stack information by setting probes in the target program, convert it into a tree structure, and divide the log events according to the maximum number of common ancestors to limit the log context range and avoid code recompilation. , improve the accuracy of analysis.
It improves the accuracy and efficiency of log analysis, avoids the impact of noise, reduces computing resource requirements, and can accurately record program execution paths and event chains.
Smart Images

Figure CN113806199B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of software engineering, and in particular relates to an event-based cloud log cutting method. Background Art
[0002] Today's cloud services are all running on large-scale server clusters. However, when a data center-scale service consisting of hundreds of software components running on thousands of computers fails, developers or operators need to use all available tools to troubleshoot and diagnose. Almost every software has a log source built in. Log is an abstraction of the changes in the system during operation. Its content is an ordered collection of certain operations of a specified object and its operation results in time. It provides detailed information that reflects the original developer's ideas about events that need attention and unusual events. These traces can accurately restore the running state of the program and analyze it in the event of system failures and failures to determine the cause and location of the problem.
[0003] As the scale of the system increases, the amount of information that operators must handle far exceeds the level that can be handled manually. Therefore, there is a huge demand for automatic processing of monitoring data. Events are atomic operations performed by users on the program. If the original log information is grouped into log sequences corresponding to events, that is, logs corresponding to atomic operations, there is a high correlation association. Once the key log information is determined, the scope of the log context corresponding to the crash event can be limited, so that system administrators can focus on specific events when analyzing logs, which can better indicate system problems than single log messages as low-level information. Existing methods can be divided into "source code analysis technology" and "process mining technology". They are subject to the two limitations of relying on the log itself and only analyzing the source code, and are easily affected by noise and difficult to obtain event characteristics.
[0004] Given the ubiquity of open source software in many production systems, as system maintainers or software developers, they have access to the source code. At the physical level, logs are based on pre-defined source code and are a real-time representation of the program's running status. Using source code as a roadmap can supplement system audits based on log information. If log information is tracked through source code, segmented, and extracted into events, this will achieve higher accuracy than pure log data analysis and overcome the weaknesses of the above methods. Summary of the invention
[0005] The purpose of the present invention is to overcome the problems in the prior art that it is easily affected by noise, difficult to obtain the characteristics of events, and requires a large amount of computing resources. It provides an event-based cloud log cutting method that can obtain the program execution status, automatically process the generated logs and split them according to events, and limit the scope of the log context corresponding to the specified event, which is important in log analysis work.
[0006] In order to achieve the above object, the present invention comprises the following steps:
[0007] S1, determine whether the target program uses the log framework transmission, if so, execute S2, if not, execute S3;
[0008] S2, locate the target function that interacts with the logging framework in the source code file that records the log, and execute S4;
[0009] S3, locates the log file that interacts with the log framework through the virtual file system VFS, and executes S4;
[0010] S4, set a probe on each function or log file, collect the process call stack when the target function or log file is called, and execute S5;
[0011] S5, convert the process call stack when being called into a tree structure, highlight the node corresponding to the log file, and execute S6;
[0012] S6, calculate the maximum number of common ancestors of adjacent highlighted nodes, and execute S7;
[0013] S7, the log is divided based on the 75% average value of the maximum number of common ancestors. Adjacent nodes with values above the 75% average value will be divided into the same event, otherwise they will be divided into different events.
[0014] In S2, a detection point is specified and a defined processing function is associated with the detection point. When the kernel executes to the detection point, the corresponding associated function is executed and then the normal code path continues.
[0015] In S3, when a file is to be read or written, the target program executes the write / read function in user mode, passes the data to the virtual file system VFS, and then enters kernel mode. The virtual file system VFS passes the data to the file system and writes it to the disk. Since the log information is passed to the virtual file system VFS through a chained function call, the program stack corresponding to the program execution write is obtained by monitoring the write function of the virtual file system VFS, and the log file in the target program is located according to the program stack.
[0016] In S4, a probe is placed on each function of the target program. When the program executes a function call, the probe will be triggered to record every stack change during the program execution;
[0017] Set a probe on the function that accepts all log inputs in the target program. When the target program writes log information to the corresponding log file, intercept the log information and record the log information and the corresponding program stack before passing it to the logging framework.
[0018] The specific method of S5 is as follows:
[0019] Perform difference analysis on the current trajectory and the previous trajectory to locate the nodes in the same part of the two.
[0020] Insert the difference into the tree as a child of the node;
[0021] After the execution tree is generated, the target node N is located using the log and path tuples and highlighted;
[0022] Attach the corresponding log information to the highlighted nodes.
[0023] The specific method of S6 is as follows:
[0024] Define DFN[u] as the order in which node u is searched in depth-first search, define LOW[i] as the order of the earliest node in the stack that i or its subtree can trace back to, and when DFN[i] == LOW[i], i or its subtree can form a strongly connected component;
[0025] Start a depth-first search with the root of the tree as the starting point, traverse all child nodes v of the point u, and mark these nodes v as visited;
[0026] Merge point v to point u on the union-find set. The expression is as follows:
[0027] ancestor[find(u)]=find(v)
[0028] Traverse the highlighted node set {N1,N2,…,N n}, with {N i , N i+1} is the query pair, find the point v that has the query relationship with point u;
[0029] If point v has been visited, determine the nearest common ancestor of point u and point v as the root node of v in the union-find set. The expression is as follows:
[0030] iF i+1 = = u and marked [N i ]==True:
[0031] LCA(N i ,N i+1 )=LCA(N i+1 ,N i ) = ancestor[x]
[0032] The depth of the LCA node is the maximum number of common ancestors between point u and point v.
[0033] The specific method of S7 is as follows:
[0034] Query the maximum number of common ancestors between adjacent highlighted nodes in the tree and calculate the 75% average. The calculation expression is as follows:
[0035]
[0036] Place N1 into the current event, traverse the highlighted node set, and divide the new event when the maximum number of common ancestors between the current node and the next node is greater than the 75% average value;
[0037] If the maximum number of common ancestors between the current node and the next node is less than 75% of the average value, no new event will be divided. The calculation expression is as follows:
[0038]
[0039] Move the current point to the next node, place N1 in the current event, and traverse the highlighted node set until the node traversal is completed.
[0040] Compared with the prior art, the present invention sets a probe through the source code, obtains the program execution path, combines the execution path with the log, and abstracts the event chain of the program execution. Compared with the log original text information analysis method, it additionally provides the program execution status corresponding to the log; compared with the source code analysis method, it can track the running status of the program in the event with high accuracy. The present invention introduces the possibility of dynamically collecting runtime information. This method avoids the tedious process of code recompilation and can accurately record each execution path of the program. In view of the different transmission paths of log messages in the program, the present invention records the program execution path corresponding to the log information by tracking the log framework docking function or the virtual file system VFS activity, thereby solving the problem of inaccurate matching only by timestamps. The algorithm of the present invention maps the original log message to the program execution tree, divides the log message according to the relationship between the marked program status record points, and abstracts it into high-level understandable events. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is an overall flow chart of the method of the present invention;
[0042] Figure 2This is the operation flow chart of Kprobe;
[0043] Figure 3 A schematic diagram for analyzing the accuracy of login behavior;
[0044] Figure 4 Schematic diagram of time complexity and space occupancy. DETAILED DESCRIPTION
[0045] The present invention will be further described below in conjunction with the accompanying drawings.
[0046] The present invention mainly consists of three stages: log source location, data flow tracking and event chain integration.
[0047] See also Figure 1 The present invention provides an event-based cloud log cutting method, comprising the following steps:
[0048] Step 1: Locate the log source;
[0049] (1a) Determine the target program to be monitored. System logs and network (HTTP, DNS, UDP / TCP) logs can be collected through system auditing tools and packet capture tools. These logs usually contain information such as timestamps, process names, and execution paths;
[0050] (1b) For programs that write logs directly to files, data is usually written through the virtual file system VFS, which provides a unified interface for applications to access files. When a file is to be read or written, the program executes the write / read function in user mode, passes the data to the virtual file system VFS, and then enters kernel mode. The virtual file system VFS executes the sys_write / sys_read function, passes the data to the file system and writes it to the disk. Since the log information is passed to the virtual file system VFS through a chained function call, by monitoring the write function of the virtual file system VFS, the corresponding program stack when the program executes the write can be directly obtained;
[0051] (1c) For the case where log information is transmitted through the logging framework, as a system administrator, you have the source code of the system and have a certain understanding of the program structure by default. Usually, for a program, the source code package will contain a source code file that interacts with the logging framework. Locating this code can monitor the transmission of log information.
[0052] (1d) According to the predefined configuration and format, this code will accept all log inputs within the program and transfer the log information in the program to the logging framework by calling logging functions in the common library, such as syslog().
[0053] Step 2: Data flow tracking;
[0054] (2a) The present invention utilizes the characteristics of Kprobe and is designed to have the ability to dynamically monitor program execution and execute specific custom instructions. Figure 2 ,Kprobe provides a set of methods to specify a probe point and associate a defined processing function with the probe point;
[0055] (2b) When the kernel executes to the detection point, the corresponding associated function is executed and then the normal code path continues.
[0056] (2c) Place a probe on each function in the program. When the program executes a function call, the probe will be triggered, recording every stack change during the program's execution;
[0057] (2d) The present invention inserts a monitoring probe on a specific function before the target program writes a log, and when the log is written, obtains the log content in the current program stack;
[0058] (2e) For programs that write logs directly to files, a probe is set on the write operation of VFS. It is activated when VFS performs a write operation. The inode number is used to determine whether the target file to be written is a file that needs to be monitored, and the program stack and the written information are printed;
[0059] (2f) For programs that pass log information through the logging framework, the probe is set directly on the function that accepts all log inputs in the program. When the program writes log information to the corresponding log file, the log information is intercepted and the log information and the corresponding program stack are recorded before passing it to the logging framework.
[0060] Step 3, event chain integration;
[0061] Algorithm 1 is used to convert the traced function call trace and the (log, path) tuple into a tree with highlighted nodes; Algorithm 2 is used to highlight the maximum number of common ancestors between nodes; Algorithm 3 is used to divide the log into events.
[0062] (3a) Using Algorithm 1, we generate a program execution tree by traversing the sequence. The algorithm has three steps, as follows:
[0063] (3a1) Analyze the difference between the current trajectory and the previous trajectory and locate the nodes in the same part of the two
[0064] (3a2) Insert the difference into the tree as the node's son
[0065] (3a3) After the execution tree is generated, the target node N is located using the (log, path) tuple and highlighted.
[0066] (3a4) Attach the corresponding log information to the highlighted nodes.
Claims
1. An event-based cloud log cutting method, characterized in that: The following steps are involved: S1, determine whether the target program uses the log framework transmission, if so, execute S2, if not, execute S3; S2, locate the target function that interacts with the logging framework in the source code file that records the log, and execute S4; S3, locates the log file that interacts with the log framework through the virtual file system VFS, and executes S4; S4, set a probe on each function or log file, collect the process call stack when the target function or log file is called, and execute S5; S5, convert the process call stack when being called into a tree structure, highlight the node corresponding to the log file, and execute S6. The specific method is as follows: Perform difference analysis on the current trajectory and the previous trajectory to locate the nodes in the same part of the two. Insert the difference into the tree as a child of the node; After the execution tree is generated, the target node N is located using the log and path tuples and highlighted; Attach corresponding log information to the highlighted nodes; S6, calculate the maximum number of common ancestors of adjacent highlighted nodes, and execute S7; the specific method of S6 is as follows: Define DFN[u] as the order in which node u is searched in depth-first search, define LOW[i] as the order of the earliest node in the stack that i or its subtree can trace back to, and when DFN[i] == LOW[i], i or its subtree can form a strongly connected component; Start a depth-first search with the root of the tree as the starting point, traverse all child nodes v of the point u, and mark these nodes v as visited; Merge point v to point u on the union-find set. The expression is as follows: ancestor[find(u)]=find(v) Traverse the highlighted node set {N1,N2,…,N n }, with {N i , N i+1 } is the query pair, find the point v that has the query relationship with point u; If point v has been visited, determine the nearest common ancestor of point u and point v as the root node of v in the union-find set. The expression is as follows: if N i+1 ==u and marked[N i ]==True: LCA(N i ,N i+1 )=LCA(N i+1 ,N i )=ancestor[x] The depth of the nearest common ancestor node is the maximum number of common ancestors between point u and point v; S7, the log is divided based on the 75% average value of the maximum number of common ancestors. Adjacent nodes with values above the 75% average value will be divided into the same event, otherwise they will be divided into different events.
2. The event-based cloud log cutting method according to claim 1, characterized in that: In S2, a detection point is specified and a defined processing function is associated with the detection point. When the kernel executes to the detection point, the corresponding associated function is executed and then the normal code path continues.
3. The event-based cloud log cutting method according to claim 1, characterized in that: In S3, when a file is to be read or written, the target program executes the write / read function in user mode, passes the data to the virtual file system VFS, and then enters kernel mode. The virtual file system VFS passes the data to the file system and writes it to the disk. Since the log information is passed to the virtual file system VFS through a chained function call, the program stack corresponding to the program execution write is obtained by monitoring the write function of the virtual file system VFS, and the log file in the target program is located according to the program stack.
4. The event-based cloud log cutting method according to claim 1, characterized in that: In S4, a probe is placed on each function of the target program. When the program executes a function call, the probe will be triggered to record every stack change during the program execution; Set a probe on the function that accepts all log inputs in the target program. When the target program writes log information to the corresponding log file, intercept the log information and record the log information and the corresponding program stack before passing it to the logging framework.
5. The event-based cloud log cutting method according to claim 1, characterized in that: The specific method of S7 is as follows: Query the maximum number of common ancestors between adjacent highlighted nodes in the tree and calculate the 75% average. The calculation expression is as follows: Place N1 into the current event, traverse the highlighted node set, and divide the new event when the maximum number of common ancestors between the current node and the next node is greater than the 75% average value; If the maximum number of common ancestors between the current node and the next node is less than 75% of the average value, no new event will be divided. The calculation expression is as follows: Move the current point to the next node, place N1 in the current event, and traverse the highlighted node set until the node traversal is completed.
