Method and apparatus for detecting anomaly of web log

By performing character-level encoding and Char-CNN network detection on HTTP network logs, the problems of complex and inaccurate feature extraction in existing technologies are solved, and accurate anomaly detection of raw network logs is achieved.

CN116451065BActive Publication Date: 2026-11-24CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210002008.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-04
Publication Date
2026-11-24
Estimated Expiration
2042-01-04

AI Technical Summary

Technical Problem

Existing network log detection methods suffer from complex feature extraction and inaccurate features, leading to inaccurate anomaly detection results. Furthermore, topology detection relies on data quality and preprocessing methods, making it impossible to effectively detect raw logs directly.

Method used

By constructing an alphabet to encode HTTP network logs at the character level, a log vector sequence with fixed length and width is generated and input into the trained Char-CNN network for anomaly detection, avoiding the complex work of feature extraction and the defects of inaccurate features.

Benefits of technology

It achieves accurate detection of unknown abnormal HTTP network logs, avoids dependence on pre-trained word vectors and syntactic structures, and improves the accuracy and efficiency of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116451065B_ABST
    Figure CN116451065B_ABST
Patent Text Reader

Abstract

This invention provides a method and apparatus for anomaly detection in web logs, relating to the field of artificial intelligence technology. The method includes: constructing an alphabet based on character information from HTTP web logs; encoding the HTTP web logs according to the alphabet to obtain a log vector sequence with fixed length and width; and inputting the log vector sequence into a trained convolutional neural network (Char-CNN) to determine the anomaly detection result of the HTTP web logs. The anomaly detection method and apparatus provided by this invention, by encoding HTTP web logs at the character level and inputting the encoded log vector sequence into a trained Char-CNN network for anomaly detection, avoids the need for pre-trained word vectors and grammatical structures, thus avoiding the complex work of feature extraction and the defects of inaccurate features, achieving accurate detection of abnormal HTTP web logs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and specifically to a method and apparatus for detecting anomalies in network logs. Background Technology

[0002] Existing network logs typically use anomaly detection based on log semantic analysis or construct an adjacency matrix through topological structure, extract sliding time series segments using a sliding window, and then use a gated convolutional neural network to detect abnormal network logs.

[0003] Existing network log detection methods, particularly those based on log semantic analysis, suffer from complex feature extraction processes and inaccurate feature representation, leading to inaccurate anomaly detection results. Furthermore, topology-based detection methods heavily rely on log data quality and preprocessing techniques, making them more suitable for logs after statistical feature extraction and unsuitable for direct anomaly detection of raw logs.

[0004] Therefore, it is of great significance to propose a method that can directly detect anomalies in raw network logs and avoid the complex work of feature extraction and the defects of inaccurate feature extraction, so as to achieve accurate detection of network log anomalies. Summary of the Invention

[0005] This invention provides a method and apparatus for detecting anomalies in network logs, which solves the technical problem that existing technologies cannot directly detect log anomalies in raw network logs without avoiding the complex work of feature extraction and inaccurate feature extraction.

[0006] In a first aspect, the present invention provides a method for detecting anomalies in network logs, comprising:

[0007] Construct an alphabet based on the character information in the Hypertext Transfer Protocol (HTTP) network logs;

[0008] The HTTP network logs are encoded according to the alphabet to obtain a log vector sequence with fixed length and fixed width.

[0009] The log vector sequence is input into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0010] In one embodiment, constructing the alphabet based on character information from HTTP network logs includes:

[0011] Obtain all character categories from the HTTP network log, delete Chinese character categories from the character categories, and construct an alphabet based on the remaining character categories.

[0012] In one embodiment, encoding the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width includes:

[0013] One-hot encoding is performed on the characters in the HTTP network log that are included in the alphabet to obtain an encoded vector; characters in the HTTP network log that are not included in the alphabet are converted into all-zero vectors.

[0014] Based on the encoded vector and the all-zero vector, a log vector sequence with a fixed width is obtained;

[0015] Based on a preset length threshold, the log vector sequence with a fixed width is truncated or padded to obtain a log vector sequence with a fixed length and a fixed width.

[0016] In one embodiment, prior to encoding the HTTP network log, the method further includes:

[0017] Remove the separator between the HTTP network log header and the HTTP network log message, as well as the connector between the header and the message, to obtain the HTTP network log message data;

