A risk prediction method based on operation log

The operation logs are preprocessed and modeled through the deep learning model to form an anomaly detection model, which solves the problem of difficulty in real-time detection of potential problems in the computer system in the existing technology and achieves more efficient risk detection and response.

CN117972596BActive Publication Date: 2024-10-08HEFEI GUQIU DATA TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311629393.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-30
Publication Date
2024-10-08
Estimated Expiration
2043-11-30

AI Technical Summary

Technical Problem

Existing risk prediction methods based on operation logs are difficult to detect and respond to potential problems in computer systems in real time, especially when software iterations and configuration changes occur. Traditional rule-based analysis methods become outdated or inaccurate and cannot effectively handle large-scale operation log data.

Method used

A deep learning model is used to preprocess and model the operation log data, and an anomaly detection model is formed through the Transformer encoder layer and the fully connected layer. The cross-entropy loss function and Adam optimizer are used for model training, and the mean square error and anomaly proportion are calculated. To determine risks and respond dynamically based on set thresholds.

Benefits of technology

It improves the accuracy of anomaly detection, reduces reliance on manual rules and pattern matching, significantly improves risk detection efficiency, and enables the model to adapt to changes in computer systems and applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117972596B_ABST
    Figure CN117972596B_ABST
Patent Text Reader

Abstract

The present invention discloses a risk prediction method based on operation logs, which relates to the field of risk prediction, including collecting computer system operation log data and converting them into numerical vectors, and performing data preprocessing; performing log sequence modeling based on the numerical vectors obtained by preprocessing, and training the model to form an anomaly detection model; the computer system uses the anomaly detection model to predict log entries, and judges risks and implements measures based on the difference between the model prediction and the actual log entry; and stores all data generation detection records. The method of the present invention accurately models the complex patterns and dependencies in the log data through a deep learning model, and regularly updates and retrains the model to adapt the model to changes in computer systems and applications, improve the accuracy of anomaly detection, reduce the reliance on manual rules and pattern matching, and greatly improve the efficiency of risk detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of risk prediction, and in particular to a risk prediction method based on operation logs. Background Art

[0002] As the complexity of modern computing environments increases, the number of operational logs generated by computer systems and applications is also increasing dramatically. These logs contain a large amount of information that can be used to monitor the health of computer systems, diagnose problems, and predict potential risks. Traditional automation tools are often unable to effectively handle data of this scale. With the iteration and update of software and changes in configuration, the behavior of computer systems is also constantly changing, which means that the pattern and structure of logs may change over time, making rule-based analysis methods outdated or inaccurate. For many critical applications, even a short downtime or performance degradation is unacceptable, which requires log analysis tools to detect and respond to potential problems in real time. Summary of the invention

[0003] In view of the problems existing in the above-mentioned existing risk prediction methods based on operation logs, the present invention is proposed.

[0004] Therefore, the problem to be solved by the present invention is how to provide a risk prediction method based on operation logs.

[0005] To solve the above technical problems, the present invention provides the following technical solutions: a risk prediction method based on operation logs, which includes collecting computer system operation log data, converting it into a numerical vector, and performing data preprocessing;

[0006] Log sequence modeling is performed based on the numerical vector obtained by preprocessing, and the model is trained to form an anomaly detection model;

[0007] The computer system uses anomaly detection models to predict log entries, and determines risks and implements measures based on the differences between model predictions and actual log entries;

[0008] Generate test records for all data and store them.

[0009] As a preferred solution of the risk prediction method based on operation logs described in the present invention, the collected computer system operation log data is converted into a numerical vector, including using a file reading function of a programming language to open and read the content of the log file, using regular expression matching to extract timestamps, event IDs and log messages from each line of the log, using an NLP library to load a pre-trained NER model, extracting keywords and phrases from each log message, using an NLP library to load a pre-trained word embedding model, applying the word embedding model to the extracted keywords and phrases, and converting them into numerical vectors.

[0010] As a preferred solution of the risk prediction method based on operation logs described in the present invention, the data preprocessing includes cleaning the data to remove outliers in the data and fill in missing values, calculating the mean and standard deviation of the numerical vector, and taking the mean plus or minus 3 times the standard deviation as the abnormal judgment threshold, marking the numerical vector beyond the threshold range as abnormal and deleting it from the data, and if there are missing values ​​in the numerical vector, using the mean or median to fill in and fill in.

