Microservice system anomaly detection method, storage medium, and electronic device

Through technologies such as spectral residual algorithm and multi-layer perceptron, the multi-modal data of the microservice system is integrated to build an anomaly detection model, which solves the problem of heterogeneous data fusion and improves the accuracy and comprehensiveness of anomaly detection.

CN118643455BActive Publication Date: 2024-10-15安徽思高智能科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411124322.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2024-10-15
Estimated Expiration
2044-08-16

AI Technical Summary

Technical Problem

Heterogeneous multi-modal data in microservice systems are difficult to fuse, making monitoring difficult. Traditional monitoring methods are difficult to effectively handle high-dimensional and noisy problems.

Method used

The index data features are extracted through the spectral residual algorithm, and the log data features are obtained through log analysis. A multi-layer perceptron and a temporal convolution network are used to build an anomaly detection model. The autoencoder compresses the high-dimensional features into low dimensions, and calculates the system anomaly score. Determine whether the system is abnormal.

Benefits of technology

It improves the accuracy and comprehensiveness of anomaly detection, provides more explanation clues by integrating business logs and indicator data, and enhances the comprehensiveness of system monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118643455B_ABST
    Figure CN118643455B_ABST
Patent Text Reader

Abstract

The present invention discloses a microservice system anomaly detection method, storage medium, and electronic device, which belongs to the field of microservice system detection, including obtaining multivariate microservice system data of indicator data and log data and corresponding labels; constructing an anomaly detection model, using the characteristics of the indicator data and the characteristics of the log data and the corresponding labels to train the anomaly detection model, the anomaly detection model includes: an input layer, a TCN module, and an output layer, the input layer splices the characteristics of the indicator data and the characteristics of the log data to form a new feature, the TCN module captures the dependency in the time series of the new feature, and the input and output layers generate the final anomaly score; the data to be detected is input into the trained anomaly detection model to obtain the system abnormality. The present invention integrates the microservice system indicator data and daily data, enriches the information perspective, and provides a powerful solution for comprehensive anomaly monitoring in a complex microservice environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of microservice system detection, and specifically to a microservice system anomaly detection method, a storage medium, and an electronic device. Background Art

[0002] In today's digital age, microservice architecture, as a highly flexible and scalable software design pattern, has become the mainstream choice for building large-scale applications and services. However, as the scale and complexity of microservice systems increase, monitoring the health of these services becomes increasingly critical. The complexity of microservice systems is mainly reflected in the diverse service combinations, communication and collaboration in a distributed environment, and the processing of heterogeneous data. These characteristics make anomaly monitoring more difficult, and traditional monitoring methods are not up to the task. The indicator data of a microservice system usually involves multiple dimensions and modalities, and it is of great significance to fuse these heterogeneous multimodal data. How to integrate this data, model temporal relationships, and effectively handle high dimensions and noise is an important challenge. Summary of the invention

[0003] The purpose of the present invention is to solve the problem that it is difficult to integrate heterogeneous multimodal data of a microservice system, which leads to difficulty in monitoring the microservice system. The present invention proposes a microservice system anomaly detection method, which provides a comprehensive and efficient monitoring and anomaly detection solution for the microservice system to promote the stability and reliability of the system, and includes the following steps:

[0004] S1. Obtain the data of the multi-microservice system and the corresponding labels. The data of the multi-microservice system includes indicator data and log data. The label indicates whether the data of the multi-microservice system is abnormal.

[0005] S2, extracting the features of the indicator data through the spectral residual algorithm, and obtaining the features of the log data through log parsing;

[0006] S3, integrating the features of indicator data and log data to build an anomaly detection model;

[0007] Specifically:

[0008] The characteristics of the indicator data and the characteristics of the log data are mapped to the same dimension through a multi-layer perceptron to obtain the hidden layer characteristics of the indicator data and the hidden layer characteristics of the log data;

[0009] Input the hidden layer features of the indicator data and the hidden layer features of the log data into the network with the temporal convolutional network TCN as the backbone to obtain the high-dimensional hidden layer features of the indicator data and the high-dimensional hidden layer features of the log data;

