Anomaly detection algorithm based on log and call chain data fusion for microservice architecture

By performing fine-grained word segmentation and embedding vector extraction on the log and call chain, and combining the probabilistic label model and the GraphSAGE model, the problem of anomaly detection in the fusion of log and call chain data in the microservice architecture is solved, achieving higher detection accuracy and robustness. Great sex.

CN117349740BActive Publication Date: 2024-09-06SHANGHAI DINGMAO INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311438727.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-01
Publication Date
2024-09-06
Estimated Expiration
2043-11-01

AI Technical Summary

Technical Problem

The existing technology is difficult to detect anomalies in logs and call chain data through a single data source in a microservice architecture, and cannot effectively detect call anomalies between microservices.

Method used

The data preprocessing stage is used to perform fine-grained word segmentation and embedding vector extraction on logs and call chains, and log and call chain events are integrated through graph structures. The probabilistic label model and Deep SVDD ideas are combined, and PU learning and GraphSAGE models are used for anomaly detection.

Benefits of technology

It realizes anomaly detection for microservice applications and improves detection accuracy and robustness. The F1-score is 48.72% higher than the single-modal algorithm, and Precision, Recall and F1-score all reach the highest.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117349740B
    Figure CN117349740B
Patent Text Reader

Abstract

The present invention discloses an anomaly detection algorithm for the fusion of log and call chain data for microservice architecture, which belongs to the technical field of multimodal operation and maintenance data anomaly detection algorithm. The anomaly detection algorithm for the fusion of log and call chain data for microservice architecture includes the following specific steps: S1, data preprocessing stage, log and call chain parsing extract event templates, using a word segmenter to semantically perform fine-grained word segmentation on words, and then using the word embedding obtained by the pre-training model and TF-IDF aggregation to obtain event embedding vectors through PCA, with the help of a graph structure, logs and call chain events are represented as nodes of the graph, and time series relationships and call relationships are represented as edges. The present invention proposes an anomaly detection algorithm for the fusion of log and call chain data for microservice architecture, which supports inferring the overall sample label distribution when some reliable labels are known, accurately detecting anomalies of microservice applications, and has great application prospects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of multimodal operation and maintenance data anomaly detection algorithms, and specifically relates to an anomaly detection algorithm for log and call chain data fusion for microservice architecture. Background Art

[0002] With the advent of the digital age, the complexity and scale of software applications continue to increase, and the traditional monolithic application development model can no longer meet the growing business needs. In order to better meet these challenges, modern software development has gradually turned to microservice architecture. Microservice architecture is a development framework that splits large applications into several microservices that collaborate to complete the equivalent business services provided by monolithic applications. It splits complex applications into a series of small, autonomous services. This modular design allows teams to develop and maintain applications more flexibly and better adapt to changing needs and growing traffic. As the number of software access users and system functions continue to increase, the operation and maintenance of microservice architecture also brings great difficulties, such as the complex calling relationship between microservices and the pressure of massive monitoring data analysis.

[0003] Current anomaly detection methods mainly focus on a single data source, such as log data, call chain data, etc. If you only rely on logs for anomaly detection, you will not be able to obtain the actual call relationship between each microservice, making it difficult to discover incorrect call anomalies between different microservices. Therefore, it is necessary to study an accurate and robust anomaly detection algorithm that integrates log and call chain data for microservice architecture. Summary of the invention

[0004] The technical problem to be solved by the present invention is to overcome the shortcomings of the above-mentioned prior art and provide an anomaly detection algorithm for microservice architecture by integrating log and call chain data.

[0005] The technical solution adopted to solve the above technical problems is to provide an anomaly detection algorithm for the fusion of log and call chain data for microservice architecture, including the following specific steps:

[0006] S1. In the data preprocessing stage, logs and call chains are parsed to extract event templates. A word segmenter is used to semantically segment words in a fine-grained manner. Then, the word embedding obtained by the pre-trained model and TF-IDF aggregation are used to obtain event embedding vectors through PCA. With the help of the graph structure, logs and call chain events are represented as graph nodes, and the time sequence relationship and call relationship are represented as edges, so that the log information and the call chain structure are effectively integrated.