[0011] As a preferred solution of the risk prediction method based on operation logs of the present invention, the log sequence modeling is performed according to the numerical vector obtained by preprocessing, and the model is trained to form an anomaly detection model, which includes the following steps:

[0012] The numerical vector obtained in the preprocessing step is used as input and the input representation of the model is obtained through the embedding layer;

[0013] Adding positional encoding provides the model with position information in the sequence;

[0014] Stack multiple Transformer encoder layers together, each of which contains a multi-head attention sublayer and a feed-forward neural network sublayer;

[0015] A fully connected layer transforms the output of the Transformer into a prediction result;

[0016] Use the cross entropy loss function to measure the difference between the model’s predictions and the true log entries;

[0017] Use Adam optimizer to update model parameters;

[0018] Use the training data set to train the model, and update the model parameters in each iteration to minimize the loss function;

[0019] After each training cycle, the performance of the model is evaluated using the validation dataset;

[0020] If the validation loss does not decrease significantly in three consecutive training cycles, the model training is stopped and the anomaly detection model is obtained.

[0021] As a preferred solution of the risk prediction method based on operation logs described in the present invention, the log sequence is imported into the anomaly detection model to predict the next log entry, and the difference between the model prediction and the actual log entry is calculated by the mean square error:

[0022]

[0023] Where MSE is the mean square error between a single model prediction and the actual log entry, Y iis the actual log entry numerical vector, Y m is the numerical vector of log entries predicted by the model, and n is the number of log entries;

[0024] After calculating all mean square errors, we get the mean (MSE′) and standard deviation (MSE′), and use the mean and standard deviation to determine the risk judgment threshold:

[0025] Threshold={mean(MSE′)-3*std(MSE′), mean(MSE′)+3*std(MSE′)}

[0026] Threshold represents the calculated risk judgment threshold. The actual log entry status is judged by comparing MSE with Threshold:

[0027] If the MSE is within the risk judgment threshold range, the actual log entry is marked as normal;

[0028] If the MSE exceeds the risk judgment threshold interval, the actual log entry is marked as abnormal;

[0029] After obtaining the status of all actual log entries, calculate the abnormal proportion K of actual log entries.

[0030] As a preferred solution of the risk prediction method based on operation logs of the present invention, after obtaining the abnormal proportion K of actual entries, the risk status of the log is judged by comparing with the judgment values ​​K1 and K2, wherein K1 and K2 are set by the staff and K1≤K2:

[0031] If K<K1, the log is judged to be in a low-risk state, and the computer system stores the anomaly detection model and keeps monitoring the log data, and regularly detects the log data to generate detection records;

[0032] If K1≤K<K2, the log is judged to be in a medium-risk state, and the computer system records the log entries marked as abnormal, improves the frequency of computer system data backup, maintains supervision of newly generated log entries, and performs anomaly detection on newly generated log entries through anomaly prediction models. If an anomaly is detected, the cause of the log anomaly is analyzed and the anomaly is handled;

[0033] If K≥K2, the log is judged to be in a high-risk state, and the computer system sends an alarm to the administrator. The administrator manually supervises the operation of the computer system and temporarily restricts access to the computer system and data. The computer system synchronously integrates all abnormal log entries to analyze the cause of the log abnormality and handles it. After the processing is completed, a review analysis is performed and the computer system protection strategy is updated according to the cause of the abnormality.

[0034] As a preferred solution of the risk prediction method based on operation logs of the present invention, the analysis of the abnormal reasons of the logs includes:

[0035] Select a fixed time window to capture log entries before and after the exception;

[0036] Extract all log entries within the time window from the log database;

[0037] Use the cosine similarity formula to calculate the similarity between the abnormal log entry and each log entry in the context;

[0038] Sort the log entries in the context according to their cosine similarity to the anomaly;

[0039] Select a cosine similarity threshold and add log entries with similarity higher than the threshold to the root cause candidate list;

[0040] Use regular expressions to find common error patterns in the root cause candidate list;

[0041] Submit the identified root cause to the computer system administrator for verification.

