Robust transferable log anomaly detection method and device, equipment and medium

A robust and transferable log sequence anomaly detection model is constructed through log parsing and cross-attention mechanisms, which solves the problem of unstable performance of log detection methods in the existing technology under incomplete information and distribution migration, and achieves higher robustness. performance and interpretability.

CN118764378AInactive Publication Date: 2024-10-11XI AN JIAOTONG UNIV
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410730881.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-10-11
Estimated Expiration
Not applicable · inactive patent

Smart Images

  • Figure CN118764378A_ABST
    Figure CN118764378A_ABST
Patent Text Reader

Abstract

The invention provides a robust transferable log anomaly detection method and device, equipment and a medium, and relates to the technical field of log detection.The log analysis technology is adopted to analyze multiple pieces of original log data to obtain multiple structured logs, the structured logs are divided to obtain multiple log sequences, and the log sequences are stored in a storage medium; modeling each structured log in each log sequence by adopting a log modeling module, and processing a modeling result by adopting a log sequence modeling module to obtain a sequence representation of each log sequence; summarizing each sequence representation and using the summarized sequence representation to construct a log sequence anomaly detection model; and processing to-be-detected log data according to the step 1 and the step 2 to obtain to-be-detected log sequence representation, and inputting the to-be-detected log sequence representation into the log sequence anomaly detection model to obtain a detection result. According to the log anomaly detection model constructed by the method, each piece of original log data is comprehensively analyzed, the robustness and the mobility are improved, and a more interpretable anomaly detection result is provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of log detection technology, and in particular to a robust and migratable log anomaly detection method, device, equipment and medium. Background Art

[0002] Log messages record the runtime information of devices and systems in the form of unstructured text. Existing log-based anomaly detection methods can be divided into three categories: manual detection methods, traditional machine learning-based methods, and deep learning-based methods. Manual detection methods have been replaced by learning-based methods because they are not suitable for practical applications. Compared with manual detection methods, traditional machine learning-based methods are more effective when processing large-scale data. However, the detection performance of traditional machine learning-based methods is unstable on different data sets.

[0003] In recent years, deep learning models have been widely used in various applications. In the field of log detection, many deep learning-based methods such as DeepLog, LogAnomaly, and LogRobust have emerged to extract more fine-grained representations from log messages to achieve effective anomaly detection. For example, DeepLog uses a long short-term memory (LSTM) model to learn sequence patterns from log sequences. LogAnomaly and LogRobust further include more semantic information, such as synonyms and antonyms, in log sequence modeling.

[0004] Despite the higher detection accuracy, these methods only provide anomaly predictions without interpretable details. Moreover, in real-world deployment applications, existing learning-based methods suffer severely from incomplete information and distribution shift. Summary of the invention

[0005] The present application provides a robust and transferable log anomaly detection method, apparatus, device and medium to solve the problems of incomplete information and distribution migration in existing learning-based log detection methods.

[0006] In a first aspect of an embodiment of the present application, a robust and migratable log anomaly detection method is provided, the method comprising:

[0007] Step 1: using log parsing technology to parse multiple original log data to obtain multiple structured logs, where the multiple original log data are multiple different unstructured logs obtained;

[0008] Step 2: Divide the multiple structured logs into multiple log sequences, use the log modeling module to model each structured log in each log sequence, and use the log sequence modeling module to process the modeling results to obtain a sequence representation of each log sequence, wherein the log sequence contains different numbers of structured logs;

[0009] Step 3: Summarize each of the sequence representations, and use the summarized sequence representations to build a log sequence anomaly detection model, wherein the log sequence anomaly detection model includes a log modeling sub-model and an anomaly detection sub-model;

[0010] Step 4: Process the log data to be detected according to steps 1 and 2 to obtain the log sequence representation to be detected, and input it into the log sequence anomaly detection model to obtain the detection result.

[0011] In an optional embodiment of the present application, in step 2, based on a partitioning strategy, structured logs with the same identifier are partitioned into a log sequence;

[0012] Exponential neurons are used to capture the cross-features of different structured logs in a log sequence, and all cross-features of a log sequence are represented as logs;

[0013] Log cross attention is used to perform feature extraction on the log representation to obtain a sequence representation of the log sequence. In the log cross attention, a key vector K and a value vector V are dynamically generated by the log representation based on the log sequence, and each query vector Q is a learnable global latent vector.

