A log abnormality early warning method, device, electronic device and storage medium
By classifying and serializing log data, and using deep learning technology to train log prediction models, the problem of low reliability of log data anomaly detection in the existing technology is solved, and more efficient log anomaly warning is achieved.
Patent Information
- Application Number
- CN202111362830.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-11-17
AI Technical Summary
In the existing technology, the reliability of log data anomaly detection is low, mainly because the traditional automatic detection method is based on keyword matching of regular expressions, which easily misses keywords and generates noise, resulting in low efficiency and accuracy of manual analysis and automatic detection. high.
By classifying and serializing the log data, using deep learning technology to train the log prediction model, predict the number of template identifiers and the matching of the actual identifiers, count the number of prediction failures within the preset time period, and issue log abnormality warnings if the threshold is exceeded. .
It improves the reliability and efficiency of log anomaly warning, reduces the need for manual analysis, and enhances the ability to quickly detect log data anomalies.
Smart Images

Figure CN114064434B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a log abnormality early warning method, device, electronic equipment and storage medium. Background Art
[0002] At present, almost all backend services generate log data in real time when they are running, recording the events and system status of the backend services during operation. Log data plays an important role in anomaly detection and early warning of operation and maintenance monitoring systems.
[0003] In the prior art, large online services are usually developed and maintained by hundreds of developers and operators. Developers and operators tend to analyze log anomalies from a local perspective, which can easily lead to inaccurate log analysis. In addition, due to the surge in the number of logs, manual analysis of log data anomalies has become impractical. The traditional way to automatically detect log data anomalies is based on regular expression keyword matching. This method requires the generation of a keyword library based on experience. Since it is impossible to exhaustively enumerate keywords, it is easy to miss keywords and generate a lot of noise, resulting in low reliability of anomaly detection. Summary of the invention
[0004] In view of the problems in the prior art, the embodiments of the present invention provide a log abnormality early warning method, device, electronic device and storage medium, which can at least partially solve the problems in the prior art.
[0005] On the one hand, the present invention provides a log abnormality early warning method, comprising:
[0006] Classify and serialize each piece of log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each piece of log data corresponds to a classification identifier;
[0007] Counting the number of template identifiers included in the template sequence corresponding to each classification identifier, and predicting the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is obtained by pre-training based on historical log data;
[0008] According to the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, counting the number of prediction failures corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within the preset time period;
[0009] If it is determined that the prediction failure amount is greater than a set threshold, a log abnormality warning is issued.
[0010] On the other hand, the present invention provides an early warning device for log abnormality, comprising:
[0011] The acquisition module is used to classify and serialize each log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each log data corresponds to a classification identifier;
[0012] A prediction module, used to count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is obtained by pre-training based on historical log data;
[0013] A statistics module, for counting the number of prediction failures corresponding to the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number within a preset time period, based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number;
[0014] The early warning module is used to issue a log abnormality early warning after determining that the prediction failure amount is greater than a set threshold.
[0015] On the other hand, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the log abnormality warning method described in any of the above embodiments when executing the program.
[0016] In yet another aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the log anomaly warning method described in any of the above embodiments.
[0017] In yet another aspect, the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the log anomaly warning method described in any of the above embodiments.
[0018] The log anomaly warning method, device, electronic device and storage medium provided by the embodiments of the present invention can classify and serialize each log data in turn, obtain the template sequence corresponding to each classification identifier, count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, and based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, count the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within a preset time period, and if it is determined that the predicted failure amount is greater than the set threshold, a log anomaly warning is issued, thereby improving the reliability of the log anomaly warning. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0020] Figure 1 It is a flowchart of a log abnormality early warning method provided by the first embodiment of the present invention.
[0021] Figure 2 It is a flow chart of a log abnormality early warning method provided by the second embodiment of the present invention.
[0022] Figure 3 It is a flowchart of a log abnormality early warning method provided by the third embodiment of the present invention.
[0023] Figure 4 It is a flowchart of a method for early warning of log anomalies provided in a fourth embodiment of the present invention.
[0024] Figure 5 It is a flowchart of a log abnormality early warning method provided in the fifth embodiment of the present invention.
[0025] Figure 6 It is a flowchart of a log abnormality early warning method provided by a sixth embodiment of the present invention.
[0026] Figure 7 It is a flowchart of a log abnormality early warning method provided by the seventh embodiment of the present invention.
[0027] Figure 8It is a flowchart of a log abnormality early warning method provided in the eighth embodiment of the present invention.
[0028] Fig. 9 It is a flowchart of a log abnormality early warning method provided by the ninth embodiment of the present invention.
[0029] Fig.10 It is a structural diagram of a log abnormality early warning device provided by the tenth embodiment of the present invention.
[0030] Fig.11 It is a structural diagram of a log abnormality early warning device provided by the eleventh embodiment of the present invention.
[0031] Fig.12 It is a structural diagram of a log abnormality early warning device provided in the twelfth embodiment of the present invention.
[0032] Fig.13 It is a structural diagram of a log abnormality early warning device provided in the thirteenth embodiment of the present invention.
[0033] Fig.14 It is a structural diagram of a log abnormality early warning device provided in the fourteenth embodiment of the present invention.
[0034] Fig.15 It is a schematic diagram of the structure of a log abnormality early warning device provided in the fifteenth embodiment of the present invention.
[0035] Fig.16 It is a structural diagram of a log abnormality early warning device provided in the sixteenth embodiment of the present invention.
[0036] Fig.17 It is a structural diagram of a log abnormality early warning device provided in the seventeenth embodiment of the present invention.
[0037] Fig.18 It is a structural diagram of a log abnormality early warning device provided in the eighteenth embodiment of the present invention.
[0038] Fig.19 It is a schematic diagram of the physical structure of an electronic device provided in the nineteenth embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention. It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other arbitrarily.
[0040] In order to facilitate the understanding of the technical solution provided by the present application, the relevant contents of the technical solution of the present application are described below. Log data is a kind of text data, and there are obvious differences between normal logs and abnormal logs. Current deep learning technology has many excellent performances in text data mining, especially BERT (Bidirectional Encoder Representations from Transformers, referred to as BERT), gated recurrent unit (Gated Recurrent Unit, referred to as GRU), bidirectional long short-term memory (Bi-directional Long Short-Term Memory, referred to as BiLSTM), attention mechanism (Attention) and other models are widely used in the field of text analysis. In the context of large-scale online services and massive log data processing, in order to find the anomaly of log data faster and improve the automation of log data processing, the present invention uses historical log data and deep learning technology to train and obtain a log prediction model, and then predicts the online log data based on the log prediction model to warn the abnormal log data.
[0041] The following uses a server as an example to illustrate the specific implementation process of the log anomaly warning method provided by the embodiment of the present invention. It is understandable that the execution subject of the log anomaly warning method provided by the embodiment of the present invention is not limited to the server.
[0042] Figure 1 FIG. 1 is a flow chart of a method for early warning of log anomalies provided by a first embodiment of the present invention. Figure 1 As shown, the log abnormality early warning method provided by the embodiment of the present invention includes:
[0043] S101, classify and serialize each piece of log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each piece of log data corresponds to a classification identifier;
[0044] Specifically, the server can obtain real-time log data, and then classify and serialize each log data in turn, and obtain a template sequence corresponding to each classification identifier, wherein the template sequence includes a plurality of template identifiers arranged in sequence, and the arrangement order of each template identifier is arranged in the order of the timestamps of each log data corresponding to each template identifier, and can be regarded as time series data. Among them, the classification identifier is preset, and a process number or a thread number can be used. Each log data will include the classification identifier.
[0045] S102, counting the number of template identifiers included in the template sequence corresponding to each classification identifier, and predicting the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is obtained by pre-training based on historical log data;
[0046] Specifically, since the real-time log data is constantly changing, the number of template identifiers included in the template sequence corresponding to the obtained classification identifier will also change. The server will count the number of template identifiers included in the template sequence corresponding to each classification identifier. When the number of template identifiers is equal to the preset number, the template sequence corresponding to the classification identifier whose number of template identifiers is equal to the preset number is predicted based on the log prediction model, and the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number can be obtained. There can be multiple predicted template identifiers. Among them, the log prediction model is pre-trained based on historical log data. The preset number is set according to actual needs, and the embodiment of the present invention does not limit it.
[0047] It should be noted that the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number is the next log data corresponding to the preset number of log data corresponding to the template sequence whose number of template identifiers is equal to the preset number of classification identifiers. For example, if the preset number of log data is n log data, then the next log data of the preset number of log data is the n+1th log data. The n+1 log data have the same classification identifier, and the n+1 log data have a time sequence relationship.
[0048] It is understandable that after the number of template identifiers included in the template sequence corresponding to the classification identifier is equal to a preset number, the template sequence corresponding to the classification identifier will be reacquired.
[0049] S103, counting the number of prediction failures corresponding to the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number within a preset time period according to the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number;
[0050] Specifically, the server can obtain the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, and then perform template matching on the above-mentioned next log data, so as to obtain the template identifier corresponding to the next log data, and use it as the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number. The server can determine whether the template identifier of the next log data fails to be predicted based on the predicted template identifier and the actual template identifier of the next log data. Within a preset time period, the server can obtain multiple next log data, determine whether the template identifier of each next log data fails to be predicted, and count the number of template prediction failures of each next log data within the preset time period as the prediction failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within the preset time period. Among them, the preset time period is set according to actual needs, and the embodiments of the present invention are not limited thereto.
[0051] For example, after obtaining the predicted template identifier and the actual template identifier of the next log data, the server compares the actual template identifier with each template identifier included in the predicted template identifier. If there is a template identifier identical to the actual template identifier among the template identifiers included in the predicted template identifier, it can be determined that the template identifier prediction of the next log data is successful. If there is no template identifier identical to the actual template identifier among the template identifiers included in the predicted template identifier, it can be determined that the template identifier prediction of the next log data fails.
[0052] For example, within the preset time period, the template identification prediction for the next log data corresponding to classification identification a failed 3 times, the template identification prediction for the next log data corresponding to classification identification b failed 2 times, and the template identification prediction for the next log data corresponding to classification identification c failed 1 time. Then the server counts that the number of template identifications within the preset time period is equal to the number of prediction failures corresponding to the next log data corresponding to the preset number of classification identifications, which is 3+2+1=6.
[0053] S104: If it is determined that the prediction failure amount is greater than a set threshold, a log abnormality warning is issued.
[0054] Specifically, after obtaining the predicted failure amount corresponding to the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number within the preset time period, the server compares the predicted failure amount with the set threshold value, and if the predicted failure amount is greater than the set threshold value, a log abnormality warning may be issued through system messages, emails, etc. The set threshold value is set according to actual needs and is not limited in the embodiment of the present invention.
[0055] The log anomaly warning method provided by the embodiment of the present invention can classify and serialize each log data in turn, obtain the template sequence corresponding to each classification identifier, count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, and based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within a preset time period, count the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number. If it is determined that the predicted failure amount is greater than the set threshold, a log anomaly warning is issued, thereby improving the reliability of the log anomaly warning.
[0056] Figure 2 FIG. 1 is a flow chart of a method for early warning of log anomalies provided by a second embodiment of the present invention. Figure 2 As shown, based on the above embodiments, further, the step of classifying and serializing each log data in turn to obtain a template sequence corresponding to each classification identifier includes:
[0057] S201, performing template matching on each piece of log data to obtain a template identifier corresponding to each piece of log data;
[0058] Specifically, the server may obtain log data, and then perform template matching on each piece of log data to obtain a log template matching each piece of log data, and obtain a template identifier of the matching log template as the template identifier corresponding to each piece of log data.
[0059] Among them, a log template library can be established in advance, and the log template library includes multiple log templates, and each log template has a unique corresponding template identifier. Each log data includes a fixed string and a variable. Different log templates can be obtained by clustering the historical log data, extracting the fixed string and replacing the variable with a wildcard. The log template corresponds to the log identifier one by one. The log template includes a template content, and the template content includes a regular expression composed of a fixed string and a wildcard. The regular expression is used to match the log data. If the log data matches the regular expression included in the log template, it means that the log data matches the log template, and then the template identifier corresponding to the log template is used as the template identifier corresponding to the log data. Among them, the log template can be extracted through the Logmine tool to achieve the establishment of the log template library.
[0060] When template matching is performed on log data, each log template in the log template library is traversed to determine whether there is a regular expression matching the log data in each log template. If there is a regular expression matching the log data, it means that the log data matches the log template. Then the template identifier corresponding to the log template to which the regular expression belongs will be used as the template identifier corresponding to the log data.
[0061] In addition, if no log template matching the log data is found in the log template library, log template extraction is performed on the log data for which no matching log template is found, and a new log template is established.
[0062] S202, classifying each piece of log data according to the classification identifier, and obtaining the classification identifier corresponding to each piece of log data;
[0063] Specifically, for each log data, the server searches the log data according to the classification identifier. If the log data includes the classification identifier, the classification identifier is used as the classification identifier corresponding to the log data. There is no sequence relationship between step S201 and step S202. The classification identifier can be a process number or a thread number, which is set according to actual needs and is not limited in the embodiment of the present invention.
[0064] S203 . Obtain a template sequence corresponding to each classification identifier according to the classification identifier corresponding to each piece of log data, the template identifier corresponding to each piece of log data, and the timestamp corresponding to each piece of log data.
[0065] Specifically, the server will sort the template identifiers corresponding to the log data with the same classification identifier according to the order of the timestamps corresponding to the log data, and obtain the template sequences corresponding to the classification identifiers. For real-time log data, after obtaining the classification identifier and template identifier corresponding to the latest log data, it can be queried based on the classification identifier whether the template sequence corresponding to the classification identifier has been established. If the template sequence corresponding to the classification identifier has been established, the template identifier corresponding to the latest log data can be directly used as the last template identifier of the template sequence corresponding to the classification identifier. If the template sequence corresponding to the classification identifier has not been established, then the template sequence corresponding to the classification identifier is established, and the template identifier corresponding to the latest log data is used as the first template identifier of the template sequence corresponding to the classification identifier.
[0066] Figure 3 : is a flow chart of a method for early warning of log anomalies provided by a third embodiment of the present invention, such as Figure 3As shown, on the basis of the above embodiments, further, the log prediction model is used to predict the template sequence corresponding to the classification identifiers whose number of template identifiers is equal to the preset number, and the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number is obtained, including:
[0067] S301, performing feature processing on a template sequence corresponding to a classification identifier whose number of template identifiers is equal to a preset number, to obtain prediction feature data corresponding to the classification identifier;
[0068] Specifically, after determining that the number of template identifiers included in the template sequence corresponding to the classification identifier is equal to the preset number, the server performs feature processing on the template sequence corresponding to the classification identifier to obtain the prediction feature data corresponding to the classification identifier. The specific process of feature processing is described below and will not be repeated here.
[0069] S302: Obtain a prediction template identifier of the next log data corresponding to the classification identifier according to the prediction feature data corresponding to the classification identifier and a log prediction model.
[0070] Specifically, after obtaining the predicted feature data corresponding to the classification identifier, the server inputs the predicted feature data corresponding to the classification identifier into the log prediction model. After processing by the log prediction model, the server can output the prediction template identifier of the next log data corresponding to the classification identifier. The above-mentioned prediction template identifier can include multiple template identifiers, which are set according to actual needs and are not limited in the embodiments of the present invention.
[0071] Figure 4 : is a flow chart of a method for early warning of log anomalies provided by a fourth embodiment of the present invention, such as Figure 4 As shown, based on the above embodiments, further, the feature processing is performed on the template sequence corresponding to the classification identifiers whose number of template identifiers is equal to the preset number to obtain the prediction feature data corresponding to the classification identifiers, including:
[0072] S401, according to each template identifier and the template vector library included in the template sequence, obtaining a log template vector corresponding to each template identifier; wherein the template vector library is pre-established and includes log template vectors corresponding to the template identifiers one by one;
[0073] Specifically, the server queries the corresponding log template vector from the template vector library according to each template identifier included in the template sequence, and can obtain the log template vector corresponding to each template identifier in the template sequence. The template vector library is pre-established, and the template vector library includes multiple log template vectors, and the log template vectors correspond to the template identifiers one by one.
[0074] S402, counting the number of identical template identifiers included in the template sequence as the frequency corresponding to each template identifier;
[0075] Specifically, the server counts the number of identical template identifiers in each template identifier included in the template sequence as the frequency corresponding to the template identifier, and can obtain the frequency corresponding to each different template identifier included in the template sequence.
[0076] For example, the template sequence X includes 10 template identifiers arranged in sequence, including 4 template identifiers a, 2 template identifiers b, 3 template identifiers c and 1 template identifier d. Then the server can count the frequency of template identifier a as 4, the frequency of template identifier b as 2, the frequency of template identifier c as 3, and the frequency of template identifier d as 1.
[0077] S403: Use the log template vector and the corresponding frequency corresponding to each template identifier in the template sequence as prediction feature data corresponding to the classification identifier.
[0078] Specifically, the server uses the log template vector corresponding to each template identifier in the template sequence and the frequency corresponding to each template identifier in the template sequence as the prediction feature data corresponding to the classification identifier corresponding to the template sequence.
[0079] Figure 5 FIG. 5 is a flow chart of a method for early warning of log anomalies provided by a fifth embodiment of the present invention. Figure 5 As shown, based on the above embodiments, further, the step of establishing a template vector library includes:
[0080] S501, according to the log template and the word vector library, obtain the word vector corresponding to each word in the log template; wherein the log template and the template identifier correspond one to one; the word vector library is obtained in advance;
[0081] Specifically, the server searches for a word vector corresponding to each word in the template content of the log template from a word vector library, wherein the word vector library is obtained in advance; and the log template and the template identifier correspond one to one.
[0082] For the word vector library, the LRWE model can be used to train the word vectors of the historical log data. During the training, the synonym library and the antonym library are also required as the input of the LRWE model. Among them, the synonym library and the antonym library are established by extracting synonyms and antonyms from the historical log data. Synonyms and antonyms can be manually extracted from the historical log data based on operation and maintenance experience.
[0083] S502, calculating the average value of the word vectors corresponding to each word included in the log template as the corresponding log template vector;
[0084] Specifically, after obtaining the word vector corresponding to each word in the log template, the server sums the word vectors, and then calculates the average value of the vectors to obtain the log template vector corresponding to the log template.
[0085] S503: Store the log template vector corresponding to the log template and the corresponding template identifier in correspondence with each other.
[0086] Specifically, the server stores the template vector corresponding to the log template and the template identifier corresponding to the log template in correspondence. A plurality of log template vectors and their corresponding template identifiers constitute the template vector library.
[0087] Figure 6 is a flow chart of a method for early warning of log anomalies provided by a sixth embodiment of the present invention, such as Figure 6 As shown, on the basis of the above embodiments, further, according to the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, counting the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within the preset time period includes:
[0088] S601, performing template matching on the next log data corresponding to the classification identifier to obtain an actual template identifier of the next log data corresponding to the classification identifier;
[0089] Specifically, the server can obtain the next log data corresponding to the classification identifier whose number of template identifiers is equal to a preset number, and then perform template matching on the next log data corresponding to the above classification identifier to obtain a log template matching the next log data corresponding to the above classification identifier, and use the template identifier of the log template as the actual template identifier of the next log data corresponding to the above classification identifier.
[0090] S602: If it is determined that the predicted template identifier of the next log data corresponding to the classification identifier does not include the actual template identifier of the next log data corresponding to the classification identifier, record that the prediction of the next log data corresponding to the classification identifier fails.
[0091] Specifically, the server compares the actual template identifier of the next log data corresponding to the classification identifier with each template identifier in the predicted template identifier of the next log data corresponding to the classification identifier. If the predicted template identifier of the next log data corresponding to the classification identifier does not contain a template identifier that is the same as the actual template identifier of the next log data corresponding to the classification identifier, then it is recorded that the prediction of the next log data corresponding to the classification identifier fails. If the predicted template identifier of the next log data corresponding to the classification identifier contains a template identifier that is the same as the actual template identifier of the next log data corresponding to the classification identifier, then it can be recorded that the prediction of the next log data corresponding to the classification identifier is successful.
[0092] Figure 7 is a flow chart of a method for early warning of log anomalies provided by a seventh embodiment of the present invention, such as Figure 7 As shown, on the basis of the above embodiments, further, the step of obtaining a log prediction model based on historical log data training includes:
[0093] S701, classifying and serializing the historical log data to obtain a plurality of fixed template sequences; wherein each fixed template sequence corresponds to a classification identifier;
[0094] Specifically, the server may classify and serialize the historical log data to obtain a plurality of fixed template sequences, each of which includes the same number of template identifiers, and each fixed template sequence corresponds to a classification identifier. The number of template identifiers included in each fixed template sequence is set according to actual needs and is not limited in the embodiment of the present invention.
[0095] S702, performing sliding sampling on each fixed template sequence to obtain training data, and obtaining a template identifier corresponding to the next log data corresponding to each sample sequence as a label corresponding to each sample sequence; wherein the training data includes multiple sample sequences, each sample sequence has a fixed length and each sample sequence corresponds to a classification identifier;
[0096] Specifically, the server performs sliding sampling on each fixed template sequence to obtain multiple sample sequences, each sample sequence includes the preset number of template identifiers, and each sample sequence corresponds to a classification identifier. The sample sequences obtained by sampling each fixed template sequence constitute training data. The server can obtain the next log data corresponding to each sample sequence from the historical log data, and then perform template matching on the next log data corresponding to each sample sequence to obtain a log template matching the next log data corresponding to each sample sequence, and obtain the template identifier of the matched log template as the template identifier corresponding to the next log data corresponding to each sample sequence, and the template identifier is used as the label corresponding to each sample sequence.
[0097] Among them, the next log data corresponding to the sample sequence is the next log data corresponding to the log data corresponding to the preset number of template identifiers included in the sample sequence. The log data corresponding to the preset number of template identifiers and the corresponding next log data have the same classification identifier and have a time sequence relationship. Relative to the log data corresponding to the preset number of template identifiers, the next log data corresponding to the log data corresponding to the preset number of template identifiers appears the latest.
[0098] S703, performing feature processing on each sample sequence in the training data to obtain training feature data; wherein the training sample data included in the training feature data corresponds one to one with the sample sequence;
[0099] Specifically, after obtaining the training data, the server can perform feature processing on each sample sequence in the training data to obtain the training sample data corresponding to each sample sequence, and the training sample data corresponding to all sample sequences constitute the training feature data. Since each sample sequence has a corresponding label, the label corresponding to the sample sequence corresponding to the training sample data is the label corresponding to the training sample data. Since the label corresponding to the training sample data can be automatically obtained without manual labeling, the training efficiency of the model is improved.
[0100] S704: Train and obtain a log prediction model according to the original combination model, the training sample data included in the training feature data, and the corresponding labels.
[0101] Specifically, the training feature data can be divided into a training set and a validation set, and each piece of training sample data and the corresponding label included in the training set are input into the original combination model to perform model training to obtain a log prediction model to be verified. The log prediction model to be verified is then verified by the validation set, and the log prediction model to be verified that passes the verification is used as the log prediction model. Among them, the original combination model can adopt a combination of GRU and Attention models, or a combination of Long Short-Term Memory (LSTM) and Attention, which can be selected according to actual needs, and the embodiment of the present invention does not limit it.
[0102] Figure 8 is a flow chart of a method for early warning of log anomalies provided by an eighth embodiment of the present invention, such as Figure 8 As shown, based on the above embodiments, further, the historical log data is classified and serialized to obtain multiple fixed template sequences, including:
[0103] S801, obtaining each piece of historical log data one by one, and performing template matching on each piece of historical log data to obtain a template identifier corresponding to each piece of historical log data;
[0104] Specifically, the server can obtain log data one by one from the historical log data, and then perform template matching on each historical log data to obtain a log template corresponding to each historical log data, and use the template identifier of the matched log template as the template identifier corresponding to each historical log data. The specific implementation process of this step is similar to step S201, and will not be repeated here.
[0105] S802, classifying each piece of historical log data according to the classification identifier, and obtaining the classification identifier corresponding to each piece of historical log data;
[0106] Specifically, for each piece of historical log data, the server searches the historical log data according to the classification identifier. If the historical log data includes the classification identifier, the classification identifier is used as the classification identifier corresponding to the historical log data. There is no sequence relationship between step S801 and step S802. The classification identifier can be a process number or a thread number, which is set according to actual needs and is not limited in the embodiment of the present invention.
[0107] S803: Obtain multiple fixed template sequences according to the classification identifier corresponding to each piece of historical log data, the template identifier corresponding to each piece of historical log data, and the timestamp corresponding to each piece of historical log data.
[0108] Specifically, the server will sort the template identifiers corresponding to the historical log data with the same classification identifier according to the order of the timestamps corresponding to the historical log data. For the sorting results corresponding to different classification identifiers, a set number of template identifiers are sequentially obtained from the first template identifier in each sorting result to form a fixed template sequence, and multiple fixed template sequences can be obtained. Among them, the set number is set according to actual needs and is not limited in the embodiment of the present invention.
[0109] Fig. 9 is a flow chart of a method for early warning of log anomalies provided by a ninth embodiment of the present invention, such as Fig. 9 As shown, on the basis of the above embodiments, further, performing feature processing on each sample sequence in the training data to obtain training feature data includes:
[0110] S901, according to each template identifier and the template vector library included in the sample sequence, obtaining a log template vector corresponding to each template identifier; wherein the template vector library is pre-established and includes log template vectors corresponding to the template identifiers one by one;
[0111] Specifically, the server queries the corresponding log template vector from the template vector library according to each template identifier included in the sample sequence, and can obtain the log template vector corresponding to each template identifier in the sample sequence. The template vector library is pre-established, and the template vector library includes multiple log template vectors, and the log template vectors correspond to the template identifiers one by one.
[0112] S902, counting the number of identical template identifiers included in the sample sequence as the frequency corresponding to the identical template identifier;
[0113] Specifically, the server counts the number of identical template identifiers among the template identifiers included in the sample sequence as the frequency corresponding to the template identifier, and can obtain the frequency corresponding to each different template identifier included in the template sequence.
[0114] S903: Use the log template vector corresponding to each template identifier in the sample sequence and the frequency corresponding to each template identifier as training sample data corresponding to the sample sequence.
[0115] Specifically, the server uses the log template vector corresponding to each template identifier in the sample sequence and the frequency corresponding to each template identifier in the sample sequence as the training sample data corresponding to the sample sequence.
[0116] On the basis of the above embodiments, further, the classification identifier is a process number or a thread number.
[0117] Specifically, the log data may include a process number and / or a thread number, and the process number or the thread number may be used as the classification identifier.
[0118] The log anomaly warning method provided by the embodiment of the present invention is tested using log data from a production environment. First, the logs of the normal operation time period of the business system are used for training, and then the logs of the normal time period and the abnormal time period are used for prediction analysis. Through testing, it is found that the number of log prediction failures in the normal time period is very small and very stable, while the number of log prediction failures in the abnormal time period will rise sharply. The test shows that the log anomaly warning method provided by the embodiment of the present invention has a very good effect on the detection of log anomalies.
[0119] Fig.10 is a schematic diagram of the structure of the early warning device for log abnormality provided by the tenth embodiment of the present invention, such as Fig.10 As shown, the log abnormality warning device provided by the embodiment of the present invention includes an acquisition module 1010, a prediction module 1020, a statistics module 1030 and an early warning module 1040, wherein:
[0120] The acquisition module 1010 is used to classify and serialize each log data in turn to obtain the template sequence corresponding to each classification identifier; wherein each log data corresponds to a classification identifier; the prediction module 1020 is used to count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is pre-trained based on historical log data; the statistics module 1030 is used to count the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within a preset time period based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; the warning module 1040 is used to issue a log abnormality warning after determining that the predicted failure amount is greater than a set threshold.
[0121] Specifically, the acquisition module 1010 can obtain real-time log data, and then classify and serialize each log data in turn, and obtain a template sequence corresponding to each classification identifier, wherein the template sequence includes a plurality of template identifiers arranged in sequence, and the arrangement order of each template identifier is arranged in the order of the timestamps of each log data corresponding to each template identifier, and can be regarded as time series data. Among them, the classification identifier is preset, and a process number or a thread number can be used. Each log data will include the classification identifier.
[0122] Since real-time log data is constantly changing, the number of template identifiers included in the template sequence corresponding to the obtained classification identifier will also change. The prediction module 1020 will count the number of template identifiers included in the template sequence corresponding to each classification identifier. When the number of template identifiers is equal to the preset number, the template sequence corresponding to the classification identifier whose number of template identifiers is equal to the preset number is predicted based on the log prediction model. The predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number can be obtained. There can be multiple predicted template identifiers. Among them, the log prediction model is obtained by pre-training based on historical log data. The preset number is set according to actual needs and is not limited in the embodiments of the present invention.
[0123] The statistics module 1030 can obtain the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, and then perform template matching on the above-mentioned next log data, so as to obtain the template identifier corresponding to the next log data, and use it as the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number. The statistics module 1030 can determine whether the template identifier of the next log data fails to be predicted based on the predicted template identifier and the actual template identifier of the next log data. Within a preset time period, the statistics module 1030 can obtain multiple next log data, determine whether the template identifier of each next log data fails to be predicted, and count the number of template prediction failures of each next log data within the preset time period as the prediction failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within the preset time period. Among them, the preset time period is set according to actual needs, and the embodiment of the present invention is not limited thereto.
[0124] After obtaining the predicted failure amount corresponding to the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number within the preset time period, the warning module 1040 compares the predicted failure amount with the set threshold value. If the predicted failure amount is greater than the set threshold value, a log abnormality warning may be issued through system messages, emails, etc. The set threshold value is set according to actual needs and is not limited in the embodiment of the present invention.
[0125] The log anomaly warning device provided by the embodiment of the present invention can classify and serialize each log data in turn, obtain the template sequence corresponding to each classification identifier, count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, and based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within a preset time period, count the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, and if it is determined that the predicted failure amount is greater than the set threshold, a log anomaly warning is issued, thereby improving the reliability of the log anomaly warning.
[0126] Fig.11 is a schematic diagram of the structure of the early warning device for log abnormality provided by the eleventh embodiment of the present invention, such as Fig.11 As shown, on the basis of the above embodiments, further, the obtaining module 1010 includes a first obtaining unit 1011, a first classification unit 1012 and a second obtaining unit 1013, wherein:
[0127] The first obtaining unit 1011 is used to perform template matching on each log data to obtain the template identifier corresponding to each log data; the first classification unit 1012 is used to classify each log data according to the classification identifier to obtain the classification identifier corresponding to each log data; the second obtaining unit 1013 is used to obtain the template sequence corresponding to each classification identifier according to the classification identifier corresponding to each log data, the template identifier corresponding to each log data and the timestamp corresponding to each log data.
[0128] Fig.12 is a schematic diagram of the structure of the early warning device for log abnormality provided by the twelfth embodiment of the present invention, such as Fig.12 As shown, based on the above embodiments, the prediction module 1020 further includes a third obtaining unit 1021 and a prediction unit 1022, wherein:
[0129] The third acquisition unit 1021 is used to perform feature processing on the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number, and obtain the predicted feature data corresponding to the classification identifier; the prediction unit 1022 is used to obtain the predicted template identifier of the next log data corresponding to the classification identifier based on the predicted feature data corresponding to the classification identifier and the log prediction model.
[0130] Fig.13 is a schematic diagram of the structure of the early warning device for log abnormality provided by the thirteenth embodiment of the present invention, such as Fig.13As shown, based on the above embodiments, further, the third obtaining unit 1021 includes a first obtaining subunit 10211, a counting subunit 10212 and a serving subunit 10213, wherein:
[0131] The first acquisition subunit 10211 is used to obtain the log template vector corresponding to each template identifier according to each template identifier and the template vector library included in the template sequence; wherein the template vector library is pre-established and includes log template vectors corresponding one to one to the template identifiers; the statistical subunit 10212 is used to count the number of identical template identifiers included in the template sequence as the frequency corresponding to the identical template; the subunit 10213 is used to use the log template vectors and the corresponding frequencies corresponding to each template identifier in the template sequence as the predicted feature data corresponding to the classification identifier.
[0132] Fig.14 is a schematic diagram of the structure of the early warning device for log abnormality provided by the fourteenth embodiment of the present invention, such as Fig.14 As shown, on the basis of the above embodiments, further, the early warning device for log anomaly provided by the embodiment of the present invention further includes a word vector acquisition module 1050, a calculation module 1060 and a storage module 1070, wherein:
[0133] The word vector acquisition module 1050 is used to obtain the word vector corresponding to each word in the log template according to the log template and the word vector library; wherein the log template and the template identifier correspond one to one; the calculation module 1060 is used to calculate the average value of the word vectors corresponding to each word included in the log template as the corresponding log template vector; the storage module 1070 is used to store the log template vector corresponding to the log template in correspondence with the corresponding template identifier.
[0134] Fig.15 is a schematic diagram of the structure of the log abnormality early warning device provided by the fifteenth embodiment of the present invention, such as Fig.15 As shown, based on the above embodiments, further, the statistical module 1030 includes a fourth obtaining unit 1031 and a recording unit 1032, wherein:
[0135] The fourth obtaining unit 1031 is used to perform template matching on the next log data corresponding to the classification identifier to obtain the actual template identifier of the next log data corresponding to the classification identifier; the recording unit 1032 is used to record the failure of prediction of the next log data corresponding to the classification identifier after determining that the predicted template identifier of the next log data corresponding to the classification identifier does not include the actual template identifier of the next log data corresponding to the classification identifier.
[0136] Fig.16is a schematic diagram of the structure of the early warning device for log abnormality provided by the sixteenth embodiment of the present invention, such as Fig.16 As shown, on the basis of the above embodiments, further, the early warning device for log anomalies provided by the embodiment of the present invention further includes a classification and serialization module 1080, a sampling module 1090, a feature processing module 1100 and a training module 1110, wherein:
[0137] The classification and serialization module 1080 is used to classify and serialize the historical log data to obtain multiple fixed template sequences; wherein each fixed template sequence corresponds to a classification identifier; the sampling module 1090 is used to perform sliding sampling on each fixed template sequence to obtain training data, and obtain the template identifier corresponding to the next log data corresponding to each sample sequence as the label corresponding to each sample sequence; wherein the training data includes multiple sample sequences, each sample sequence has a fixed length and each sample sequence corresponds to a classification identifier; the feature processing module 1100 is used to perform feature processing on each sample sequence in the training data to obtain training feature data; wherein the training sample data included in the training feature data corresponds one-to-one to the sample sequence; the training module 1110 is used to train and obtain a log prediction model based on the original combination model, the training sample data included in the training feature data, and the corresponding labels.
[0138] Fig.17 is a schematic diagram of the structure of the early warning device for log abnormality provided by the seventeenth embodiment of the present invention, such as Fig.17 As shown, based on the above embodiments, further, the classification and serialization module 1080 includes a fifth obtaining unit 1081, a second classification unit 1082 and a sixth obtaining unit 1083, wherein:
[0139] The fifth acquisition unit 1081 is used to obtain each historical log data one by one, and perform template matching on each historical log data to obtain the template identifier corresponding to each historical log data; the second classification unit 1082 is used to classify each historical log data according to the classification identifier, and obtain the classification identifier corresponding to each historical log data; the sixth acquisition unit 1083 is used to obtain multiple fixed template sequences according to the classification identifier corresponding to each historical log data, the template identifier corresponding to each historical log data and the timestamp corresponding to each historical log data.
[0140] Fig.18 is a schematic diagram of the structure of the early warning device for log abnormality provided by the eighteenth embodiment of the present invention, such as Fig.18 As shown, on the basis of the above embodiments, the feature processing module 1100 further includes a seventh obtaining unit 1101, a statistical unit 1102 and an as unit 1103, wherein:
[0141] The seventh obtaining unit 1101 is used to obtain the log template vector corresponding to each template identifier included in the sample sequence; wherein the log template vector corresponding to each template identifier is pre-generated; the statistical unit 1102 is used to count the number of identical template identifiers included in the sample sequence as the frequency corresponding to the identical template identifier; the as unit 1103 is used to use the log template vector corresponding to each template identifier in the sample sequence and the frequency corresponding to each template identifier as the training sample data corresponding to the sample sequence.
[0142] The embodiments of the apparatus provided in the embodiments of the present invention can be specifically used to execute the processing flow of the above-mentioned method embodiments, and its functions are not described in detail here, and reference can be made to the detailed description of the above-mentioned method embodiments.
[0143] Fig.19 is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Fig.19 As shown, the electronic device may include: a processor (processor) 1901, a communication interface (Communications Interface) 1902, a memory (memory) 1903 and a communication bus 1904, wherein the processor 1901, the communication interface 1902, and the memory 1903 communicate with each other through the communication bus 1904. Processor 1901 can call the logic instructions in memory 1903 to execute the following method: classify and serialize each log data in turn to obtain the template sequence corresponding to each classification identifier; wherein each log data corresponds to a classification identifier; count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to a preset number; wherein the log prediction model is pre-trained based on historical log data; based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to a preset number, count the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to a preset number within a preset time period; if it is determined that the predicted failure amount is greater than the set threshold, a log abnormality warning is issued.
[0144] In addition, the logic instructions in the above-mentioned memory 1903 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, 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, and 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 method 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 and other media that can store program codes.
[0145] The present embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: classifying and serializing each log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each log data corresponds to a classification identifier; counting the number of template identifiers included in the template sequence corresponding to each classification identifier, and predicting the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on a log prediction model to obtain a predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is pre-trained based on historical log data; according to the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, counting the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within a preset time period; if it is determined that the predicted failure amount is greater than a set threshold, a log abnormality warning is issued.
[0146] The present embodiment provides a computer-readable storage medium, which stores a computer program, and the computer program enables the computer to execute the methods provided by the above-mentioned method embodiments, for example, including: classifying and serializing each log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each log data corresponds to a classification identifier; counting the number of template identifiers included in the template sequence corresponding to each classification identifier, and predicting the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on a log prediction model, to obtain a predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is pre-trained based on historical log data; based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, counting the predicted failure amount corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within a preset time period; if it is determined that the predicted failure amount is greater than a set threshold, a log abnormality warning is issued.
[0147] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0148] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0149] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0151] In the description of this specification, the description with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0152] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A log abnormality early warning method, characterized in that: include: Classify and serialize each piece of log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each piece of log data corresponds to a classification identifier; Counting the number of template identifiers included in the template sequence corresponding to each classification identifier, and predicting the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is obtained by pre-training based on historical log data; According to the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number, counting the number of prediction failures corresponding to the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number within the preset time period; If it is determined that the prediction failure amount is greater than a set threshold, a log abnormality warning is issued; The step of predicting the template sequence corresponding to the classification identifiers whose number of template identifiers is equal to the preset number based on the log prediction model to obtain the predicted template identifier of the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number includes: Performing feature processing on a template sequence corresponding to a classification identifier whose number of template identifiers is equal to a preset number, to obtain prediction feature data corresponding to the classification identifier; Obtaining a prediction template identifier for the next log data corresponding to the classification identifier according to the prediction feature data corresponding to the classification identifier and the log prediction model; The performing feature processing on the template sequence corresponding to the classification identifiers whose number of template identifiers is equal to the preset number to obtain the prediction feature data corresponding to the classification identifiers includes: According to each template identifier and the template vector library included in the template sequence, a log template vector corresponding to each template identifier is obtained; wherein the template vector library is pre-established and includes log template vectors corresponding to the template identifiers one by one; Counting the number of identical template identifiers included in the template sequence as the frequency corresponding to the identical template identifier; Using the log template vector and the corresponding frequency corresponding to each template identifier in the template sequence as the prediction feature data corresponding to the classification identifier; The steps of establishing a template vector library include: According to the log template and the word vector library, a word vector corresponding to each word in the log template is obtained; wherein the log template and the template identifier correspond one to one; Calculate the average value of the word vectors corresponding to each word included in the log template as the corresponding log template vector; The log template vector corresponding to the log template and the corresponding template identifier are stored in correspondence.
2. The method according to claim 1, characterized in that The step of classifying and serializing each piece of log data in turn to obtain a template sequence corresponding to each classification identifier includes: Perform template matching on each piece of log data to obtain the template identifier corresponding to each piece of log data; Classify each piece of log data according to the classification identifier, and obtain the classification identifier corresponding to each piece of log data; According to the classification identifier corresponding to each piece of log data, the template identifier corresponding to each piece of log data, and the timestamp corresponding to each piece of log data, a template sequence corresponding to each classification identifier is obtained.
3. The method according to claim 1, characterized in that The step of counting the prediction failure amount corresponding to the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number within the preset time period based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number comprises: Performing template matching on the next log data corresponding to the classification identifier to obtain an actual template identifier of the next log data corresponding to the classification identifier; If it is determined that the predicted template identifier of the next log data corresponding to the classification identifier does not include the actual template identifier of the next log data corresponding to the classification identifier, it is recorded that the prediction of the next log data corresponding to the classification identifier fails.
4. The method according to claim 1, characterized in that: The step of obtaining a log prediction model based on historical log data training includes: Classifying and serializing the historical log data to obtain a plurality of fixed template sequences, wherein each fixed template sequence corresponds to a classification identifier; Perform sliding sampling on each fixed template sequence to obtain training data, and obtain the template identifier corresponding to the next log data corresponding to each sample sequence as the label corresponding to each sample sequence; wherein the training data includes multiple sample sequences, each sample sequence has a fixed length and each sample sequence corresponds to a classification identifier; Performing feature processing on each sample sequence in the training data to obtain training feature data; wherein the training sample data included in the training feature data corresponds one-to-one to the sample sequence; A log prediction model is obtained through training according to the original combination model, the training sample data included in the training feature data, and the corresponding labels.
5. The method according to claim 4, characterized in that The classifying and serializing the historical log data to obtain a plurality of fixed template sequences comprises: Obtain each piece of historical log data one by one, and perform template matching on each piece of historical log data to obtain the template identifier corresponding to each piece of historical log data; Classify each piece of historical log data according to the classification identifier, and obtain the classification identifier corresponding to each piece of historical log data; A plurality of fixed template sequences are obtained according to the classification identifier corresponding to each piece of historical log data, the template identifier corresponding to each piece of historical log data, and the timestamp corresponding to each piece of historical log data.
6. The method according to claim 4, characterized in that The performing feature processing on each sample sequence in the training data to obtain training feature data comprises: According to each template identifier included in the sample sequence, a log template vector corresponding to each template identifier is obtained; wherein the log template vector corresponding to each template identifier is generated in advance; Counting the number of identical template identifiers included in the sample sequence as the frequency corresponding to the identical template identifier; The log template vector corresponding to each template identifier in the sample sequence and the frequency corresponding to each template identifier are used as training sample data corresponding to the sample sequence.
7. The method according to any one of claims 1 to 6, characterized in that: The classification identifier is a process number or a thread number.
8. A log abnormality early warning device, characterized in that: include: The acquisition module is used to classify and serialize each log data in turn to obtain a template sequence corresponding to each classification identifier; wherein each log data corresponds to a classification identifier; A prediction module, used to count the number of template identifiers included in the template sequence corresponding to each classification identifier, and predict the template sequence corresponding to the classification identifier whose number of template identifiers is equal to a preset number based on the log prediction model, to obtain the predicted template identifier of the next log data corresponding to the classification identifier whose number of template identifiers is equal to the preset number; wherein the log prediction model is obtained by pre-training based on historical log data; A statistics module, for counting the number of prediction failures corresponding to the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number within a preset time period, based on the predicted template identifier and the actual template identifier of the next log data corresponding to the classification identifiers whose number of template identifiers is equal to the preset number; An early warning module is used to issue a log abnormality early warning after determining that the prediction failure amount is greater than a set threshold; A word vector acquisition module, used to obtain the word vector corresponding to each word in the log template according to the log template and the word vector library; wherein the log template and the template identifier correspond one to one; A calculation module, used to calculate the average value of the word vectors corresponding to each word included in the log template as the corresponding log template vector; A storage module, used for storing the log template vector corresponding to the log template and the corresponding template identifier in correspondence; Wherein, the prediction module includes: A third obtaining unit is used to perform feature processing on a template sequence corresponding to a classification identifier whose number of template identifiers is equal to a preset number, to obtain prediction feature data corresponding to the classification identifier; A prediction unit, configured to obtain a prediction template identifier of a next log data corresponding to the classification identifier according to the prediction feature data corresponding to the classification identifier and a log prediction model; Wherein, the third obtaining unit includes: A first obtaining subunit is used to obtain a log template vector corresponding to each template identifier according to each template identifier and a template vector library included in the template sequence; wherein the template vector library is pre-established and includes log template vectors corresponding to the template identifiers one by one; A counting subunit, used for counting the number of identical template identifiers included in the template sequence as a frequency corresponding to the identical template identifier; As a subunit, it is used to use the log template vector and the corresponding frequency corresponding to each template identifier in the template sequence as the prediction feature data corresponding to the classification identifier.
9. The device according to claim 8, characterized in that The acquisition module comprises: A first obtaining unit is used to perform template matching on each piece of log data to obtain a template identifier corresponding to each piece of log data; The first classification unit is used to classify each log data according to the classification identifier to obtain the classification identifier corresponding to each log data; The second obtaining unit is used to obtain the template sequence corresponding to each classification identifier according to the classification identifier corresponding to each log data, the template identifier corresponding to each log data and the timestamp corresponding to each log data.
10. The device according to claim 8, characterized in that The statistics module includes: A fourth obtaining unit, configured to perform template matching on the next log data corresponding to the classification identifier to obtain an actual template identifier of the next log data corresponding to the classification identifier; The recording unit is used to record the failure of prediction of the next log data corresponding to the classification identifier after determining that the prediction template identifier of the next log data corresponding to the classification identifier does not include the actual template identifier of the next log data corresponding to the classification identifier.
11. The device according to claim 8, characterized in that Also includes: A classification and serialization module, used to classify and serialize the historical log data to obtain a plurality of fixed template sequences; wherein each fixed template sequence corresponds to a classification identifier; A sampling module, used to perform sliding sampling on each fixed template sequence to obtain training data, and obtain a template identifier corresponding to the next log data corresponding to each sample sequence as a label corresponding to each sample sequence; wherein the training data includes multiple sample sequences, each sample sequence has a fixed length and each sample sequence corresponds to a classification identifier; A feature processing module, used to perform feature processing on each sample sequence in the training data to obtain training feature data; wherein the training sample data included in the training feature data corresponds one-to-one to the sample sequence; The training module is used to train and obtain a log prediction model according to the original combination model, the training sample data included in the training feature data, and the corresponding labels.
12. The device according to claim 11, characterized in that The classification and serialization module includes: A fifth obtaining unit, used to obtain each piece of historical log data one by one, and perform template matching on each piece of historical log data to obtain a template identifier corresponding to each piece of historical log data; The second classification unit is used to classify each piece of historical log data according to the classification identifier to obtain the classification identifier corresponding to each piece of historical log data; The sixth obtaining unit is used to obtain multiple fixed template sequences according to the classification identifier corresponding to each piece of historical log data, the template identifier corresponding to each piece of historical log data, and the time stamp corresponding to each piece of historical log data.
13. The device according to claim 11, characterized in that The feature processing module comprises: a seventh obtaining unit, configured to obtain, according to each template identifier included in the sample sequence, a log template vector corresponding to each template identifier; wherein the log template vector corresponding to each template identifier is generated in advance; A statistical unit, used for counting the number of identical template identifiers included in the sample sequence as a frequency corresponding to the identical template identifier; As a unit, it is used to use the log template vector corresponding to each template identifier in the sample sequence and the frequency corresponding to each template identifier as the training sample data corresponding to the sample sequence.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