[0007] Through the above technical solution, log and call chain parsing extracts event templates, log parsing algorithm is used to extract log event templates, call chain event templates are extracted according to the Span type of the call chain, and log and call chain template vectors are generated. After using regular expressions to filter special words, in order to further improve the representation ability of the template, the log and call chain templates are segmented according to semantics and roots, and the language model is used to convert text information into digital vectors. Then, the TF-IDF of each word is counted, and the word vectors in each template are aggregated according to TF-IDF to obtain sentence vectors. Since the original sentence vector represents a large dimension, PCA is used to reduce the dimension to reduce the calculation burden. The log and call chain fusion graph is constructed, and the log and call chain events are grouped according to traceId. After the grouping is completed, each event is used as a node in the graph. For all call chain template nodes with call relationships in the graph, an edge is added from the caller template node to the callee template node. This step obtains a log and call chain fusion graph with more representation ability through fine-grained preprocessing.

[0008] S2. In the probabilistic label model and detection model training phase, we combine the ideas of PU learning and Deep SVDD, use reliable positive sample label data to train a compact hypersphere, estimate the labels of the overall samples, provide label support for training the supervision model, and enhance the robustness of the model. At the same time, based on the distance from the log and call chain graph vector to the center of the hypersphere, we design a flexibly adjustable probabilistic label calculation method to achieve label smoothing, improve the model's ability to discriminate unknown data, complete the fitting of the probabilistic estimation model, and obtain the probabilistic labels of all training samples. Based on this, we train the log call chain fusion based on GraphSAGE. Figure 2 Classification detection model;

[0009] Through the above technical solution, the purpose of the label estimation stage is to estimate the overall label distribution based on a part of reliable label samples through PU learning. According to the known reliable normal samples, a compact hypersphere representation of normal log and call chain fusion graph in the feature space can be trained through the GGNN backbone network and Deep SVDD. Through the probability label calculation formula, the distance from the coordinates of the log and call chain fusion graph to the center of the hypersphere can be converted into a probability label in the feature space. At the same time, the model training will obtain the probability labels of all data after probability estimation through the unlabeled training data set, so that it can be merged with the initial training data into a new data set. This data set will be used to train the anomaly detection binary classifier. This step is to estimate the overall label distribution through PU learning, and integrate the idea of ​​label smoothing, and express the general one-hot label encoding as a probability form. The two parts of the work are jointly trained to obtain a robust binary classification model.

[0010] S3, anomaly detection stage, after completing the training, the log and call chain fusion graph are input into the algorithm to obtain the anomaly probability at the end of GraphSAGE.

[0011] Furthermore, there are 6 spans in the call chain referred to by the fusion graph in S1, and each span has parsed log event nodes and call chain events inside, corresponding to asynchronous calls and synchronous requests / responses respectively.

[0012] Furthermore, in S1, the extracted log and event call chain templates are finely segmented from the semantics and roots of compound words, and PCA is used to reduce the sentence vector dimension to obtain the log and call chain event embedding vector; when constructing the graph, the Root Span of the call chain is treated as a log event.

[0013] Furthermore, the label smoothing formula of the probability label calculation method in S2 is:

[0014]

[0015] Through the above technical solution, in the standard Deep SVDD, as long as the coordinates are in the hypersphere, it is judged as a positive example, otherwise it is a negative example, which is equivalent to a probability of only 0 or 1. However, relevant literature shows that label smoothing can help the model obtain better generalization ability, that is, it has better performance for new logs and call chains.

[0016] Furthermore, the label smoothing formula adjusts the probability of the coordinates located at the boundary of the hypersphere, so that for the incorrect results of Deep SVDD classification, the model can also be better adjusted according to its corrected probability value.

[0017] Furthermore, in S2, the probability labels of the log and call chain graph vectors are calculated based on the distances between the log and call chain graph vectors and the center of the hypersphere, and the degree of smoothing can be adjusted by setting different parameters.

[0018] Furthermore, after the unlabeled training data set in S3 is labeled with the predicted probability, it will be merged with the initial training data into a new data set, which will be used to train a binary fault classifier. The main structure of the classifier is a three-layer GraphSAGE network. GraphSAGE adopts the idea of ​​inductive learning. It learns an aggregation function to aggregate the feature vectors of neighbor nodes to generate the feature vector of the target node, and then outputs the probability of abnormality through a full connection and softmax layer.

[0019] Furthermore, after the probability estimation model and the classification model in S3 are trained, the abnormal probability of the sample can be obtained by directly inputting the log and the call chain fusion graph into the classification model.

