Abnormality detection method and device, equipment, storage medium and program product
By combining the standardization of historical logs and trajectories with prediction models to calculate the status of logs and trajectories, the problem of low anomaly detection accuracy in the existing technology is solved, and more accurate system status judgment and alarms are achieved.
Patent Information
- Application Number
- CN202410835683.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-20
AI Technical Summary
The accuracy of anomaly detection in the existing technology is low, resulting in inaccurate alarm methods for data security maintenance.
By obtaining the historical log and the trajectory to be detected, standardize it into a log template and a trajectory template, and input it into the prediction model. Combine the prediction log and historical log, the predicted trajectory and the trajectory to be detected, and calculate the log status and trajectory error rate. If the system status is If an exception occurs, a warning message is output.
It improves the accuracy of anomaly detection, ensures that alarm information can be output in a timely manner when the system status is abnormal, and enhances the reliability of data security.
Smart Images

Figure CN118673489A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data security technology, and in particular to an anomaly detection method, device, equipment, storage medium and program product. Background Art
[0002] With the continuous development of information technology, the importance of data security has become increasingly prominent.
[0003] At present, the method of maintaining data security in the prior art usually adopts obtaining log data and performing distributed trajectory tracking, and warnings are issued for abnormal logs and abnormal distributed trajectories by setting alarm rules.
[0004] However, the inventors have discovered that the prior art has at least the following technical problems: the accuracy of current anomaly detection is low. Summary of the invention
[0005] The present application provides an anomaly detection method, apparatus, device, storage medium and program product to solve the problem of low accuracy of anomaly detection.
[0006] In a first aspect, the present application provides an anomaly detection method, including: obtaining historical logs, trajectories to be detected, and historical trajectories; standardizing historical logs and historical trajectories to obtain log templates and trajectory templates; inputting log templates and trajectory templates into a prediction model to obtain predicted logs and predicted trajectories; determining log status based on predicted logs and historical logs; determining trajectory error rate based on predicted trajectories and trajectories to be detected; determining system status based on log status and trajectory error rate; and outputting a warning message if the system status is abnormal.
[0007] In a possible implementation, the log status is determined according to the predicted log and the historical log, including: if any historical log includes all fields of the predicted log, normal is determined as the log status, otherwise abnormal is determined as the log status.
[0008] In a possible implementation, the predicted trajectory includes at least one predicted interval, and the trajectory to be detected includes at least one interval to be detected; accordingly, the trajectory error rate is determined according to the predicted trajectory and the trajectory to be detected, including: calculating the interval similarity between the interval to be detected and the predicted interval; determining the predicted interval whose interval similarity is less than a preset value as an error interval; and dividing the number of error intervals by the total number of predicted intervals to obtain the trajectory error rate.
[0009] In a possible implementation, determining a trajectory error rate according to the predicted trajectory and the trajectory to be detected includes: calculating a trajectory similarity between the predicted trajectory and the trajectory to be detected; and subtracting the trajectory similarity from a preset value to obtain the trajectory error rate.
[0010] In a possible implementation, before inputting the standard log and the standard trajectory into the prediction model to obtain the prediction log and the prediction trajectory, it also includes: obtaining the training detection log, the historical training log, the training detection trajectory, the historical training trajectory, the standard log template and the standard trajectory template; standardizing the historical training log and the historical training trajectory to obtain the standard training log and the standard training trajectory; inputting the standard training log and the standard training trajectory into the prediction model to be trained to obtain the training prediction log and the training prediction trajectory output by the prediction model to be trained; in the standard log template, determining the target standard log template corresponding to the training detection log; in the standard trajectory template, determining the target standard trajectory template corresponding to the training detection trajectory; using the target standard log template, the target standard trajectory template, the training prediction log and the training prediction trajectory to determine the joint loss; if the joint loss is greater than or equal to the preset error threshold, using the joint loss to optimize the prediction model to be trained, and repeatedly executing the steps of obtaining training data to determining the joint loss until the joint loss is less than the preset error threshold, and the prediction model to be trained is determined as the prediction model.
[0011] In a possible implementation, in the standard log template, determining the target standard log template corresponding to the training detection log includes: segmenting the training detection log to obtain at least one training word; matching the training word with the standard log template, if the match is successful, determining the successfully matched annotated log template as the target standard log template, if the match fails, using the longest common subsequence algorithm to determine the target standard log template that matches the training word with the standard log template.
[0012] In the second aspect, the present application provides an anomaly detection device, including: a data acquisition module, used to acquire historical logs, historical logs, trajectories to be detected and historical trajectories; a standardization module, used to standardize historical logs and historical trajectories to obtain log templates and trajectory templates; a prediction module, used to input the log template and trajectory template into a prediction model to obtain a predicted log and a predicted trajectory; a first determination module, used to determine the log status according to the predicted log and the historical log; a second determination module, used to determine the trajectory error rate according to the predicted trajectory and the trajectory to be detected; a third determination module, used to determine the system status according to the log status and the trajectory error rate; an information output module, used to output a warning message if the system status is abnormal.
[0013] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the anomaly detection method described in the first aspect.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the anomaly detection method described in the first aspect.
[0015] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the anomaly detection method described in the first aspect.
[0016] The anomaly detection method, apparatus, device, storage medium and program product provided by the present application obtain historical logs, trajectories to be detected and historical trajectories, standardize the historical logs and historical trajectories, obtain log templates and trajectory templates, combine the log templates and trajectory templates with the prediction model to obtain predicted logs and predicted trajectories, determine the log status in combination with the predicted logs and historical logs, determine the trajectory error rate in combination with the predicted trajectory and the trajectory to be detected, and output alarm information when the system status is determined to be abnormal based on the log status and the trajectory error rate, thereby accurately determining the system status and issuing an alarm when the system status is abnormal. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 A schematic diagram of an application scenario of the anomaly detection method provided in an embodiment of the present application;
[0019] Figure 2 A flowchart of an anomaly detection method provided in an embodiment of the present application;
[0020] Figure 3 A schematic diagram of the structure of an abnormality detection device provided in an embodiment of the present application;
[0021] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0022] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0023] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0024] With the rapid development of information technology, data security has become a core issue that cannot be ignored. Faced with an increasingly complex network environment, ensuring the integrity and confidentiality of data has become a topic that must be addressed by enterprises and even the entire society.
[0025] The existing data security maintenance strategy is no longer satisfied with traditional passive defense, but adopts a more advanced method - intelligent analysis of log data and real-time tracking of distributed trajectories. By pre-setting alarm rules, once the logs and trajectories trigger the preset alarm rule threshold, the emergency response mechanism will be immediately activated to send an alarm to the administrator to ensure the safety of the data. However, the alarm method in the existing technology has low accuracy.
[0026] In response to the above technical problems, the inventors proposed the following technical concept: by obtaining historical logs, trajectories to be detected and historical trajectories, converting historical logs and historical trajectories into log templates and trajectory templates, and inputting the log templates and trajectory templates into the prediction model, obtaining the predicted logs and predicted trajectories output by the prediction model, combining the predicted trajectory, the trajectory to be detected, the predicted logs and the historical logs, determining the system status, and outputting alarm information when the system status is abnormal.
[0027] This application is used in the scenario of anomaly detection. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0028] Figure 1 Schematic diagram of application scenarios of the anomaly detection method provided in the embodiment of the present application. Figure 1 , this scenario includes: terminal device 101 and server 102.
[0029] In the specific implementation process, the terminal device 101 may include a computer, a server, a tablet, a mobile phone, a PDA (Personal Digital Assistant) and a notebook, etc., which can input data.
[0030] The server 102 can be implemented using a server or a cluster of multiple servers with more powerful processing capabilities and higher security. If possible, it can also be replaced by a computer, laptop, etc. with stronger computing power.
[0031] The connection between the server 102 and the terminal device 101 can be a wired connection or a wireless connection.
[0032] The server 102 is used to accept access from the terminal device 101, generate log information and track information according to the access and operation activities, and determine whether there is an abnormal state according to the log information and track information.
[0033] It is understandable that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the anomaly detection method. In other feasible implementations of the present application, the above architecture may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently, which can be determined according to the actual application scenario and is not limited here. Figure 1 The components shown may be implemented by hardware, software, or a combination of software and hardware.
[0034] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0035] Figure 2 A flowchart of an abnormality detection method provided in an embodiment of the present application. The execution subject of the embodiment of the present application may be Figure 1 The server in the embodiment may also be a computer and / or a mobile phone, etc., and this embodiment does not impose any special restrictions on this. Figure 2 As shown, the method includes:
[0036] S201: Obtain historical logs, tracks to be detected, and historical tracks.
[0037] In this step, the historical log may include a log generated before the historical log, the trajectory to be detected may be a trajectory newly generated by the server system, or a trajectory that has not been detected by the server, and the historical trajectory may be a trajectory generated by the server system.
[0038] Among them, the historical log, the trajectory to be detected and the historical trajectory may contain various information about the specific operation being performed.
[0039] S202: Standardize the historical logs and historical tracks to obtain a log template and a track template.
[0040] In this step, the log may consist of a constant part and a variable part, which are respectively referred to as a log template and a log parameter. Since the parameters have a large variability, a common method for representing a log is to extract the constant part through a log parsing process, that is, to create a standard log template from a given log; it may also include removing the variables in the historical log and determining the remaining part as a standard log. The maximum size of the log template is limited by the maximum log size parameter. The process of standardizing the historical trajectory may include first constructing a collection of character sequences that appear in the historical trajectory, extracting the character sequence from the interval collection, obtaining each interval of the trajectory template, and splicing each interval to obtain the trajectory template. In the case where there are different numbers of intervals in the trajectory template, a preset mark is added to expand the trajectory template containing a smaller number of intervals so that the number of intervals in the trajectory template is unified. The standardization process may also include initializing each word of a specific length using a random vector.
[0041] S203: Input the log template and the trajectory template into the prediction model to obtain the predicted log and the predicted trajectory.
[0042] In this step, the prediction model can be an LSTM (Long Short-Term Memory) model; it can also include two LSTM connections, and an additional linear layer feed, an LSTM input log template, and an LSTM input trajectory template to obtain the predicted log and predicted trajectory output by the linear layer. The prediction model can use a normalized exponential function to filter the predicted logs and trajectories, and retain the logs and trajectories with higher credibility as the predicted logs and predicted trajectories respectively.
[0043] S204: Determine the log status according to the predicted log and the historical log.
[0044] In this step, the similarity between the historical log and the predicted log may be calculated, and the log status may be determined according to whether the similarity exceeds a preset status threshold.
[0045] S205: Determine a trajectory error rate according to the predicted trajectory and the trajectory to be detected.
[0046] In this step, the cosine similarity between the predicted trajectory and the trajectory to be detected may be calculated, and the trajectory error rate may be calculated using the cosine similarity.
[0047] S206: Determine the system status according to the log status and the trajectory error rate.
[0048] In this step, if the log status is normal and the trajectory error rate is less than the preset error rate threshold, normal is determined as the system status, otherwise abnormal is determined as the system status.
[0049] S207: If the system status is abnormal, a warning message is output.
[0050] In this step, the preset alarm information may be sent to the alarm terminal; or the log status and the trajectory error rate may be written into the preset alarm information template to obtain the alarm information.
[0051] From the description of the above embodiments, it can be seen that the embodiments of the present application obtain historical logs, trajectories to be detected and historical trajectories, standardize historical logs and historical trajectories, obtain log templates and trajectory templates, combine the log templates and trajectory templates with the prediction model to obtain predicted logs and predicted trajectories, determine the log status in combination with the predicted logs and historical logs, determine the trajectory error rate in combination with the predicted trajectory and the trajectory to be detected, and output alarm information when the system status is determined to be abnormal based on the log status and the trajectory error rate, so as to accurately determine the system status and issue an alarm when the system status is abnormal.
[0052] In a possible implementation, in the above step S204, determining the log status according to the predicted log and the historical log includes:
[0053] S204A1: Calculate the similarity between the predicted log and at least one historical log to obtain a target similarity corresponding to the historical log.
[0054] In this step, the cosine similarity between the predicted log and the historical log may be calculated as the target similarity.
[0055] S204A2: If any target similarity is greater than or equal to a preset log similarity threshold, normal is determined as the log state, otherwise abnormal is determined as the log state.
[0056] In this step, the log similarity threshold may be preset by the staff based on experimental data or empirical parameters.
[0057] From the description of the above embodiments, it can be seen that the embodiments of the present application calculate the similarity between the predicted log and the historical log, and when the similarity corresponding to the historical log is greater than the preset log similarity threshold, determine that the log status is normal, thereby increasing the accuracy of the log status judgment.
[0058] In a possible implementation, in the above step S204, determining the log status according to the predicted log and the historical log includes:
[0059] S204B1: If any historical log includes all fields of the predicted log, normal is determined as the log state, otherwise abnormal is determined as the log state.
[0060] In this step, it can include searching for fields in the predicted log in the target historical log. If all fields in the predicted log can be found, normal is determined as the log state, where the target historical log is any historical log. If all fields in the predicted log are not found, the historical log that has not been searched is determined as the new target historical log, and the search is performed again until all fields in the predicted log are found, and normal is determined as the log state, or until all fields in the predicted log are not found after traversing all historical logs, abnormal is determined as the log state.
[0061] From the description of the above embodiments, it can be seen that the embodiments of the present application determine whether the log status is abnormal by comparing historical logs and predicted logs, thereby increasing the accuracy of log status determination and thus also increasing the accuracy of server abnormal status determination.
[0062] In a possible implementation, the predicted trajectory includes at least one predicted interval, and the trajectory to be detected includes at least one to be detected interval.
[0063] Accordingly, in the above step S205, the trajectory error rate is determined according to the predicted trajectory and the trajectory to be detected, including:
[0064] S2051: Calculate the interval similarity between the interval to be detected and the predicted interval.
[0065] In this step, the cosine similarity between the interval to be detected and the predicted interval may be calculated, and the cosine similarity may be determined as the interval similarity; or the similarity between the interval to be detected and the predicted interval may be calculated using a normalized exponential function.
[0066] S2052: Determine the prediction interval whose interval similarity is less than a preset value as an error interval.
[0067] In this step, the preset value may be preset by the staff according to experimental data or empirical parameters.
[0068] For example, if the preset value is 0.85, and the interval similarity corresponding to prediction interval A is 0.7, then prediction interval A is an error interval. For another example, if the preset value is 0.92, and the interval similarity corresponding to prediction interval B is 0.9, then prediction interval B is an error interval.
[0069] S2053: Divide the number of error intervals by the total number of prediction intervals to obtain a trajectory error rate.
[0070] In this step, for example, if there are 10 prediction intervals in the predicted trajectory, of which 4 are erroneous intervals, the trajectory error rate is 40%; for another example, if there are 20 prediction intervals, of which 2 are erroneous intervals, the trajectory error rate is 10%; for another example, if there are 8 prediction intervals, of which 1 is erroneous interval, the trajectory error rate is 0.125.
[0071] From the description of the above embodiments, it can be seen that the embodiments of the present application calculate the interval similarity between the interval to be detected and the predicted interval, and determine the predicted interval whose interval similarity is less than the preset value as an error interval. The trajectory error rate is obtained by combining the number of error intervals and the total number of predicted intervals, so as to facilitate the subsequent use of the trajectory error rate to determine whether the trajectory data is abnormal.
[0072] In a possible implementation, in the above step S205, determining the trajectory error rate according to the predicted trajectory and the trajectory to be detected includes:
[0073] S2051: Calculate the trajectory similarity between the predicted trajectory and the trajectory to be detected.
[0074] In this step, it may include calculating the cosine similarity between the predicted trajectory and the trajectory to be detected; it may also include determining the interval in the predicted trajectory as the predicted interval, determining the interval in the trajectory to be detected as the interval to be detected, determining the number of identical intervals in the predicted interval that are identical to the interval to be detected, and dividing the number of identical intervals by the total number of predicted intervals to obtain trajectory similarity.
[0075] S2052: Subtract the trajectory similarity from the preset value to obtain the trajectory error rate.
[0076] In this step, the preset value, such as 1, may also be a parameter value set by other staff based on experience.
[0077] From the description of the above embodiments, it can be seen that the embodiments of the present application calculate the trajectory similarity between the predicted trajectory and the trajectory to be detected, and calculate the trajectory error rate based on the trajectory similarity, so as to accurately judge the deviation between the predicted trajectory and the actual trajectory, thereby facilitating the subsequent judgment of whether the system is abnormal.
[0078] In a possible implementation, before the standard log and the standard trajectory are input into the prediction model to obtain the predicted log and the predicted trajectory in step S203, the following is further included:
[0079] S220: Obtain training detection logs, historical training logs, training detection trajectories, historical training trajectories, standard log templates, and standard trajectory templates.
[0080] In this step, it can include reading training detection logs, historical training logs, training detection trajectories, historical training trajectories, standard log templates and standard trajectory templates from the database. These data can be extracted from actual data or pre-entered by staff.
[0081] In addition, there may be missing logs within a specific time range. In this case, the data that lacks the target value is marked and removed from the historical training log to ensure that the model training is not affected. In this way, the existing data can be used more effectively to improve the prediction accuracy and stability of the model. When creating a log message block, the method adopted includes connecting all log messages from the start time of the first interval to the end time of the last interval into a block, so as to facilitate accurate prediction of the next expected log.
[0082] S221: Standardize the historical training logs and historical training trajectories to obtain standard training logs and standard training trajectories.
[0083] This step is similar to the above step S202 and will not be repeated here.
[0084] S222: Input the standard training log and the standard training trajectory into the prediction model to be trained, and obtain the training prediction log and the training prediction trajectory output by the prediction model to be trained.
[0085] This step is similar to the above step S203 and will not be repeated here.
[0086] S223: Determine, in the standard log template, a target standard log template corresponding to the training detection log.
[0087] In this step, the training detection log may be standardized to obtain a training detection log template, the similarity between the training detection log template and each standard log template may be calculated, and the standard log template with the highest similarity may be determined as the target standard log template.
[0088] S224: Determine, in the standard trajectory template, a target standard trajectory template corresponding to the training detection trajectory.
[0089] This step may be similar to the above step S223; it may also include calculating the similarity between the standard trajectory template and each standard trajectory template, and determining the standard trajectory template with the highest similarity as the target standard trajectory template; it may also include inputting the training detection trajectory and the standard trajectory template into the Chameleon algorithm, and the Chameleon algorithm selects the target standard trajectory template from the standard trajectory template.
[0090] S225: Determine the joint loss using the target standard log template, the target standard trajectory template, the training prediction log, and the training prediction trajectory.
[0091] In this step, it can include calculating the log classification cross entropy loss between the target standard log template and the training prediction log, calculating the trajectory classification cross entropy loss between the target standard trajectory template and the training prediction trajectory, and summing the log classification cross entropy loss and the trajectory classification cross entropy loss to obtain the total classification cross entropy loss.
[0092] The calculation method of the joint loss can be expressed as follows:
[0093] L((s,l),f(x,y))=L(f(x),s)+L(f(y),l)
[0094] where L(·,·) represents the categorical cross entropy loss, L((s,l),f(x,y)) represents the joint loss, s and l represent the target standard trajectory template and the target standard log template, respectively, x and y represent the training prediction log and the training prediction trajectory, respectively, f(x) represents the function of the training prediction log, and f(y) represents the function of the training prediction trajectory.
[0095] S226: If the joint loss is greater than or equal to the preset error threshold, the joint loss is used to optimize the prediction model to be trained, and the steps of obtaining training data to determining the joint loss are repeated until the joint loss is less than the preset error threshold, and the prediction model to be trained is determined as the prediction model.
[0096] In this step, the step of acquiring training data may be the above-mentioned step S220, the step of determining the joint loss may be the above-mentioned step S225, and the preset error threshold may be set by the staff according to experimental data or empirical parameters.
[0097] From the description of the above embodiments, it can be seen that the embodiments of the present application obtain training detection logs, historical training logs, training detection trajectories, historical training trajectories, standard log templates and standard trajectory templates, standardize the historical training logs and historical training trajectories and input them into the prediction model to be trained, obtain the training prediction logs and training prediction trajectories output by the prediction model to be trained, find the target standard log templates and target standard trajectory templates corresponding to the training detection logs and training detection trajectories, optimize the model after calculating the joint loss, obtain the prediction model, realize model training based on the comprehensive logs and trajectories, and facilitate the subsequent use of the prediction model to predict the logs and trajectories.
[0098] In a possible implementation, in the above step S223, determining the target standard log template corresponding to the training detection log in the standard log template includes:
[0099] S2231: Segment the training detection log into words to obtain at least one training word.
[0100] In this step, any one of the maximum matching word segmentation algorithm, the shortest path word segmentation algorithm, the generative model word segmentation algorithm, the discriminative model word segmentation algorithm, the neural network word segmentation algorithm, etc. may be used to segment words to obtain training words.
[0101] S2232: Match the training words with the standard log template. If the match is successful, determine the successfully matched annotated log template as the target standard log template. If the match fails, use the longest common subsequence algorithm to determine the target standard log template that matches the training words with the standard log template.
[0102] In this step, the matching method may be implemented by using any one of the linear fast matching algorithm, the naive matching algorithm, the KMP (Knuth-Morris-Pratt) algorithm, the DFA (Deterministic Finite Automaton) algorithm, etc. The longest common subsequence (LCS) algorithm is used to determine the target standard log template that matches the training word with the standard log template, including generating an inverted index file corresponding to the standard log template, inputting the inverted index file and the training word into the LCS algorithm, obtaining the longest common subsequence output by the LCS algorithm, and determining the longest common subsequence as the target standard log template.
[0103] From the description of the above embodiments, it can be seen that the embodiments of the present application segment the training detection log to obtain training words, use the training words and the standard log template for the first match, and directly use the matched annotation log template to determine the target standard log template if the match is successful. If the match fails, the longest common subsequence algorithm is used for a second match to obtain the target standard log template, thereby achieving the effect of reducing matching time and reducing resource usage.
[0104] From the description of the above embodiment, it can be seen that in the above embodiment, if the predicted log can match any of the previous several historical logs (which can be a previously preset time length), the log status is determined to be normal; otherwise, the log status is determined to be abnormal.
[0105] For anomaly detection of trajectory data, the decision process needs to comprehensively consider the prediction accuracy of all intervals in the predicted trajectory. Specifically, if for a given interval, the similarity between the true interval and the predicted interval exceeds a preset value, then we consider that the interval is correctly predicted. For each trajectory, we count the number of correctly predicted intervals and calculate a cumulative value based on this. Correspondingly, the ratio of the incorrectly predicted interval to the trajectory length is calculated, and this ratio will be used as the anomaly score of the trajectory. By setting a suitable threshold score, abnormal trajectory detection can be effectively performed.
[0106] In one possible implementation, the process of normalizing the logs may include creating a set of word indices from the tokens representing the vocabulary of all tokens in the logs. Words are retrieved from the set of word indices by means of indices to form log templates. Traces, i.e. distributed traces, are a request-centric way to describe behavior within a distributed system. This information represents information about the operations performed in a service when processing an external request (e.g., start time, end time, service name, Hypertext Transfer Protocol path). The intervals of a trace usually represent calls, indicating the interconnection between intervals within the trace. HTTP calls are described by paths, schemes, and methods. RPC calls are represented by the functions they are executing. At the same time, two intervals (start interval and end interval) are added to the beginning and end of the trace respectively, thereby retaining the knowledge of the length of the trace. Intervals represented in this form have a similar representation to logs, but with the additional constraint that the intervals are further restricted by the operations performed in the trace. This means that they also face the problem of noise entering the representation caused by different parameters. Similar to logs, applying template extraction techniques generates a set of representative template intervals. It allows each trajectory to be represented as a sequence of template ranges.
[0107] Each function call invoked is a sequence of characters, so a set of character sequences that appear in a given set of trajectories is constructed. The set of character sequences provides a way to describe all the intervals that appear in a trajectory. Since there are different numbers of intervals, in order to provide an appropriate format for subsequent processing, each trajectory is augmented with preset markers to make the number of intervals uniform.
[0108] Figure 3 This is a schematic diagram of the structure of the abnormality detection device provided in the embodiment of the present application. Figure 3 As shown, the abnormality detection device 300 includes: a data acquisition module 301, a standardization module 302, a prediction module 303, a first determination module 304, a second determination module 305, a third determination module 306 and an information output module 307.
[0109] The data acquisition module 301 is used to obtain historical logs, historical logs, trajectories to be detected and historical trajectories;
[0110] A standardization module 302 is used to standardize historical logs and historical tracks to obtain log templates and track templates;
[0111] Prediction module 303, used to input the log template and the trajectory template into the prediction model to obtain the predicted log and the predicted trajectory;
[0112] A first determination module 304 is used to determine the log status according to the predicted log and the historical log;
[0113] A second determination module 305 is used to determine a trajectory error rate according to the predicted trajectory and the trajectory to be detected;
[0114] A third determination module 306 is used to determine the system status according to the log status and the trajectory error rate;
[0115] The information output module 307 is used to output warning information if the system status is abnormal.
[0116] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0117] In a possible implementation, the first determination module 304 is specifically configured to determine normal as the log state if any historical log includes all fields of the predicted log, and otherwise determine abnormal as the log state.
[0118] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0119] In a possible implementation, the predicted trajectory includes at least one predicted interval, and the trajectory to be detected includes at least one interval to be detected; accordingly, the second determination module 305 is specifically used to calculate the interval similarity between the interval to be detected and the predicted interval; determine the predicted interval whose interval similarity is less than a preset value as an error interval; and divide the number of error intervals by the total number of predicted intervals to obtain a trajectory error rate.
[0120] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0121] In a possible implementation, the second determination module 305 is specifically configured to calculate the trajectory similarity between the predicted trajectory and the trajectory to be detected; and obtain the trajectory error rate by subtracting the trajectory similarity from a preset value.
[0122] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0123] In a possible implementation, the anomaly detection device 300 further includes: a model training module 308 .
[0124] The model training module 308 is used to obtain training detection logs, historical training logs, training detection trajectories, historical training trajectories, standard log templates and standard trajectory templates; standardize historical training logs and historical training trajectories to obtain standard training logs and standard training trajectories; input the standard training logs and standard training trajectories into the prediction model to be trained to obtain the training prediction logs and training prediction trajectories output by the prediction model to be trained; in the standard log template, determine the target standard log template corresponding to the training detection log; in the standard trajectory template, determine the target standard trajectory template corresponding to the training detection trajectory; use the target standard log template, the target standard trajectory template, the training prediction log and the training prediction trajectory to determine the joint loss; if the joint loss is greater than or equal to the preset error threshold, use the joint loss to optimize the prediction model to be trained, and repeat the steps of obtaining training data to determining the joint loss until the joint loss is less than the preset error threshold, and the prediction model to be trained is determined as the prediction model.
[0125] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0126] In a possible implementation, the model training module 308 is specifically used to segment the training detection log into words to obtain at least one training word; match the training word with the standard log template, if the match is successful, determine the successfully matched annotated log template as the target standard log template, if the match fails, use the longest common subsequence algorithm to determine the target standard log template that matches the training word with the standard log template.
[0127] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0128] In order to implement the above embodiment, the embodiment of the present application also provides an electronic device.
[0129] refer to Figure 4 , which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present application, and the electronic device 400 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0130] like Figure 4 As shown, the electronic device 400 may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 401, and a memory 402 connected to the processor in communication, which can perform various appropriate actions and processes according to the program stored in the memory 402, the computer execution instruction, or the program loaded from the storage device 408 to the random access memory (Random Access Memory, referred to as RAM) 403, to implement the abnormality detection method in any of the above embodiments, wherein the memory can be a read-only memory (Read Only Memory, referred to as ROM). In RAM403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the memory 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0131] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0132] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the memory 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0133] It should be noted that the computer-readable storage medium mentioned above in the present application may be a computer-readable signal medium or a computer storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable storage medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0134] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0135] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.
[0136] The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0137] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0138] The modules involved in the embodiments of the present application may be implemented by software or hardware. The name of the unit does not limit the module itself in some cases. For example, the standardization module may also be described as a "data standardization module".
[0139] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0140] The present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the processor executes the computer-executable instructions, the technical solution of the anomaly detection method in any of the above-mentioned embodiments is implemented. Its implementation principle and beneficial effects are similar to those of the anomaly detection method. Please refer to the implementation principle and beneficial effects of the anomaly detection method, which will not be repeated here.
[0141] In the context of the present application, 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 equipment, 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.
[0142] The present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the technical solution of the anomaly detection method in any of the above embodiments. Its implementation principle and beneficial effects are similar to those of the anomaly detection method. Please refer to the implementation principle and beneficial effects of the anomaly detection method, which will not be repeated here.
[0143] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
[0144] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0145] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. An anomaly detection method, It is characterized in that include: Obtain historical logs, trajectories to be detected, and historical trajectories; Standardizing the historical log and the historical track to obtain a log template and a track template; Inputting the log template and the trajectory template into a prediction model to obtain a prediction log and a prediction trajectory; Determining a log status according to the predicted log and the historical log; Determining a trajectory error rate according to the predicted trajectory and the trajectory to be detected; Determining a system state according to the log state and the trajectory error rate; If the system status is abnormal, a warning message is output.
2. The method according to claim 1, It is characterized in that The determining the log status according to the predicted log and the historical log includes: If any historical log includes all the fields of the predicted log, normal is determined as the log state, otherwise abnormal is determined as the log state.
3. The method according to claim 1, It is characterized in that The predicted trajectory includes at least one predicted interval, and the to-be-detected trajectory includes at least one to-be-detected interval; Accordingly, determining the trajectory error rate according to the predicted trajectory and the trajectory to be detected includes: Calculating the interval similarity between the to-be-detected interval and the predicted interval; The prediction interval whose interval similarity is less than a preset value is determined as an error interval; The number of error intervals is divided by the total number of prediction intervals to obtain the trajectory error rate.
4. The method according to claim 1, It is characterized in that The determining of the trajectory error rate according to the predicted trajectory and the trajectory to be detected includes: Calculating the trajectory similarity between the predicted trajectory and the trajectory to be detected; The trajectory error rate is obtained by subtracting the trajectory similarity from a preset value.
5. The method according to any one of claims 1 to 4, It is characterized in that Before inputting the standard log and the standard trajectory into a prediction model to obtain a prediction log and a prediction trajectory, the method further includes: Obtain training and detection logs, historical training logs, training and detection trajectories, historical training trajectories, standard log templates, and standard trajectory templates; Standardizing the historical training log and the historical training track to obtain a standard training log and a standard training track; Inputting the standard training log and the standard training trajectory into the prediction model to be trained, and obtaining the training prediction log and the training prediction trajectory output by the prediction model to be trained; In the standard log template, determining a target standard log template corresponding to the training detection log; In the standard trajectory template, determining a target standard trajectory template corresponding to the training detection trajectory; Determine a joint loss using the target standard log template, the target standard trajectory template, the training prediction log, and the training prediction trajectory; If the joint loss is greater than or equal to a preset error threshold, the joint loss is used to optimize the prediction model to be trained, and the steps of obtaining training data to determining the joint loss are repeated until the joint loss is less than the preset error threshold, and the prediction model to be trained is determined as the prediction model.
6. The method according to claim 5, It is characterized in that Determining, in the standard log template, a target standard log template corresponding to the training detection log includes: Segmenting the training detection log into words to obtain at least one training word; The training words are matched with the standard log template. If the match is successful, the successfully matched annotated log template is determined as the target standard log template. If the match fails, the longest common subsequence algorithm is used to determine the target standard log template that matches the training words with the standard log template.
7. An abnormality detection device, It is characterized in that include: The data acquisition module is used to obtain historical logs, historical logs, trajectories to be detected, and historical trajectories; A standardization module, used for standardizing the historical log and the historical track to obtain a log template and a track template; A prediction module, used for inputting the log template and the trajectory template into a prediction model to obtain a prediction log and a prediction trajectory; A first determination module, used to determine a log status according to the predicted log and the historical log; A second determination module, configured to determine a trajectory error rate according to the predicted trajectory and the trajectory to be detected; A third determination module, used to determine a system state according to the log state and the trajectory error rate; The information output module is used to output a warning message if the system status is abnormal.
8. An electronic device, It is characterized in that include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the abnormality detection method according to any one of claims 1 to 6.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the anomaly detection method according to any one of claims 1 to 6.
10. A computer program product, It is characterized in that The invention comprises a computer program, which implements the abnormality detection method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Cited By
Abnormal path behavior detection method and device
CN116127374A
Abnormal path behavior detection method and device
CN116127374B
Method, system and device for detecting newly added bad block of SSD (Solid State Disk)
CN121075404A