[0010] Combined with the automatic encoder, the high-dimensional hidden layer features of the indicator data and the high-dimensional hidden layer features of the log data are compressed into a low-dimensional embedding space to obtain the low-dimensional features of the indicator data and the low-dimensional features of the log data;

[0011] Calculate the system anomaly score based on the characteristics of low-dimensional indicator data and low-dimensional log data, and determine whether the system is abnormal based on the system anomaly score;

[0012] S4. Input the data to be detected into the anomaly detection model to determine whether the system is abnormal.

[0013] Furthermore, step S1 is specifically as follows:

[0014] S11. Collect indicator data during normal system operation and log data , and Set the data label to 0 and set the indicator data and log data , indicator data and log data The corresponding label is set as the training set ;

[0015] S12. Set fault injection parameters, randomly inject faults into the system according to the fault injection parameters, and collect indicator data and log data , the indicator data collected during the fault injection period and log data The label is set to 1, and the indicator data collected in other time periods and log data The label is set to 0, and the indicator data and log data , indicator data and log data The corresponding label is set to the test set ;

[0016] S13, set the sampling time interval, from the training set and test set Sampling training set The training samples are and test set The test sample is .

[0017] Furthermore, in step S2, the characteristics of the index data are extracted by a spectral residual algorithm, specifically:

[0018] Based on the indicator data, convert the indicator data from the spatial domain to the frequency domain using Fourier transform to obtain frequency spectrum information of the indicator data;

[0019] Calculate the magnitude spectrum of the frequency spectrum of the indicator data;

[0020] Performing a spectral residual transformation on the amplitude spectrum to obtain an amplitude spectrum after the spectral residual transformation;

[0021] Perform inverse Fourier transform on the amplitude spectrum after spectral residual transformation, convert the complex frequency domain result back to the spatial domain, and obtain the saliency map of the indicator data;

[0022] The saliency maps of the indicator data are normalized and spliced ​​vertically to obtain the features of the indicator data.

[0023] Furthermore, in step S2, the features of the log data are extracted through log parsing, specifically:

[0024] Use the Drain log parsing tool to cluster the log data. Each cluster represents a log template to obtain a log template set. , where N represents the number of clusters;

[0025] Preset a time interval, count the frequency of each log template in different time periods of the preset time interval, and convert it into a log template frequency matrix. Normalize the log template frequency matrix to obtain the characteristics of the log data. .

[0026] Furthermore, the system anomaly score is calculated according to the characteristics of the low-dimensional index data and the characteristics of the low-dimensional log data, and whether the system is abnormal is determined based on the system anomaly score as follows:

[0027] The system anomaly score is calculated as follows:

[0028]

[0029] Among them, s represents the system anomaly score, and express The mean and covariance matrix of Represents the training data set The training samples in are low-dimensional features obtained by the anomaly detection model. Represents the test data set The test samples in the anomaly detection model obtain low-dimensional features, and the system anomaly score represents and The Mahalapino distance between

[0030] If s is greater than the preset threshold, the test sample is an outlier; on the contrary, the test sample It is a normal value.

[0031] Furthermore, the loss function of the network with the temporal convolutional network TCN as the backbone is defined as:

[0032]

[0033] in, represents the contrastive learning loss, express and The cosine similarity between represents the hidden layer features of the i-th indicator data, represents the hidden layer feature of the i-th log data, represents the kth log data hidden layer feature, and n represents the number of indicator data hidden layer features.

[0034] Furthermore, the loss function of the autoencoder is expressed as:

[0035]

[0036] in, represents the loss function of the autoencoder, represents the square of the Euclidean norm, represents the result of encoding h, Express The decoding result, h represents the high-dimensional hidden layer features.

[0037] Furthermore, the entire anomaly detection model is optimized by minimizing the overall loss function of the anomaly detection model. The overall loss function of the anomaly detection model is expressed as:

[0038]

[0039] in, represents the overall loss function of the anomaly detection model, Represents the weight coefficient.

[0040] The present invention also proposes a computer-readable storage medium, on which a data processing program is stored. When the data processing program is executed by a processor, the above-mentioned microservice system anomaly detection method is implemented.

[0041] The present invention also proposes an electronic device, comprising a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises computer-readable instructions, and the processor is configured to call the computer-readable instructions to execute the above-mentioned microservice system anomaly detection method.