[0042] As a preferred solution of the risk prediction method based on operation logs described in the present invention, the computer system collects all data and stores them by category according to data characteristics, encrypts the data, sets data access permissions, and generates records for synchronous storage when the computer system views the stored data.

[0043] An intelligent computer device, characterized in that it includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the above-mentioned risk prediction method based on operation logs are implemented.

[0044] A computer-readable storage medium, characterized in that computer-readable instructions are stored on the computer-readable storage medium, and when the computer-readable instructions are executed by a processor, the steps of the above-mentioned risk prediction method based on operation logs are implemented.

[0045] The beneficial effects of the present invention are as follows: the present invention accurately models the complex patterns and dependencies in log data through a deep learning model, and regularly updates and retrains the model to adapt the model to changes in computer systems and applications, thereby improving the accuracy of anomaly detection, reducing reliance on manual rules and pattern matching, and greatly improving risk detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0047] Figure 1 The figure is a flowchart of the risk prediction method based on operation logs. DETAILED DESCRIPTION

[0048] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.

[0049] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0050] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor is it a separate or selective embodiment that is mutually exclusive with other embodiments.

[0051] Example 1

[0052] Reference Figure 1 , which is the first embodiment of the present invention, and this embodiment provides a risk prediction method based on operation logs, and the risk prediction method based on operation logs includes the following steps:

[0053] S1, collect computer system operation log data and convert it into numerical vectors, and perform data preprocessing;

[0054] Specifically, collecting computer system operation log data and converting it into a numerical vector includes using a file reading function of a programming language to open and read the content of a log file, using regular expression matching to extract a timestamp, event ID, and log message from each line of the log, using an NLP library to load a pre-trained NER model, extracting keywords and phrases from each log message, using an NLP library to load a pre-trained word embedding model, applying the word embedding model to the extracted keywords and phrases, and converting them into numerical vectors.

[0055] The pre-trained NER models and pre-trained word embedding models obtained from the NLP library are trained on text datasets containing a large number of labeled entities. They can understand and recognize multiple types of entities and can also adapt to the needs of specific applications by fine-tuning on data in specific fields. Pre-trained models can usually be used directly for specific tasks without training from scratch, which greatly improves development efficiency and model performance, and effectively improves the quality and efficiency of data processing.

[0056] Furthermore, data preprocessing includes cleaning the data to remove outliers and fill in missing values, calculating the mean and standard deviation of the numerical vector, taking the mean plus or minus 3 times the standard deviation as the abnormality judgment threshold, marking the numerical vectors beyond the threshold range as abnormal and deleting them from the data, and if there are missing values ​​in the numerical vector, using the mean or median to fill in.

[0057] Removing irrelevant, duplicate or erroneous data improves the overall quality and reliability of the data set. By identifying and removing outliers, noise and interference are reduced, making the data more concentrated in the normal operating range, which helps the accuracy of subsequent analysis and model training. Using the mean or median to fill missing values ​​enhances the integrity of the data set and ensures that important information is not lost due to missing data during the analysis and modeling process. By calculating the mean and standard deviation and using these statistics to standardize the data, the model can learn patterns in the data more effectively and reduce deviations caused by differences in data scales. Setting thresholds based on the mean and standard deviation effectively identifies outliers and helps build more robust and accurate prediction models. The preprocessing step not only improves the quality and availability of the data, but also lays a solid foundation for building efficient and accurate risk prediction models.

[0058] S2. Perform log sequence modeling based on the numerical vector obtained by preprocessing, and train the model to form an anomaly detection model;

[0059] Specifically, log sequence modeling is performed according to the numerical vector obtained by preprocessing, and the model is trained to form an anomaly detection model, which includes the following steps:

[0060] The numerical vector obtained in the preprocessing step is used as input and the input representation of the model is obtained through the embedding layer;

[0061] Adding positional encoding provides the model with position information in the sequence;

[0062] Stack multiple Transformer encoder layers together, each of which contains a multi-head attention sublayer and a feed-forward neural network sublayer;

[0063] A fully connected layer transforms the output of the Transformer into a prediction result;

[0064] Use the cross entropy loss function to measure the difference between the model’s predictions and the true log entries;

[0065] Use Adam optimizer to update model parameters;

