Operation log generation method, fault query method and device

CN114064586BActive Publication Date: 2025-04-01BEIJING QINGYUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111355558.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-16
Publication Date
2025-04-01
Estimated Expiration
2041-11-16

AI Technical Summary

Technical Problem

In the prior art, the operation logging method has redundant code, reduced readability, easy omission, and incomplete records, resulting in security vulnerabilities in log audits and different operating record formats, facing customized secondary development problems.

Method used

By receiving the operations to be executed, a job global identifier is generated, and a thread is created for each job to be executed, a job identification is assigned, and a job generation task information is executed. Finally, a unified operation log is generated based on the job global identifier, job information, job identification and task information.

Benefits of technology

It realizes unified recording of operation logs, avoids redundant code, improves code readability and quality, ensures the integrity and security of records, and is unified in operation record format, which is easy to process and analyze, and is conducive to fault location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064586B_ABST
    Figure CN114064586B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an operation log generation method, a fault query method and a device. The operation log generation method includes: receiving an operation to be executed and generating a global job identifier; determining at least one job to be executed according to the operation to be executed, creating a thread for each job to be executed, and generating job information; assigning a job identifier to each thread according to the global job identifier, executing the corresponding job to be executed through each thread, and generating task information; generating an operation log according to the global job identifier, job information, job identifier and task information. The information generated during the operation process is identified, and all information generated during the operation process is uniformly recorded. The operation record format is unified, which is convenient for processing and analysis, and is conducive to information query and fault location in the later stage. The job identifier is generated through the global job identifier, and the relationship between the job identifiers and the relationship between the jobs are established. The call is simple, redundant code is saved, and the applicability is strong.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to an operation log generation method, a fault query method and a device. Background Art

[0002] With the development of information technology, Internet business is becoming more and more extensive, involving more and more services. It faces many challenges in terms of manpower and time costs, security audit requirements, and development, maintenance and operation pressures. There is a need for security audits in the public libraries used to develop various service projects, and its functions involving sensitive, security and other issues need to be audited to comply with security regulations. There is a need for unified maintenance of operation logs for each product line. When developing new functions, there is a unified functional testing requirement, hoping to understand whether the function's parameter passing and return are in line with expectations. When a business fails, it is necessary to track the fault point, troubleshoot and fix the problem. To a certain extent, the business side can automatically handle the failure.

[0003] In the prior art, there are generally several ways to record operation logs: 1) Add relevant codes to the function for processing. These codes will exist redundantly in many places, which not only has high manpower and time costs, but also reduces the readability of the code, affecting the quality of the code. At the same time, such operations are easily missed, resulting in incomplete records and security vulnerabilities in log audits. In addition, each product line will be developed separately, resulting in different operation record formats and facing customized secondary development problems. 2) Use function decorators to simply record to local log files. These logs are scattered in the local hard disks of all service nodes. On the one hand, the scattered logs need to be extracted and analyzed in a targeted manner, which brings certain complexity and workload; on the other hand, the operation process is distributed, and a job may perform work in multiple services in sequence. If a pipelined recording mode is not formed, it will bring certain operation and maintenance difficulties to the troubleshooting and repair of fault points, and it is also difficult for the business side to achieve automated processing related to transaction rollback. Summary of the invention

[0004] The present invention provides an operation log generation method, a fault query method and a device, so as to realize unified recording of the operation log.

[0005] In a first aspect, an embodiment of the present invention provides a method for generating an operation log, the method comprising:

[0006] Receive the operation to be executed and generate a global identifier for the job;

[0007] Determine at least one job to be executed according to the operation to be executed, create a thread for each job to be executed, and generate job information;

[0008] Assigning a job identifier to each of the threads according to the job global identifier, executing a corresponding job to be executed through each of the threads, and generating task information;

[0009] An operation log is generated according to the job global identifier, job information, job identifier and task information.

[0010] In a second aspect, an embodiment of the present invention provides a fault query method, the fault query method comprising:

[0011] Obtaining a job identifier to be queried and an operation log, wherein the operation log is generated by the operation log generation method described in any embodiment of the present invention;

[0012] The task table in the operation log is queried according to the job identifier to be queried to determine the fault information.

[0013] In a third aspect, an embodiment of the present invention further provides an operation log generating device, the operation log generating device comprising:

[0014] An operation receiving module, used for receiving the operation to be executed and generating a global identifier of the job;

[0015] A job information generating module, used for determining at least one job to be executed according to the operation to be executed, creating a thread for each job to be executed, and generating job information;

[0016] A task information generating module, used for allocating a job identifier to each of the threads according to the job global identifier, executing the corresponding job to be executed through each of the threads, and generating task information;

[0017] The operation log generation module is used to generate an operation log according to the job global identifier, job information, job identifier and task information.

[0018] In a fourth aspect, an embodiment of the present invention further provides a fault query device, the fault query device comprising:

[0019] A log acquisition module, which acquires a job identifier to be queried and an operation log, wherein the operation log is generated by the operation log generation device described in any embodiment of the present invention;