[0014] In an optional embodiment of the present application, the sequence representation of the log sequence is obtained by the following log cross attention mechanism:

[0015]

[0016] in, K=HW K , V = HW V , key vector weight W V Sum value vector weight Q represents the query vector, n p Represents QK T The matrix variance of , T represents the matrix transpose.

[0017] In an optional embodiment of the present application, the exponential neuron is used to capture the cross-features of different structured logs, and all cross-features of the log sequence are represented as logs, which is performed according to the following formula:

[0018]

[0019] Among them, h n is the nth exponential neuron using interaction weight w n Captured feature-specific interaction terms, interaction weights is obtained dynamically through the gated attention mechanism:

[0020]

[0021] Among them, z n represents the features after the gated attention mechanism, v n represents the vector of learnable attention weight values ​​associated with the nth index neuron.

[0022] In an optional embodiment of the present application, in step 3, the log sequence anomaly detection model is optimized using the following loss function:

[0023]

[0024] Among them, y represents the true label of the original log data, θ MLP (·) represents the multilayer perceptron that produces the final anomaly prediction label, is the binary cross entropy loss for training the log sequence anomaly detection model, and H′ represents the final sequence representation.

[0025] In an optional embodiment of the present application, the loss function is minimized by the following constraint function, and the calculation formula of the constraint function is as follows:

[0026]

[0027] Among them, E represents the log training environment e∈{1,2,...,E}, φ represents the log modeling submodel, θ represents the anomaly detection submodel, and λ represents the parameter used to balance the relative strength between the two loss terms. Indicates loss.

[0028] In an optional embodiment of the present application, the log modeling sub-model includes a log modeling module and a log sequence modeling module, and the anomaly detection sub-model includes a prediction module;

[0029] The method further comprises:

[0030] The log parsing technology is used to parse the log data to be detected into structured logs to be detected;

[0031] Based on the division strategy, the structured log to be detected is divided into a sequence of logs to be detected;

[0032] The log modeling module is used to model each structured log to be detected in the log sequence to be detected, and the log sequence modeling module is used to model the log sequence to be detected to obtain a representation of the log sequence to be detected;

[0033] The log sequence representation to be detected is input into the log sequence anomaly detection model to obtain a detection result.

[0034] In a second aspect of an embodiment of the present application, a robust and migratable log anomaly detection device is provided, the device comprising:

[0035] A parsing module, which uses log parsing technology to parse multiple original log data to obtain multiple structured logs, where the multiple original log data are multiple different unstructured logs obtained;

[0036] A log partitioning and modeling module, used to partition a plurality of structured logs into a plurality of log sequences, use a log modeling module to model each structured log in each of the log sequences, and use a log sequence modeling module to process the modeling results to obtain a sequence representation of each of the log sequences, wherein the log sequences contain different numbers of structured logs;

[0037] A construction module, used to summarize each of the sequence representations, and use the summarized sequence representations to build a log sequence anomaly detection model, wherein the log sequence anomaly detection model includes a log modeling sub-model and an anomaly detection sub-model;

[0038] The detection module is used to process the log data to be detected according to the parsing module and the modeling module to obtain the log sequence representation to be detected, and input the log sequence anomaly detection model to obtain the detection result.

[0039] In a third aspect of an embodiment of the present application, an electronic device is proposed, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the robust and migratable log anomaly detection method described in any one of the first aspects above.

[0040] In a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the robust and migratable log anomaly detection method described in any one of the first aspects above is implemented.

[0041] The present application includes the following advantages: The present application provides a robust and portable log anomaly detection method, device, equipment and medium, which uses log parsing technology to parse multiple original log data to obtain multiple structured logs, and the multiple original log data are multiple different unstructured logs obtained; the multiple structured logs are divided into multiple log sequences, and the log modeling module is used to model each structured log in each log sequence, and the log sequence modeling module is used to process the modeling results to obtain a sequence representation of each log sequence, and the log sequence contains different numbers of structured logs; each of the sequence representations is summarized, and the summarized sequence representation is used to construct a log sequence anomaly detection model, and the log sequence anomaly detection model includes a log modeling sub-model and anomaly detection sub-model; the log data to be detected is processed according to step 1 and step 2 to obtain the log sequence representation to be detected, and input into the log sequence anomaly detection model to obtain the detection result. The method constructs a robust and portable log sequence anomaly detection model, explicitly solves the problems of robustness and data migration, comprehensively analyzes each original log data, improves robustness and portability, and further provides more explainable anomaly detection results. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 It is a flowchart of the steps of a robust and migratable log anomaly detection method provided by an embodiment of the present application;