[0018] The message data of the HTTP network log and the tag data corresponding to the HTTP network log are combined to form a log tuple, and the log tuple is used as the HTTP network log.

[0019] In one embodiment, the Char-CNN network is trained through the following steps:

[0020] Based on the log vector sequence, construct a normal log vector sequence dataset;

[0021] The normal log vector sequence dataset is input into the Char-CNN network for training, resulting in the trained Char-CNN network.

[0022] In one embodiment, after constructing the normal log vector sequence dataset, the method further includes:

[0023] Delete duplicate log vector sequences from the normal log vector sequence dataset.

[0024] Secondly, the present invention also provides an anomaly detection device for network logs, comprising:

[0025] The alphabet building module is used to build an alphabet based on character information from the Hypertext Transfer Protocol (HTTP) web logs.

[0026] The log encoding module is used to encode the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width.

[0027] The log anomaly detection module is used to input the log vector sequence into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0028] Thirdly, the present invention also 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 executes the computer program to implement the steps of the above-described network log anomaly detection method.

[0029] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of any of the above-described methods for detecting anomalies in network logs.

[0030] Fifthly, the present invention also provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, it implements the steps of the above-described network log anomaly detection method.

[0031] The present invention provides a method, apparatus, electronic device, and storage medium for anomaly detection in web logs. By encoding HTTP web logs at the character level, a log vector sequence with fixed length and width is obtained. This log vector sequence is then input into a trained convolutional neural network (Char-CNN) for anomaly detection. This eliminates the need for pre-trained word vectors and syntactic structures, avoiding the complexities and inaccuracies of feature extraction, and achieving accurate detection of unknown abnormal HTTP web logs. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0033] Figure 1 A flowchart illustrating the anomaly detection method for network logs provided by this invention;

[0034] Figure 2 A flowchart illustrating the anomaly detection method for network logs provided by this invention;

[0035] Figure 3A schematic diagram of the structure of the network log anomaly detection device provided by the present invention;

[0036] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0038] Figure 1 This is a flowchart illustrating the anomaly detection method for network logs provided by the present invention. (Refer to...) Figure 1 The anomaly detection method for network logs provided by this invention may include:

[0039] S110. Construct an alphabet based on the character information in the Hypertext Transfer Protocol (HTTP) network logs;

[0040] S120. Encode the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width;

[0041] S130. Input the log vector sequence into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0042] The execution subject of the network log anomaly detection method provided by this invention can be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), ATMs, or self-service machines, etc., and this invention does not impose specific limitations.

[0043] The following uses the example of a computer executing the network log anomaly detection method provided by this invention to illustrate the technical solution of this invention in detail.

[0044] In step S110, the alphabet is composed of pre-defined characters. All characters appearing in the HTTP network log are extracted, and the composition of the alphabet is determined based on the extracted characters.

[0045] Optionally, the characters in the specifically constructed alphabet may include: abcdefghijklmnopqrstuvwxyz0123456789-,;.! ? :′\″ / \\|_@#$%^&*~`+-=<>()[]{}.

[0046] In step S120, the characters in the HTTP network log are encoded one by one according to the alphabet determined in step S110 to obtain a log vector sequence with fixed length and fixed width.

[0047] Understandably, based on the alphabet, HTTP network log encoding is character-level encoding. In subsequent log anomaly detection, character-level encoding eliminates the need for pre-trained word vectors and syntactic structures. Furthermore, character-level encoding for log anomaly detection can be easily generalized to all languages.

[0048] In step S130, after obtaining the log vector sequence, the log vector is input into the trained Char-CNN network. The trained Char-CNN network performs anomaly detection on the input log vector sequence to obtain the anomaly detection result of the HTTP network log.

[0049] Char-CNN is a text classification model based entirely on character-level data. It achieves highly accurate anomaly detection without requiring word-level meaning or information about language grammar and syntax. Furthermore, as an end-to-end text classification network, Char-CNN can automatically extract text features, avoiding the complexities and inaccuracies of manual feature extraction.

[0050] The Char-CNN model, based on character-level convolutional neural networks, consists of an input layer, an output layer, and hidden layers.

[0051] Input layer: Maps the log vector sequence into two-dimensional planar information, which facilitates the convolutional neural network in learning features;