[0020] The fault information determination module is used to query the task table in the operation log according to the job identifier to be queried to determine the fault information.

[0021] The embodiment of the present invention provides an operation log generation method, a fault query method and a device, which receive an operation to be executed and generate a global job identifier; determine at least one job to be executed according to the operation to be executed, create a thread for each job to be executed, and generate job information; assign a job identifier to each thread according to the global job identifier, execute the corresponding job to be executed through each thread, and generate task information; generate an operation log according to the global job identifier, job information, job identifier and task information. The information generated during the operation process is identified by the global job identifier and the job identifier, and all information generated during the operation process is uniformly recorded. The operation record format is unified, which is convenient for processing and analysis, and is conducive to information query and fault location at a later stage. The job identifier is generated by the global job identifier, and the relationship between the job identifiers is established, and the relationship between the jobs is further established. The calling process is simple, a large amount of redundant code is saved, and the applicability is strong. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a flow chart of a method for generating an operation log in Embodiment 1 of the present invention;

[0023] Figure 2 is a flow chart of a method for generating an operation log in Embodiment 2 of the present invention;

[0024] Figure 3 This is an example diagram showing the relationship between a job and a task in the second embodiment of the present invention;

[0025] Figure 4 This is a schematic diagram of an implementation of generating an operation log in the second embodiment of the present invention;

[0026] Figure 5 is a flow chart of a fault query method in Embodiment 3 of the present invention;

[0027] Figure 6 It is a structural schematic diagram of an operation log generating device in Embodiment 4 of the present invention;

[0028] Figure 7 It is a structural schematic diagram of a fault query device in Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0030] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0031] In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0032] Embodiment 1

[0033] Figure 1 A flow chart of an operation log generation method provided in the first embodiment of the present application is provided, and the method is applicable to the case where the operation is recorded when any operation is performed during the development process. The method can be executed by a computer device configured with a python operating environment, and the computer device can be composed of two or more physical entities, or can be composed of one physical entity. Generally speaking, the computer device can be a notebook, a desktop computer, a smart tablet, etc.

[0034] like Figure 1 As shown, the first embodiment provides a method for generating an operation log, which specifically includes the following steps:

[0035] S101. Receive an operation to be executed and generate a global job identifier.

[0036] In this embodiment, the operation to be executed can be specifically understood as an operation that needs to be executed by a computer, for example, creating a virtual machine, creating a backup for a virtual machine, etc. The job global identifier can be specifically understood as a global identifier ID in the process of executing the operation to be executed.

[0037] Specifically, a user initiates an operation to be executed. The user can be any user with operation authority, such as a project developer or a product user. The computer device receives the operation to be executed initiated by the user. The operation to be executed may generate multiple jobs in parallel. Each job can be interspersed among multiple service nodes to perform work tasks in sequence. The global job identifier can be a randomly generated string or a string generated according to certain rules. The global job identifier is used to identify the main operation process of executing the operation to be executed.

[0038] It should be noted that the operation log generation method provided in this application is executed by a python function decorator, and the python function decorator is applied to the function to realize the recording and generation of the operation log. The decorator in this application logically has two types, one for the first entry function of job distribution and the other for the specific function of executing the job to be executed. The number of decorators can be set according to demand.

[0039] S102: Determine at least one job to be executed according to the operations to be executed, create a thread for each job to be executed, and generate job information.

[0040] In this embodiment, the pending job can be specifically understood as a job that needs to be executed after decomposing the pending operation. For example, if the pending operation is to create three virtual machines, the number of the pending jobs is three, all of which are to create virtual machines. The job information can be specifically understood as information generated when the pending operation is executed, such as information such as the submitter, request parameters, and return results.

[0041] Specifically, the operation to be executed is parsed to determine the job to be executed corresponding to the operation to be executed. A thread is created for each job to be executed to execute the job to be executed. Job information is generated based on the parameter information carried by the operation to be executed and the return result updated after the operation is completed, and the operation process is recorded.

[0042] S103: assigning a job identifier to each thread according to the job global identifier, executing the corresponding job to be executed through each thread, and generating task information.

[0043] In this embodiment, the job identification can be specifically understood as identification information for each job to be executed. Task information can be specifically understood as information generated during the execution of the job to be executed, such as task sequence number, task identification ID, caller, executor, request parameters, return information and other data.

[0044] Specifically, in the process of executing the pending job through each thread, a job identifier is assigned to each thread. Among them, the job identifier is determined and generated according to the job global identifier, so the association between the job global identifier and the job identifier can be established. For example, the job global identifier is ppl-123abc, and the job identifiers are ppl-123abc#1, ppl-123abc#2, ppl-123abc#3, etc. The job identifier will be recorded in the thread local variable (Thread Local) and passed through to the thread local variables of all services that this pending job needs to go through. It is determined whether the thread variable has a job identifier. When the job identifier exists, the operation log will be recorded during the execution of the corresponding pending job by the thread, otherwise it will not be recorded. The execution of a pending job will call the corresponding function to complete the task. This application records the execution process of the job by applying a decorator to the function and assigning an identifier to the job, thereby solving problems such as easy omissions and incomplete records, and saving manpower and time costs. At the same time, the code remains concise and does not affect the code quality. The operation record format is unified, which is convenient for data analysis and processing.