[0044] Figure 2 It is a flowchart of a robust and migratable log anomaly detection method provided by an embodiment of the present application;

[0045] Figure 3 This is a log data analysis diagram provided by an embodiment of the present application;

[0046] Figure 4 It is a flow chart of log sequence division and modeling provided by an embodiment of the present application;

[0047] Figure 5 This is a schematic diagram of a process of log sequence anomaly detection provided by an embodiment of the present application;

[0048] Figure 6 It is an architecture diagram of a robust and migratable log anomaly detection device provided in an embodiment of the present application;

[0049] Figure 7 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0051] Log messages record the runtime information of devices and systems in the form of unstructured text. Existing log-based anomaly detection methods can be divided into three categories: manual detection methods, traditional methods based on machine learning, and methods based on deep learning. Manual detection methods match keywords (such as "fail" and "down") based on rules predefined by experts. They may produce false positives and false negatives. In addition, manual detection methods are labor-intensive, and their feasibility becomes impractical as the data scale of log messages increases. Therefore, manual detection methods have gradually been replaced by learning-based methods.

[0052] Traditional machine learning-based methods, such as principal component analysis (PCA), logistic regression (LR), invariant mining, and log clustering, use manual statistical features to automatically capture the relationship between log messages and find abnormal log messages whose features deviate from normal log messages in high-dimensional space. Compared with manual detection methods, these methods are more effective when processing large-scale data. However, the detection performance of traditional machine learning-based methods is unstable on different datasets. In recent years, deep learning models have been widely used in various applications. In the field of log detection, many deep learning-based methods, such as DeepLog, LogAnomaly, and LogRobust, have emerged to extract more fine-grained representations from log messages to achieve effective anomaly detection. For example, DeepLog uses a long short-term memory (LSTM) model to learn sequence patterns from log sequences. LogAnomaly and LogRobust further include more semantic information, such as synonyms and antonyms, in log sequence modeling. Despite higher detection accuracy, these methods only provide anomaly predictions without interpretable details. Moreover, in real-world deployment applications, existing learning-based methods suffer severely from incomplete information and distribution shift.

[0053] Based on this, this application proposes a robust and portable log anomaly detection method to solve the problem that existing log detection methods are affected by incomplete information and distribution migration. Figure 1 , Figure 1 A robust and portable log anomaly detection method is provided in an embodiment of the present application, and the method comprises the following steps:

[0054] Step 1: using log parsing technology to parse multiple original log data to obtain multiple structured logs, where the multiple original log data are multiple different unstructured logs obtained;

[0055] Step 2: Divide the multiple structured logs into multiple log sequences, use the log modeling module to model each structured log in each log sequence, and use the log sequence modeling module to process the modeling results to obtain a sequence representation of each log sequence, wherein the log sequence contains different numbers of structured logs;

[0056] Step 3: Summarize each of the sequence representations, and use the summarized sequence representations to build a log sequence anomaly detection model, wherein the log sequence anomaly detection model includes a log modeling sub-model and an anomaly detection sub-model;

[0057] Step 4: Process the log data to be detected according to steps 1 and 2 to obtain the log sequence representation to be detected, and input it into the log sequence anomaly detection model to obtain the detection result.

[0058] In order to further explain the robust and portable log anomaly detection method proposed in this application, Figure 2 To explain it, Figure 2 This is a flowchart of a robust and portable log anomaly detection method provided by an embodiment of the present application, which is as follows:

[0059] When implementing step 1, log parsing technology is used to parse the log data. The purpose of log parsing is to convert the original unstructured log message into a structured log. When parsing the log data, log sequence parsing technology is used to parse the collected original log data into two parts: message header and log event. The message header consists of a fixed number of fields, including time, date, pid, level, and parameters of related components. After parsing, structured log data is obtained.