[0020] The beneficial effects of the present invention are as follows: (1) The present invention proposes an anomaly detection algorithm for microservice architecture based on log and call chain data fusion, which supports inferring the overall sample label distribution when some reliable labels are known, accurately detecting the anomalies of microservice applications, and has great application prospects; (2) In the data preprocessing stage, the present invention uses fine-grained word segmentation to obtain template event vectors and fuses log and call chain events with the help of call graph structure to obtain a stronger system state representation vector than a single modality. Through ablation experiment comparison, the anomaly detection algorithm combining log and call chain has a maximum F1-score improvement of 48.72% compared with the single modality algorithm; (3) The present invention proposes a set of model training methods based on PU learning, which can estimate the overall label distribution based on some known reliable sample labels, and designs a label smoothing formula to improve the model reasoning ability and enhance the robustness of the model. Compared with the existing log and call chain fusion anomaly detection algorithm, this patent has achieved the highest precision, recall and F1-score. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a flow chart of the anomaly detection algorithm of the present invention for the fusion of log and call chain data for microservice architecture;

[0022] Figure 2 This is an example diagram of constructing a log and call chain fusion graph of the present invention;

[0023] Figure 3 It is a schematic diagram of the coordinate axes of the label smoothing formula of the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0025] like Figure 1 As shown, the anomaly detection algorithm for the microservice architecture-oriented log and call chain data fusion of this embodiment includes the following specific steps:

[0026] S1. In the data preprocessing stage, the log and call chain are parsed to extract the event template. The log statement is divided into a log header and a log message consisting of multiple fields according to the predefined log format. The format of the sample log is " <date> <time> <unknown> <level> <content>", use regular expressions to identify commonly used variable words in logs and call chain messages, and use the identifier "<*>" to replace them. Taking log data as an example, the corresponding regular expressions include "( / |)([0-9]+\.){3}[0-9]+(:[0-9]+|)(:|)" (IP address), "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})" (order number), use the word segmenter to semantically segment words in fine-grained manner, and then use the word embedding obtained by the pre-trained model and TF-IDF aggregation to obtain the event embedding vector through PCA, and use the word segmentation to separate the log data into two parts. The log and call chain messages are divided into word sequences. Then, for the event templates parsed from the log, word segmentation is performed in a fine-grained manner. The word segmentation methods include word segmentation based on spaces and word segmentation based on the word ninja. The 300-dimensional GloVe pre-trained language model is used to obtain word vectors. The TF-IDF of log events and call chain events are calculated respectively, and the word vectors are aggregated to obtain event vectors. Finally, PCA is used to compress the event vectors to 50 dimensions. With the help of the graph structure, the log and call chain events are represented as nodes of the graph, and the temporal relationship and call relationship are represented as edges. The log information is effectively integrated with the call chain structure, and the logs are sorted according to the Trace IDs are grouped, and the log events and call chain events belonging to the unified Trace are constructed into the edges of the fusion graph according to the call relationship and timing relationship. The call chain events without Root Span or Parent Span are regarded as log events, and only the edges of the timing relationship are connected. In summary, a log and call chain fusion graph can be obtained. Table 1 shows the performance of this algorithm using the log and call chain fusion graph and only using log / call chain information on the same data set. It can be seen that compared with using a single data source, the algorithm that integrates information from multiple data sources performs the best.

[0027] S2, Probabilistic label model and detection model training phase, half of the normal log data in the training set is divided as samples with reliable known labels, and these reliable samples with known labels are used to train a hypersphere based on GGNN and DeepSVDD, where the center of the hypersphere is the average value of all samples in the feature space, and the radius of the hypersphere is the 95th percentile of the distance from all reliable samples to the center of the sphere. The idea of ​​SVDD is to use reliable positive sample label data to train a compact hypersphere, estimate the labels of the overall samples, provide label support for training supervision models, and enhance model robustness. At the same time, based on the distance from the log and call chain graph vector to the center of the hypersphere, a flexibly adjustable probability label calculation method is designed to achieve label smoothing and improve the model's ability to discriminate unknown data. After the hypersphere-based probability estimation model is trained, all training samples are input into the model, and the distance from these samples to the center of the hypersphere is calculated. Then, the label smoothing formula is used to calculate the probability labels of all samples, where in_section is 0.05, in_prob_section is 0.1, and out_section is 0.15. The probability estimation model is fitted to obtain the probability labels of all training samples, and the samples with probability labels are input into the GraphSAGE-based anomaly detection model for training. Binary cross entropy is used as the loss function to calculate the loss of each training, and back propagation is performed to adjust the model parameters. Based on this, the log call chain fusion based on GraphSAGE is trained. Figure 2 Classification detection model;