[0045] S104: Generate an operation log according to the job global identifier, job information, job identifier and task information.

[0046] In this embodiment, the operation log can be specifically understood as log information that records the operation process. The operation information is identified by the global job identifier. The task information is identified by the job identifier. When the task is executed on different service nodes, it is identified by a unified job identifier. Therefore, unified management of operations can be achieved.

[0047] The embodiment of the present invention provides an operation log generation method, which receives an operation to be executed and generates a global job identifier; determines at least one job to be executed according to the operation to be executed, creates a thread for each job to be executed, and generates job information; assigns a job identifier to each thread according to the global job identifier, executes the corresponding job to be executed through each thread, and generates task information; generates an operation log according to the global job identifier, job information, job identifier, and task information. The information generated during the operation process is identified by the global job identifier and the job identifier, and all information generated during the operation process is uniformly recorded. The operation record format is unified, which is convenient for processing and analysis, and is conducive to information query and fault location at a later stage. The job identifier is generated by the global job identifier, and the relationship between the job identifiers is established, and the relationship between the jobs is further established. The calling process is simple, a large amount of redundant code is saved, and the applicability is strong.

[0048] Embodiment 2

[0049] Figure 2This is a flow chart of an operation log generation method provided in Embodiment 2 of the present invention. The technical solution of this embodiment is further refined on the basis of the above technical solution, and specifically mainly includes the following steps:

[0050] S201: Receive an operation to be executed and generate a global job identifier.

[0051] S202: Call a parsing function to parse the operation to be executed.

[0052] In this embodiment, the parsing function may be specifically understood as a function for parsing codes, character strings, etc. The parsing function is called to perform data parsing on the operation to be executed.

[0053] S203: Determine at least one job to be executed according to the analysis result.

[0054] Taking the operation to be executed as creating three virtual machines as an example, by calling the parsing function to parse the data of the operation to be executed, the parsing result can be: task-create virtual machine, quantity-3; accordingly, the determined job to be executed is to create 1 virtual machine, and the number of jobs to be executed is 3.

[0055] S204: Create a thread for each job to be executed.

[0056] S205: Determine the submitter, caller, and request parameters according to the operation to be executed.

[0057] In this embodiment, the submitter can be understood as the user who submits the operation to be executed; the caller can be understood as the gateway that executes the operation to be executed; the request parameter can be specifically understood as the parameter information when executing the operation to be executed, such as parameter name, parameter value, etc. When the user generates the operation to be executed by triggering or inputting, the submitter, caller, and request parameters are generated at the same time, and the above information is carried in the operation to be executed.

[0058] S206: Determine return information according to the execution result of the thread creation.

[0059] In this embodiment, the return information can be the result of execution, or the information after processing the execution result. For example, if the return information can only be true or false, the execution result is verified to obtain true or false as the return information. A thread is created to execute the job to be executed. The execution result of the created thread can be creation success, creation failure, thread information when creation is successful, failure reason when creation fails, etc. The return information is determined according to the execution result.

[0060] S207: Generate job information according to the submitter, caller, request parameters and return information.

[0061] The submitter, caller, request parameters and return information are used as job information to record the data generated during the execution of the create thread operation.

[0062] S208: Allocate a job identifier to each thread according to the global job identifier.

[0063] S209: For each thread, determine a target processing flow according to the job to be executed, where the target processing flow includes a task processing sequence, a task processing node, and a processing instruction.

[0064] In this embodiment, the target processing flow can be specifically understood as the data processing flow when executing the job to be executed, that is, the processing process of the job to be executed is decomposed into one or more tasks. The target processing flow defines the pipeline tasks when the job to be executed is executed, and at which service node each task is executed. The processing instruction is the instruction when the task is executed, indicating what kind of processing the task is to perform. The task processing order can be specifically understood as the order in which each task is processed. The execution of a job will call the corresponding function to complete the task. The function call is sequential, so it is necessary to generate a task processing order to sort the tasks. The task processing node can be specifically understood as the service node that processes the task.

[0065] For example, Figure 3 This is an example diagram showing the relationship between jobs and tasks provided by an embodiment of the present invention. Figure 3 As shown, the pending operation 31 is decomposed into three pending jobs 32, and the three pending jobs 32 all execute the same target processing flow. The target processing flow includes tasks 1 to 5, where tasks 1-2 are executed on service node a, task 3 is executed on service node b, and tasks 4-5 are executed on service node c.