[0052] Hidden layers: These consist of convolutional layers and pooling layers. Convolutional layers use ReLU as the activation function to map the input data to a high-dimensional space, learning the implicit feature information within the input data. Pooling layers perform dimensionality reduction sampling on the extracted features, reducing computation and improving the model's operational efficiency. In deep convolutional neural networks, convolutional and pooling layers are alternated to accurately and efficiently learn the feature information of abnormal behavior. A configuration of 6 convolutional and pooling layers can be used, as shown in Table 1, the structure design table for hidden layers.

[0053] Table 1 Structural Design of Hidden Layers

[0054]

[0055] Where N / A indicates that pooling operations are not required.

[0056] Output layer: Contains a fully connected layer and a Softmax classifier. The fully connected layer maps the extracted features to a one-dimensional array, which is then used as input to the Softmax classifier. The output classification result is the log anomaly detection result. A three-layer fully connected layer can be used, with a dropout layer with a dropout probability of 0.5 used before the last layer for regularization to prevent overfitting. Finally, the Softmax classifier is connected to achieve binary or multi-class classification. The configuration is shown in Table 2, the output layer structure design table.

[0057] Table 2 Structural Design of Output Layer

[0058]

[0059] The key module of the Char-CNN network is the convolution module. For a discrete input function g(x), the range of values ​​is real numbers in [1, l], i.e., g(x) ∈ [1, l] → R. And a discrete kernel function f(x), the range of values ​​is real numbers in [1, k], i.e., f(x) ∈ [1, k] → R. The convolution h(y) of f(x) and g(x) with stride d is:

[0060]

[0061] Where l is the length of the input log vector sequence, and k is the size of the convolution kernel.

[0062] Defineable:

[0063]

[0064] Where x is the position in the kernel function, y is the position related to the input position when calculating the position of the input function, and c is the offset constant, c = k - d + 1.

[0065] Specifically, when the input is gi (x) and the output is h j When (y), the kernel function can be expressed as f ij (x)(i=1,2,…,m; j=1,2,…,n), the kernel function is usually also called the weight. Each g i These are called input features, each h j This is called the output feature, where m is the size of the input feature and n is the size of the output feature. The output result is h. j (y) is through g i (x) and f ij It is obtained by convolution kernels between (x).

[0066] Another key module is the max pooling layer module, which helps the model train deeper. If we have a discrete input function g(x) whose range is real numbers in [1, l], i.e., g(x) ∈ [1, l] → R, then its max pooling layer operation function h(y) is:

[0067]

[0068] It can be defined as:

[0069]

[0070] Similarly, c = k - d + 1 is an offset constant. This unique pooling model enables convolutional neural networks to be trained to depths exceeding 6 layers. The nonlinear methods used in the model can be rectifiers or threshold functions h(x) = max{0,x}, which are similar to the ReLU function. The optimal algorithm can be stochastic gradient descent.

[0071] The anomaly detection method for web logs provided by this invention encodes HTTP web logs at the character level to obtain a log vector sequence with fixed length and width. This log vector sequence is then input into a trained convolutional neural network (Char-CNN) for anomaly detection. This eliminates the need for pre-trained word vectors and syntactic structures, avoiding the complexities and inaccuracies of feature extraction, and achieving accurate detection of unknown abnormal HTTP web logs.

[0072] In one embodiment, constructing an alphabet based on character information from HTTP network logs includes: obtaining all character categories from the HTTP network logs, deleting Chinese character categories from the character categories, and constructing an alphabet from the remaining character categories.

[0073] Specifically, all character categories appearing in the HTTP network logs are obtained. To ensure generality, Chinese character categories are removed from all obtained character categories, and an alphabet is constructed based on the remaining character categories.

[0074] Optionally, the characters in the specifically constructed alphabet may include: abcdefghijklmnopqrstuvwxyz0123456789-,;.! ? :′\″ / \\|_@#$%^&*~`+-=<>()[]{}.

[0075] The anomaly detection method for network logs provided by this invention deletes Chinese character categories from all character categories in HTTP network logs and constructs an alphabet from the remaining character categories, thus ensuring the universality of the encoding while achieving HTTP network log encoding.