[0042] The beneficial effects brought by the technical solution provided by the present invention are:

[0043] The present invention enriches the information perspective of anomaly detection by integrating business logs and indicators, provides more clues for the interpretation and location of anomalies, and improves the comprehensiveness of system monitoring; the microservice indicator data is feature extracted through Fourier transform and spectral residual transform, which not only captures complex patterns in the time domain, but also performs comprehensive analysis in the frequency domain. The present invention can integrate heterogeneous multimodal data and improve the accuracy and comprehensiveness of anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is a flow chart of a microservice system anomaly detection method according to an embodiment of the present invention;

[0045] Figure 2 It is the characteristics of the original index data of CPU utilization of the microservice system and the microservice index data in the embodiment of the present invention;

[0046] Figure 3 It is a block diagram of an electronic device in an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0047] To make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described below with reference to the accompanying drawings.

[0048] A flowchart of a microservice system anomaly detection method according to an embodiment of the present invention is as follows: Figure 1 As shown, the following steps are included:

[0049] S1. Obtain multiple microservice system data and corresponding labels. The multiple microservice system data includes microservice system indicator data and log data. The label indicates whether the multiple microservice system data is abnormal.

[0050] In a further embodiment, the microservice system indicator data and log data with abnormal labels are obtained by means of fault injection, specifically:

[0051] S11. Collect indicator data during normal system operation and log data , and The data label is set to 0, which means normal. and log data and indicator data and log data The corresponding label is set as the training set Specifically, Prometheus and Node_exporter tools are used to collect indicator data. , collect log data through FileBeat .

[0052] S12. Set fault injection parameters, which specifically include: host CPU utilization, host memory utilization, host network packet loss rate, service response time delay, container CPU utilization, container memory utilization, container network packet loss rate, etc.

[0053] Randomly inject faults into the system according to the fault injection parameters and collect indicator data and log data Specifically, Prometheus, Node_exporter, and FileBeat tools are used to collect metrics and log data; the metric data collected during the fault injection period is injected into the and log data The label is set to 1, 1 indicates an abnormality, and the indicator data collected in other time periods and log data The label is set to 0, which means normal, and the indicator data and log data and indicator data and log data The corresponding label is set to the test set .

[0054] S13, set the sampling time interval, specifically, set the time interval to 5s, from the training set and test set Sampling training set The training samples are and test set The test sample is .

[0055] S2. Extract the features of the indicator data based on the spectral residual algorithm, and obtain the features of the log data through log parsing.

[0056] In a further embodiment, the features of the microservice indicator data are extracted by a spectral residual algorithm, specifically:

[0057] (1) Based on the index data obtained above, Fourier transform is used to convert the index data from the spatial domain to the frequency domain to obtain the spectrum information of the index data.

[0058]

[0059]

[0060]

[0061] in, represents the Fourier transform, Represents one-dimensional time series data, that is, indicator data, represents the amplitude in the frequency domain, Indicates the phase in the frequency domain. Amplitude(.) and Phrase(.) respectively represent the amplitude and phase in the frequency domain. Indicates the amplitude frequency The result of log calculation.

[0062] (2) Calculate the amplitude spectrum of the frequency spectrum of the index data, that is, the modulus of the frequency spectrum.

[0063]

[0064] in, Express The result after mean filtering is: is a q×q window function, i.e., a filter, which is used to average the amplitude spectrum, specifically expressed as:

[0065]

[0066] (3) Performing a spectral residual transformation on the amplitude spectrum, taking the logarithm of the amplitude spectrum of each frequency component, subtracting the average filter to highlight the significant features in the input index, and obtaining the amplitude spectrum after the spectral residual transformation.

[0067]

[0068] in, Represents the magnitude spectrum after spectral residual transformation.

[0069] (4) Perform an inverse transform on the amplitude spectrum after the spectral residual transform, usually using the inverse Fourier transform, to convert the complex frequency domain result back to the spatial domain to obtain a saliency map of the indicator data.

[0070]

[0071] in, represents the inverse Fourier transform, i is the imaginary unit, represents the magnitude of a vector, The saliency map representing the indicator data is the indicator saliency map vector expression obtained by the spectral residual algorithm.

[0072] (5) Normalize the saliency map of the indicator data and splice it vertically to obtain the characteristics of the indicator data.