[0066] Taking the job to be executed as creating a virtual machine backup as an example, the target processing flow can be: (1) suspend the virtual machine; (2) refresh the cache; (3) create a snapshot; (4) restore the virtual machine; (5) extract data; (6) back up data. Among them, steps (1)-(4) are executed on service node a, step (5) is executed on service node b, and step (6) is executed on service node c. Among them, numbers (1)-(6) are the task processing order. The processing instructions are to create a snapshot, suspend the virtual machine, etc. The task processing nodes are service node a, service node b, and service node c.

[0067] Specifically, the processing flow of different job execution processes is predefined, and after the job to be executed is determined according to the operation to be executed, the corresponding target processing flow is searched according to the job to be executed. Although the threads executing the job to be executed in this application are different, since the types of the jobs to be executed (for example, all are to create virtual machines) are the same, when determining the target processing flow, the target processing flow can be determined once for each thread, or it can be determined only once.

[0068] S210, executing the target processing flow through threads, generating task identifiers according to the execution order during the execution process, and associating the job identifier corresponding to the thread with the processing instruction.

[0069] In this embodiment, the task identifier can be specifically understood as information for identifying the task when executing each task in the target processing flow, for example, 0001.

[0070] Specifically, when a thread executes a target processing flow, it executes each processing instruction on each task processing node in turn according to the task processing order in the target processing flow. And a task identifier is generated according to the execution order. For example, when executing (1) suspending the virtual machine on service node a, task identifier 0001 is generated; when executing (2) refreshing the cache on service node a, task identifier 0002 is generated. Each processing execution is identified by a task identifier. Since each thread has been assigned a job identifier during the execution process, the job identifier corresponding to each thread can be determined. The job identifier corresponding to the thread is associated with the processing instruction to establish a relationship between the job and the task.

[0071] S211. Determine the execution result of the thread, and determine the execution state according to the execution result.

[0072] In this embodiment, the execution result is the result obtained after the thread executes the target processing flow, such as insufficient storage space, virtual machine downtime, etc. The execution status can be specifically understood as the status after the task is executed, such as success, failure, etc. Determine the execution result of the thread executing the target processing flow. For example, the job to be executed is to create a backup for the virtual machine. The execution result is included in the function return code. The function return code is used to determine that the execution result is insufficient storage space and the backup is not completed. Analyze the execution result, or verify the execution result by a predefined method to determine the execution status. The execution status includes: successful execution and failed execution.

[0073] S212: Generate task information according to the task identifier, task processing sequence, processing instruction, job identifier, execution result and execution status.

[0074] Each task identifier corresponds to a job identifier, a processing instruction, a task processing sequence, a task processing node, an execution result and an execution status. The above data is used as a piece of data to generate task information.

[0075] As an optional embodiment of the present embodiment, the present optional embodiment further optimizes determining the execution status according to the execution result to: verifying the execution result according to a predefined verification method to determine the execution status.

[0076] In this embodiment, the verification method can be specifically understood as a method for verifying the execution result, such as a predefined rule, function, etc. When the types of the jobs to be executed are different, the data format or type of the execution result returned after the execution is completed may be the same or different. Therefore, the same verification method can be set to verify the execution result, or different verification methods can be set to verify the execution result. If different verification methods are set to verify the execution result, the jobs to be executed or the operations to be executed can be associated with the corresponding verification methods in advance, and during verification, the corresponding verification method is obtained to verify the execution result and determine the execution status.

[0077] S213: Acquire data operation mode.

[0078] In this embodiment, the data operation mode can be specifically understood as the operation method used when performing data storage. For example, when the data storage space is a database, the data operation mode can be a singleton mode. The operation method of the database or database cluster is declared through the singleton mode. The decorator directly calls this method to perform data storage operations and stores the data in the database in a relational manner. The database in the embodiment of this application can be mysql, postgresql, Oracle, etc. The data operation mode is pre-defined, and the data operation model is directly obtained when performing data storage.

[0079] S214: Output the job global identifier and job information to the database according to the data operation mode, and generate a job table.

[0080] Output the job global identifier and job information to the database according to the operation mode declared in the data operation mode to form a job table. Build the relationship between operations and jobs, and between jobs. The job table can be used to determine which gateway executes the operation or job, as well as the request parameters involved in the execution process.

[0081] Exemplarily, Table 1 provides a worksheet:

[0082] Logo Submitted by Executor … ppl-123abc Name1 Implement1 ppl-123abc#1 Name1 Implement2 ppl-123abc#2 Name1 Implement3 … … … …

[0083] S215. Output the job identification and task information to the database according to the data operation mode, and generate a task table.

[0084] Output the job ID and task information to the database according to the operation mode declared in the data operation mode to form a task table. Build the relationship between jobs and tasks, and the relationship between tasks.

[0085] Exemplarily, Table 2 provides a task table:

[0086]

[0087]

[0088] S216: Generate an operation log according to the job list and the task list.

[0089] The job table and task table record the data generated by the execution of the operation to be performed, and mark each operation step with an identifier. The operation log formed records the operation process and establishes the relationship between each task, job and operation for easy viewing.