[0076] In one embodiment, encoding HTTP network logs according to an alphabet to obtain a log vector sequence with fixed length and fixed width includes: performing one-hot encoding on characters in the HTTP network logs that are included in the alphabet to obtain an encoded vector; converting characters in the HTTP network logs that are not included in the alphabet into an all-zero vector; obtaining a log vector sequence with fixed width based on the encoded vector and the all-zero vector; and truncating or padding the log vector sequence with fixed width according to a preset length threshold to obtain a log vector sequence with fixed length and fixed width.

[0077] Specifically, based on the characters in the alphabet, the size of the alphabet is determined to be m, where m is the number of characters in the alphabet. Referring to the alphabet, each character in the HTTP network log that is contained in the alphabet is one-hot encoded. Characters in the HTTP network log that are not contained in the alphabet are converted into all-zero vectors. It can be understood that after encoding, the original HTTP network log is transformed into a log vector sequence of width m.

[0078] A preset length threshold L is used to transform a log vector sequence of width m into a log vector sequence of length L. If the length of the log vector sequence exceeds L, the portion exceeding L is truncated. If the length of the log vector sequence is less than L, padding is applied to the log vector sequence. Automatic zero-padding at the end of the log vector sequence can be used to pad it to length L. The length L is determined by analyzing the length distribution of a batch of one-hot encoded HTTP web logs and selecting an 80% length coverage ratio.

[0079] The anomaly detection method for network logs provided by this invention obtains a log vector sequence with fixed length and width by encoding HTTP network logs at the character level. This character-level HTTP network log encoding method allows for the vectorization of HTTP network logs for use in detection models without requiring syntactic or syntax information.

[0080] In one embodiment, before encoding the HTTP network log, the method further includes: deleting the separator between the HTTP network log header and the HTTP network log message, as well as the connector between the header and the message, to obtain the HTTP network log message data; forming a log tuple from the HTTP network log message data and the corresponding HTTP network log tag data, and using the log tuple as the HTTP network log.

[0081] Specifically, the delimiters between the HTTP network log header and the HTTP network log message are deleted, and the connectors between the header and the message are also deleted to obtain the HTTP network log message data, thereby reducing unnecessary data volume.

[0082] The HTTP network log message data and its corresponding tag data are combined to form a log tuple. The tag corresponding to the HTTP network log indicates the type of the HTTP network log. This log tuple is then used as the input for the subsequent training of the Char-CNN model and as data input for the Char-CNN model.

[0083] The network log anomaly detection method provided by this invention reduces unnecessary data volume and improves data processing efficiency by deleting delimiters and connectors between message headers and messages in HTTP network logs.

[0084] In one embodiment, the Char-CNN network is trained by the following steps: constructing a normal log vector sequence dataset based on the log vector sequence; inputting the normal log vector sequence dataset into the Char-CNN network for training to obtain the trained Char-CNN network.

[0085] Optionally, a batch of normal HTTP network logs can be obtained from an HTTP network log library. The batch of normal HTTP network logs is then preprocessed. This involves removing the separator between the HTTP network log header and the HTTP network log message, as well as the concatenation operator between the header and the message.

[0086] Based on the alphabet, preprocessed HTTP network logs are encoded to construct a normal log vector sequence dataset. This normal log vector sequence dataset is then input into a Char-CNN network for training, resulting in the trained Char-CNN network.

[0087] The anomaly detection method for web logs provided by this invention trains a Char-CNN network to obtain a trained Char-CNN network. Inputting the log vector sequence into the trained Char-CNN network for anomaly detection eliminates the need for pre-trained word vectors and syntactic structures, avoiding the complexities and inaccuracies of feature extraction, and achieving accurate detection of unknown abnormal HTTP web logs.

[0088] In one embodiment, after constructing the normal log vector sequence dataset, the method further includes: deleting duplicate log vector sequences in the normal log vector sequence dataset.

[0089] The normal log vector sequence dataset is obtained from the HTTP web log library. Since the HTTP web log library often contains a large number of duplicate logs, in order to avoid the model becoming overtrained on a certain type of log and thus reducing the efficiency of analyzing other types of logs, duplicate log vector sequences in the log vector sequence dataset are deleted to improve the efficiency of log analysis.