[0028] S3, anomaly detection stage, after training, the log and call chain fusion graph are input into the algorithm to obtain the anomaly probability at the end of GraphSAGE. Table 2 shows the performance of PUTraLog and other anomaly detection algorithms on the same data set. For fairness, LogAnomaly and TraceAnomaly also use log and call chain data and sort them according to the events that occurred to obtain the event sequence, which is then input into the detection model to obtain the final test results. As can be seen from the table, PUTraLog performs the best, with F1-score improved by 4.8% to 66.2% compared with other algorithms.

[0029] Precision Recall F1-score PUTraLog (use log only) 0.984 0.971 0.977 PUTraLog (use call chain only) 0.644 0.675 0.659 PUTraLog 1.0 0.974 0.987

[0030] Table 1 shows the performance comparison of anomaly detection algorithms using different data sources.

[0031]

[0032] Table 2 is a performance comparison of different anomaly detection algorithms. The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention.< / content> < / level> < / unknown> < / time> < / date>

Claims

1. An anomaly detection algorithm based on log and call chain data fusion for microservice architecture, characterized by: The specific steps include: S1. In the data preprocessing stage, logs and call chains are parsed to extract event templates. A word segmenter is used to semantically segment words in a fine-grained manner. Then, the word embedding obtained by the pre-trained model and TF-IDF aggregation are used to obtain event embedding vectors through PCA. With the help of the graph structure, logs and call chain events are represented as graph nodes, and the time sequence relationship and call relationship are represented as edges, so that the log information and the call chain structure are effectively integrated. S2. In the probabilistic label model and detection model training phase, the idea of ​​PU learning and DeepSVDD is combined, and reliable positive sample label data is used to train the compact hypersphere to estimate the labels of the overall samples, provide label support for the training supervision model, and enhance the robustness of the model. At the same time, based on the distance from the log and call chain graph vector to the center of the hypersphere, a flexibly adjustable probabilistic label calculation method is designed to achieve label smoothing, improve the model's ability to distinguish unknown data, complete the fitting of the probabilistic estimation model to obtain the probabilistic labels of all training samples, and based on this, train the log call chain fusion graph binary classification detection model based on GraphSAGE; The label smoothing formula of the probability label calculation method is: The label smoothing formula adjusts the abnormal probability of the fusion graph according to the distance from the coordinates of the fusion graph of the log and call chain in the feature space to the center of the hypersphere, so that for the incorrect results of Deep SVDD classification, the model can also make better adjustments based on its corrected probability value; S3, anomaly detection stage, after completing the training, the log and call chain fusion graph are input into the algorithm to obtain the anomaly probability at the end of GraphSAGE.

2. According to claim 1, the anomaly detection algorithm for microservice architecture-oriented log and call chain data fusion is characterized in that: There are 6 spans in the call chain referred to by the fusion graph in S1, and each span has parsed log event nodes and call chain events inside, corresponding to asynchronous calls and synchronous requests / responses respectively.

3. The anomaly detection algorithm based on log and call chain data fusion for microservice architecture according to claim 1 is characterized in that: In S1, the extracted log and event call chain templates are finely segmented from the semantics and roots of compound words, and PCA is used to reduce the sentence vector dimension to obtain the log and call chain event embedding vector; when constructing the graph, the RootSpan of the call chain is treated as a log event.

4. The anomaly detection algorithm based on log and call chain data fusion for microservice architecture according to claim 1 is characterized in that: In S2, the probability labels of the log and call chain graph vectors are calculated based on the distances between the log and call chain graph vectors and the center of the hypersphere, and the degree of smoothing can be adjusted by setting different parameters.

5. The anomaly detection algorithm for microservice architecture-oriented log and call chain data fusion according to claim 1 is characterized in that: After the unlabeled training data set in S3 is labeled with the predicted probability, it will be merged with the initial training data into a new data set, which will be used to train the fault binary classifier. The main structure of the classifier is a 3-layer GraphSAGE network. GraphSAGE adopts the idea of ​​inductive learning. It learns an aggregation function to aggregate the feature vectors of neighbor nodes to generate the feature vector of the target node, and then outputs the probability of abnormality through a full connection and softmax layer.

6. The anomaly detection algorithm based on log and call chain data fusion for microservice architecture according to claim 1 is characterized by: After the probability estimation model and the classification model in S3 are trained, the abnormal probability of the sample can be obtained by directly inputting the log and the call chain fusion graph into the classification model.