[0090] When generating operation logs, this application uses a pipeline recording method to assign a job ID to each job, assign a task processing order and a task ID to the functions executed by the job, and establish relationships between jobs and tasks, thereby assisting developers and operators to quickly analyze and locate problem points. Business logic can automatically handle faults based on these records. The method of this application does not need to distinguish between ordinary functions or class member functions during implementation, and has strong adaptability. Developers can easily call it, saving a lot of redundant code; the operation record format is unified, which is convenient for processing and analysis; the convenience of use can make the function's operation log record more comprehensive and reduce review loopholes.

[0091] As an optional embodiment of this embodiment, this optional embodiment is further optimized to include: before receiving the operation to be executed, receiving a target type, a target name and a target description information;

[0092] Correspondingly, after receiving the operation to be executed, the method further includes associating the target type, target name and target description information with the operation to be executed or the processing instruction.

[0093] In this embodiment, the target type can be specifically understood as the type of operation or task to be performed, which is divided into a job type (e.g., a virtual machine) and a task type. The target name can be specifically understood as the name of the operation or task to be performed, which is divided into a job name and a task name. The target description information is divided into the description information of the job or the description information of the task.

[0094] Before receiving the operation to be performed, the user of this application can set the job type, job name and description information according to the scenario of application of this application. The parameters of the decorator are set according to the target type, target name and target description information. After receiving the operation to be performed, the decorator can associate the operation to be performed or the processing instruction with the target type, target name and target description information. Among them, the job type, job name, and description information of the job are associated with the operation to be performed; the task type, task name, and description information of the task are associated with the processing instruction. When the method for generating an operation log is executed by a decorator, the target type, target name and target description information can be used as parameter information to describe the operation to be performed or the processing instruction. For example, when it is known that the job type is a virtual machine, it can be determined that the operation to be performed is a related operation on the virtual machine.

[0095] The decorators in this application logically include two types of decorators. Decorators can customize parameters or set default parameters to adapt to various scenarios. For example, the decorator of the first entry function for job distribution, the implementation code for setting the job type, job name and description information can be:

[0096] @pipelining_x(pipelining_type,pipelining_name,description,lambda_is_response_ok)

[0097] def create_snapshot(resource_id):

[0098] Among them, pipelining is a job, which defines parameters such as job type, job name, description information, etc. When not specified, a default value can be specified, such as the job name directly using the function name. Or it can be set by the target type, target name and target description information entered by the user. lambda_is_response_ok expresses that the execution result of the function will be verified by this method, that is, the predefined verification method, to obtain the function execution status, that is, success or failure. The above parameters can be defined by the developer to achieve a unified record format and variable content, so as to achieve the purpose of flexible use.

[0099] The decorator of the specific function for implementing the job for job distribution. The implementation code for setting the task type, task name, and task description information can be:

[0100] @instruction_x(instruction_type,instruction_name,description,lambda_is_response_ok)

[0101] def do_snapshot(resource_id):

[0102] Among them, instruction is a task, which defines parameters such as task type, task name, description information, etc. Its principle is the same as the principle of pipelining mentioned above, and will not be repeated here.

[0103] For example, Figure 4 A schematic diagram of an implementation of generating an operation log provided by an embodiment of the present invention is provided. The method for generating an operation log is implemented by three modules: a job module 41, an operation module 42, and an output module 43, wherein both the job module 41 and the operation module 42 are decorators; the decorator of the job module 41 is used in the first entry function of job distribution, and the decorator of the operation module 42 acts on the specific function of the real-time job. After the user initiates the operation to be executed, it is sent to the job module 41, and the job module generates the global job identifier, the job identifier, and the job information. The job identifier is recorded in the thread local variable. When the operation module executes the job to be executed, it generates the task information according to the job identifier, and the job ends. Both the job information and the task information are sent to the output module 43, which stores them in the database according to the data operation mode to generate an operation log.

[0104] The embodiment of the present invention provides an operation log generation method, which identifies the information generated during the operation process through the global job identifier and the job identifier, and uniformly records all the information generated during the operation process. The operation record format is unified, which is convenient for processing and analysis, and is conducive to information query and fault location in the later stage. The job identifier is generated through the global job identifier, and the relationship between each job identifier is established, and the relationship between each job is further established. The calling process is simple, a large amount of redundant code is saved, and the applicability is strong. By adopting a pipeline recording method, a job identifier is assigned to each job, and a task processing order and task identifier are assigned to the function executed by the job, and the relationship between jobs and the relationship between tasks are established, thereby assisting the development and operation personnel to quickly analyze and locate the problem point. The business logic can automatically handle faults based on these records. The method of the present application does not need to distinguish between ordinary functions or class member functions when implemented, and has strong adaptability. It is easy to use, so that the operation log of the function is recorded more comprehensively, reducing the review loopholes.

[0105] Embodiment 3

[0106] Figure 5 A flowchart of a fault query method provided in Embodiment 3 of the present invention, the method comprising:

[0107] S501. Obtain a job identifier to be queried and an operation log, where the operation log is generated by the operation log generation method described in any embodiment of the present invention.

[0108] In this embodiment, the job identifier to be queried can be specifically understood as a job identifier with a query requirement. When performing troubleshooting or security auditing, the user enters the job identifier to be queried according to the requirement. The execution device of the present application obtains the job identifier to be queried and obtains the operation log from the database.

[0109] S502: query the task table in the operation log according to the job identifier to be queried to determine the fault information.

[0110] In this embodiment, the fault information may include whether a fault occurs, the fault location when the fault occurs, the cause of the fault, etc.

[0111] The task table in the operation log stores information such as the execution results, execution status, and corresponding service nodes of the tasks (or processing instructions), including the location of the failure, the cause of the failure, etc. The task table is queried and matched according to the job identifier to be queried to obtain the location of the failure. For example, the failure point is to create a snapshot, and its location is service node a execution.

[0112] As an optional embodiment of the present invention, this optional embodiment further queries the task table in the operation log according to the job identifier to be queried, and determines that the fault information is optimized as follows:

[0113] A. Filter the task table in the operation log according to the job ID to be queried, and determine the candidate information corresponding to the job ID to be queried.

[0114] In this embodiment, the candidate information can be specifically understood as information in the task execution process corresponding to the job identifier to be queried, such as task processing sequence, processing instructions, job identifier, execution result and execution status.

[0115] Specifically, the job identifiers in the operation log are matched and screened by the job identifier to be queried, and the task processing sequence, processing instructions, job identifier, execution result and execution status corresponding to the matched job identifier are determined. Alternative information is formed according to the task processing sequence, processing instructions, job identifier, execution result and / or execution status. The same job identifier in the data table in the operation log corresponds to multiple different data, and each data (i.e., each set of task processing sequence, processing instructions, job identifier, execution result and execution status) can form an alternative information.

[0116] B. Filter out the target execution status whose execution status is failed from each candidate information.

[0117] In this embodiment, the target execution state can be specifically understood as the execution state of failure. Each candidate information includes an execution state, which is divided into two types: successful execution and failed execution. The execution state of failed execution is determined and used as the target execution state. The number of target execution states can be more than one.

[0118] If there is no target execution status of failure, it can be determined that the tasks corresponding to the job identifier to be queried are all executed successfully without fault information, or the fault information is no fault.

[0119] C. Determine the processing instructions corresponding to each target execution state as fault instructions.

[0120] Determine the processing instructions corresponding to each target execution state, and determine each processing instruction as a fault instruction, for example, backing up data, restoring a virtual machine.

[0121] D. Determine the fault information based on the fault instruction and its corresponding task processing node and execution result.

[0122] The fault instruction and its corresponding task processing node and execution result are used as fault information. When performing fault query, the machine where the fault is located can be located according to the task processing node, the problem point can be determined according to the fault instruction, and the cause of the fault can be determined according to the execution result.

[0123] As an optional embodiment of the present invention, this optional embodiment is further optimized to include: determining a fault resolution method according to fault information; and performing a fault self-healing operation based on the fault resolution method.

[0124] In this embodiment, the fault resolution method can be specifically understood as a method for resolving the fault to ensure that future operations can proceed smoothly. Since the fault information includes the fault instruction and the execution result, the fault resolution method is determined by analyzing the fault instruction and the execution result, and the fault self-healing is performed based on the fault resolution method.

[0125] For example, the present application provides several fault resolution methods corresponding to different fault information:

[0126] Fault information 1: From the operation log query, we know that the fault instruction (problem point) is "create snapshot", and the task location is executed on service node a on machine A. The operator can easily locate the fault point and cover the fault surface.

[0127] Fault information 2: From the operation log query, we know that the faulty instruction is "backup data", and from the function return code record, we know that there is insufficient storage space. The cloud platform automatic maintenance program can identify this type of fault, determine that the fault solution is to free up space, and initiate a recycle bin cleanup to free up space so that future operations can proceed normally.

[0128] Fault information 3: From the query of the operation log, it is known that the fault instruction is "Restore the virtual machine". The cloud platform automatic maintenance program can identify this type of fault, determine that the virtual machine has crashed, determine that the fault solution is to restart the virtual machine, and initiate a virtual machine forced restart instruction, thereby restoring the operation of the virtual machine and achieving the effect of self-healing of the fault.

[0129] The embodiment of the present invention provides a fault query method, which obtains a job identifier to be queried and an operation log, wherein the operation log is generated by the operation log generation method described in any embodiment of the present invention; and queries the task table in the operation log according to the job identifier to be queried to determine the fault information. This enables rapid troubleshooting and location of the fault. At the same time, based on the fault information, the fault can be automatically processed, saving staff time and improving work efficiency.

[0130] Embodiment 4

