Fault detection method and device for micro-service architecture, computer equipment, medium and product
By preprocessing the sample data of the microservice architecture and feature extraction of Kalman filtering algorithm, and combining the random forest model for fault detection, the problem that traditional methods are difficult to identify system-level faults is solved, and the accuracy of fault detection is improved.
Patent Information
- Application Number
- CN202411752993.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-18
AI Technical Summary
In microservice architecture, traditional single-metric anomaly detection is difficult to accurately identify system-level failures caused by multiple service exceptions, especially in the case of complex dependencies between services.
By preprocessing the sample data of the microservice architecture, feature extraction is performed using the Kalman filtering algorithm, the sum of the first-order difference, the filtered first-order difference value and the filtered difference are extracted as the target feature group, and input them into the trained random forest model for fault detection.
This method can more accurately capture the inherent connection between different feature combinations and faults, improve the accuracy of fault detection, better reflect the overall status of the system, and identify system-level faults.
Smart Images

Figure CN119645867A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a fault detection method, apparatus, computer equipment, medium and product for a microservice architecture. Background Art
[0002] With the rapid development of cloud computing technology, microservice architecture has won wide recognition and application in the field of cloud computing due to its high flexibility, excellent scalability and lightweight characteristics. Microservice architecture not only improves the maintainability and scalability of the system by splitting large applications into a series of small, autonomous services, but also promotes the practice of continuous integration and continuous delivery. In the operation and maintenance process of microservice architecture system, fault detection is a key link to ensure system stability and reliability.
[0003] Traditional fault detection methods often rely on single-indicator anomaly detection based on statistical models. This method identifies anomalies by monitoring a single system operation data indicator (such as CPU usage, memory occupancy, response time, etc.).
[0004] However, since there are usually complex dependencies between services in a microservice architecture, the anomaly of a single service may trigger a chain reaction and affect the stability of the entire cluster. Single indicator detection can only analyze the data indicators of a single service and cannot fully reflect the overall status of the cluster. Therefore, it is difficult to accurately identify system-level failures caused by multiple service anomalies. Summary of the invention
[0005] Based on this, it is necessary to provide a fault detection method, device, computer equipment, medium and product for a microservice architecture that can accurately detect system faults in response to the above technical problems.
[0006] In a first aspect, the present application provides a fault detection method for a microservice architecture, comprising:
[0007] Perform data preprocessing on the sample data of the microservice architecture to obtain the target sample;
[0008] The target sample is subjected to feature extraction by a Kalman filter algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the first-order difference value after filtering, and the filtering difference value;
[0009] The target feature group is input into the trained random forest model and the fault detection result is output.
[0010] In one embodiment, the step of performing data preprocessing on sample data of the microservice architecture to obtain a target sample includes:
[0011] Oversample the sample data of the microservice architecture to generate new samples in the categories that are under-represented in the sample data;
[0012] Perform undersampling on the sample data after oversampling to reduce the number of samples in the category whose sample number ratio in the sample data exceeds a preset value;
[0013] The sample data after undersampling is deduplicated to obtain the target sample.
[0014] In one embodiment, the step of extracting features from target samples by using a Kalman filter algorithm to obtain a target feature group includes:
[0015] Perform first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points;
[0016] The target samples are filtered by the Kalman filter algorithm, and the first-order difference calculation is performed on the filtered target samples to obtain the filtered first-order difference value;
[0017] The difference between the target sample and the filtered target sample is obtained to obtain a filtered difference.
[0018] In one embodiment, the step of performing first-order difference calculation on the filtered target sample to obtain the filtered first-order difference value includes:
[0019] According to the preset time interval, the first-order difference calculation is repeatedly performed on the filtered target samples for multiple times to obtain the filtered first-order difference values corresponding to multiple time intervals.
[0020] In one embodiment, the training process of the random forest model includes:
[0021] A sampling method with replacement is adopted to obtain multiple training samples from the training data set; each training sample consists of multiple feature values;
[0022] For each training sample, a preset number of feature values are randomly selected as target features;
[0023] The nodes of the random forest model are trained through the target features to obtain a single decision tree model;
[0024] All single decision tree models are combined to obtain the trained random forest model.
[0025] In one embodiment, the step of inputting the target feature group into the trained random forest model and outputting the fault detection result includes:
[0026] Input the target feature group into the trained random forest model to obtain the prediction results of each single decision tree model;
[0027] All prediction results are counted and the fault detection results are obtained based on the statistical results output.
[0028] In a second aspect, the present application also provides a fault detection device for a microservice architecture, including:
[0029] The data processing module is used to preprocess the sample data of the microservice architecture to obtain the target sample;
[0030] A feature extraction module is used to extract features of target samples through a Kalman filter algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target samples, the filtered first-order difference value and the filtered difference value;
[0031] The fault detection module is used to input the target feature group into the trained random forest model and output the fault detection result.
[0032] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method steps of any one of the first aspects are implemented.
[0033] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements any one of the method steps in the first aspect when the computer program is executed by a processor.
[0034] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which implements any one of the method steps in the first aspect when executed by a processor.
[0035] The fault detection method, device, computer equipment, medium and product of the above-mentioned microservice architecture can extract features that can more truly reflect the essential change trend of the data from the original data by using the Kalman filtering algorithm for feature extraction, and filter out noise information that may be caused by random factors or measurement errors, so that subsequent models can learn and judge based on purer and more representative features, and then perform fault detection through the trained random forest model, which can better capture the intrinsic connection between different feature combinations and faults, thereby improving the accuracy of fault detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 An application environment diagram of a fault detection method for a microservice architecture in one embodiment;
[0038] Figure 2 A schematic diagram of a process flow of a fault detection method for a microservice architecture in one embodiment;
[0039] Figure 3 A comparison diagram of data sequences before and after Kalman filtering in one embodiment;
[0040] Figure 4 A schematic diagram of training a random forest model in one embodiment;
[0041] Figure 5 A schematic diagram of a process flow of a fault detection method for a microservice architecture in another embodiment;
[0042] Figure 6 It is a structural block diagram of a fault detection device of a microservice architecture in one embodiment;
[0043] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application 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 application and are not used to limit the present application.
[0045] The microservice architecture fault detection method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 is used to perform data preprocessing on the sample data of the microservice architecture to obtain the target sample, extract the features of the target sample through the Kalman filter algorithm, obtain the target feature group, input the target feature group into the trained random forest model, and output the fault detection result. Among them, the terminal 102 can be but not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0046] In an exemplary embodiment, Figure 2 As shown, a fault detection method for a microservice architecture is provided, which is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, including the following steps 202 to 206. Among them:
[0047] S202: Perform data preprocessing on the sample data of the microservice architecture to obtain a target sample.
[0048] Alternatively, microservice architecture refers to splitting a large application into a set of small, independent services, each of which can be independently developed, deployed, expanded, and maintained. These microservices collaborate with each other through lightweight communication mechanisms to form a complete application system. When processing sample data in a microservice architecture, the data may often have various problems, such as missing data, data noise, and inconsistent data formats. Through data preprocessing, the original sample data is made more suitable for subsequent analysis and processing to obtain the target sample.
[0049] S204: extracting features of the target samples through a Kalman filter algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target samples, the filtered first-order difference value, and the filtered difference value.
[0050] Optionally, due to the complexity of the system and the existence of data noise, directly using the sample data of the microservice architecture for fault detection often has poor results. Therefore, in the embodiment of the present application, the data is feature extracted by the Kalman filter algorithm. The Kalman filter algorithm can effectively remove the noise in the data by recursively combining the prediction and update steps, and can highlight the feature expression of the system fault in the data, and finally extract the feature data closely related to the system state. These features not only have high accuracy, but also can reflect the dynamic changes of the system under different states, which provides strong support for subsequent fault detection and classification. Among them, the first-order difference can reflect the change of data at adjacent moments, and calculating the sum of its first-order differences can capture a certain trend feature of the data change as a whole, such as the cumulative effect of the increase or decrease of the data over a period of time. By processing the first-order difference with the Kalman filter algorithm, some of the noise can be removed, and a differential value that can more accurately reflect the real change trend of the data can be obtained. These values can better reflect the dynamic characteristics of the data as features. The filter difference is the difference between the data before and after the Kalman filter. It can reflect the part of the original data that is considered as noise and removed by the filtering algorithm, and provides information about the data quality and change characteristics from another perspective.
[0051] S206: Input the target feature group into the trained random forest model, and output the fault detection result.
[0052] Optionally, the random forest model is an ensemble learning algorithm based on decision trees, which consists of multiple decision trees. In the training phase, each decision tree can learn the relationship between different feature combinations and fault states by learning a large amount of labeled sample data (including data in normal and fault states). In the prediction phase, for the input new feature data (i.e., the target feature group), each decision tree makes predictions separately, and then the prediction results of all decision trees are combined to obtain the final fault detection result.
[0053] In the fault detection method of the above-mentioned microservice architecture, by using the Kalman filtering algorithm for feature extraction, features that can more truly reflect the essential change trend of the data can be extracted from the original data, and noise information that may be caused by random factors or measurement errors can be filtered out, so that subsequent models can learn and judge based on purer and more representative features. Then, fault detection can be performed through the trained random forest model, which can better capture the intrinsic connection between different feature combinations and faults, thereby improving the accuracy of fault detection.
[0054] In an exemplary embodiment, the steps of performing data preprocessing on sample data of a microservice architecture to obtain target samples include: oversampling the sample data of the microservice architecture to generate new samples in categories with insufficient numbers in the sample data; undersampling the oversampled sample data to reduce the number of samples in categories whose sample numbers in the sample data exceed a preset value; and deduplicating the undersampled sample data to obtain target samples.
[0055] Optionally, in the sample data of the microservice architecture, there may be an imbalance in data categories. For example, in the sample data of fault detection, the data in the normal operating state may be far more than the data in the fault state. The purpose of oversampling is to generate new samples in categories with a small number of samples (such as fault data categories). Common oversampling methods include the Synthetic Minority Over-sampling Technique (SMOTE) algorithm, which generates new synthetic samples in the feature space of minority class samples.
[0056] Furthermore, after oversampling, although the number of minority class samples has been supplemented, the number of samples in certain categories may account for too high a proportion. Undersampling is to reduce the number of samples in categories (usually the majority class) whose sample proportion exceeds the preset value. For example, the Edited Nearest Neighbours (ENN) algorithm is used to edit the data set to remove samples that may cause the classifier performance to deteriorate. The algorithm traverses each sample in the data set and finds its nearest neighbor sample. If the nearest neighbor sample is inconsistent with the category of the current sample, then the current sample is likely to be near the decision boundary and is a noise or difficult-to-classify sample, so it will be deleted from the data set. Finally, through deduplication processing, duplicate samples are removed to obtain the final target sample.
[0057] In this embodiment, through oversampling and undersampling, the category imbalance problem in the sample data of the microservice architecture can be effectively solved, and the model's ability to recognize fault conditions can be improved, thereby improving the accuracy of the model.
[0058] In an exemplary embodiment, the steps of extracting features of a target sample by using a Kalman filter algorithm to obtain a target feature group include: performing a first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points; filtering the target sample by using a Kalman filter algorithm, performing a first-order difference calculation on the filtered target sample to obtain a filtered first-order difference value; obtaining the difference between the target sample and the filtered target sample to obtain a filtered difference.
[0059] Optionally, the first-order difference is used to calculate the difference between adjacent data points, and the sum of the first-order differences can reflect the overall change trend of the data within the entire sequence. After filtering the target sample, a filtered sample data sequence is obtained. Similarly, the first-order difference calculation is performed on the filtered sample data to obtain the filtered first-order difference value. Compared with the original first-order difference value, these difference values can more accurately reflect the real change trend of the data due to the noise reduction processing of the Kalman filter. For each data point and the corresponding filtered data point, the difference is calculated. The filter difference can intuitively reflect the part removed from the original data by the Kalman filter. These parts are usually considered to be noise. By analyzing the filter difference, the size and distribution of the noise in the original data can be understood.
[0060] For example, Figure 3 As shown, Figure 3 The data sequence before and after Kalman filter processing is compared. The curve before filtering shows obvious fluctuations and irregularities, which is caused by a large amount of noise impurities. The curve after Kalman filter processing is relatively smooth, and the small fluctuations and outliers that originally interfered with the interpretation of the data have been largely eliminated. This shows that the Kalman filter algorithm effectively removes the noise in the data, making the data purer and closer to the actual state of the real system. In addition, in the original data, due to the presence of noise, some features that may be related to real system failures are not obvious, or may even be completely covered. However, in the data after Kalman filter processing, the originally unclear features related to the failure begin to become clearly identifiable. For example, the data may continue to deviate from the normal range within a certain period of time, or there may be some sudden jumps that do not conform to the normal data change law. These may be potential signals of system failures, and Kalman filtering enables these signals to be presented more prominently, providing clearer clues for subsequent fault diagnosis.
[0061] In this embodiment, the target samples are filtered by the Kalman filter algorithm, which can reduce noise interference in the data, so that the subsequent model can learn and judge based on purer and more representative features, thereby improving the accuracy of the model.
[0062] In an exemplary embodiment, the step of performing a first-order difference calculation on the filtered target samples to obtain the filtered first-order difference value includes: repeatedly performing a first-order difference calculation on the filtered target samples multiple times at preset time intervals to obtain the filtered first-order difference values corresponding to multiple time intervals.
[0063] Optionally, for the filtered target samples, the first-order difference calculation is performed at a set time interval, and each calculated first-order difference reflects the change of data in the corresponding time interval. In the performance monitoring of the microservice architecture, the first-order difference of a short time interval can capture the rapid fluctuation of data, which may be related to some temporary, small-scale performance changes, such as changes in resource usage caused by a peak request in a short period of time.
[0064] In this embodiment, by performing first-order difference calculations at different time intervals, changes in filtered data can be observed on multiple time scales, thereby enhancing the feature representation of the data and improving the accuracy and reliability of fault detection.
[0065] In an exemplary embodiment, the training process of the random forest model includes: obtaining multiple training samples from a training data set by sampling with replacement; each training sample consists of multiple feature values; for each training sample, randomly selecting a preset number of feature values as target features; training the nodes of the random forest model through the target features to obtain a single decision tree model; and combining all the single decision tree models to obtain a trained random forest model.
[0066] Optionally, multiple training samples are obtained from the training data set by sampling with replacement. Sampling with replacement means that after each sample is extracted, it is put back into the data set so that the sample may still be extracted in the next sampling. This sampling method can increase the diversity of the data, so that each training sample may contain repeated data points, thereby simulating different distributions of the data. Among them, each training sample consists of multiple eigenvalues, which are used to describe various attributes of the sample. For each training sample, a preset number of eigenvalues are randomly selected as target features. By randomly selecting features, the impact of the correlation between features on the model can be reduced. The nodes of the random forest model are trained by the target features to obtain a single decision tree model. Among them, the decision tree is a classification or regression model based on a tree structure. It divides the sample by making a series of judgments on the eigenvalues (such as judging whether a certain eigenvalue is greater than a certain threshold) and finally forms a tree structure. During the training process, according to the selected target features, the information gain or mean square error of each eigenvalue for the classification or regression task is calculated, and the optimal features and division points are selected to construct the nodes of the decision tree. Finally, all the single decision tree models are combined to obtain the trained random forest model.
[0067] For example, a random forest model is Figure 4As shown in the figure, assuming that the total number of data samples is n, each sample contains a features (indicators), and n samples are selected from the original samples using the sampling method with replacement. K (k≤a) of the a features are randomly selected from the n samples, and the best split point of each node is obtained by establishing a decision tree. A single decision tree model is trained, and this is repeated many times to obtain several decision tree models. When predicting the input sample, each child decision tree model will output a prediction result, and the majority voting mechanism is used to determine the final prediction output.
[0068] In this embodiment, since sampling with replacement and random feature selection are adopted, each decision tree is trained on a slightly different data subset and feature subset. Since the random forest model combines the prediction results of multiple decision trees, the accuracy of the model can be improved.
[0069] In an exemplary embodiment, the step of inputting the target feature group into the trained random forest model and outputting the fault detection result includes: inputting the target feature group into the trained random forest model to obtain the prediction result of each single decision tree model; performing statistics on all the prediction results, and outputting the fault detection result according to the statistical results.
[0070] Optionally, when the target feature group is input into the trained random forest model, each decision tree in the model processes the input and gives a prediction result. After obtaining the prediction results of each decision tree, these results need to be counted. In classification problems (such as fault detection is a binary classification problem, i.e., fault and non-fault), the most common statistical method is voting. Assuming that there are 100 decision trees in the random forest, the number of decision trees predicted as fault states and the number predicted as non-fault states are counted. The final result of fault detection is output based on the statistical results. Under the voting mechanism, if the number of decision trees predicted as fault states is greater than the number predicted as non-fault states, the fault state is output as the final fault detection result; otherwise, the non-fault state is output. For example, there are 60 decision trees predicted as fault states and 40 decision trees predicted as non-fault states. Since 60>40, the fault state is finally output as the fault detection result.
[0071] In this embodiment, fault detection is performed using a trained random forest model, which can better capture the intrinsic relationship between different feature combinations and faults, thereby improving the accuracy of fault detection.
[0072] In an exemplary embodiment, Figure 5 As shown, a fault detection method for a microservice architecture is provided, the method comprising the following steps:
[0073] The sample data of the microservice architecture is oversampled to generate new samples in the categories with insufficient number in the sample data; the sample data after oversampling is undersampled to reduce the number of samples in the categories whose sample number ratio in the sample data exceeds the preset value; the sample data after undersampling is deduplicated to obtain the target sample.
[0074] Perform first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points; filter the target sample through the Kalman filter algorithm, and repeat the first-order difference calculation on the filtered target sample multiple times according to the preset time interval to obtain the filtered first-order difference values corresponding to multiple time intervals; obtain the difference between the target sample and the filtered target sample to obtain the filtered difference.
[0075] A sampling method with replacement is adopted to obtain multiple training samples from the training data set; each training sample consists of multiple feature values;
[0076] For each training sample, a preset number of feature values are randomly selected as the target features; the nodes of the random forest model are trained through the target features to obtain a single decision tree model; all single decision tree models are combined to obtain the trained random forest model.
[0077] The target feature group is input into the trained random forest model to obtain the prediction results of each single decision tree model; all the prediction results are counted and the fault detection results are obtained according to the statistical results output.
[0078] In this embodiment, by using the Kalman filtering algorithm for feature extraction, features that can more truly reflect the essential change trend of the data can be extracted from the original data, and noise information that may be caused by random factors or measurement errors can be filtered out, so that subsequent models can learn and judge based on purer and more representative features, and then fault detection can be performed through the trained random forest model, which can better capture the intrinsic connection between different feature combinations and faults, thereby improving the accuracy of fault detection.
[0079] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0080] Based on the same inventive concept, the embodiment of the present application also provides a microservice architecture fault detection device for implementing the above-mentioned microservice architecture fault detection method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in the embodiments of one or more microservice architecture fault detection devices provided below can refer to the limitations of the microservice architecture fault detection method above, and will not be repeated here.
[0081] In an exemplary embodiment, Figure 6 As shown, a fault detection device of a microservice architecture is provided, comprising: a data processing module 10, a feature extraction module 20 and a fault detection module 30, wherein:
[0082] The data processing module 10 is used to perform data preprocessing on the sample data of the microservice architecture to obtain target samples.
[0083] The feature extraction module 20 is used to extract features of the target sample by using a Kalman filter algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the filtered first-order difference value and the filtered difference value.
[0084] The fault detection module 30 is used to input the target feature group into the trained random forest model and output the fault detection result.
[0085] In an exemplary embodiment, the data processing module 10 is also used to oversample the sample data of the microservice architecture to generate new samples in categories with insufficient numbers in the sample data; to undersample the sample data after the oversampling process to reduce the number of samples in categories whose sample numbers in the sample data exceed a preset value; and to deduplicate the sample data after the undersampling process to obtain target samples.
[0086] In an exemplary embodiment, the feature extraction module 20 is also used to perform a first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points; filter the target sample through a Kalman filter algorithm, perform a first-order difference calculation on the filtered target sample, and obtain the filtered first-order difference value; obtain the difference between the target sample and the filtered target sample to obtain the filtered difference.
[0087] In an exemplary embodiment, the feature extraction module 20 is further configured to repeatedly perform first-order difference calculations on the filtered target samples at preset time intervals to obtain filtered first-order difference values corresponding to multiple time intervals.
[0088] In an exemplary embodiment, the fault detection module 30 is also used to obtain multiple training samples from a training data set by adopting a sampling method with replacement; each training sample is composed of multiple feature values; for each training sample, a preset number of feature values are randomly selected as target features; the nodes of the random forest model are trained through the target features to obtain a single decision tree model; all single decision tree models are combined to obtain a trained random forest model.
[0089] In an exemplary embodiment, the fault detection module 30 is also used to input the target feature group into the trained random forest model to obtain the prediction results of each single decision tree model; perform statistics on all the prediction results, and obtain the fault detection results based on the statistical results output.
[0090] Each module in the fault detection device of the above microservice architecture can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.
[0091] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 7As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (Near Field Communication, NFC) or other technologies. When the computer program is executed by the processor, a fault detection method of a microservice architecture is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0092] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0093] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: performing data preprocessing on sample data of a microservice architecture to obtain a target sample; performing feature extraction on the target sample by a Kalman filtering algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the filtered first-order difference value, and the filtered difference value; the target feature group is input into a trained random forest model, and a fault detection result is obtained as an output.
[0094] In one embodiment, the processor executes a computer program that involves performing data preprocessing on sample data of a microservice architecture to obtain a target sample, including: oversampling the sample data of the microservice architecture to generate new samples in categories with insufficient numbers in the sample data; undersampling the oversampled sample data to reduce the number of samples in categories whose sample numbers in the sample data exceed a preset value; and deduplicating the undersampled sample data to obtain a target sample.
[0095] In one embodiment, when a processor executes a computer program, it involves extracting features of a target sample through a Kalman filter algorithm to obtain a target feature group, including: performing a first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points; filtering the target sample through a Kalman filter algorithm, performing a first-order difference calculation on the filtered target sample to obtain a filtered first-order difference value; obtaining the difference between the target sample and the filtered target sample to obtain a filtered difference.
[0096] In one embodiment, when a processor executes a computer program, the first-order difference calculation on the filtered target sample is performed to obtain the filtered first-order difference value, including: according to a preset time interval, the first-order difference calculation on the filtered target sample is repeatedly performed multiple times to obtain the filtered first-order difference values corresponding to multiple time intervals.
[0097] In one embodiment, the training process of the random forest model involved in the execution of the computer program by the processor includes: obtaining multiple training samples from the training data set by sampling with replacement; each training sample consists of multiple feature values; for each training sample, randomly selecting a preset number of feature values as target features; training the nodes of the random forest model through the target features to obtain a single decision tree model; and combining all the single decision tree models to obtain a trained random forest model.
[0098] In one embodiment, when the processor executes the computer program, the target feature group is input into the trained random forest model to obtain the prediction results of each single decision tree model; all the prediction results are counted, and the fault detection results are obtained according to the statistical results output.
[0099] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: data preprocessing is performed on sample data of a microservice architecture to obtain a target sample; feature extraction is performed on the target sample by a Kalman filtering algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the filtered first-order difference value and the filtered difference value; the target feature group is input into a trained random forest model, and a fault detection result is obtained as an output.
[0100] In one embodiment, when a computer program is executed by a processor, it involves data preprocessing of sample data of a microservice architecture to obtain a target sample, including: oversampling the sample data of the microservice architecture to generate new samples in categories with insufficient numbers in the sample data; undersampling the oversampled sample data to reduce the number of samples in categories whose sample numbers in the sample data exceed a preset value; and deduplicating the undersampled sample data to obtain a target sample.
[0101] In one embodiment, when a computer program is executed by a processor, it involves extracting features of a target sample through a Kalman filter algorithm to obtain a target feature group, including: performing a first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points; filtering the target sample through a Kalman filter algorithm, performing a first-order difference calculation on the filtered target sample to obtain a filtered first-order difference value; obtaining the difference between the target sample and the filtered target sample to obtain a filtered difference.
[0102] In one embodiment, when a computer program is executed by a processor, the first-order difference calculation on the filtered target samples is performed to obtain the filtered first-order difference value, including: according to a preset time interval, the first-order difference calculation on the filtered target samples is repeated multiple times to obtain the filtered first-order difference values corresponding to multiple time intervals.
[0103] In one embodiment, the training process of the random forest model involved when the computer program is executed by the processor includes: obtaining multiple training samples from the training data set by adopting a sampling method with replacement; each training sample consists of multiple feature values; for each training sample, randomly selecting a preset number of feature values as target features; training the nodes of the random forest model through the target features to obtain a single decision tree model; and combining all the single decision tree models to obtain a trained random forest model.
[0104] In one embodiment, when the computer program is executed by a processor, the target feature group is input into a trained random forest model to obtain prediction results of each single decision tree model; all prediction results are counted, and fault detection results are obtained according to the statistical results output.
[0105] In one embodiment, a computer program product is provided, including a computer program, which implements the following steps when executed by a processor: performing data preprocessing on sample data of a microservice architecture to obtain a target sample; performing feature extraction on the target sample by a Kalman filtering algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the filtered first-order difference value and the filtered difference value; the target feature group is input into a trained random forest model, and a fault detection result is obtained as an output.
[0106] In one embodiment, when a computer program is executed by a processor, it involves data preprocessing of sample data of a microservice architecture to obtain a target sample, including: oversampling the sample data of the microservice architecture to generate new samples in categories with insufficient numbers in the sample data; undersampling the oversampled sample data to reduce the number of samples in categories whose sample numbers in the sample data exceed a preset value; and deduplicating the undersampled sample data to obtain a target sample.
[0107] In one embodiment, when a computer program is executed by a processor, it involves extracting features of a target sample through a Kalman filter algorithm to obtain a target feature group, including: performing a first-order difference calculation on the target sample to obtain the sum of the first-order differences between each data point in the target sample and the adjacent data points; filtering the target sample through a Kalman filter algorithm, performing a first-order difference calculation on the filtered target sample to obtain a filtered first-order difference value; obtaining the difference between the target sample and the filtered target sample to obtain a filtered difference.
[0108] In one embodiment, when a computer program is executed by a processor, the first-order difference calculation on the filtered target samples is performed to obtain the filtered first-order difference value, including: according to a preset time interval, the first-order difference calculation on the filtered target samples is repeated multiple times to obtain the filtered first-order difference values corresponding to multiple time intervals.
[0109] In one embodiment, the training process of the random forest model involved when the computer program is executed by the processor includes: obtaining multiple training samples from the training data set by adopting a sampling method with replacement; each training sample consists of multiple feature values; for each training sample, randomly selecting a preset number of feature values as target features; training the nodes of the random forest model through the target features to obtain a single decision tree model; and combining all the single decision tree models to obtain a trained random forest model.
[0110] In one embodiment, when the computer program is executed by a processor, the target feature group is input into a trained random forest model to obtain prediction results of each single decision tree model; all prediction results are counted, and fault detection results are obtained according to the statistical results output.
[0111] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0112] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0113] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A fault detection method for a microservice architecture, characterized in that: The method comprises: Perform data preprocessing on the sample data of the microservice architecture to obtain the target sample; Extracting features of the target sample by a Kalman filter algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the filtered first-order difference value and the filtered difference value; The target feature group is input into the trained random forest model, and the fault detection result is output.
2. The method according to claim 1, characterized in that The data preprocessing of the sample data of the microservice architecture to obtain the target sample includes: Oversampling the sample data of the microservice architecture to generate new samples in the categories that are under-represented in the sample data; Performing under-sampling processing on the sample data after the over-sampling processing to reduce the number of samples in the category whose sample number ratio in the sample data exceeds a preset value; The sample data after undersampling is deduplicated to obtain the target sample.
3. The method according to claim 1, characterized in that The feature extraction of the target sample by the Kalman filter algorithm to obtain a target feature group includes: Performing first-order difference calculation on the target sample to obtain the sum of first-order differences between each data point in the target sample and adjacent data points; The target samples are filtered by a Kalman filter algorithm, and a first-order difference calculation is performed on the filtered target samples to obtain a filtered first-order difference value; The difference between the target sample and the filtered target sample is obtained to obtain a filtered difference.
4. The method according to claim 3, characterized in that The first-order difference calculation is performed on the filtered target sample to obtain the filtered first-order difference value, including: According to the preset time interval, the first-order difference calculation is repeatedly performed on the filtered target samples for multiple times to obtain the filtered first-order difference values corresponding to multiple time intervals.
5. The method according to claim 1, characterized in that: The training process of the random forest model includes: A sampling method with replacement is adopted to obtain multiple training samples from the training data set; each training sample consists of multiple feature values; For each training sample, a preset number of feature values are randomly selected as target features; The nodes of the random forest model are trained by using the target features to obtain a single decision tree model; All single decision tree models are combined to obtain the trained random forest model.
6. The method according to claim 5, characterized in that The step of inputting the target feature group into the trained random forest model and outputting a fault detection result includes: Inputting the target feature group into the trained random forest model to obtain the prediction results of each single decision tree model; All prediction results are counted and the fault detection results are obtained based on the statistical results output.
7. A fault detection device for a microservice architecture, characterized in that: The device comprises: The data processing module is used to preprocess the sample data of the microservice architecture to obtain the target sample; A feature extraction module, used to extract features of the target sample by a Kalman filter algorithm to obtain a target feature group; the target feature group includes the sum of the first-order differences of the target sample, the filtered first-order difference value and the filtered difference value; The fault detection module is used to input the target feature group into the trained random forest model and output the fault detection result.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.