[0090] The network log anomaly detection method provided by this invention removes duplicate log vector sequences from the normal log vector sequence dataset, thereby avoiding the problem of overtraining of the model on a certain type of log during subsequent dataset construction and model training, which would reduce the efficiency of log analysis for other types of logs and improve log analysis efficiency.

[0091] The following is a flowchart illustrating an anomaly detection method for network logs provided by this invention. Figure 2 For example, the technical solution provided by this invention will be explained:

[0092] Retrieve a batch of normal HTTP network logs from the HTTP network log library. Preprocess the batch of normal HTTP network logs. The preprocessing process includes: removing duplicate logs from the batch of normal HTTP network logs; removing HTTP network log headers and delimiters and concatenation characters between messages.

[0093] Based on a predefined alphabet, preprocessed HTTP network logs are encoded to construct a normal log vector sequence dataset. This normal log vector sequence dataset is then input into a Char-CNN network for training, resulting in the trained Char-CNN network.

[0094] Obtain unknown HTTP network logs and preprocess them. The preprocessing process includes removing the headers and separators / concatenation characters from the unknown HTTP network logs.

[0095] Based on a predefined alphabet, preprocessed unknown HTTP network logs are encoded to construct a log vector sequence. This log vector sequence is then input into a trained Char-CNN network for detection, yielding anomaly detection results for the unknown HTTP network logs.

[0096] The present invention also provides an anomaly detection device for network logs, which can be referred to in correspondence with the anomaly detection method for network logs described above.

[0097] Figure 3 This is a schematic diagram of the network log anomaly detection device provided by the present invention, as shown below. Figure 3 As shown, the device includes:

[0098] Alphabet construction module 310 is used to construct an alphabet based on character information from the Hypertext Transfer Protocol (HTTP) network logs;

[0099] The log encoding module 320 is used to encode the HTTP network log according to the alphabet to obtain a log vector sequence with fixed length and fixed width.

[0100] The log anomaly detection module 330 is used to input the log vector sequence into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0101] The anomaly detection device for web logs provided by this invention encodes HTTP web logs at the character level to obtain a log vector sequence with fixed length and width. This log vector sequence is then input into a trained convolutional neural network (Char-CNN) for anomaly detection. This eliminates the need for pre-trained word vectors and syntactic structures, avoiding the complexities and inaccuracies of feature extraction, and achieving accurate detection of unknown abnormal HTTP web logs.

[0102] In one embodiment, the alphabet construction module 310 is specifically used for:

[0103] Obtain all character categories from the HTTP network log, delete Chinese character categories from the character categories, and construct an alphabet based on the remaining character categories.

[0104] In one embodiment, the log encoding module 320 is specifically used for:

[0105] The step of encoding the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width includes:

[0106] One-hot encoding is performed on the characters in the HTTP network log that are included in the alphabet to obtain an encoded vector; characters in the HTTP network log that are not included in the alphabet are converted into all-zero vectors.

[0107] Based on the encoded vector and the all-zero vector, a log vector sequence with a fixed width is obtained;

[0108] Based on a preset length threshold, the log vector sequence with a fixed width is truncated or padded to obtain a log vector sequence with both fixed length and fixed width.

[0109] In one embodiment, the log encoding module 320 is further configured to:

[0110] Before encoding the HTTP network logs, the following steps are also included:

[0111] Remove the separator between the HTTP network log header and the HTTP network log message, as well as the connector between the header and the message, to obtain the HTTP network log message data;

[0112] The message data of the HTTP network log and the tag data corresponding to the HTTP network log are combined to form a log tuple, and the log tuple is used as the HTTP network log.

[0113] In one embodiment, the log anomaly detection module 330 is specifically used for:

[0114] Based on the log vector sequence, construct a normal log vector sequence dataset;

[0115] The normal log vector sequence dataset is input into the Char-CNN network for training, resulting in the trained Char-CNN network.

[0116] In one embodiment, the log anomaly detection module 330 is further configured to:

[0117] After constructing the normal log vector sequence dataset, the following is also included:

[0118] Delete duplicate log vector sequences from the normal log vector sequence dataset.

[0119] The present invention also provides an electronic device, such as... Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute the steps of the network log anomaly detection method, such as including:

[0120] Construct an alphabet based on the character information in the Hypertext Transfer Protocol (HTTP) network logs;

[0121] The HTTP network logs are encoded according to the alphabet to obtain a log vector sequence with fixed length and fixed width.