[0131] Figure 6 This is a schematic diagram of the structure of an operation log generating device provided in Embodiment 4 of the present invention. The device includes: an operation receiving module 61, a job information generating module 62, a task information generating module 63 and an operation log generating module 64.

[0132] The operation receiving module 61 is used to receive the operation to be executed and generate a global identifier of the operation;

[0133] A job information generating module 62, configured to determine at least one job to be executed according to the operation to be executed, create a thread for each job to be executed, and generate job information;

[0134] The task information generating module 63 is used to assign a job identifier to each of the threads according to the job global identifier, execute the corresponding job to be executed through each of the threads, and generate task information;

[0135] The operation log generating module 64 is used to generate an operation log according to the job global identifier, job information, job identifier and task information.

[0136] The embodiment of the present invention provides an operation log generation device, which receives an operation to be executed and generates a global job identifier; determines at least one job to be executed according to the operation to be executed, creates a thread for each job to be executed, and generates job information; assigns a job identifier to each thread according to the global job identifier, executes the corresponding job to be executed through each thread, and generates task information; generates an operation log according to the global job identifier, job information, job identifier, and task information. The information generated during the operation process is identified by the global job identifier and the job identifier, and all information generated during the operation process is uniformly recorded. The operation record format is unified, which is convenient for processing and analysis, and is conducive to information query and fault location at a later stage. The job identifier is generated by the global job identifier, and the relationship between the job identifiers is established, and the relationship between the jobs is further established. The calling process is simple, a large amount of redundant code is saved, and the applicability is strong.

[0137] Furthermore, the operation information generating module 62 includes:

[0138] A parsing unit, used for calling a parsing function to parse the operation to be executed;

[0139] The job determination unit is used to determine at least one job to be executed according to the analysis result.

[0140] Furthermore, the operation information generating module 62 includes:

[0141] A parameter determination unit, used to determine a submitter, a caller, and a request parameter according to the operation to be performed;

[0142] A return information determination unit, used to determine return information according to the execution result created by the thread;

[0143] The job information determination unit is used to generate job information according to the submitter, caller, request parameters and return information.

[0144] Furthermore, the task information generating module 63 includes:

[0145] A process determination unit, configured to determine, for each thread, a target processing process according to the job to be executed, wherein the target processing process includes a task processing sequence, a task processing node, and a processing instruction;

[0146] A process execution unit, used to execute the target processing process through the thread, generate a task identifier according to the execution order during the execution process, and associate the job identifier corresponding to the thread with the processing instruction;

[0147] a state determination unit, configured to determine an execution result of the thread, and determine an execution state according to the execution result;

[0148] The task information generating unit is used to generate task information according to the task identifier, task processing sequence, processing instruction, job identifier, task processing node, execution result and execution status.

[0149] Furthermore, the state determination unit is specifically used to: verify the execution result according to a predefined verification method to determine the execution state.

[0150] Furthermore, the device also includes:

[0151] An information receiving module, used for receiving target type, target name and target description information before receiving the operation to be executed;

[0152] Accordingly, the device further comprises:

[0153] The association module is used to associate the target type, target name and target description information with the operation to be executed or the processing instruction after receiving the operation to be executed.

[0154] Furthermore, the operation log generating module 64 includes:

[0155] A mode acquisition unit, used for acquiring a data operation mode;

[0156] A job table generating unit, used for outputting the job global identifier and job information to a database according to the data operation mode, and generating a job table;

[0157] A task table generating unit, used for outputting the job identification and task information to a database according to the data operation mode to generate a task table;

[0158] The log generating unit is used to generate an operation log according to the operation table and the task table.

[0159] The operation log generating device provided in the embodiment of the present invention can execute the operation log generating method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0160] Embodiment 5

[0161] Figure 7 This is a structural diagram of a fault query device provided in Embodiment 5 of the present invention. The device includes: a log acquisition module 71 and a fault information determination module 72.

[0162] The log acquisition module 71 acquires the job identifier to be queried and the operation log, wherein the operation log is generated by the operation log generation device described in any embodiment of the present invention;

[0163] The fault information determination module 72 is used to query the task table in the operation log according to the job identifier to be queried, and determine the fault information.

[0164] The embodiment of the present invention provides a fault query device, which obtains a job identifier to be queried and an operation log, wherein the operation log is generated by the operation log generation method described in any embodiment of the present invention; queries the task table in the operation log according to the job identifier to be queried to determine the fault information. This enables rapid troubleshooting and location of the fault. At the same time, based on the fault information, the fault can be automatically processed, saving staff time and improving work efficiency.

[0165] Furthermore, the fault information determination module 72 includes:

[0166] An identification screening unit, used to screen the task table in the operation log according to the identification of the job to be queried, and determine the candidate information corresponding to the identification of the job to be queried;

[0167] An execution status screening unit, used to screen out target execution statuses whose execution status is failure from each of the candidate information;

[0168] a fault instruction determination unit, configured to determine a processing instruction corresponding to each of the target execution states as a fault instruction;