[0066] Use the training data set to train the model, and update the model parameters in each iteration to minimize the loss function;

[0067] After each training cycle, the performance of the model is evaluated using the validation dataset;

[0068] If the validation loss does not decrease significantly in three consecutive training cycles, the model training is stopped and the anomaly detection model is obtained.

[0069] Transformer is a deep learning model that relies on the "attention mechanism" to capture the global dependencies of the input sequence. Its effect is very prominent in a variety of natural language processing tasks. In this embodiment, multiple Transformer encoder layers are stacked together, and a fully connected layer converts the output of the Transformer into a prediction result. When predicting, given a log sequence as input, the Transformer model will try to predict the content of the next log entry. The model will consider the contextual information in the sequence to generate the most likely subsequent entries. The use of the Adam optimizer can converge to the local optimal solution faster during the training process, and can handle the situation where the gradient changes of different parameters are inconsistent. It can effectively optimize the model parameters, obtain the training data set and the verification data set from the data set sharing platform or through historical data to train and test the model to ensure that the generated model can generalize better and achieve the expected test effect.

[0070] S3. The computer system uses the anomaly detection model to predict log entries, and determines the risk and implements measures based on the difference between the model prediction and the actual log entries;

[0071] Specifically, the log sequence is imported into the anomaly detection model to predict the next log entry, and the difference between the model prediction and the actual log entry is calculated by the mean square error:

[0072]

[0073] Where MSE is the mean square error between a single model prediction and the actual log entry, Y i is the actual log entry numerical vector, Y m is the numerical vector of log entries predicted by the model, and n is the number of log entries;

[0074] After calculating all mean square errors, we get the mean (MSE′) and standard deviation (MSE′), and use the mean and standard deviation to determine the risk judgment threshold:

[0075] Threshold={mean(MSE′)-3*std(MSE′), mean(MSE′)+3*std(MSE′)}

[0076] Threshold represents the calculated risk judgment threshold. The actual log entry status is judged by comparing MSE with Threshold:

[0077] If the MSE is within the risk judgment threshold range, the actual log entry is marked as normal;

[0078] If the MSE exceeds the risk judgment threshold interval, the actual log entry is marked as abnormal;

[0079] After obtaining the status of all actual log entries, calculate the abnormal proportion K of actual log entries.

[0080] The risk judgment threshold is determined by calculating the MSE mean and standard deviation of all log entries. This method can adapt to different data characteristics and changes, and provides a dynamic, data-based threshold setting method. Calculating the anomaly ratio K can help evaluate the health status of the entire computer system, which is critical for quickly responding to potential risk issues. It can quickly identify abnormal log entries, making it possible to take timely measures to mitigate or avoid potential damage. This method is not limited to specific types of logs or computer systems, but can be widely used in different log analysis tasks.

[0081] Furthermore, after obtaining the actual abnormal proportion K of entries, the log risk status is determined by comparing it with the judgment values ​​K1 and K2, where K1 and K2 are set by the staff and updated and adjusted regularly, and K1≤K2:

[0082] If K<K1, the log is judged to be in a low-risk state, and the computer system stores the anomaly detection model and keeps monitoring the log data, and regularly detects the log data to generate detection records;

[0083] If K1≤K<K2, the log is judged to be in a medium-risk state, and the computer system records the log entries marked as abnormal, improves the frequency of computer system data backup, maintains supervision of newly generated log entries, and performs anomaly detection on newly generated log entries through anomaly prediction models. If an anomaly is detected, the cause of the log anomaly is analyzed and the anomaly is handled;

[0084] If K≥K2, the log is judged to be in a high-risk state, and the computer system sends an alarm to the administrator. The administrator manually supervises the operation of the computer system and temporarily restricts access to the computer system and data. The computer system synchronously integrates all abnormal log entries to analyze the cause of the log abnormality and handles it. After the processing is completed, a review analysis is performed and the computer system protection strategy is updated according to the cause of the abnormality.