[0060] Specifically, see Figure 3 , Figure 3A log data parsing diagram provided for an embodiment of the present application, the content of the message header mainly depends on the log framework and can be extracted using standard parsing techniques. In contrast, the format of log events varies from log system to log system, which reflects the inherent behavior of the system. Typically, a log event is derived from a constant log event template and multiple variable parameters. The parameters in the log event are replaced with "<*>" in the log event template. When performing anomaly detection on the log, the parameters usually do not contain much useful information. The main focus is on the events corresponding to the log template. Therefore, the parameters need to be removed to extract the corresponding log event template. The example is as follows: 081109 203518 35INFOdfs.FSNamesystem:BLOCK*NameSystem.allocate Block: / mnt / hadoop / mapred / system / job_200811092030_0001 / job.jar.blk_1608999687919862906 081109 203519 143INFOdfs.DataNode$DataXceiver:Receiving block blk_1608999687919862906src: / 10.250.10.6:40524dest: / 10.250.10.6:50010;Template:Receiving block blk_<*>src:<*>dest:<*>

[0061] Specifically, in step 2, after parsing the raw log data, the structured logs are divided into log sequences for anomaly detection, because detecting anomalies on log sequences is more effective than using a single log for anomaly detection. After log segmentation, a machine learning or deep learning model is used to convert each log sequence into a digital feature vector for subsequent anomaly detection.

[0062] In an optional embodiment of the present application, based on the partitioning strategy, structured logs with the same identifier are divided into a log sequence; see Figure 4 , Figure 4A flow chart of log sequence partitioning and modeling provided for an embodiment of the present application, wherein the partitioning strategies include: partitioning based on a fixed window, partitioning based on a sliding window, and partitioning based on a session window. Among them, the partitioning strategy based on a fixed window and the partitioning strategy based on a sliding window are performed using the timestamp or time field of each structured log; and the partitioning strategy based on a session window is based on the identifier field of each structured log, which refers to the ID of the generated structured log. Specifically, the partitioning based on a fixed window uses a predefined window size to divide all logs into log sequences in chronological order. Each sequence includes a fixed number of structured logs, and there is no overlap in consecutive sequences. For the partitioning strategy based on a sliding window, in addition to the predefined window size, the strategy also introduces a step size to set the time forwarding distance. In contrast, the partitioning strategy based on a session window divides structured logs with the same identifier into a log sequence, and its log sequence contains different numbers of structured logs.

[0063] In an optional embodiment of the present application, after the structured log is divided to obtain a log sequence, the log sequence is modeled. Figure 4 , Figure 4 A flow chart of log sequence partitioning and modeling provided in an embodiment of the present application, wherein the modeling process includes: using exponential neurons to capture cross-features of different structured logs in a log sequence, and taking all cross-features of a log sequence as log representation; using log cross-attention to perform feature extraction on the above log representation to obtain a sequence representation of the log sequence, wherein in the above log cross-attention, the key vector K and the value vector V are dynamically generated by the log representation based on the log sequence, and each query vector Q is a learnable global potential vector.

[0064] Specifically, in anomaly detection, feature interactions between fields of each structured log can capture useful information. For example, certain types of log events tend to occur at peak times, and certain components with specific pids may generate more warning levels than other components. These feature interactions between log fields, namely (log event, time) and (component, pid, and level), are key indicators of the existence of anomalies and should therefore be utilized in modeling. In order to model feature interactions of arbitrary order (arbitrary order here refers to different fields), the applicant modeled the ARM module based on adaptive relational modeling technology. The ARM module uses exponential neurons to dynamically capture cross-features, namely feature interactions, conditioned on the current log, and selectively captures non-information log features filtered using a gated attention mechanism, that is, features based on time, date, etc. that are not log events. The gated attention mechanism can be used for effective feature screening. That is, when given a feature vector x = [x1, x2, ..., x M] log x, first transform each categorical feature value x m By e m =E m [:,x m ] is converted into an embedding vector As for each numerical eigenvalue x m Use To convert, where n p is the size of feature embedding, E m is the corresponding category embedding lookup matrix, and is the numerical embedding vector. Next, we use N o Index neurons and do it by:

[0065]

[0066] Among them, h n is the nth exponential neuron using interaction weight w n The specific feature interactions captured, is obtained dynamically through the gated attention mechanism:

[0067]

[0068] in, z n represents the features after the gated attention mechanism, v n represents the vector of learnable attention weight values ​​associated with the nth index neuron, in is the bilinear attention function φ att (·) the weight matrix shared among the exponential neurons, is the learnable query vector associated with the nth index neuron for comparing with the input feature e m The bilinear attention alignment of Used to dynamically capture the relative importance of the m-th field to the n-th neuron.