[0073] refer to Figure 2 , Figure 2It is a feature of the original index data of CPU utilization of the microservice system and the microservice index data in the embodiment of the present invention.

[0074] In a further embodiment, the features of log data are extracted through log parsing, specifically:

[0075] (1) Use the Drain log parsing tool to cluster the log data. Each cluster represents a log template, and a log template set is obtained. Where N represents the number of clusters.

[0076] (2) Preset a time interval, count the frequency of each log template in different time periods of the preset time interval, and convert it into a log template frequency matrix, where the log template frequency matrix represents the frequency of each log template in different time periods. For example, the bth column of the ath row represents the number of times log template b appears in the ath time period. Normalize the log template frequency matrix to obtain the log data vector , which is the characteristic of log data.

[0077] S3. The features of the indicator data and the log data are integrated to build an anomaly detection model.

[0078] Specifically:

[0079] The characteristics of the indicator data and the characteristics of the log data are mapped to the same dimension through a multi-layer perceptron, and the hidden layer characteristics of the indicator data and the hidden layer characteristics of the log data are expressed as:

[0080]

[0081]

[0082] in, is the hidden layer feature of the indicator data, is the hidden layer feature of log data, represents a multi-layer perceptron, Represents the characteristics of indicator data, Represents the characteristics of log data.

[0083] The hidden features of the indicator data and the hidden features of the log data are input into the network with the temporal convolutional network TCN as the backbone to obtain the high-dimensional hidden features h.

[0084] Combined with the automatic encoder, the high-dimensional hidden layer features h are compressed into a low-dimensional embedding space to obtain the features of the low-dimensional indicator data and the low-dimensional log data.

[0085] The system anomaly score is calculated as follows:

[0086]

[0087] Among them, s represents the system anomaly score, and express The mean and covariance matrix of Represents the training data set The training samples in are low-dimensional features obtained by the anomaly detection model. Represents the test data set The test samples in the anomaly detection model obtain low-dimensional features, and the system anomaly score represents and The Mahalapino distance between

[0088] If s is greater than the preset threshold, the test sample is an outlier; on the contrary, the test sample It is a normal value.

[0089] In a further embodiment, the loss function of the network with the temporal convolutional network TCN as the backbone is defined as:

[0090]

[0091] in, represents the contrastive learning loss, express and The cosine similarity between represents the hidden layer features of the i-th indicator data, represents the hidden layer feature of the i-th log data, represents the kth log data hidden layer feature, and n represents the number of indicator data hidden layer features.

[0092] In a further embodiment, the loss function of the autoencoder is expressed as:

[0093]

[0094] in, represents the loss function of the autoencoder, represents the square of the Euclidean norm, represents the result of encoding h, Express The result of decoding.

[0095] In a further embodiment, the entire anomaly detection model is optimized by minimizing the overall loss function of the anomaly detection model, and the overall loss function of the anomaly detection model is expressed as:

[0096]

[0097] in, represents the overall loss function of the anomaly detection model, Represents the weight coefficient.

[0098] S4. Input the data to be detected into the anomaly detection model to determine whether the system is abnormal.

[0099] The anomaly detection effect of the proposed method in the fault injection scenario is verified on two datasets, Sock-shop and Online-boutique, and the performance is compared with the classic anomaly detection methods K-Nearest Neighbors (KNN) and support vector machines (SVM) as shown in Table 1. The comparison indicators are: precision, recall and F1 score (F1-Score).

[0100] Table 1

[0101]

[0102] In an exemplary embodiment, a computer-readable storage medium is included, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned microservice system anomaly detection method is implemented.

[0103] See also Figure 3 In an exemplary embodiment, an electronic device is also included, including at least one processor, at least one memory, and at least one communication bus.

[0104] Among them, a computer program is stored in the memory, and the computer program includes computer-readable instructions. The processor calls the computer-readable instructions stored in the memory through the communication bus to execute the above-mentioned microservice system anomaly detection method.