[0085] By setting different risk thresholds, risk management strategies can be adjusted more accurately according to actual conditions. Risk assessment and response measures can be dynamically adjusted based on the real-time calculated abnormality ratio K, which improves the computer system's ability to respond to potential threats. Detailed analysis of log entries marked as abnormal helps to more accurately identify and handle problems. At the same time, staff regularly updates and adjusts K1 and K2, which greatly improves the flexibility of the computer system in judging risks. Through this dynamic risk assessment and management mechanism, the stability and reliability of the computer system can be continuously improved. Overall, this dynamic risk assessment and layered response mechanism based on abnormality ratio provides a comprehensive, flexible and efficient framework for effective log management and risk control.

[0086] It should also be noted that the reasons for abnormal analysis logs include:

[0087] Select a fixed time window to capture log entries before and after the exception;

[0088] Extract all log entries within the time window from the log database;

[0089] Use the cosine similarity formula to calculate the similarity between the abnormal log entry and each log entry in the context;

[0090] Sort the log entries in the context according to their cosine similarity to the anomaly;

[0091] Select a cosine similarity threshold and add log entries with similarity higher than the threshold to the root cause candidate list;

[0092] Use regular expressions to find common error patterns in the root cause candidate list;

[0093] Submit the identified root cause to the computer system administrator for verification.

[0094] In-depth analysis can help accurately identify the specific cause of the anomaly, whether it is a computer system error, security vulnerability or operational error. By promptly identifying the source of the problem, measures can be taken quickly to resolve the problem and reduce potential damage or interruption time. Understanding the cause of the anomaly can help prevent similar incidents from happening again in the future and improve the overall robustness and reliability of the computer system. The results of anomaly analysis can be used to guide improvements in computer system design and optimization of operating processes, improve computer system efficiency and user experience, and analyze security-related anomalies to help strengthen computer system security protection measures and prevent security vulnerabilities from being exploited. Recording the causes of anomalies and how to deal with them can enrich the internal knowledge base and accelerate the resolution of similar problems in the future. Transparent analysis and effective handling of the causes of anomalies can enhance user trust and satisfaction with computer systems. By comprehensively analyzing the anomalies in the log, not only can the immediate problem be solved in a timely manner, but it can also provide valuable experience and knowledge for future computer system operation and maintenance and management.

[0095] S4, storing all data generated test records;

[0096] Specifically, the computer system collects all data and stores them by categories according to data characteristics, encrypts the data, sets data access permissions, and generates records and stores them synchronously when the computer system views the stored data.

[0097] Example 2

[0098] This is the second embodiment of the present invention, and the difference between this embodiment and the previous embodiment is that:

[0099] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0100] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by an instruction-executing computer system, device or apparatus (such as a computer-based computer system, a computer system including a processor, or other computer system that can fetch instructions from an instruction-executing computer system, device or apparatus and execute the instructions), or in conjunction with such instruction-executing computer systems, devices or apparatuses. For purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate or transport a program for use by an instruction-executing computer system, device or apparatus, or in conjunction with such instruction-executing computer systems, devices or apparatuses.

[0101] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0102] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution computer system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0103] Example 3

[0104] This is the third embodiment of the present invention. This embodiment is different from the previous two embodiments. In order to verify the beneficial effects of the method of the present invention, the method of the present invention is compared with the prior art to demonstrate and prove the comparison results. Table 1 shows.

[0105] Table 1: Comparison table of the method of the present invention and the prior art experiments

[0106] Prior art Method of the present invention Accuracy (%) 85 95 Detection time (seconds) 5 3 Cause analysis time (seconds) 10 7 Model training time (hours) 4 2.5 Model update frequency (days / times) 7 5 Anomaly detection sensitivity (%) 80 90 Anomaly detection specificity (%) 82 88

[0107] It can be concluded from the above table that the method of the present invention has obvious improvements in accuracy, detection time, cause analysis time, model training time, update frequency, anomaly detection sensitivity and specificity, which effectively improves the efficiency of risk prediction through operation logs and has obvious advantages.