[0069] In particular, Where Δ M is an M-dimensional probability simple form, is the Tsallis α-entropy:

[0070] When α≠1, When α = 1, unlike the softmax function which always generates dense output, here The argmax solution p of generates sparse output. Therefore, Less important features in the M log fields can be filtered out. In addition, similar to q n, v n is a vector of learnable attention weight values ​​associated with the nth index neuron, which encodes the global attention weights for each of the corresponding M fields. By design, the feature interaction term h n The dynamic and selective attention weights w n This should result in more efficient and interpretable log modeling. These feature interaction terms are then summed up by Each structured log x is characterized by summing up to get the final log representation

[0071] Furthermore, the log sequence X = [x1, x2, x3, ..., x T ] is converted to a log representation H = [h1, h2, h3, ..., h T ], log cross attention is used to extract the sequence representation of the log sequence This representation is obtained through the following attention mechanism:

[0072]

[0073] in, K=HW K , V = HW V ,as well as are the weights of the attention key and value vector, Q represents the query vector, and n p Represents QK T , T represents the matrix transpose. Unlike the existing scaled dot product attention, in log cross attention, the key vector and value vector K, V come directly from the log representation H in the traditional attention mechanism, which is dynamically generated based on the current log sequence, while each query vector is a learnable global latent vector, which extracts the basic log sequence representation in the corresponding latent space for subsequent anomaly detection. Log cross attention is more effective than the widely adopted LSTM in modeling log sequences. In addition, log cross attention improves efficiency over the mainstream sequence learning model Transformer. Because the computational complexity of cross attention is linear with the sequence length, rather than quadratic, i.e. O(N q T), not O(T 2 ), and thus can be better extended to longer logarithmic sequence detection.

[0074] When implementing step 3, each sequence representation obtained after processing in step 1 and step 2 is summarized, and the summarized sequence representation is used for the log sequence anomaly detection model. The log sequence representation after step 1 and step 2 is extracted as By summing Summarize to get the final sequence representation For anomaly detection: The log sequence anomaly detection model is optimized using the following loss function: Among them, y represents the true label of the original log data, Indicates the final sequence representation using the prediction module The prediction result obtained by prediction, θ MLP (·) represents the multilayer perceptron that produces the final anomaly prediction label, is the binary cross entropy loss for training the log sequence anomaly detection model, and H′ represents the final sequence representation. In the above manner, the entire log sequence anomaly detection model including the above three modules (log modeling module, log sequence modeling module, anomaly detection module) can be end-to-end optimized using a standard gradient-based optimizer (such as SGD or Adam).

[0075] In an optional embodiment of the present application, in order to obtain a more robust and transferable anomaly detection model in different operating environments, by retaining the log environment information and introducing a general regularization technique to extract the environment-invariant representation, this can be well generalized to unseen environments. Specifically, the environment generalization can be expressed as follows: Given E log training environments e∈{1,2,...,E}, then the constraint objective is:

[0076]

[0077] This constraint objective requires that the learning model f(·) should perform well in the unseen new environment E+1. This approach is a new learning paradigm called domain generalization. In order to make the learned log sequence representation more environment-invariant in different operating environments, the EG regularization based on invariant risk minimization is introduced into log-based anomaly detection. Since the log sequence anomaly detection model includes a log modeling sub-model and anomaly detection sub-model, it is expressed as Where φ:X→h is the log modeling sub-model, including the log modeling module and the log sequence modeling module, and θ:h→y is the prediction module. Formally, EG regularization aims to achieve the following constraint objectives:

[0078]

[0079] The constraint condition it represents is that, given a log sequence feature extractor φ, the prediction module θ should be optimal for each observable environment. To achieve this, φ needs to extract only features that are invariant to the environment, otherwise the prediction module θ cannot be optimal in different environments. This is a challenging two-level optimization problem that can be solved by Lagrangian relaxation. Based on this, this application proposes a constraint function that minimizes the loss function. The calculation formula of the constraint function is as follows:

[0080]

[0081] Among them, E represents the log training environment e∈{1,2,...,E}, φ represents the log modeling submodel, θ represents the anomaly detection submodel, and λ represents the parameter used to balance the relative strength between the two loss terms. Represents the loss. The second term in the above constraint function is the loss The gradient norm is regularized, that is, the extracted log sequence representation is used for abnormal prediction. Such a gradient norm loss meets the first-order optimality condition, that is, the gradient is required to be zero at the minimum, and λ is used to balance the relative strength between the two loss terms.