[0105] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A microservice system anomaly detection method, characterized in that: The following steps are involved: S1. Obtain the data of the multi-microservice system and the corresponding labels. The data of the multi-microservice system includes indicator data and log data. The label indicates whether the data of the multi-microservice system is abnormal. Specifically: S11. Collect indicator data during normal system operation and log data , and Set the data label to 0 and set the indicator data and log data , indicator data and log data The corresponding label is set as the training set ; S12. Set fault injection parameters, randomly inject faults into the system according to the fault injection parameters, and collect indicator data and log data , the indicator data collected during the fault injection period and log data The label is set to 1, and the indicator data collected in other time periods and log data The label is set to 0, and the indicator data and log data , indicator data and log data The corresponding label is set to the test set ; S13, set the sampling time interval, from the training set and test set Sampling training set The training samples are and test set The test sample is ; S2, extracting the features of the indicator data through the spectral residual algorithm, and obtaining the features of the log data through log parsing; The characteristics of the index data are extracted through the spectral residual algorithm, specifically: Based on the indicator data, convert the indicator data from the spatial domain to the frequency domain using Fourier transform to obtain frequency spectrum information of the indicator data; Calculate the magnitude spectrum of the frequency spectrum of the indicator data; Performing a spectral residual transformation on the amplitude spectrum to obtain an amplitude spectrum after the spectral residual transformation; Perform inverse Fourier transform on the amplitude spectrum after spectral residual transformation, convert the complex frequency domain result back to the spatial domain, and obtain the saliency map of the indicator data; Normalize the saliency map of the indicator data and splice it vertically to obtain the characteristics of the indicator data; The features of log data are extracted through log parsing, specifically: Use the Drain log parsing tool to cluster the log data. Each cluster represents a log template to obtain a log template set. , where N represents the number of clusters; Preset a time interval, count the frequency of each log template in different time periods of the preset time interval, and convert it into a log template frequency matrix. Normalize the log template frequency matrix to obtain the characteristics of the log data. ; S3, integrating the features of indicator data and log data to build an anomaly detection model; Specifically: The characteristics of the indicator data and the characteristics of the log data are mapped to the same dimension through a multi-layer perceptron to obtain the hidden layer characteristics of the indicator data and the hidden layer characteristics of the log data; Input the hidden layer features of the indicator data and the hidden layer features of the log data into the network with the temporal convolutional network TCN as the backbone to obtain the high-dimensional hidden layer features of the indicator data and the high-dimensional hidden layer features of the log data; Combined with the automatic encoder, the high-dimensional hidden layer features of the indicator data and the high-dimensional hidden layer features of the log data are compressed into a low-dimensional embedding space to obtain the low-dimensional features of the indicator data and the low-dimensional features of the log data; The system anomaly score is calculated based on the characteristics of the low-dimensional indicator data and the low-dimensional log data, and whether the system is abnormal is determined based on the system anomaly score; specifically: The system anomaly score is calculated as follows: Among them, s represents the system anomaly score, and express The mean and covariance matrix of Represents the training data set The training samples in are low-dimensional features obtained by the anomaly detection model. Represents the test data set The test samples in the anomaly detection model obtain low-dimensional features, and the system anomaly score represents and The Mahalapino distance between If s is greater than the preset threshold, the test sample is an outlier; on the contrary, the test sample is a normal value; The loss function of the network with the temporal convolutional network TCN as the backbone is defined as: in, represents the contrastive learning loss, express and The cosine similarity between represents the hidden layer features of the i-th indicator data, represents the hidden layer feature of the i-th log data, represents the kth log data hidden layer feature, n represents the number of indicator data hidden layer features; The loss function of the autoencoder is expressed as: in, represents the loss function of the autoencoder, represents the square of the Euclidean norm, represents the result of encoding h, Express The decoding result, h represents the high-dimensional hidden layer features; S4. Input the data to be detected into the anomaly detection model to determine whether the system is abnormal.

2. A microservice system anomaly detection method according to claim 1, characterized in that: The entire anomaly detection model is optimized by minimizing the overall loss function of the anomaly detection model. The overall loss function of the anomaly detection model is expressed as: in, represents the overall loss function of the anomaly detection model, Represents the weight coefficient.

3. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data processing program, and when the data processing program is executed by a processor, the method according to any one of claims 1 to 2 is implemented.

4. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises computer-readable instructions, and the processor is configured to call the computer-readable instructions to execute the method as claimed in any one of claims 1 to 2.