A database detection method, device, equipment and storage medium
Through the combination of sliding time window and anomaly detection model, the problem of inaccurate log parsing in the existing technology is solved, the accuracy and robustness of database detection are improved, and the reliability of detection results is ensured.
Patent Information
- Application Number
- CN202410933798.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-07-12
AI Technical Summary
Existing database anomaly detection models ignore changes in log content, resulting in inaccurate log parsing and inability to fully utilize contextual information, affecting the accuracy of detection results.
By obtaining the target log data of the index items to be detected in the database, using the sliding time window to vectorize and segment it, and combining the deformation bidirectional gated recurrent unit (Mogrifier BiGRU) and the self-attention layer to build an anomaly detection model to predict log events, and Historical log data is considered to train the initial detection model and improve detection accuracy.
It improves the accuracy of database detection results, can only affect a single sliding time window when the data sequence changes, takes into account changes in log content over time, and enhances the robustness of detection.
Smart Images

Figure CN118467403B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of database operation and maintenance, and in particular to a database detection method, device, equipment and storage medium. Background Art
[0002] At present, most enterprises store daily operation data in databases. The continuous and normal operation of databases is crucial to users. However, due to large data volume, complex data forms, unreasonable database settings, etc., database anomalies often occur. Existing technologies mainly use anomaly detection models to analyze various behavioral characteristics of database systems to detect whether there are anomalies in the database system.
[0003] However, existing anomaly detection models ignore the changes in log content in the database system, which can easily lead to problems in understanding log information during log parsing. In addition, when processing sequence data, the contextual information is not fully utilized, which may lead to the loss of log information and inaccurate understanding of the current time step. At the same time, over-reliance on time sequence is also easily affected by changes in the sequence data order, all of which will affect the accuracy of the detection results. Summary of the invention
[0004] The present disclosure provides a database detection method, device, equipment and storage medium to at least solve the above technical problems existing in the prior art.
[0005] According to a first aspect of the present disclosure, a database detection method is provided, the method comprising: obtaining target log data of a database indicator item to be detected within a target time range; segmenting the target log vector after vectorization of the target log data through a sliding time window to obtain a target log sequence; determining a possible log event set of a next sliding time window of the target time range based on the target log sequence through an anomaly detection model; if the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold, determining that the target log data is abnormal; the anomaly detection model is trained on an initial detection model based on historical log data of an indicator item related to a database operating state and historical log events corresponding to the historical log data, and the anomaly detection model is used to predict log events that may occur in the next sliding time window.
[0006] In one possible implementation, before determining the possible log event set of the next sliding time window of the target time range, it also includes: obtaining historical log data of indicator items related to the database operation status and historical log events corresponding to the historical log data; segmenting the historical log vector after the historical log data is vectorized through the sliding time window to obtain a historical log sequence; training the initial detection model based on the historical log sequence and the historical log events corresponding to the historical log vector to obtain the anomaly detection model, wherein the initial detection model includes a deformable bidirectional gated recurrent unit Mogrifier BiGRU layer, a self-attention layer and a fully connected layer.
[0007] In one embodiment, the loss function of the initial detection model is:
[0008]
[0009] in, is the loss function, is the total number of sliding time windows in the historical log sequence, is the total number of categories corresponding to the historical log events, is the i-th historical log event in the current sliding time window, is the output of the fully connected layer The probability of occurrence.
[0010] In one possible implementation, determining the possible log event set of the next sliding time window of the target time range includes: inputting the target log sequence into the Mogrifier BiGRU layer of the anomaly detection model, the Mogrifier BiGRU layer outputting the hidden state corresponding to each sliding time window in the target log sequence, the hidden state representing the context information of all target log vectors in the sliding time window; inputting the hidden state into the self-attention layer of the anomaly detection model, the self-attention layer outputting the association vector corresponding to each sliding time window in the target log sequence, the association vector representing the degree of association between the sliding time window and other sliding time windows; inputting the association vector into the fully connected layer of the anomaly detection model, the fully connected layer outputting the occurrence probability of each category of log events in the next sliding time window of the target time range; the possible log event set is composed of log events whose occurrence probability is greater than a second threshold.
[0011] In one possible implementation, the calculation formula for fusion attention in the self-attention layer is:
[0012]
[0013] in, For the fusion attention, is the query vector corresponding to each sliding time window, is the key vector corresponding to each sliding time window, is the value vector corresponding to each sliding time window, N is the total number of sliding time windows in the target log sequence, is the nth query vector in Q, is the transpose symbol, express The transposed vector of is the nth key vector in K, is the nth value vector in V, is the scaling factor.
[0014] In one embodiment, the activation function of the fully connected layer is:
[0015]
[0016] in, Characterize the activation function, is the i-th log event, for The corresponding weight vector, The weight matrix W is located at List, is the correlation vector corresponding to the i-th sliding time window in the target log sequence, is the jth log event, is the total number of categories corresponding to the log event, is the correlation vector With the weight vector The angle between.
[0017] In one possible implementation, it also includes: if the target log data is abnormal, determining the indicator item corresponding to the abnormal actual log event in the actual log event set that does not overlap with the possible log event set; and displaying the indicator item corresponding to the abnormal actual log event and the abnormal actual log event.
[0018] According to a second aspect of the present disclosure, a database detection device is provided, the device comprising: an acquisition module, used to acquire target log data of a database indicator item to be detected within a target time range; a segmentation module, used to segment the target log vector after the target log data is vectorized through a sliding time window to obtain a target log sequence; a first determination module, used to determine a possible log event set of a next sliding time window of the target time range based on the target log sequence through an anomaly detection model; a second determination module, used to determine that the target log data is abnormal if the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold; the anomaly detection model is trained on an initial detection model based on historical log data of an indicator item related to a database operating state and historical log events corresponding to the historical log data, and the anomaly detection model is used to predict log events that may occur in the next sliding time window.
[0019] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0020] at least one processor; and
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.
[0023] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method of the present disclosure.
[0024] The present invention discloses a database detection method, device, equipment and storage medium. First, target log data of a database indicator item to be detected within a target time range is obtained, and the target log vector after the target log data is vectorized is segmented through a sliding time window to obtain a target log sequence. Then, a possible log event set of the next sliding time window of the target time range is determined based on the target log sequence through an anomaly detection model. If the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold, the target log data is determined to be abnormal. Therefore, the anomaly detection model performs targeted detection on the features of the target log sequence with time as the dimension. Even if the data sequence of a sliding time window in the target log sequence changes, only the sliding time window will be affected. Moreover, the anomaly detection model takes into account the changes of the log content over time and the context information of each sliding time window in the target log sequence, which can improve the accuracy of the detection result.
[0025] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0027] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0028] Figure 1 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 1 ;
[0029] Figure 2 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 2 ;
[0030] Figure 3 A schematic diagram of the structure of the initial detection model in an embodiment of the present disclosure is shown;
[0031] Figure 4 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 3 ;
[0032] Figure 5 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 4 ;
[0033] Figure 6 A schematic diagram of the structure of a database detection device according to an embodiment of the present disclosure is shown;
[0034] Figure 7 A schematic diagram of the structure of a database detection system according to an embodiment of the present disclosure is shown;
[0035] Figure 8 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0036] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0037] Figure 1 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 1 ,like Figure 1 As shown, a database detection method includes:
[0038] Step S101, obtaining target log data of the indicator item to be detected in the database within a target time range.
[0039] In this embodiment, the indicator item to be detected is at least one of the indicator items related to the operating status of the database, and the target time range is the time range in which the indicator item to be detected needs to be detected. The user can select the indicator item to be detected and the target time range corresponding to the indicator item to be detected in the indicator management unit of the database detection system. The default value of the target time range in the indicator management unit is 1 hour, and the maximum value is two weeks. The target log data can be directly collected according to the indicator item to be detected and the target time range set by the user.
[0040] In one implementation method, the indicator items related to the database operation status include 25 indicator items in 7 indicator categories, and the indicator categories include capacity layer, resource layer, abnormal event layer, object layer, session layer, SQL (Structured Query Language) layer and parameter layer. The capacity layer includes 4 indicator items, namely, UNDO (undo) table space analysis, UNDO active block usage, table space and temporary table space usage; the resource layer includes 2 indicator items, namely, process usage and PGA (Program Global Area) usage; the abnormal event layer includes 7 indicator items, namely, abnormal GC (Global Cache) wait, common GC class wait, row-level lock wait, table-level lock wait, other ENQ (Enqueue) lock wait, Latch (latch) wait and Log File Sync (log file synchronization) wait; the object layer includes 1 indicator item, which is the statistical information expiration object; the session layer includes 2 indicator items, namely the total number of sessions and the number of active sessions; the SQL layer includes 8 indicator items, namely the TOPSQL (top SQL) indicator item that monitors the occupation of TEMP (temporary tablespace), the indicator layer includes the proportion of CPU Time (Central Processing Unit Time) in DB Time (Database Time), Redo Generated Per Sec (the amount of redo data generated per second), read IO (input / output, Input / Output) response time, write IO response time, physical write IO, physical read IO and RAC (real application cluster, Real Application Clusters) private network traffic is too high; the parameter layer includes 1 indicator item, which is a standard parameter comparison.
[0041] Step S102 , segmenting the target log vector obtained by vectorizing the target log data through a sliding time window to obtain a target log sequence.
[0042] In this embodiment, after obtaining the target log data, the unstructured target log data can be parsed into structured target log data, and then the structured target log data can be vectorized based on semantic word embedding and vocabulary information embedding to obtain the target log vector corresponding to the target log data, and then the target log vector can be segmented by a sliding time window to obtain a target log sequence, such as ,in, They respectively represent a sliding time window, each sliding time window includes a number of target log vectors, and the size of the sliding time window can be determined according to actual conditions, and this disclosure does not limit it.
[0043] Step S103: determine a possible set of log events in the next sliding time window of the target time range based on the target log sequence through an anomaly detection model.
[0044] In this embodiment, the anomaly detection model is trained based on the historical log data of the indicator items related to the database operation status and the historical log events corresponding to the historical log data. The anomaly detection model is used to predict the log events that may occur in the next sliding time window. After obtaining the target log sequence, the target log sequence is input into the anomaly detection model. The anomaly detection model outputs the possible log event set of the next sliding time window of the target time range, that is, the sliding time window The set of possible log events for the next sliding time window.
[0045] Step S104: If the overlap between the actual log event set and the possible log event set in the next sliding time window is less than a first threshold, it is determined that the target log data is abnormal.
[0046] In this embodiment, a set of actual log events that actually occur in the next sliding time window of the target time range is obtained. If the degree of overlap between the actual log events in the actual log event set and the possible log events in the possible log event set is less than a first threshold, the target log data is determined to be abnormal and an abnormal alarm can be issued.
[0047] In the present disclosure, firstly, the target log data of the to-be-detected index item of the database within the target time range is obtained, and the target log vector after the target log data is vectorized is segmented through a sliding time window to obtain a target log sequence, and then the possible log event set of the next sliding time window of the target time range is determined based on the target log sequence through an anomaly detection model. If the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold, the target log data is determined to be abnormal. Thus, the anomaly detection model performs targeted detection on the features of the target log sequence with time as the dimension. Even if the data sequence of a sliding time window in the target log sequence changes, it will only affect the sliding time window. Moreover, the anomaly detection model takes into account the changes of the log content over time and the context information of each sliding time window in the target log sequence, which can improve the accuracy of the detection result.
[0048] Figure 2 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 2 ,like Figure 2 As shown, before "determining a possible set of log events of the next sliding time window of the target time range" in step S103, a database detection method further includes:
[0049] Step S201, obtaining historical log data of indicator items related to the database operation status and historical log events corresponding to the historical log data.
[0050] In this embodiment, it is necessary to train an anomaly detection model. First, historical log data of indicator items related to the database operation status is obtained, and then the unstructured historical log data is parsed into structured historical log data. Then, based on semantic word embedding and vocabulary information embedding, the structured historical log data is vectorized to obtain the historical log vector corresponding to the historical log data. Since the historical log vectors of historical log data generated by the same historical log event have a closer vector distance, it is also necessary to classify the historical log data according to the historical log vector using a density-based application spatial clustering algorithm (DBSCAN, Density-Based Spatial Clustering of Applications with Noise) to determine the historical log event corresponding to each historical log data.
[0051] Step S202, segmenting the historical log vector after the historical log data is vectorized through a sliding time window to obtain a historical log sequence.
[0052] In this embodiment, after obtaining the historical log data and the historical log events corresponding to the historical log data, the historical log vector after the historical log data is vectorized can be segmented by a sliding time window to obtain a historical log sequence, such as ,in, They represent a sliding time window respectively. Each sliding time window includes several historical log vectors. Each historical log vector is marked with its corresponding historical log event.
[0053] Step S203: training the initial detection model based on the historical log sequence and the historical log events corresponding to the historical log vectors to obtain an anomaly detection model.
[0054] Figure 3 FIG. 4 shows a schematic diagram of the structure of the initial detection model in an embodiment of the present disclosure. Figure 3 As shown in the figure, the initial detection model includes a time series input layer, a deformable bidirectional gated recurrent unit Mogrifier BiGRU layer, a self-attention layer and a fully connected layer. The historical log sequence is input into the initial detection model through the time series input layer of the initial detection model to train the initial detection model, and an anomaly detection model can be obtained.
[0055] In one possible implementation, the loss function of the initial detection model is:
[0056]
[0057] in, is the loss function, is the total number of sliding time windows in the historical log sequence, is the total number of categories corresponding to historical log events, is the i-th historical log event in the current sliding time window, The output of the fully connected layer The probability of occurrence, Figure 3 The output Predict of the fully connected layer includes the occurrence probability of k historical log events in each sliding time window.
[0058] In the present disclosure, the initial detection model is connected to the self-attention layer after the Mogrifier BiGRU layer, which can calculate the importance of the input log event to the anomaly detection task, enhance the robustness of the anomaly detection model, and alleviate the problem of decreased anomaly detection performance caused by changes in statements in log data. In addition, the loss function of the initial detection model updates the weights of the anomaly detection model by minimizing the gradient descent loss between the input and output, so as to obtain a more accurate anomaly detection model.
[0059] Figure 4 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 3 ,like Figure 4 As shown, in step S103, "determining a possible set of log events for the next sliding time window of the target time range" includes:
[0060] Step S301, input the target log sequence to the Mogrifier BiGRU layer of the anomaly detection model, and the Mogrifier BiGRU layer outputs the hidden state corresponding to each sliding time window in the target log sequence.
[0061] In this embodiment, after obtaining the target log sequence, the target log sequence is input into the Mogrifier BiGRU layer of the anomaly detection model. In the Mogrifier BiGRU layer, each target log vector in the target log sequence corresponds to a Mogrifier BiGRU unit. The Mogrifier BiGRU layer constructs a forward GRU network structure and a backward GRU network structure respectively. The input of the forward GRU network structure at the tth moment is the candidate state. and the hidden state at the previous moment , output hidden state vector ; The input of the backward GRU network structure at time t is and the hidden state at the next moment , output hidden state vector ; The hidden state vector at time t is ,in represents the update gate, ⊙ represents vector multiplication, and ⊕ represents vector concatenation. The output sequence of the last hidden layer of the Mogrifier BiGRU layer is ,in, They are the hidden state vectors corresponding to each sliding time window in the target log sequence, and the hidden state vector represents the context information of all target log vectors in the sliding time window.
[0062] Step S302: Input the hidden state into the self-attention layer of the anomaly detection model, and the self-attention layer outputs the association vector corresponding to each sliding time window in the target log sequence.
[0063] In this embodiment, the hidden state output by the Mogrifier BiGRU layer is input into the self-attention layer of the anomaly detection model. The self-attention layer performs an operation on the hidden state. Each element in Apply linear transformation to obtain the query vector, key vector, and value vector corresponding to each sliding time window. , the key vector , value vector ,in, , and are all neural network parameters, which are adjusted during the calculation process with back propagation. For the hidden state vector of each sliding time window, the self-attention layer can determine the association vector corresponding to each sliding time window according to the query vector, the key vector and the value vector and output it, wherein the association vector represents the degree of association between the sliding time window and other sliding time windows.
[0064] In one embodiment, the calculation formula for fused attention in the self-attention layer is:
[0065]
[0066] in, To integrate attention, is the query vector corresponding to each sliding time window, is the key vector corresponding to each sliding time window, is the value vector corresponding to each sliding time window, N is the total number of sliding time windows in the target log sequence, is the nth query vector in Q, is the transpose symbol, express The transposed vector of is the nth key vector in K, is the nth value vector in V, is the scaling factor, and .
[0067] Step S303: input the association vector to the fully connected layer of the anomaly detection model, and the fully connected layer outputs the probability of occurrence of each category of log events in the next sliding time window of the target time range.
[0068] In this embodiment, the association vector output by the self-attention layer is input into the fully connected layer of the anomaly detection model. The fully connected layer maps the association vector into a k-dimensional probability vector, which represents the predicted probability distribution of k types of log events at time t. The activation function is used in the fully connected layer to normalize the value range of the occurrence probability of the i-th log event to [0,1].
[0069] In one embodiment, the activation function of the fully connected layer is:
[0070]
[0071] in, Representation activation function, is the i-th log event, for The corresponding weight vector, The weight matrix W is located at List, is the correlation vector corresponding to the i-th sliding time window in the target log sequence, is the jth log event, is the total number of categories corresponding to log events, is the correlation vector With the weight vector The angle between.
[0072] Step S304: Log events with occurrence probabilities greater than a second threshold form a possible log event set.
[0073] In this embodiment, the possible log event set is composed of log events whose occurrence probability is greater than the second threshold, or the first g log events with the highest occurrence probability are taken to form the possible log event set.
[0074] In this disclosure, in order to reduce the computational complexity of self-attention and avoid the excessive inner product affecting the initial detection network training and the efficiency of the anomaly detection model in predicting the possible log event set, the calculation formula of the fused attention in the self-attention layer is redesigned, that is, The calculation formula of , and because the database data form is complex, the activation function of the fully connected layer is redesigned, that is, The function tries to avoid the influence of different text lengths of different data sets on the results, which not only improves the efficiency of initial detection network training and anomaly detection model prediction of possible log event sets, but also ensures the accuracy of possible log event sets.
[0075] Figure 5 The following is a schematic diagram showing a process of a database detection method according to an embodiment of the present disclosure. Figure 4 ,like Figure 5 As shown, a database detection method includes:
[0076] Step S401, obtaining target log data of the indicator item to be detected in the database within a target time range.
[0077] Step S402 , segmenting the target log vector obtained by vectorizing the target log data through a sliding time window to obtain a target log sequence.
[0078] Step S403: determine a possible set of log events in the next sliding time window of the target time range based on the target log sequence through an anomaly detection model.
[0079] Step S404: If the overlap between the actual log event set and the possible log event set in the next sliding time window is less than a first threshold, it is determined that the target log data is abnormal.
[0080] The specific implementation details of step S401 to step S404 are similar to those of step S101 to step S104 and will not be repeated here.
[0081] Step S405: If the target log data is abnormal, determine the indicator items corresponding to the abnormal actual log events in the actual log event set that do not overlap with the possible log event set.
[0082] In this embodiment, if the target log data is abnormal, the actual log events in the actual log event set that do not overlap with the possible log event set are determined as abnormal actual log events, and the indicator items corresponding to the abnormal actual log events are identified.
[0083] Step S406, displaying the indicator items and the abnormal actual log events corresponding to the abnormal actual log events.
[0084] In this embodiment, the indicator items corresponding to the abnormal actual log events and the abnormal actual log events are returned to the database detection system for display. In one example, the display results can be shown in the following table 1:
[0085] Table 1
[0086]
[0087] In one possible implementation, all actual log events in the actual log event set, indicator items corresponding to the actual log events, and the status of the actual log events may also be returned to the database detection system for display.
[0088] In one possible implementation, a "result export" button is provided for each indicator category in the database detection system. By clicking the button, a status table can be output for all indicator items of the indicator category, showing detailed information of each indicator item.
[0089] In the present disclosure, the indicator items corresponding to the abnormal actual log events and the abnormal actual log events are displayed, which can facilitate operation and maintenance personnel to quickly locate problems and check related abnormal indicator items. By checking the abnormal indicator items, operation and maintenance personnel can further analyze the causes of the abnormalities and take corresponding measures to fix the problems to ensure the stability and normal operation of the database.
[0090] Figure 6 A schematic diagram of the structure of a database detection device according to an embodiment of the present disclosure is shown. Figure 6 As shown, a database detection device includes: an acquisition module 10, which is used to obtain target log data of a database indicator item to be detected within a target time range; a segmentation module 11, which is used to segment the target log vector after the target log data is vectorized through a sliding time window to obtain a target log sequence; a first determination module 12, which is used to determine the possible log event set of the next sliding time window of the target time range based on the target log sequence through an anomaly detection model; a second determination module 13, which is used to determine that the target log data is abnormal if the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold; wherein the anomaly detection model is based on the historical log data of the indicator item related to the database operation status and the historical log events corresponding to the historical log data, and the initial detection model is trained to obtain the anomaly detection model, and the anomaly detection model is used to predict the log events that may occur in the next sliding time window.
[0091] In one possible implementation, a database detection device also includes: a training module, used to obtain historical log data of indicator items related to the database operation status and historical log events corresponding to the historical log data; segmenting the historical log vector after the historical log data is vectorized through a sliding time window to obtain a historical log sequence; training an initial detection model based on the historical log sequence and the historical log events corresponding to the historical log vector to obtain an anomaly detection model, the initial detection model includes a deformable bidirectional gated recurrent unit Mogrifier BiGRU layer, a self-attention layer and a fully connected layer.
[0092] In one possible implementation, the loss function of the initial detection model in the training module is:
[0093]
[0094] in, is the loss function, is the total number of sliding time windows in the historical log sequence, is the total number of categories corresponding to historical log events, is the i-th historical log event in the current sliding time window, The output of the fully connected layer The probability of occurrence.
[0095] In one possible implementation, the first determination module 12 is also used to: input the target log sequence into the Mogrifier BiGRU layer of the anomaly detection model, the Mogrifier BiGRU layer outputs the hidden state corresponding to each sliding time window in the target log sequence, and the hidden state represents the context information of all target log vectors in the sliding time window; input the hidden state into the self-attention layer of the anomaly detection model, the self-attention layer outputs the association vector corresponding to each sliding time window in the target log sequence, and the association vector represents the degree of association between the sliding time window and other sliding time windows; input the association vector into the fully connected layer of the anomaly detection model, and the fully connected layer outputs the probability of occurrence of each category of log events in the next sliding time window of the target time range; and the possible log event set is composed of log events whose occurrence probability is greater than the second threshold.
[0096] In one embodiment, the calculation formula for fusion attention in the self-attention layer in the first determination module 12 is:
[0097]
[0098] in, To integrate attention, is the query vector corresponding to each sliding time window, is the key vector corresponding to each sliding time window, is the value vector corresponding to each sliding time window, N is the total number of sliding time windows in the target log sequence, is the nth query vector in Q, is the transpose symbol, express The transposed vector of is the nth key vector in K, is the nth value vector in V, is the scaling factor.
[0099] In one possible implementation, the activation function of the fully connected layer in the first determination module 12 is:
[0100]
[0101] in, Representation activation function, is the i-th log event, for The corresponding weight vector, The weight matrix W is located at List, is the correlation vector corresponding to the i-th sliding time window in the target log sequence, is the jth log event, is the total number of categories corresponding to log events, is the correlation vector With the weight vector The angle between.
[0102] In one possible implementation, a database detection device also includes: a display module, which is used to determine the indicator items corresponding to the abnormal actual log events in the actual log event set that do not overlap with the possible log event set if the target log data is abnormal; and display the indicator items and abnormal actual log events corresponding to the abnormal actual log events.
[0103] Figure 7 A schematic diagram of the structure of a database detection system according to an embodiment of the present disclosure is shown. Figure 7 As shown, a database detection system includes: a basic function unit 20, an indicator management unit 21, an anomaly detection unit 22 and a result display unit 23;
[0104] The basic function unit 20 is used to manage the basic functions in the database detection system;
[0105] The indicator management unit 21 is used to manage the indicator categories and indicator items in the database detection system;
[0106] The anomaly detection unit 22 is used to detect the target log data of the database to be detected index item within the target time range to obtain the detection result. The database detection method and the database detection device are applied to the anomaly detection unit;
[0107] The result display unit 23 is used to display the detection result sent by the abnormality detection unit.
[0108] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0109] Figure 8A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0110] like Figure 8 As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 to a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0111] A number of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0112] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as a database detection method. For example, in some embodiments, a database detection method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of a database detection method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform a database detection method in any other appropriate manner (e.g., by means of firmware).
[0113] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0114] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0115] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0116] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0117] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0118] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0119] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0120] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0121] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A database detection method, characterized in that: The method comprises: Obtain target log data of the database indicator item to be detected within the target time range; The target log vector after the target log data is vectorized is segmented through a sliding time window to obtain a target log sequence; Determine a possible set of log events for the next sliding time window of the target time range based on the target log sequence by using an anomaly detection model; If the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold, determining that the target log data is abnormal; The anomaly detection model is obtained by training an initial detection model based on historical log data of indicator items related to the database operation status and historical log events corresponding to the historical log data. The anomaly detection model is used to predict log events that may occur in the next sliding time window; Wherein, the determining of a possible set of log events of the next sliding time window of the target time range includes: Input the target log sequence to the Mogrifier BiGRU layer of the anomaly detection model, and the Mogrifier BiGRU layer outputs the hidden state corresponding to each sliding time window in the target log sequence, and the hidden state represents the context information of all target log vectors in the sliding time window; Inputting the hidden state into the self-attention layer of the anomaly detection model, the self-attention layer outputs the association vector corresponding to each sliding time window in the target log sequence, and the association vector represents the degree of association between the sliding time window and other sliding time windows; Input the association vector to the fully connected layer of the anomaly detection model, and the fully connected layer outputs the probability of occurrence of each category of log events in the next sliding time window of the target time range; The possible log event set is formed by the log events whose occurrence probability is greater than a second threshold; Among them, the calculation formula for fusion attention in the self-attention layer is: in, For the fusion attention, is the query vector corresponding to each sliding time window, is the key vector corresponding to each sliding time window, is the value vector corresponding to each sliding time window, N is the total number of sliding time windows in the target log sequence, is the nth query vector in Q, is the transpose symbol, express The transposed vector of is the nth key vector in K, is the nth value vector in V, is the scaling factor; Among them, the activation function of the fully connected layer is: in, Characterize the activation function, is the i-th log event, for The corresponding weight vector, The weight matrix W is located at List, is the correlation vector corresponding to the i-th sliding time window in the target log sequence, is the jth log event, is the total number of categories corresponding to the log event, is the correlation vector With the weight vector The angle between.
2. The method according to claim 1, characterized in that: Before determining a possible set of log events for a next sliding time window of the target time range, the method further includes: Obtaining historical log data of indicator items related to the database operation status and historical log events corresponding to the historical log data; The historical log vectors obtained by vectorizing the historical log data are segmented through a sliding time window to obtain a historical log sequence; The initial detection model is trained based on the historical log events corresponding to the historical log sequence and the historical log vector to obtain the anomaly detection model, wherein the initial detection model includes a deformable bidirectional gated recurrent unit Mogrifier BiGRU layer, a self-attention layer and a fully connected layer.
3. The method according to claim 2, characterized in that The loss function of the initial detection model is: in, is the loss function, is the total number of sliding time windows in the historical log sequence, is the total number of categories corresponding to the historical log events, is the i-th historical log event in the current sliding time window, is the output of the fully connected layer The probability of occurrence.
4. The method according to any one of claims 1 to 3, characterized in that: Also includes: If the target log data is abnormal, determining an indicator item corresponding to an abnormal actual log event in the actual log event set that does not overlap with the possible log event set; The indicator items corresponding to the abnormal actual log events and the abnormal actual log events are displayed.
5. A database detection device, characterized in that: The device comprises: An acquisition module is used to acquire target log data of the indicator item to be detected in the database within a target time range; A segmentation module, used for segmenting the target log vector after the target log data is vectorized through a sliding time window to obtain a target log sequence; A first determination module is used to determine a possible log event set of the next sliding time window of the target time range based on the target log sequence through an anomaly detection model; A second determination module, configured to determine that the target log data is abnormal if the overlap between the actual log event set of the next sliding time window and the possible log event set is less than a first threshold; The anomaly detection model is obtained by training an initial detection model based on historical log data of indicator items related to the database operation status and historical log events corresponding to the historical log data. The anomaly detection model is used to predict log events that may occur in the next sliding time window; Wherein, the determining of a possible set of log events of the next sliding time window of the target time range includes: Input the target log sequence to the Mogrifier BiGRU layer of the anomaly detection model, and the Mogrifier BiGRU layer outputs the hidden state corresponding to each sliding time window in the target log sequence, and the hidden state represents the context information of all target log vectors in the sliding time window; Inputting the hidden state into the self-attention layer of the anomaly detection model, the self-attention layer outputs the association vector corresponding to each sliding time window in the target log sequence, and the association vector represents the degree of association between the sliding time window and other sliding time windows; Input the association vector to the fully connected layer of the anomaly detection model, and the fully connected layer outputs the probability of occurrence of each category of log events in the next sliding time window of the target time range; The possible log event set is formed by the log events whose occurrence probability is greater than a second threshold; Among them, the calculation formula for fusion attention in the self-attention layer is: in, For the fusion attention, is the query vector corresponding to each sliding time window, is the key vector corresponding to each sliding time window, is the value vector corresponding to each sliding time window, N is the total number of sliding time windows in the target log sequence, is the nth query vector in Q, is the transpose symbol, express The transposed vector of is the nth key vector in K, is the nth value vector in V, is the scaling factor; Among them, the activation function of the fully connected layer is: in, Characterize the activation function, is the i-th log event, for The corresponding weight vector, The weight matrix W is located at List, is the correlation vector corresponding to the i-th sliding time window in the target log sequence, is the jth log event, is the total number of categories corresponding to the log event, is the correlation vector With the weight vector The angle between.
6. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1-4.