[0082] When implementing step 4, since the Drain parser achieves higher parsing accuracy and higher efficiency compared with other log parsing technologies, the Drain parser is preferably used to parse the original log data in the embodiment of the present application. The log sequence anomaly detection model constructed in step 3 includes a log modeling sub-model and an anomaly detection sub-model, the log modeling sub-model includes a log modeling module and a log sequence modeling module, and the anomaly detection sub-model includes a prediction module.

[0083] Specifically, in step 4, the log sequence anomaly detection model is used to detect the log sequence representation to be detected obtained by processing step 1 and step 2, including: using the above-mentioned log parsing technology to parse the log data to be detected into the structured log to be detected; based on the division strategy, the above-mentioned structured log to be detected is divided into the log sequence to be detected; using the above-mentioned log modeling module to model each structured log to be detected in the above-mentioned log sequence to be detected, and using the above-mentioned log sequence modeling module to model the log sequence to be detected to obtain the log sequence representation to be detected; inputting the above-mentioned log sequence representation to be detected into the log sequence anomaly detection model to obtain the detection result. The detection result is the probability corresponding to the log data to be detected, which is judged based on the preset threshold. When the probability corresponding to the log data to be detected is greater than the preset threshold, it is considered that the log data to be detected is abnormal. In general, the preset threshold is set to 0.6. Further, after the prediction is completed, the four indicators of Recall, Precision, F1-Score, and Accuracy can be used to evaluate the performance of the detection method proposed in this application.

[0084] In an optional embodiment of the present application, see Figure 5 , Figure 5 A process diagram of log sequence anomaly detection provided in an embodiment of the present application is provided. Specifically, the obtained unstructured log data to be detected is parsed into a structured log by a Drain parser, and then divided into a log sequence. The ARM module based on the adaptive key module technology and the cross attention mechanism are continuously processed to obtain a log representation of the log sequence. The log representation of the log sequence is input into a multi-layer perceptron to obtain the abnormal probability of the log representation of the log representation. When the abnormal probability is greater than a threshold, it indicates that the log data to be detected is abnormal. When the abnormal probability is less than the threshold, it indicates that the log data to be detected is abnormal.

[0085] The embodiment of the present application provides a robust and portable log anomaly detection method, which uses log parsing technology to parse multiple original log data to obtain multiple structured logs, wherein the multiple original log data are multiple different unstructured logs obtained; the multiple structured logs are divided into multiple log sequences, and each structured log in each log sequence is modeled by a log modeling module, and the modeling results are processed by a log sequence modeling module to obtain a sequence representation of each log sequence, wherein the log sequence contains different numbers of structured logs; each sequence representation is summarized, and a log sequence anomaly detection model is constructed using the summarized sequence representation, wherein the log sequence anomaly detection model includes a log modeling sub-model and anomaly detection sub-model; the log data to be detected is processed according to step 1 and step 2 to obtain a log sequence representation to be detected, and the log sequence anomaly detection model is input to obtain a detection result. The method constructs a robust and portable log sequence anomaly detection model, explicitly solves the problems of robustness and data migration, comprehensively analyzes each original log data, improves robustness and portability, and further provides a more interpretable anomaly detection result.

[0086] In a second aspect of the embodiment of the present application, a robust and portable log anomaly detection device is provided. Figure 6 , Figure 6 An architectural diagram of a robust and migratable log anomaly detection device provided in an embodiment of the present application, the device comprising:

[0087] The parsing module 601 parses a plurality of original log data using log parsing technology to obtain a plurality of structured logs, wherein the plurality of original log data are a plurality of different unstructured logs obtained;

[0088] The log partitioning and modeling module 602 is used to partition the plurality of structured logs into a plurality of log sequences, use the log modeling module to model each structured log in each of the log sequences, and use the log sequence modeling module to process the modeling results to obtain a sequence representation of each of the log sequences, wherein the log sequences contain different numbers of structured logs;

[0089] A construction module 603 is used to summarize each of the sequence representations and use the summarized sequence representations to construct a log sequence anomaly detection model, wherein the log sequence anomaly detection model includes a log modeling sub-model and an anomaly detection sub-model;