[0108] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A risk prediction method based on operation logs, characterized in that: include, Collect computer system operation log data and convert them into numerical vectors, and perform data preprocessing; Log sequence modeling is performed based on the numerical vector obtained by preprocessing, and the model is trained to form an anomaly detection model; The computer system uses anomaly detection models to predict log entries, and determines risks and implements measures based on the differences between model predictions and actual log entries; Generate test records for all data and store them; The collecting computer system operation log data and converting it into a numerical vector includes using a file reading function of a programming language to open and read the content of the log file, using regular expression matching to extract a timestamp, an event ID, and a log message from each line of the log, using an NLP library to load a pre-trained NER model, extracting keywords and phrases from each log message, using an NLP library to load a pre-trained word embedding model, applying the word embedding model to the extracted keywords and phrases, and converting them into a numerical vector; The log sequence modeling is performed based on the numerical vector obtained by preprocessing, and the model is trained to form an anomaly detection model, which includes the following steps: The numerical vector obtained in the preprocessing step is used as input and the input representation of the model is obtained through the embedding layer; Adding positional encoding provides the model with position information in the sequence; Stack multiple Transformer encoder layers together, each of which contains a multi-head attention sublayer and a feed-forward neural network sublayer; A fully connected layer transforms the output of the Transformer into a prediction result; Use the cross entropy loss function to measure the difference between the model’s predictions and the true log entries; Use Adam optimizer to update model parameters; Use the training data set to train the model, and update the model parameters in each iteration to minimize the loss function; After each training cycle, the performance of the model is evaluated using the validation dataset; If the validation loss does not decrease significantly in three consecutive training cycles, stop model training and obtain an anomaly detection model; The data preprocessing includes cleaning the data to remove outliers and fill in missing values, calculating the mean and standard deviation of the numerical vector, taking the mean plus or minus 3 times the standard deviation as the abnormality judgment threshold, marking the numerical vector beyond the threshold range as abnormal and deleting it from the data, and if there are missing values ​​in the numerical vector, using the mean or median to fill in and fill in; Import the log sequence into the anomaly detection model to predict the next log entry and calculate the difference between the model prediction and the actual log entry using the mean squared error: Where MSE is the mean square error between a single model prediction and the actual log entry, Y i is the actual log entry numerical vector, Y m is the numerical vector of log entries predicted by the model, and n is the number of log entries; After calculating all mean square errors, we get the mean (MSE') and standard deviation (MSE'), and use the mean and standard deviation to determine the risk judgment threshold: Threshold={mean(MSE')-3*std(MSE'), mean(MSE')+3*std(MSE')} Threshold represents the calculated risk judgment threshold. The actual log entry status is judged by comparing MSE with Threshold: If the MSE is within the risk judgment threshold range, the actual log entry is marked as normal; If the MSE exceeds the risk judgment threshold interval, the actual log entry is marked as abnormal; After obtaining the status of all actual log entries, calculate the abnormal proportion K of actual log entries; After obtaining the actual abnormal proportion K of entries, the log risk status is determined by comparing it with the judgment values ​​K1 and K2, where K1 and K2 are set by the staff and K1≤K2: If K<K1, the log is judged to be in a low-risk state, and the computer system stores the anomaly detection model and keeps monitoring the log data, and regularly detects the log data to generate detection records; If K1≤K<K2, the log is judged to be in a medium-risk state, and the computer system records the log entries marked as abnormal, improves the frequency of computer system data backup, maintains supervision of newly generated log entries, and performs anomaly detection on newly generated log entries through anomaly prediction models. If an anomaly is detected, the cause of the log anomaly is analyzed and the anomaly is handled; If K≥K2, the log is judged to be in a high-risk state, and the computer system sends an alarm to the administrator. The administrator manually supervises the operation of the computer system and temporarily restricts access to the computer system and data. The computer system simultaneously analyzes the cause of the log anomaly and processes it based on all abnormal log entries. After processing, it conducts a re-analysis and updates the computer system protection strategy based on the cause of the anomaly. The reasons for abnormal analysis logs include: Select a fixed time window to capture log entries before and after the exception; Extract all log entries within the time window from the log database; Use the cosine similarity formula to calculate the similarity between the abnormal log entry and each log entry in the context; Sort the log entries in the context according to their cosine similarity to the anomaly; Select a cosine similarity threshold and add log entries with similarity higher than the threshold to the root cause candidate list; Use regular expressions to find common error patterns in the root cause candidate list; Submit the identified root cause to the computer system administrator for verification.

2. The risk prediction method based on operation logs according to claim 1, characterized in that: The computer system collects all data and stores them by categories according to data characteristics, encrypts the data, sets data access permissions, and generates records and stores them synchronously when the computer system views the stored data.