A method and device for detecting abnormality of business data
By combining the generation of tasks to be detected based on the access address status code and the training model, the problem of accuracy and comprehensiveness of access address detection in the existing technology is solved, and a more efficient detection and alarm mechanism is achieved.
Patent Information
- Application Number
- CN202210228957.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-10
- Publication Date
- 2024-10-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, status code detection of access addresses relies on manually configured alarm rules, which is difficult to meet the needs of complex scenarios, resulting in poor detection accuracy and low comprehensiveness, and there is a risk of missed alarms.
By generating a task to be detected based on the status code of the access address, the corresponding detection model is determined according to the data type of the access address, and the trained detection model is used for detection, and the detection model is managed by combining consistent hashing operations and preset period thresholds to improve Detection accuracy and efficiency.
It improves the accuracy and comprehensiveness of detecting whether the access address is being accessed normally, reduces the risk of missing alarms, and improves detection efficiency and memory management flexibility.
Smart Images

Figure CN114650240B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method and device for detecting anomalies in business data. Background Art
[0002] With the advancement of technology, the number of access addresses (such as domain names, server IP addresses, etc.) is increasing, so it is necessary to perform status detection on the access addresses to determine whether the access addresses can be accessed normally.
[0003] Furthermore, the status detection result of the access address is determined by the status code of the access address. The status code of the access address is used to characterize the access status fed back when an access request is sent to the access address. For example, the access status includes successful access, access exception, specific exception type (such as the exception type of the 404 page), etc.
[0004] In the prior art, the status code detection of the access address is generally performed through manually configured alarm rules for detection and alarm, such as an alarm when the number of abnormal status codes reaches a threshold.
[0005] However, manually configured alarm rules are difficult to maintain and cannot meet the needs of scenarios with complex status code types. There is a risk of missed alarms. That is, the existing technology has poor detection accuracy and low comprehensiveness in determining whether an access address can be accessed normally. Summary of the invention
[0006] The embodiments of the present invention provide a method and device for detecting anomalies in business data, which are used to improve the comprehensiveness and accuracy of the detection of determining whether an access address can be accessed normally.
[0007] In a first aspect, an embodiment of the present invention provides a data detection method, including:
[0008] Generate a task to be detected based on various status codes of the access address within a first preset time period; wherein each status code is used to represent the access status of the access address;
[0009] Determine the detection model corresponding to the task to be detected according to the data type corresponding to the access address; the data type corresponding to the access address is determined according to various status codes of the access address in the first historical period; the detection model is obtained by training based on various status codes corresponding to the data type in the second historical period;
[0010] The task to be detected is detected based on the detection model corresponding to the task to be detected to obtain a detection result, and the detection result is used to determine whether to issue an alarm for the access status of the access address.
[0011] In the above technical scheme, the data type of the access address is used to match the corresponding detection model to the detection task, and the detection task is matched with the corresponding detection model to detect the detection task, thereby improving the detection accuracy of determining whether the access address can be accessed normally; because the detection model is trained through various status codes corresponding to the data type, the detection accuracy of the detection model is improved, thereby improving the detection accuracy of determining whether the access address can be accessed normally.
[0012] Optionally, the data type corresponding to the access address is determined according to various status codes of the access address in the first historical period, including:
[0013] Various status codes of the access address in the first historical period are detected according to a continuous rule on a preset time series to determine the data type corresponding to the access address.
[0014] Optionally, detecting various status codes of the access address in the first historical period according to a continuous rule on a preset time series to determine the data type corresponding to the access address includes:
[0015] Determine whether, among various status codes of the access address in the first historical period, there are no status codes at consecutive time points in the time series; if so, determine that the data type corresponding to the access address is a discrete type;
[0016] Otherwise, it is determined that the data type corresponding to the access address is a continuous type.
[0017] In the above technical solution, the data type of the access address is determined based on various status codes of the access address in the first historical period to classify the access address, thereby achieving targeted detection of the access address, thereby improving the targetedness and accuracy of the access address detection.
[0018] Optionally, determining that the data type corresponding to the access address is a continuous type includes:
[0019] Converting the time series of various status codes in the first historical period into a frequency spectrum according to Fourier transform;
[0020] Determine whether the spectrum is periodic according to a preset rule; if so, determine the data type corresponding to the access address as a periodic type; otherwise, determine the data type corresponding to the access address as a non-periodic type.
[0021] Optionally, determining the data type corresponding to the access address as a non-periodic type includes:
[0022] The data type corresponding to the access address is determined as a stationary type or a non-stationary type according to a unit root test algorithm.
[0023] In the above technical solution, the data types are divided into discrete type, periodic type, stable type and non-stable type, so as to increase the comprehensiveness of the access address classification.
[0024] Optionally, the detection model is trained based on various status codes corresponding to the data type in the second historical period, including:
[0025] For each discrete type of status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the isolation forest model to obtain a discrete type detection model;
[0026] For each status code of the periodic type, the various status codes in the second historical period are divided into each detection data according to the second preset time length, and each detection data is subjected to the periodic detection algorithm SeasonalAD to obtain a periodic type detection model;
[0027] For each type of stable status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the mutation detection algorithm PersistAD to obtain a stable type detection model;
[0028] For each type of non-stationary status code, each type of status code in the second historical period is divided into each detection data according to a second preset time length, and each detection data is subjected to a box plot algorithm to obtain a non-stationary type detection model.
[0029] In the above technical solution, for the status code of any data type, a detection model of the corresponding data type is obtained, thereby improving the comprehensiveness and accuracy of access address detection.
[0030] Optionally, the detection model includes various detection sub-models; each detection sub-model is determined according to the abnormal type of the status code in each detection data.
[0031] In the above technical solution, the detection model is further divided according to the abnormal type of the status code (such as 2xx type status code, 4xx type status code, etc.), thereby further improving the comprehensiveness of the access address detection.
[0032] Optionally, determining the detection model corresponding to the task to be detected according to the data type corresponding to the access address includes:
[0033] A consistent hash operation is performed on the access address to determine the processing process corresponding to the task to be detected; the detection model corresponding to the task to be detected is cached in the processing process; the detection model corresponding to the task to be detected is determined according to the data type corresponding to the access address and loaded into the processing process.
[0034] In the above technical solution, the processing process corresponding to the access address is determined through consistent hashing operation, so that the processing process only needs to load the detection model corresponding to the access address, without loading all the detection models, thereby reducing the memory of the processing process; and improving the parallel capability of access address detection and improving detection efficiency.
[0035] Optionally, also include:
[0036] For any detection model, if it is determined that the detection model has not been used within a preset time period threshold, the detection model is released from the processing process.
[0037] In the above technical solution, the detection model is released regularly by setting a preset time period threshold, thereby improving the flexibility and real-time performance of reducing the memory usage in the processing process and improving the efficiency of access address detection.
[0038] Optionally, after obtaining the test results, the following is also included:
[0039] If the detection result satisfies a preset abnormal condition, the access address is marked abnormally; the preset abnormal condition is that each detection sub-result in the detection result is abnormal; or the number of abnormal detection sub-results is greater than a first threshold;
[0040] Within the third preset time period, when the number of abnormal marks of the access address is greater than the abnormal threshold, an abnormal alarm is issued for the access address.
[0041] Optionally, after an abnormal alarm is issued for the access address, the method further includes:
[0042] Send an alarm message to the processor; the alarm message includes a link address; the link address is used to instruct the processor to feedback response information through the link address; the response information is used to indicate whether the alarm message is correct; the link address is set with a personalized threshold; the personalized threshold is used to shield the alarm message and / or response message.
[0043] In the above technical solution, whether the access address is abnormal is determined by multiple detection sub-results, thereby improving the accuracy of access address detection; by sending alarm information to the processing party, it is further determined whether the access address is alarmed, thereby improving the accuracy of access address alarm.
[0044] In a second aspect, an embodiment of the present invention provides a device for detecting anomalies in business data, including:
[0045] A generation module, used to generate a task to be detected based on various status codes of the access address within a first preset time period; wherein each status code is used to represent the access status of the access address;
[0046] A processing module, configured to determine a detection model corresponding to the task to be detected according to a data type corresponding to the access address; the data type corresponding to the access address is determined according to various status codes of the access address in a first historical period; and the detection model is obtained by training based on various status codes corresponding to the data type in a second historical period;
[0047] The task to be detected is detected based on the detection model corresponding to the task to be detected to obtain a detection result, and the detection result is used to determine whether to issue an alarm for the access status of the access address.
[0048] Optionally, the processing module is specifically used for:
[0049] Various status codes of the access address in the first historical period are detected according to a continuous rule on a preset time series to determine the data type corresponding to the access address.
[0050] Optionally, the processing module is specifically used for:
[0051] Determine whether, among various status codes of the access address in the first historical period, there are no status codes at consecutive time points in the time series; if so, determine that the data type corresponding to the access address is a discrete type;
[0052] Otherwise, it is determined that the data type corresponding to the access address is a continuous type.
[0053] Optionally, the processing module is specifically used for:
[0054] Converting the time series of various status codes in the first historical period into a frequency spectrum according to Fourier transform;
[0055] Determine whether the spectrum is periodic according to a preset rule; if so, determine the data type corresponding to the access address as a periodic type; otherwise, determine the data type corresponding to the access address as a non-periodic type.
[0056] Optionally, the processing module is specifically used for:
[0057] The data type corresponding to the access address is determined as a stationary type or a non-stationary type according to a unit root test algorithm.
[0058] Optionally, the processing module is specifically used for:
[0059] For each discrete type of status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the isolation forest model to obtain a discrete type detection model;
[0060] For each status code of the periodic type, the various status codes in the second historical period are divided into each detection data according to the second preset time length, and each detection data is subjected to the periodic detection algorithm SeasonalAD to obtain a periodic type detection model;
[0061] For each type of stable status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the mutation detection algorithm PersistAD to obtain a stable type detection model;
[0062] For each type of non-stationary status code, each type of status code in the second historical period is divided into each detection data according to a second preset time length, and each detection data is subjected to a box plot algorithm to obtain a non-stationary type detection model.
[0063] Optionally, the detection model includes various detection sub-models; each detection sub-model is determined according to the abnormal type of the status code in each detection data.
[0064] Optionally, the processing module is specifically used for:
[0065] A consistent hash operation is performed on the access address to determine the processing process corresponding to the task to be detected; the detection model corresponding to the task to be detected is cached in the processing process; the detection model corresponding to the task to be detected is determined according to the data type corresponding to the access address and loaded into the processing process.
[0066] Optionally, the processing module is further used for:
[0067] For any detection model, if it is determined that the detection model has not been used within a preset time period threshold, the detection model is released from the processing process.
[0068] Optionally, the processing module is further used for:
[0069] After obtaining the detection result, if the detection result meets a preset abnormal condition, the access address is marked abnormally; the preset abnormal condition is that each detection sub-result in the detection result is abnormal; or the number of abnormal detection sub-results is greater than a first threshold;
[0070] Within the third preset time period, when the number of abnormal marks of the access address is greater than the abnormal threshold, an abnormal alarm is issued for the access address.
[0071] Optionally, the processing module is further used for:
[0072] After an abnormal alarm is issued for the access address, an alarm message is sent to the processing party; the alarm message includes a link address; the link address is used to instruct the processing party to feedback response information through the link address; the response information is used to indicate whether the alarm message is correct; the link address is set with a personalized threshold; the personalized threshold is used to shield the alarm message and / or response message.
[0073] In a third aspect, an embodiment of the present invention further provides a computer device, including:
[0074] A memory for storing program instructions;
[0075] The processor is used to call the program instructions stored in the memory and execute the above-mentioned business data anomaly detection method according to the obtained program.
[0076] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned method for detecting anomalies in business data. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0078] Figure 1 A schematic diagram of a system architecture provided by an embodiment of the present invention;
[0079] Figure 2 A flowchart of a method for detecting anomalies in business data provided by an embodiment of the present invention;
[0080] Figure 3 A schematic diagram of the structure of a device for detecting anomalies in business data provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0081] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0082] In the prior art, when any user makes a visit to an access address, an access status corresponding to the visit will be responded, such as a successful access or an abnormal access; that is, the status code described in the embodiment of the present invention.
[0083] When the status code is abnormal, it includes multiple abnormal types. For example, a 404 page is a status code of an abnormal type. In an embodiment of the present invention, a page starting with "4" (such as a 404 page) is determined as a 4xx abnormal type status code, a page starting with "2" is determined as a 2xx abnormal type status code, and a page starting with "5" is determined as a 5xx abnormal type status code. In the embodiment of the present invention, 2xx, 4xx and 5xx abnormal type status codes are used as examples for description, but the abnormal type status codes are not limited.
[0084] For status code alarms, currently, the status code is generally detected by manually configuring alarm rules, and then the access address is alarmed to determine whether the access address is abnormal, that is, it cannot be accessed normally. For example, the number of 404 status codes that appear within a preset time period and other rules.
[0085] However, the manually configured alarm rules are numerous and difficult to maintain; and the manually configured alarm rules are relatively simple and cannot meet the needs of complex status code types, resulting in the risk of missed detection and missed alarms. Therefore, the existing technology has poor accuracy and low comprehensiveness in access address detection. Therefore, there is an urgent need for an abnormal detection method for business data to improve the comprehensiveness and accuracy of detection of whether an access address can be accessed normally.
[0086] Figure 1 A system architecture applicable to an embodiment of the present invention is exemplarily shown, and the system architecture includes a status code data module 110 , a classification result module 120 , a model library 130 , an exception pool 140 and a feedback pool 150 .
[0087] Among them, the status code data module 110 is used to record the status code of each access address in real time, such as recording various status codes of Baidu access address in real time, such as 4xx and 5xx abnormal type status codes, etc.;
[0088] The classification result module 120 is used to classify the various status codes of each access address recorded in the status code data module 110, and then determine the data type of each access address; specifically, for any access address, starting from the detection time, take the various status codes within the first preset time period (such as within 3 days from the detection time), and then perform data classification calculation on the various status codes within the first preset time period of the access address to determine the data type to which the status code of the access address belongs at the current detection time, that is, the data type of the access address.
[0089] The model library 130 is used to store the detection model, which is trained according to the status code recorded in the status code data module 110; specifically, according to the data types corresponding to the various status codes of the accessed address, combined with the various status codes in the second historical period (such as nearly 15 minutes from the detection time), the detection model corresponding to the various status codes of the accessed address is trained;
[0090] An exception pool 140 is used to record a preset abnormal condition, where the preset abnormal condition is that all detection sub-results in the detection result of the detection model are abnormal; or the number of abnormal detection sub-results is greater than a first threshold; and is used to determine whether the access address is abnormal;
[0091] The feedback pool 150 is used to record the detection results of the access address, abnormal alarms, etc.
[0092] It should be noted that the above Figure 1 The structure shown is only an example and is not limited to this embodiment of the present invention.
[0093] Based on the above description, Figure 2 A schematic flow chart of a method for detecting anomalies in business data provided by an embodiment of the present invention is exemplarily shown, and the flow chart can be executed by a data detection device.
[0094] like Figure 2 As shown in the figure, the process specifically includes:
[0095] Step 210: Generate a task to be detected based on various status codes of the access address within a first preset time period.
[0096] In an embodiment of the present invention, each type of status code is used to characterize the access status of the access address; for example, when a user accesses an access address (such as an official website address), a corresponding access status (such as successful access, access exception, exception type, etc.) is obtained, that is, the access status is the status code of the user's access to the access address this time.
[0097] For example, when a user visits an official website address A, the status code obtained is a 404 page; that is, this visit is an access exception, and the exception type is a 4xx exception type status code.
[0098] The task to be detected is equivalent to a collection of various status codes within the first preset time period. For example, the task to be detected includes information such as the number of status codes representing successful access, the number of status codes representing access exceptions, and the type of exception when access is abnormal.
[0099] Step 220: Determine the detection model corresponding to the task to be detected according to the data type corresponding to the access address.
[0100] In an embodiment of the present invention, the data type corresponding to the access address is determined based on various status codes of the access address in the first historical period; the detection model is trained based on various status codes corresponding to the data type in the second historical period.
[0101] The first historical period is the first period preset from the current detection time. For example, if the current detection time is 7:00 on March 2, 2021, and the preset historical period is 12 hours, then the period from 7:00 on March 2, 2021 to 19:00 on March 1, 2021 is the first historical period. The preset first period can be a value preset by the R&D personnel based on experience, and is not limited here.
[0102] The second historical period is a preset second period starting from the current detection time. For example, if the current detection time is 9:00 on May 6, 2021, and the preset historical period is 72 hours, then the period from 9:00 on May 6, 2021 to 9:00 on May 3, 2021 is the second historical period. The preset second period can be a value preset by the R&D personnel based on experience, and is not limited here.
[0103] Specifically, the status codes in a preset time series (ie, the first historical period) are detected according to a preset algorithm to determine the data type of the status codes in the first historical period; then the data type of the status codes in the first historical period is used as the data type corresponding to the access address.
[0104] For example, based on various status codes and time series in the first historical period, it is determined that the data type of various status codes in the first historical period is a discrete type, and then the data type of the access address is determined to be a discrete type; then training is performed based on various status codes of the discrete type in the second historical period to obtain a discrete type detection model, wherein the second historical period can be less than, equal to or greater than the first historical period, and there is no limitation here.
[0105] Step 230: Detect the task to be detected based on the detection model corresponding to the task to be detected to obtain a detection result.
[0106] In the embodiment of the present invention, the detection result is used to determine whether to issue an alarm for the access status of the access address.
[0107] Further, in step 210, various status codes within the first preset time are pulled from the status code data module after determining the data type of the access address. For example, the access address A1 needs to be detected at the current moment, and a task to be detected B1 is generated based on various status codes within 1 minute before the current moment, and the task to be detected B1 is used to determine whether the access address needs to be alarmed.
[0108] The first preset duration is the duration of the access status of the access address to be detected, and the first historical duration preset from the time to be detected. For example, if the time to be detected is 7:02 and the preset first historical duration is 1 minute, then 7:01 to 7:02 is the first preset duration. The first preset duration can be a value preset based on experience, such as 1 minute, 2 minutes, etc., which is not limited here. In the embodiment of the present invention, the first preset duration is determined according to the data type of the access address.
[0109] For example, when the data type of the access address is a discrete type, the first preset time length is 5 minutes; when the data type of the access address is a stable type, the first preset time length is 3 minutes; no further details will be given here, nor will the specific time length of the first preset time length be limited for any data type.
[0110] To further exemplify, the access address to be detected is obtained, a data pulling task is generated in real time, and sent to the task queue; based on the data pulling task in the task queue, a status code of the corresponding length (equivalent to the corresponding data type) is pulled to generate a task to be detected.
[0111] In addition, the determination of the data type of the access address is explained in the description of step 220 below.
[0112] In step 220, the data type of the access address is determined based on various status codes of the access address in the first historical period and a preset detection algorithm; wherein the preset detection includes but is not limited to a Fourier transform algorithm and a unit root test algorithm.
[0113] According to the continuous rules on the preset time series, various status codes of the access address in the first historical period are detected to determine the data type corresponding to the access address. This is equivalent to classifying the various status codes of the access address in the first historical period, thereby determining the data type of the various status codes of the access address in the first historical period, and then determining the data type corresponding to the access address.
[0114] Further, determine whether there are no status codes at consecutive time points in the time series among various status codes of the access address within the first historical period; if so, determine that the data type corresponding to the access address is a discrete type; otherwise, determine that the data type corresponding to the access address is a continuous type.
[0115] For example, the first historical period is 24 hours, and each minute point is used as a time point in 24 hours, that is, 1440 time points are included. If, among the 1440 time points, the time points with status code data are less than half (i.e., 720) of the number of time points in the first historical period, then it is determined that the status code data in the first historical period is discrete type data, and further the access address is determined to be a discrete type access address.
[0116] For another example, for any access address of the data type to be determined, within the 24 hours of a certain day, there is status code data at the time points from 8:00 to 16:00, and there is no status code data at the time points from 16:01 to 7:59, then the status code data within the first historical period is determined to be discrete type data, and then the access address is determined to be a discrete type access address.
[0117] In the embodiment of the present invention, the continuous type is divided into a periodic type and a non-periodic type to improve the comprehensiveness and accuracy of the access address classification.
[0118] Specifically, when it is determined that the data type of each type of status code in the first historical period is a continuous type (i.e., a non-discrete type), the time series of each type of status code in the first historical period is converted into a spectrum according to Fourier transform; according to preset rules, it is determined whether the spectrum is periodic; if so, the data type corresponding to the access address is determined to be a periodic type; otherwise, the data type corresponding to the access address is determined to be a non-periodic type.
[0119] For example, for various status codes in the first historical period of continuous type, the time series of various status codes in the first historical period are converted into a spectrum; then, based on multiple amplitudes (preset rules) in the spectrum, it is determined whether the spectrum is periodic; if so, the data type of the various status codes in the first historical period is determined to be a periodic type, and then the data type of the access address is determined to be a periodic type; otherwise, the data type of the various status codes in the first historical period is determined to be a non-periodic type, and then the data type of the access address is determined to be a non-periodic type.
[0120] In the embodiment of the present invention, in order to further improve the comprehensiveness and accuracy of the access address classification, the non-periodic type is divided into a stable type and a non-steady type.
[0121] Specifically, the data type corresponding to the access address is determined as a stationary type or a non-stationary type according to a unit root test algorithm.
[0122] Furthermore, when the data types of various status codes in the first historical period are determined to be non-periodic types through the Fourier transform algorithm, the data types of various status codes in the first historical period are classified as stationary types or non-stationary types according to ADF (Augmented Dickey-Fuller, unit root test algorithm). Then, the data type corresponding to the access address is determined to be stationary type or non-stationary type.
[0123] For example, for each type of state code in the first historical period of the non-periodic type, the unit root test algorithm is used to calculate each type of state code in the first historical period to obtain a p value. If the p value is less than the unit root test threshold (such as 1%), the data type of each type of state code in the first historical period is determined to be a stationary type, and then the data type corresponding to the access address is determined to be a stationary type; otherwise, the data type of each type of state code in the first historical period is determined to be a non-stationary type, and then the data type corresponding to the access address is determined to be a non-stationary type. The unit root test threshold can be a value preset based on experience, which is not limited here.
[0124] In summary, the data types in the embodiments of the present invention include but are not limited to discrete types, periodic types, stationary types and non-stationary types.
[0125] In an embodiment of the present invention, the detection model is trained based on the status code of each data type, and the detection model includes various detection sub-models; wherein each detection sub-model is determined based on the abnormal type of the status code in each detection data.
[0126] Exemplarily, for each discrete type of status code, each type of status code in the second historical period is divided into each detection data according to the second preset time length, and each detection data is passed through the isolation forest model to obtain a discrete type detection model. Among them, the isolation forest model uses an outlier detection algorithm to determine whether the discrete type of access address can be accessed normally.
[0127] The second preset duration is a preset second historical duration for determining training samples for model training; for example, the historical duration between fixed dates is determined as the second preset duration, such as Monday to Tuesday of each week as the second preset duration; or the second historical duration is preset from a fixed time of each day, such as 0:00 every day to 36 hours before 0:00 as the second preset duration. The first preset duration can be a value preset based on experience, such as 7 days, 14 days, etc., which is not limited here.
[0128] For example, for various discrete status codes, the second preset time length is 7 days, then the various discrete status codes corresponding to the access address within 7 days are taken as training samples, and then trained through the isolation forest model to obtain a discrete type detection model.
[0129] In one feasible method, for status codes of different abnormal types, segmentation training is performed based on training samples and an isolation forest model to obtain discrete type detection sub-models for abnormal types; for example, the abnormal types of the status code include 2xx abnormal types, 4xx abnormal types, and 5xx abnormal types, and the corresponding training obtains discrete type detection sub-models L1, discrete type detection sub-models L2, and discrete type detection sub-models L3, and then the obtained discrete type detection sub-models are stored in a model library.
[0130] Exemplarily, for each type of status code of the periodic type, each type of status code in the second historical period is divided into each detection data according to the second preset time length, and each detection data is passed through the periodic detection algorithm SeasonalAD to obtain a periodic type detection model.
[0131] For example, for various status codes of periodic type, the second preset time length is 3 days, then various status codes of periodic type corresponding to the access address within 3 days are taken as training samples, and then trained through the periodic detection algorithm SeasonalAD to obtain a periodic type detection model.
[0132] In one feasible method, for status codes of different exception types, a periodic type detection sub-model for the exception type is obtained; for example, if only the exception types of the status code are 2xx exception type and 5xx exception type, the corresponding training obtains the periodic type detection sub-model Z1 and the periodic type detection sub-model Z2, and then the obtained periodic type detection sub-models are stored in the model library.
[0133] Exemplarily, for each type of stable status code, each type of status code in the second historical period is divided into detection data according to the second preset time length, and each detection data is passed through the mutation detection algorithm PersistAD to obtain a stable type detection model; based on the above-mentioned feasible method, it can be known that for status codes of different abnormal types, a stable type detection sub-model for the abnormal type can be obtained, which will not be elaborated here.
[0134] Exemplarily, for various types of non-stationary status codes, various types of status codes in the second historical period are divided into various detection data according to the second preset time length, and each detection data is subjected to a box plot algorithm to obtain a non-stationary type detection model. Based on the above-mentioned feasible method, it can be known that for status codes of different abnormal types, a non-stationary type detection sub-model for abnormal types can be obtained, which will not be elaborated here.
[0135] In the embodiment of the present invention, the data type determination of the access address and the detection model determination can be periodically updated at a time point; for example, at 0:00 every day, the data type of the access address is re-determined and each detection model is updated. In other words, the data type determination of the access address and the detection model determination are determined by offline detection.
[0136] For the task to be detected in real time, by matching the processing process, the detection model cached in the corresponding processing process is used to detect the task to be detected to obtain the detection result.
[0137] Specifically, a consistent hash operation is performed on the access address to determine the processing process corresponding to the task to be detected; the detection model corresponding to the task to be detected is cached in the processing process; the detection model corresponding to the task to be detected is determined according to the data type corresponding to the access address and loaded into the processing process.
[0138] Among them, consistent hashing is used to implement a certain request to be processed by a fixed server. For example, each access address that needs to be detected is obtained from the database, and a hash operation is performed on each access address to obtain the corresponding hash result. Then, based on the number of processing processes and the hash results of each access address, a fixed processing process is determined for each access address.
[0139] For example, the processing processes include J1, J2 and J3, and the access addresses include A1, A2, A3, A4 and A5. After the consistent hashing operation, it is determined that the access addresses A1 and A2 are processed by the processing process J1; the access addresses A3 and A5 are processed by the processing process J2; and the access address A4 is processed by the processing process J3.
[0140] In one example, a hash operation is performed on multiple access addresses to obtain hash values corresponding to the multiple access addresses, and then the hash values corresponding to the multiple access addresses are processed according to a preset processing method to determine the access addresses with the same hash; the access addresses with the same hash are sent to a fixed task queue for processing; wherein the task queue can correspond to a server, and a task queue is processed by a corresponding server or multiple corresponding servers, so as to increase the balance and efficiency of the access status detection of the access address. Among them, the preset processing method can be a modulo operation, processing based on a fixed number of bits (such as the last bit of the hash value, the second to last bit, etc.), etc., which are not specifically limited here.
[0141] For example, there are 100,000 access addresses in total, and the corresponding tasks to be detected are 100,000. Hash operations are performed on the 100,000 access addresses respectively to obtain 100,000 corresponding hash values. The 100,000 hash values are modulo 7 (preset value), and then the hash values with the same remainders are determined as hash values with the same hash, that is, access addresses with the same hash; this is equivalent to dividing the 100,000 hash values, that is, 100,000 tasks to be detected, into 7 parts, that is, 7 task queues; for any task queue, the server corresponding to the task queue detects the access status of the tasks to be detected in the task queue.
[0142] Or hash values with the same hash value tail (including from 0 to 9) are determined as hash values with the same hash, that is, access addresses with the same hash; this is equivalent to dividing 100,000 hash values, that is, 100,000 tasks to be detected, into 10 parts, that is, 10 task queues.
[0143] Through the above method, multiple tasks to be detected can be evenly divided, and the tasks to be detected can be sent to a fixed processing process (ie, server) for processing, thereby improving detection balance and detection efficiency.
[0144] Based on the above description, for any processing process, after determining the access address to be detected corresponding to the processing process, the corresponding detection model is pre-cached in the processing process according to the data type of the access address and the abnormal type of the status code.
[0145] Based on the above description, for example, the access address to be processed of the processing process J3 is the access address A4. Assuming that the data type of the access address A4 is a discrete type, the discrete type detection sub-model L1, the discrete type detection sub-model L2 and the discrete type detection sub-model L3 are pre-cached in the processing process J3.
[0146] In one practicable manner, if a new access address is added, the detection model is loaded from the model library in real time according to the data type of the access address. For example, if a new access address A6 is added, and the data type of the access address A6 is a periodic type, the periodic type detection sub-model Z1 and the periodic type detection sub-model Z2 are loaded in the model library in real time, thereby achieving efficiency and speed in calling the detection model.
[0147] In another practicable manner, for any detection sub-model, if it is determined that the detection sub-model is not used within a preset time period threshold, the detection model is released from the processing process. For example, if the period type detection sub-model Z1 is not used within 10 minutes (preset time period threshold), the period type detection sub-model Z1 is released from the processing process, thereby reducing the memory of the processing process.
[0148] In step 230, after any detection sub-model detects the task to be detected, a detection sub-result is obtained, and then whether the access address is abnormal is determined based on multiple detection sub-results.
[0149] Specifically, if the detection result meets the preset abnormal condition, the access address is marked as abnormal; wherein the preset abnormal condition is that each detection sub-result in the detection result is abnormal; or the number of abnormal detection sub-results is greater than a first threshold; within a third preset time period, when the number of abnormal marks of the access address is greater than the abnormal threshold, an abnormal alarm is issued for the access address.
[0150] Based on the above description, the task B1 to be detected of the access address A1 is detected by the discrete type detection sub-model L1, the discrete type detection sub-model L2 and the discrete type detection sub-model L3 respectively, and the detection sub-results S1, S2 and S3 are obtained; if the characterization results of S1, S2 and S3 are all abnormal, or two of the characterization results are abnormal, it is determined that the access address for the task to be detected is abnormal.
[0151] In one implementable manner, the preset exception condition corresponds to the data type.
[0152] For example, for a discrete type of access address, the corresponding preset abnormal condition is that all detection sub-results are abnormal;
[0153] For a periodic type access address, the corresponding preset abnormal condition is that the number of abnormal detection sub-results is greater than a first threshold;
[0154] For a stable access address, the corresponding preset abnormal condition is that any detection result is abnormal, etc. Other data types are not described here.
[0155] In another practicable manner, the preset abnormal condition further includes a threshold value of the number of status codes of the abnormal type.
[0156] For example, for discrete type access addresses, the preset exception conditions also include the number of status codes of 2xx exception types exceeding a first discrete threshold (such as 100), the number of status codes of 4xx exception types exceeding a second discrete threshold (such as 200), the number of status codes of 5xx exception types exceeding a third discrete threshold (such as 300), etc.
[0157] For periodic type access addresses, the preset exception conditions also include the number of 2xx exception type status codes exceeding the first cycle threshold (such as 150), the number of 5xx exception type status codes exceeding the second cycle threshold (such as 270), etc. Other data types are not described here.
[0158] In the embodiment of the present invention, the third preset time length and the abnormal threshold value may also correspond to the data type.
[0159] For example, for a discrete type of access address, the third preset time length is 3 minutes and the abnormal threshold is 2;
[0160] For periodic access addresses, the third preset duration is 4 minutes and the abnormal threshold is 3; other data types are not described here.
[0161] By detecting abnormal types of status codes, the comprehensiveness and accuracy of access address detection can be improved.
[0162] After an alarm is issued for the access status of the access address, a response message of the processor to the alarm may be received to determine whether the alarm is a false alarm, thereby improving the accuracy of the alarm.
[0163] Specifically, after an alarm is issued on the access status of the access address, an alarm message is sent to the processor; wherein the alarm message includes a link address (such as a URL address); the link address is used to instruct the processor to feedback response information through the link address; the response information is used to indicate whether the alarm message is correct; the link address is set with a personalized threshold; the personalized threshold is used to shield the alarm message and / or response information.
[0164] In an embodiment of the present invention, by determining the data type of the access address, a corresponding detection model is matched to the detection task, and the detection model is used to detect the detection task, thereby improving the detection accuracy of the access address; since the various status codes of the access address are in different forms, it is difficult to use a unified model for detection, so each type of status code is detected separately through data classification, which not only improves the detection recall rate, but also improves the detection accuracy.
[0165] Based on the same technical concept, Figure 3 A schematic structural diagram of a device for detecting anomalies in business data provided by an embodiment of the present invention is exemplarily shown, and the device can execute the process of the data detection method.
[0166] like Figure 3 As shown, the device specifically includes:
[0167] A generating module 310 is used to generate a task to be detected based on various status codes of the access address within a first preset time period; wherein each status code is used to represent the access status of the access address;
[0168] The processing module 320 is used to determine the detection model corresponding to the to-be-detected task according to the data type corresponding to the access address; the data type corresponding to the access address is determined according to various status codes of the access address in the first historical period; the detection model is obtained by training based on various status codes corresponding to the data type in the second historical period;
[0169] The task to be detected is detected based on the detection model corresponding to the task to be detected to obtain a detection result, and the detection result is used to determine whether to issue an alarm for the access status of the access address.
[0170] Optionally, the processing module 320 is specifically used for:
[0171] Various status codes of the access address in the first historical period are detected according to a continuous rule on a preset time series to determine the data type corresponding to the access address.
[0172] Optionally, the processing module 320 is specifically used for:
[0173] Determine whether, among various status codes of the access address in the first historical period, there are no status codes at consecutive time points in the time series; if so, determine that the data type corresponding to the access address is a discrete type;
[0174] Otherwise, it is determined that the data type corresponding to the access address is a continuous type.
[0175] Optionally, the processing module 320 is specifically used for:
[0176] Converting the time series of various status codes in the first historical period into a frequency spectrum according to Fourier transform;
[0177] Determine whether the spectrum is periodic according to a preset rule; if so, determine the data type corresponding to the access address as a periodic type; otherwise, determine the data type corresponding to the access address as a non-periodic type.
[0178] Optionally, the processing module 320 is specifically used for:
[0179] The data type corresponding to the access address is determined as a stationary type or a non-stationary type according to a unit root test algorithm.
[0180] Optionally, the processing module 320 is specifically used for:
[0181] For each discrete type of status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the isolation forest model to obtain a discrete type detection model;
[0182] For each status code of the periodic type, the various status codes in the second historical period are divided into each detection data according to the second preset time length, and each detection data is subjected to the periodic detection algorithm SeasonalAD to obtain a periodic type detection model;
[0183] For each type of stable status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the mutation detection algorithm PersistAD to obtain a stable type detection model;
[0184] For each type of non-stationary status code, each type of status code in the second historical period is divided into each detection data according to a second preset time length, and each detection data is subjected to a box plot algorithm to obtain a non-stationary type detection model.
[0185] Optionally, the detection model includes various detection sub-models; each detection sub-model is determined according to the abnormal type of the status code in each detection data.
[0186] Optionally, the processing module 320 is specifically used for:
[0187] A consistent hash operation is performed on the access address to determine the processing process corresponding to the task to be detected; the detection model corresponding to the task to be detected is cached in the processing process; the detection model corresponding to the task to be detected is determined according to the data type corresponding to the access address and loaded into the processing process.
[0188] Optionally, the processing module 320 is further used for:
[0189] For any detection model, if it is determined that the detection model has not been used within a preset time period threshold, the detection model is released from the processing process.
[0190] Optionally, the processing module 320 is further used for:
[0191] After obtaining the detection result, if the detection result meets a preset abnormal condition, the access address is marked abnormally; the preset abnormal condition is that each detection sub-result in the detection result is abnormal; or the number of abnormal detection sub-results is greater than a first threshold;
[0192] Within the third preset time period, when the number of abnormal marks of the access address is greater than the abnormal threshold, an abnormal alarm is issued for the access address.
[0193] Optionally, the processing module 320 is further used for:
[0194] After an abnormal alarm is issued for the access address, an alarm message is sent to the processing party; the alarm message includes a link address; the link address is used to instruct the processing party to feedback response information through the link address; the response information is used to indicate whether the alarm message is correct; the link address is set with a personalized threshold; the personalized threshold is used to shield the alarm message and / or response message.
[0195] Based on the same technical concept, an embodiment of the present invention further provides a computer device, including:
[0196] A memory for storing program instructions;
[0197] The processor is used to call the program instructions stored in the memory and execute the above-mentioned business data anomaly detection method according to the obtained program.
[0198] Based on the same technical concept, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned business data anomaly detection method.
[0199] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0200] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0201] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0202] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0203] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for detecting anomalies in business data, characterized in that: include: Generate a task to be detected based on various status codes of the access address within a first preset time period; wherein each status code is used to represent the access status of the access address; According to the data type corresponding to the access address, the detection model corresponding to the task to be detected is determined; the data type corresponding to the access address is determined according to various status codes of the access address in the first historical period; the detection model is obtained by training based on various status codes corresponding to the data type in the second historical period; the data type corresponding to the access address includes: discrete type and continuous type, the continuous type is divided into periodic type and non-periodic type, and the non-periodic type is divided into stationary type and non-stationary type; Detecting the task to be detected based on the detection model corresponding to the task to be detected to obtain a detection result, wherein the detection result is used to determine whether to issue an alarm for the access status of the access address; Wherein, the detection model includes various detection sub-models; and each detection sub-model is determined according to the abnormal type of the status code in each detection data.
2. The method according to claim 1, characterized in that The data type corresponding to the access address is determined according to various status codes of the access address in the first historical period, including: Various status codes of the access address in the first historical period are detected according to a continuous rule on a preset time series to determine the data type corresponding to the access address.
3. The method according to claim 2, characterized in that Detecting various status codes of the access address in the first historical period according to a continuous rule on a preset time series to determine the data type corresponding to the access address includes: Determine whether, among various status codes of the access address in the first historical period, there are no status codes at consecutive time points in the time series; if so, determine that the data type corresponding to the access address is a discrete type; Otherwise, it is determined that the data type corresponding to the access address is a continuous type.
4. The method according to claim 3, characterized in that Determining that the data type corresponding to the access address is a continuous type includes: Converting the time series of various status codes in the first historical period into a frequency spectrum according to Fourier transform; Determine whether the spectrum is periodic according to a preset rule; if so, determine the data type corresponding to the access address as a periodic type; otherwise, determine the data type corresponding to the access address as a non-periodic type.
5. The method according to claim 4, characterized in that Determining the data type corresponding to the access address as a non-periodic type includes: The data type corresponding to the access address is determined as a stationary type or a non-stationary type according to a unit root test algorithm.
6. The method according to any one of claims 1 to 5, characterized in that: The detection model is trained based on various status codes corresponding to the data type in the second historical period, including: For each discrete type of status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and pass each detection data through the isolation forest model to obtain a discrete type detection model; For each status code of the periodic type, the various status codes in the second historical period are divided into each detection data according to the second preset time length, and each detection data is subjected to the periodic detection algorithm SeasonalAD to obtain a periodic type detection model; For each type of stable status code, divide each type of status code in the second historical period into each detection data according to the second preset time length, and obtain a stable type detection model by using the mutation detection algorithm PersistAD for each detection data; For each type of non-stationary status code, each type of status code in the second historical period is divided into each detection data according to a second preset time length, and each detection data is subjected to a box plot algorithm to obtain a non-stationary type detection model.
7. The method according to claim 1, characterized in that Determining, according to the data type corresponding to the access address, a detection model corresponding to the task to be detected, including: A consistent hash operation is performed on the access address to determine the processing process corresponding to the task to be detected; the detection model corresponding to the task to be detected is cached in the processing process; the detection model corresponding to the task to be detected is determined according to the data type corresponding to the access address and loaded into the processing process.
8. The method according to claim 7, characterized in that Also includes: For any detection model, if it is determined that the detection model has not been used within a preset time period threshold, the detection model is released from the processing process.
9. The method according to claim 1, characterized in that After getting the test results, it also includes: If the detection result satisfies a preset abnormal condition, the access address is marked abnormally; the preset abnormal condition is that each detection sub-result in the detection result is abnormal; or the number of abnormal detection sub-results is greater than a first threshold; Within the third preset time period, when the number of abnormal marks of the access address is greater than the abnormal threshold, an abnormal alarm is issued for the access state of the access address.
10. The method according to claim 9, characterized in that After the abnormal access status of the access address is alarmed, the method further includes: Send an alarm message to the processor; the alarm message includes a link address; the link address is used to instruct the processor to feedback response information through the link address; the response information is used to indicate whether the alarm message is correct; the link address is set with a personalized threshold; the personalized threshold is used to shield the alarm message and / or response message.
11. A device for detecting abnormality of business data, characterized in that: include: A generation module, used to generate a task to be detected based on various status codes of the access address within a first preset time period; wherein each status code is used to represent the access status of the access address; A processing module, used to determine the detection model corresponding to the task to be detected according to the data type corresponding to the access address; the data type corresponding to the access address is determined according to various status codes of the access address in a first historical period; the detection model is obtained by training based on various status codes corresponding to the data type in a second historical period; the data type corresponding to the access address is divided into: discrete type and continuous type, the continuous type is divided into periodic type and non-periodic type, and the non-periodic type is divided into stationary type and non-stationary type; The task to be detected is detected based on the detection model corresponding to the task to be detected to obtain a detection result, and the detection result is used to determine whether to issue an alarm for the access status of the access address; wherein the detection model includes various detection sub-models; and each detection sub-model is determined according to the abnormal type of the status code in each detection data.
12. A computer device, characterized in that: include: A memory for storing program instructions; A processor, configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 10 according to the obtained program.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 10.