[0090] The detection module 604 is used to process the log data to be detected according to the parsing module and the modeling module to obtain the log sequence representation to be detected, and input it into the log sequence anomaly detection model to obtain the detection result.

[0091] Wherein, the log partitioning and modeling module includes:

[0092] A partitioning submodule is used to partition structured logs with the same identifier into a log sequence based on a partitioning strategy;

[0093] A feature capture submodule is used to capture the cross-features of different structured logs in a log sequence using exponential neurons, and all cross-features of a log sequence are represented as logs;

[0094] A feature extraction submodule is used to extract features from the log representation using log cross attention to obtain a sequence representation of the log sequence, wherein a key vector K and a value vector V are dynamically generated by the log representation based on the log sequence, and each query vector Q is a learnable global potential vector.

[0095] The sequence representation of the log sequence in the log partitioning and modeling module is obtained through the following log cross attention mechanism:

[0096]

[0097] in, K=HW K , V = HW V , key vector weight W V Sum value vector weight

[0098] The feature capture submodule is performed according to the following formula:

[0099]

[0100] Among them, h n is the nth exponential neuron using interaction weight w n Captured feature-specific interaction terms, interaction weights is obtained dynamically through the gated attention mechanism:

[0101]

[0102] Among them, z n represents the features after the gated attention mechanism, v n represents the vector of learnable attention weight values ​​associated with the nth index neuron.

[0103] The construction module includes an optimization submodule, and the optimization submodule is used to optimize the log sequence anomaly detection model using the following loss function:

[0104]

[0105] in, θ MLP (·) represents the multilayer perceptron that produces the final anomaly prediction label, is the binary cross entropy loss for training the log sequence anomaly detection model, and H′ represents the final sequence representation.

[0106] The construction module further includes a constraint submodule, which is used to minimize the loss function through the following constraint function. The calculation formula of the constraint function is as follows:

[0107]

[0108] Among them, E represents the log training environment e∈{1,2,...,E}, φ represents the log modeling submodel, θ represents the anomaly detection submodel, and λ represents the parameter used to balance the relative strength between the two loss terms. Indicates loss.

[0109] The log modeling sub-model in the construction module includes a log modeling module and a log sequence modeling module, the anomaly detection sub-model includes a prediction module; and the detection module includes:

[0110] A parsing submodule, used to parse the log data to be detected into a structured log to be detected by using the log parsing technology;

[0111] A division submodule, used for dividing the structured log to be detected into a log sequence to be detected based on a division strategy;

[0112] A modeling submodule, configured to use the log modeling module to model each structured log to be detected in the log sequence to be detected, and use the log sequence modeling module to model the log sequence to be detected to obtain a representation of the log sequence to be detected;

[0113] The detection submodule is used to input the log sequence representation to be detected into the log sequence anomaly detection model to obtain a detection result.

[0114] Based on the same application concept, the embodiment of the present application discloses an electronic device in a third aspect. Figure 7 A schematic diagram of an electronic device disclosed in an embodiment of the present application is shown. Figure 7As shown, the electronic device 100 includes: a memory 110 and a processor 120, the memory of the electronic device is not less than 12G, the main frequency of the processor is not less than 2.4GHz, the memory 110 and the processor 120 are connected through a bus communication, and a computer program is stored in the memory 110. The computer program can be run on the processor 120 to implement a robust and migratable log anomaly detection method disclosed in an embodiment of the present application.

[0115] Based on the same application concept, the embodiment of the present application discloses in a fourth aspect a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, a robust and migratable log anomaly detection method disclosed in the embodiment of the present application is implemented.

[0116] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0117] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the 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 terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal 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.

[0118] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1The steps for the functions specified in one or more boxes.

[0120] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0121] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0122] The above is a detailed introduction to a robust and portable log anomaly detection method, device, equipment and medium provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A robust and portable log anomaly detection method, characterized in that: The method comprises: Step 1: using log parsing technology to parse multiple original log data to obtain multiple structured logs, where the multiple original log data are multiple different unstructured logs obtained; Step 2: Divide the multiple structured logs into multiple log sequences, use the log modeling module to model each structured log in each log sequence, and use the log sequence modeling module to process the modeling results to obtain a sequence representation of each log sequence, wherein the log sequence contains different numbers of structured logs; Step 3: Summarize each of the sequence representations, and use the summarized sequence representations to build a log sequence anomaly detection model, wherein the log sequence anomaly detection model includes a log modeling sub-model and an anomaly detection sub-model; Step 4: Process the log data to be detected according to steps 1 and 2 to obtain the log sequence representation to be detected, and input it into the log sequence anomaly detection model to obtain the detection result.