[0169] The fault information determining unit is used to determine the fault information according to the fault instruction and its corresponding task processing node and execution result.

[0170] Furthermore, the device also includes:

[0171] A solution determination module, used to determine a fault solution according to the fault information;

[0172] The fault self-healing module is used to perform a fault self-healing operation based on the fault resolution method.

[0173] The fault query device provided in the embodiment of the present invention can execute the fault query method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0174] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for generating an operation log, characterized in that: include: Receive the operation to be executed and generate a global identifier for the job; Determine at least one job to be executed according to the operation to be executed, create a thread for each job to be executed, and generate job information; Assigning a job identifier to each of the threads according to the job global identifier, executing a corresponding job to be executed through each of the threads, and generating task information; Generate an operation log according to the job global identifier, job information, job identifier and task information; The generating of the operation log according to the job global identifier, job information, job identifier and task information includes: Get data operation mode; Output the job global identifier and job information to the database according to the data operation mode to generate a job table; Output the job identification and task information to the database according to the data operation mode to generate a task table; Forming an operation log according to the operation table and the task table; The job information includes the submitter, caller, request parameters and return information; the task information includes the task identifier, job identifier, processing instructions, task processing sequence, task processing node, execution result and execution status.

2. The method according to claim 1, characterized in that The determining at least one job to be executed according to the operation to be executed comprises: Calling a parsing function to parse the operation to be executed; At least one job to be executed is determined according to the parsing result.

3. The method according to claim 1, characterized in that The generated job information includes: Determine the submitter, caller and request parameters according to the operation to be performed; Determine the return information based on the execution result of the thread creation; The job information is generated according to the submitter, caller, request parameters and return information.

4. The method according to claim 1, characterized in that: The executing of the corresponding to-be-executed jobs by each of the threads and generating task information includes: For each thread, determining a target processing flow according to the job to be executed, wherein the target processing flow includes a task processing sequence, a task processing node and a processing instruction; Executing the target processing flow through the thread, generating a task identifier according to the execution order during the execution process, and associating the job identifier corresponding to the thread with the processing instruction; Determining an execution result of the thread, and determining an execution state according to the execution result; The task information is generated according to the task identifier, task processing sequence, processing instruction, job identifier, task processing node, execution result and execution status.

5. The method according to claim 4, characterized in that Determining the execution status according to the execution result includes: The execution result is verified according to the predefined verification method to determine the execution status.

6. The method according to claim 4, characterized in that Before receiving the operation to be performed, the method further includes: Receive target type, target name and target description information; Accordingly, after receiving the operation to be performed, the method further includes: The target type, target name and target description information are associated with the operation to be performed or the processing instruction.

7. A fault query method, characterized in that: include: Obtaining a job identifier to be queried and an operation log, wherein the operation log is generated by the operation log generation method according to any one of claims 1 to 6; Query the task table in the operation log according to the job identifier to be queried to determine the fault information; The step of querying the task table in the operation log according to the job identifier to be queried to determine the fault information includes: Screening the task table in the operation log according to the job identifier to be queried, and determining candidate information corresponding to the job identifier to be queried; Filter out the target execution status whose execution status is failed from each of the candidate information; Determine the processing instructions corresponding to each of the target execution states as fault instructions; Determine the fault information according to the fault instruction and its corresponding task processing node and execution result; The candidate information includes task processing sequence, processing instructions, job identification, execution result and execution status.

8. The method according to claim 7, characterized in that Also includes: Determine a fault resolution method according to the fault information; Perform a fault self-healing operation based on the fault resolution method.

9. An operation log generating device, characterized in that: include: An operation receiving module, used for receiving the operation to be executed and generating a global identifier of the job; A job information generating module, used for determining at least one job to be executed according to the operation to be executed, creating a thread for each job to be executed, and generating job information; A task information generating module, used for allocating a job identifier to each of the threads according to the job global identifier, executing the corresponding job to be executed through each of the threads, and generating task information; An operation log generating module, used for generating an operation log according to the job global identifier, job information, job identifier and task information; The operation log generating module includes: A mode acquisition unit, used for acquiring a data operation mode; A job table generating unit, used for outputting the job global identifier and job information to a database according to the data operation mode, and generating a job table; A task table generating unit, used for outputting the job identification and task information to a database according to the data operation mode to generate a task table; A log generating unit, used for generating an operation log according to the job table and the task table; The job information includes the submitter, caller, request parameters and return information; the task information includes the task identifier, job identifier, processing instructions, task processing sequence, task processing node, execution result and execution status.

10. A fault query device, characterized in that: include: A log acquisition module, which acquires a job identifier to be queried and an operation log, wherein the operation log is generated by the operation log generation device according to claim 9; The fault information determination module is used to query the task table in the operation log according to the job identifier to be queried to determine the fault information.

Citation Information

Patent Citations

  • Fault locating method, fault locating device and fault locating system

    CN108768752A

  • Business log model, business execution method and device, electronic equipment and medium

    CN113010398A