[0122] The log vector sequence is input into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0123] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0124] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which, when executed by a computer, enable the computer to perform the steps of the network log anomaly detection method provided in the above-described method embodiments, for example including:

[0125] Construct an alphabet based on the character information in the Hypertext Transfer Protocol (HTTP) network logs;

[0126] The HTTP network logs are encoded according to the alphabet to obtain a log vector sequence with fixed length and fixed width.

[0127] The log vector sequence is input into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0128] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the network log anomaly detection method provided in the above-described method embodiments, for example including:

[0129] Construct an alphabet based on the character information in the Hypertext Transfer Protocol (HTTP) network logs;

[0130] The HTTP network logs are encoded according to the alphabet to obtain a log vector sequence with fixed length and fixed width.

[0131] The log vector sequence is input into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log.

[0132] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0133] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for anomaly detection in network logs, characterized in that, include: Construct an alphabet based on the character information in the Hypertext Transfer Protocol (HTTP) network logs; The HTTP network logs are encoded according to the alphabet to obtain a log vector sequence with fixed length and fixed width. The log vector sequence is input into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log; The step of encoding the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width includes: One-hot encoding is performed on the characters in the HTTP network log that are included in the alphabet to obtain an encoded vector; characters in the HTTP network log that are not included in the alphabet are converted into all-zero vectors. Based on the encoded vector and the all-zero vector, a log vector sequence with a fixed width is obtained; Based on a preset length threshold, the log vector sequence with a fixed width is truncated or padded to obtain a log vector sequence with a fixed length and a fixed width; the preset length threshold is determined by analyzing the length distribution of a batch of HTTP network logs after one-hot encoding. The step of constructing an alphabet based on character information from HTTP network logs includes: Obtain all character categories from the HTTP network log, delete Chinese character categories from the character categories, and construct an alphabet based on the remaining character categories.

2. The anomaly detection method for network logs according to claim 1, characterized in that, Before encoding the HTTP network log, the method further includes: Remove the separator between the HTTP network log header and the HTTP network log message, as well as the connector between the header and the message, to obtain the HTTP network log message data; The message data of the HTTP network log and the tag data corresponding to the HTTP network log are combined to form a log tuple, and the log tuple is used as the HTTP network log.

3. The anomaly detection method for network logs according to claim 1, characterized in that, The Char-CNN network was trained through the following steps: Based on the log vector sequence, construct a normal log vector sequence dataset; The normal log vector sequence dataset is input into the Char-CNN network for training, resulting in the trained Char-CNN network.

4. The anomaly detection method for network logs according to claim 3, characterized in that, After constructing the normal log vector sequence dataset, the following is also included: Delete duplicate log vector sequences from the normal log vector sequence dataset.

5. An anomaly detection device for network logs, characterized in that, include: The alphabet building module is used to build an alphabet based on character information from the Hypertext Transfer Protocol (HTTP) web logs. The log encoding module is used to encode the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width. The log anomaly detection module is used to input the log vector sequence into the trained convolutional neural network Char-CNN to determine the anomaly detection result of the HTTP network log; The step of encoding the HTTP network logs according to the alphabet to obtain a log vector sequence with fixed length and fixed width includes: One-hot encoding is performed on the characters in the HTTP network log that are included in the alphabet to obtain an encoded vector; characters in the HTTP network log that are not included in the alphabet are converted into all-zero vectors. Based on the encoded vector and the all-zero vector, a log vector sequence with a fixed width is obtained; Based on a preset length threshold, the log vector sequence with a fixed width is truncated or padded to obtain a log vector sequence with a fixed length and a fixed width; the preset length threshold is determined by analyzing the length distribution of a batch of HTTP network logs after one-hot encoding. The step of constructing an alphabet based on character information from HTTP network logs includes: Obtain all character categories from the HTTP network log, delete Chinese character categories from the character categories, and construct an alphabet based on the remaining character categories.

6. 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, it implements the steps of the network log anomaly detection method as described in any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the network log anomaly detection method as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the network log anomaly detection method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Log file format processing method, apparatus, computer device, and storage medium

    CN109271356A

  • System log anomaly detection method and device, electronic equipment and storage medium

    CN111858242A

  • Log analysis processing method and device

    CN113297051A