2. The robust and portable log anomaly detection method according to claim 1, characterized in that: In the step 2, based on the partitioning strategy, the structured logs with the same identifier are partitioned into a log sequence; Exponential neurons are used to capture the cross-features of different structured logs in a log sequence, and all cross-features of a log sequence are represented as logs; Log cross attention is used to perform feature extraction on the log representation to obtain a sequence representation of the log sequence. In the log cross attention, a key vector K and a value vector V are dynamically generated by the log representation based on the log sequence, and each query vector Q is a learnable global latent vector.

3. The robust and portable log anomaly detection method according to claim 2, characterized in that: The sequence representation of the log sequence is obtained through the following log cross attention mechanism: in, K=HW K , V = HW V , key vector weight W V Sum value vector weight Q represents the query vector, n p Represents QK T The matrix variance of , T represents the matrix transpose.

4. The robust and portable log anomaly detection method according to claim 2, characterized in that: The exponential neurons are used to capture the cross features of different structured logs, and all cross features of the log sequence are represented as logs, according to the following formula: Among them, h n is the nth exponential neuron using interaction weight w n Captured feature-specific interaction terms, interaction weights is obtained dynamically through the gated attention mechanism: Among them, z n represents the features after the gated attention mechanism, v n represents the vector of learnable attention weight values ​​associated with the nth index neuron.

5. The robust and portable log anomaly detection method according to claim 1, characterized in that: In step 3, the log sequence anomaly detection model is optimized using the following loss function: Among them, y represents the true label of the original log data, θ MLP (·) represents the multilayer perceptron that produces the final anomaly prediction label, is the binary cross entropy loss for training the log sequence anomaly detection model, and H′ represents the final sequence representation.

6. The robust and portable log anomaly detection method according to claim 5, characterized in that: The loss function is minimized by the following constraint function, and the calculation formula of the constraint function is as follows: Among them, E represents the log training environment e∈{1, 2, ..., E}, φ represents the log modeling submodel, θ represents the anomaly detection submodel, and λ represents the parameter used to balance the relative strength between the two loss terms. Indicates loss.

7. The robust and portable log anomaly detection method according to claim 1, characterized in that: The log modeling sub-model includes a log modeling module and a log sequence modeling module, and the anomaly detection sub-model includes a prediction module; The method further comprises: The log parsing technology is used to parse the log data to be detected into structured logs to be detected; Based on the division strategy, the structured log to be detected is divided into a sequence of logs to be detected; The log modeling module is used to model each structured log to be detected in the log sequence to be detected, and the log sequence modeling module is used to model the log sequence to be detected to obtain a representation of the log sequence to be detected; The log sequence representation to be detected is input into the log sequence anomaly detection model to obtain a detection result.

8. A robust and portable log anomaly detection device, characterized in that: The device comprises: A parsing module, which uses log parsing technology to parse multiple original log data to obtain multiple structured logs, where the multiple original log data are multiple different unstructured logs obtained; A log partitioning and modeling module, used to partition a plurality of structured logs into a plurality of log sequences, use a log modeling module to model each structured log in each of the log sequences, and use a log sequence modeling module to process the modeling results to obtain a sequence representation of each of the log sequences, wherein the log sequences contain different numbers of structured logs; A construction module, used to summarize each of the sequence representations, and use the summarized sequence representations to build a log sequence anomaly detection model, wherein the log sequence anomaly detection model includes a log modeling sub-model and an anomaly detection sub-model; The detection module is used to process the log data to be detected according to the parsing module and the modeling module to obtain the log sequence representation to be detected, and input the log sequence anomaly detection model to obtain the detection result.

9. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the robust and migratable log anomaly detection method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program / instruction is stored thereon, and when the computer program / instruction is executed by a processor, the robust and migratable log anomaly detection method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Network security anomaly detection system and method based on AI

    CN119583225A

  • AI-based network security anomaly detection system and method

    CN119583225B

  • Log anomaly detection method and device, equipment, medium and product

    CN119759702A

  • Log anomaly detection method, device, equipment, medium and product

    CN119759702B