Abnormality detection method and device, storage medium and electronic equipment
By monitoring and identifying the CPU and memory usage of query statements in the real-time data warehouse engine, and identifying and processing abnormal query statements, the resource occupation problem of the real-time data warehouse engine when processing complex queries is solved, and the stability and security of the system are improved. .
Patent Information
- Application Number
- CN202410471919.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-18
- Publication Date
- 2024-08-23
AI Technical Summary
When existing real-time data warehouse engines process complex SQL queries, it is difficult to detect and process abnormal query statements in a timely manner, resulting in an increase in computing resource and memory usage, which may lead to system failure.
By monitoring the CPU usage and memory usage of query statements running on the target data warehouse instance, use the preset session information statistics table to count and update indicator parameters in real time, identify and split abnormal query statements, terminate their operation, and prevent system failures. .
It improves the detection efficiency of abnormal SQL statements, avoids data warehouse instance failures, and improves the security and stability of the real-time data warehouse engine.
Smart Images

Figure CN118535453A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data warehouse technology, and in particular to an anomaly detection method, device, storage medium and electronic device. Background Art
[0002] The real-time data warehouse engine is a data management solution designed for real-time data processing and analysis. Users can receive and process a steady stream of business event stream data in real time through the data warehouse instance provided by the real-time data warehouse engine, such as transaction flow, user behavior log, device sensor data, etc., and can complete data integration and data analysis in a very short time after the data is generated, and can provide reports and dashboards that support real-time viewing by users or systems, so that users can instantly grasp key business indicator information such as real-time sales, number of active users, inventory turnover rate, etc. based on reports and dashboards.
[0003] Normally, when users receive data through a data warehouse instance and perform complex analysis and processing on the data, they need to first enter complex query statements (i.e., programs written in Structured Query Language (SQL)) to enable the data warehouse instance to perform data analysis and processing based on the received SQL statements. These complex query statements can contain thousands of lines of program code, and when there are exceptions in the SQL statements written by users, the computing resource utilization and memory utilization of the data warehouse instance will increase rapidly. If the abnormal SQL statements cannot be identified in time from the SQL statements run by the data instance, it may even cause the data warehouse instance to fail, which in turn will cause the real-time data warehouse engine to be completely unavailable.
[0004] Therefore, how to improve the detection efficiency of abnormal SQL statements is an urgent problem to be solved. Summary of the invention
[0005] This specification provides an abnormality detection method, device, storage medium and electronic device to partially solve the above-mentioned problems existing in the prior art.
[0006] This manual adopts the following technical solutions:
[0007] This specification provides an anomaly detection method, including:
[0008] Get each query statement;
[0009] Determine the data warehouse instance assigned to each query statement as the target data warehouse instance;
[0010] Run the query statements through the target data warehouse instance, and monitor the overall index parameters generated when the target data warehouse instance runs the query statements, where the index parameters include: CPU occupancy rate and memory occupancy rate;
[0011] When at least one indicator parameter is detected to be abnormal, the indicator parameters corresponding to each query statement when the target data warehouse instance runs the query statements are queried from the session information statistics table preset in the target data warehouse instance. The session information statistics table is counted and updated in real time during the process of the target data warehouse instance running the query statements.
[0012] According to the indicator parameters corresponding to each query statement, abnormal query statements are detected from the query statements run by the target data warehouse instance.
[0013] Optionally, monitoring the indicator parameters generated overall when the target data warehouse instance runs the query statements includes:
[0014] Through a preset monitoring interface, a preset operating system kernel interaction program is called to obtain from the operating system kernel the indicator parameters generated as a whole when the target data warehouse instance runs the query statements, so as to monitor the indicator parameters generated as a whole when the target data warehouse instance runs the query statements.
[0015] Optionally, for each indicator parameter of the target data warehouse instance, when it is determined that the indicator parameter exceeds a preset first parameter threshold and the time for which the indicator parameter exceeds the first parameter threshold exceeds a preset time threshold, it is determined that the indicator parameter is abnormal.
[0016] Optionally, according to the indicator parameters corresponding to each query statement, detecting abnormal query statements from the query statements run by the target data warehouse instance specifically includes:
[0017] For each query statement, determine whether the indicator parameter corresponding to the query statement exceeds a preset second parameter threshold;
[0018] If so, it is determined that the query statement is an abnormal query statement.
[0019] Optionally, the method further comprises:
[0020] Splitting the abnormal query statement to obtain blocks of each abnormal query statement;
[0021] For each abnormal query statement block, each program code contained in the abnormal query statement block is parsed to obtain an abnormality detection result corresponding to the abnormal query statement block;
[0022] According to the abnormality detection result corresponding to each abnormal query statement block, the execution of each program code contained in the abnormal query statement block is terminated.
[0023] Optionally, for each abnormal query statement block, each program code contained in the abnormal query statement block is parsed to obtain an abnormality detection result corresponding to the abnormal query statement block, specifically including:
[0024] For each abnormal query statement block, each program code contained in the abnormal query statement block is parsed to determine the data query information corresponding to the program statement contained in the abnormal query statement block, and based on the data query information corresponding to the program statement contained in the abnormal query statement block, the abnormality detection result corresponding to the abnormal query statement block is obtained, and the data query information includes: index reference information, candidate data scanning information, and data grouping information.
[0025] Optionally, determining a data warehouse instance allocated to each query statement as a target data warehouse instance specifically includes:
[0026] For each query statement, the query statement is parsed to determine the running information corresponding to the query statement, wherein the running information includes: the number of table links required to run the query statement, the number of tables that need to be fully scanned to run the query statement, and the number of temporary tables or index views that need to be created to run the query statement;
[0027] According to the running information corresponding to the query statement, the data warehouse instance allocated for the query statement is determined as the target data warehouse instance.
[0028] This specification provides an abnormality detection device, including:
[0029] An acquisition module is used to acquire each query statement;
[0030] An allocation module, used to determine a data warehouse instance allocated to each query statement as a target data warehouse instance;
[0031] A monitoring module, used to run the query statements through the target data warehouse instance, and monitor the indicator parameters generated when the target data warehouse instance runs the query statements as a whole, the indicator parameters including: CPU occupancy rate and memory occupancy rate;
[0032] A query module, configured to query the indicator parameters corresponding to each query statement when the target data warehouse instance runs the query statements from the session information statistics table preset in the target data warehouse instance when at least one indicator parameter is detected to be abnormal, wherein the session information statistics table is counted and updated in real time during the process of the target data warehouse instance running the query statements;
[0033] The detection module is used to detect abnormal query statements from the query statements run by the target data warehouse instance according to the indicator parameters corresponding to each query statement.
[0034] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned abnormality detection method is implemented.
[0035] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the above-mentioned abnormality detection method is implemented when the processor executes the program.
[0036] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0037] In the anomaly detection method provided in the present specification, each query statement is first obtained, and a data warehouse instance assigned to each query statement is determined as a target data warehouse instance, so that each query statement is run through the target data warehouse instance, and the overall indicator parameters generated when the target data warehouse instance runs each query statement are monitored. The indicator parameters include: central processing unit CPU occupancy rate, memory occupancy rate. When at least one indicator parameter is monitored to be abnormal, the indicator parameters corresponding to each query statement when the target data warehouse instance runs each query statement are queried from the session information statistics table preset in the target data warehouse instance. The session information statistics table is real-time statistics and updates during the process of the target data warehouse instance running each query statement. According to the indicator parameters corresponding to each query statement, abnormal query statements are detected from each query statement run by the target data warehouse instance.
[0038] It can be seen from the above method that a large-scale coarse screening can be performed based on the occupancy of computing resources and memory resources by each data warehouse instance that runs data query statements to determine the data warehouse instance with abnormalities. Then, when it is determined that there is an abnormality in the data warehouse instance, each data query statement running on the data warehouse instance can be finely screened to locate the abnormal data query statements based on the occupancy of computing resources and memory resources by each data query statement, thereby improving the detection efficiency of abnormal data query statements. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:
[0040] Figure 1A flowchart of an anomaly detection method provided in this specification;
[0041] Figure 2 A schematic diagram of the server monitoring method provided in this specification;
[0042] Figure 3 A schematic diagram of an abnormality detection device provided in this specification;
[0043] Figure 4 A method corresponding to the Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0045] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0046] Figure 1 A schematic diagram of an anomaly detection method provided in this specification includes the following steps:
[0047] S101: Obtain each query statement.
[0048] S102: Determine the data warehouse instance allocated to each query statement as the target data warehouse instance.
[0049] In this manual, in order to avoid the situation where the query statements entered by users when receiving data through the data warehouse instance and performing complex analysis and processing on the data contain abnormalities, which may lead to data warehouse instance failures, the business platform can monitor the usage of computing resources and memory resources when running various query statements on each data warehouse instance of the real-time data warehouse engine, so as to promptly discover data warehouse instances that may have abnormalities, and perform detailed detection on data warehouse instances that may have abnormalities, thereby improving the security of the real-time data warehouse engine.
[0050] In the above content, the possible exceptions of the query statement may be, for example: serious syntax errors when writing the query statement, logical errors such as infinite loops or recursive calls in the query statement, errors such as lock contention or deadlock in the query statement, and a large number of complex grouping operations in the query statement.
[0051] In the above content, a data warehouse instance can be an instantiated version of the data warehouse service that is actually running (which can be understood as a node in a distributed system). Each data warehouse instance contains all relevant configurations and environments such as the data warehouse architecture, storage space, computing resources, network configuration, and security policies. Each data warehouse instance is a data warehouse entity that can be managed and used independently. The real-time data warehouse engine can provide multiple data warehouse instances to respond to data processing requests from multiple users to run query statements uploaded by these users to execute the data processing tasks corresponding to the query statements uploaded by these users. These data warehouse instances together constitute a data warehouse instance cluster.
[0052] Specifically, the business platform can obtain each query statement uploaded by the user, and for each query statement, according to the current load status of each data warehouse instance in the real-time data warehouse engine, allocate a data warehouse instance for running the query statement as the target data warehouse instance.
[0053] It should be noted that in the above content, a data warehouse instance can run one or more query statements at the same time, or it can be in an idle state (that is, not running any query statement). At this time, the data warehouse instances that are running at least one query statement can be used as target data warehouse instances.
[0054] In this specification, the execution entity used to implement the anomaly detection method may refer to a designated device such as a server set up on the business platform, or may refer to a terminal device such as a desktop computer or a laptop computer. For the sake of ease of description, the business risk control method provided in this specification is described below using the server as the execution entity as an example.
[0055] Among them, when the above-mentioned execution entity is a server set up on the business platform, the server here can refer to a conventional database server used to respond to the user's business request and call the data warehouse instance provided by the real-time data warehouse engine to receive and process business event stream data in real time, or it can refer to a separately set monitoring server dedicated to monitoring the running status of each query statement running on each data warehouse instance. The monitoring server here can be deployed with a Python3 environment.
[0056] S103: Run the query statements through the target data warehouse instance, and monitor the overall indicator parameters generated when the target data warehouse instance runs the query statements, where the indicator parameters include: CPU occupancy rate and memory occupancy rate.
[0057] In this specification, the server can monitor each target data warehouse instance when running each query statement through the target data warehouse instance to avoid the target data warehouse instance failure caused by abnormal query statements. Figure 2 shown.
[0058] Figure 2 A schematic diagram of the server monitoring method provided in this specification.
[0059] Combination Figure 2 It can be seen that the server can call the preset operating system kernel interaction program through the preset monitoring interface to obtain the various indicator parameters generated as a whole when the target data warehouse instance runs each query statement from the operating system kernel, so as to monitor the various indicator parameters generated as a whole when the target data warehouse instance runs each query statement. The indicator parameters here are used to characterize the computer's computing resources and memory resource usage of the target data warehouse instance when running each query statement, such as: central processing unit CPU usage, memory usage, etc.
[0060] In the above content, the operating system kernel may refer to the operating system kernel installed on the computer where the target data warehouse instance is deployed.
[0061] S104: When at least one indicator parameter is monitored to be abnormal, the indicator parameters corresponding to each query statement when the target data warehouse instance runs the query statements are queried from the session information statistics table preset in the target data warehouse instance. The session information statistics table is counted and updated in real time during the process of the target data warehouse instance running the query statements.
[0062] The server can determine that an abnormality occurs in each indicator parameter of the target data warehouse instance when it is determined that the indicator parameter exceeds a preset first parameter threshold and the time for which the indicator parameter exceeds the first parameter threshold exceeds a preset time threshold.
[0063] Of course, there are many ways for the server to determine whether there is an abnormality in each indicator parameter of the target data warehouse instance, for example: inputting each indicator parameter of the above-mentioned target data warehouse instance into a preset neural network model to output the number of abnormal indicator parameters in each indicator parameter of the target data warehouse instance through the preset neural network model.
[0064] Furthermore, when it is determined that at least one indicator parameter of the target data warehouse instance is abnormal, the server can query the indicator parameters corresponding to each query statement when the target data warehouse instance runs each query statement from the session information statistics table preset in the target data warehouse instance, wherein the above-mentioned session information statistics table is counted and updated in real time during the process of the target data warehouse instance running each query statement.
[0065] It should be noted that the indicator parameters corresponding to each of the above-mentioned query statements may refer to data used to characterize the occupancy of computing resources and hardware resources by the target data warehouse instance when running the query statement, such as: CPU occupancy time, memory occupancy rate, CPU occupancy rate, etc.
[0066] S105: Detecting abnormal query statements from query statements run by the target data warehouse instance according to the indicator parameters corresponding to each query statement.
[0067] In this specification, after determining the indicator parameter corresponding to each query statement, the server can determine for each query statement whether the indicator parameter corresponding to the query statement exceeds a preset second parameter threshold, and if so, determine that the query statement is an abnormal query statement.
[0068] Of course, the server may also determine the confidence level corresponding to the query statement based on the indicator parameters corresponding to the query statement, and determine whether the query statement is an abnormal query statement based on whether the confidence level corresponding to the query statement exceeds a preset confidence threshold.
[0069] Furthermore, after detecting an abnormal query statement, the server can send a kill request to the target data warehouse instance to cause the target data warehouse instance to terminate the execution of the abnormal query statement, and generate a prompt message to be sent to the designated device used by the user. The designated device here can be: a mobile phone, a computer, and other devices.
[0070] In addition, since the query statements running on the data warehouse instance are usually more complex query statements (that is, in addition to the basic data query function, they usually also have functions such as data analysis and report generation. Therefore, each query statement can have thousands of lines), in order to facilitate users to adjust the query statements in a timely manner, the server can also split the abnormal query statements to obtain abnormal query statement blocks. For each abnormal query statement block, the program codes contained in the abnormal query statement block are parsed to obtain the abnormal detection results corresponding to the abnormal query statement block. According to the abnormal detection results corresponding to each abnormal query statement block, the running of the program codes contained in the abnormal query statement block is terminated.
[0071] In the above content, the method by which the server splits the abnormal query statement can be determined according to actual needs. For example: split the abnormal query statement according to symbols such as separators contained in the abnormal query statement. Another example: split the abnormal query statement according to the length of characters contained in the abnormal query statement. Another example: input the abnormal query statement into a preset segmentation model to split it according to the semantics of the abnormal query statement through the segmentation model, and output each abnormal query statement block after the split.
[0072] In addition, the server parses each program code contained in each abnormal query statement block, and the method for obtaining the abnormal detection result corresponding to each abnormal query statement block can be, for each abnormal query statement block, parsing each program code contained in the abnormal query statement block to determine the data query information corresponding to the program statement contained in the abnormal query statement block, and obtaining the abnormal detection result corresponding to the abnormal query statement block based on the data query information corresponding to the program statement contained in the abnormal query statement block.
[0073] In the above content, the data query information includes: index reference information, candidate data scanning information, and data grouping information.
[0074] From the above content, it can be seen that the server can monitor the target data instance through the above method when the target data warehouse instance runs each query statement to avoid the target data warehouse instance from malfunctioning due to running abnormal query statements.
[0075] In addition, in order to further improve the security of the target data warehouse instance, the server can also parse each query statement before assigning it to the data warehouse instance for execution to determine the execution information corresponding to the query statement, and determine the data warehouse instance assigned to the query statement as the target data warehouse instance based on the execution information corresponding to the query statement.
[0076] In the above content, the running information includes: the number of table links required to run the query statement, the number of tables that need to be fully scanned to run the query statement, and the number of temporary tables or index views that need to be created to run the query statement.
[0077] For ease of understanding, the following takes the above-mentioned running information as an example, namely the number of table links required to run the query statement, the number of tables required to perform full table scans to run the query statement, and the number of temporary tables or index views required to create to run the query statement. The method for the server in the above content to determine the data warehouse instance allocated to the query statement based on the running information corresponding to the query statement is described in detail.
[0078] Specifically, when the server determines that the number of table links required to run the query statement exceeds a preset threshold, the server can determine that there may be an exception in the query statement (because frequent table connections may cause data warehouse instance failures). At this time, the server can refuse to assign the query statement to the data warehouse instance for execution.
[0079] When the server determines that the number of table links required to run the query statement does not exceed the preset number threshold, the server can determine the load weight corresponding to the query statement based on the number of table links required to run the query statement, and determine the data warehouse instance allocated to the query statement based on the load weight corresponding to the query statement (the more times the query statement needs to be linked to the table, the greater the load weight corresponding to the query statement) and the current load status of each data warehouse instance.
[0080] When the server determines that the number of tables that need to be fully scanned to run the query statement exceeds the preset first number threshold, the server can determine that there may be an exception in the query statement (full table scan is a method that requires reading data in the data table row by row. Therefore, excessive use of full table scans will greatly increase the load on the data warehouse instance, thereby causing the data warehouse instance to fail). At this time, the server can refuse to assign the query statement to the data warehouse instance for execution.
[0081] When the server determines that the number of tables that need to be fully scanned to run the query statement does not exceed the preset first number threshold, the server can determine the load weight corresponding to the query statement based on the number of tables that need to be fully scanned to run the query statement, and determine the data warehouse instance allocated to the query statement based on the load weight corresponding to the query statement (the more tables that need to be fully scanned to run the query statement, the greater the load weight corresponding to the query statement) and the current load status of each data warehouse instance.
[0082] When the server determines that the number of temporary tables or index views required to run the query statement exceeds the preset second number threshold, the server can determine that there may be an abnormality in the query statement (the creation of too many useless temporary tables or index views may cause the memory usage of the data warehouse instance to be high, thereby causing the data warehouse instance to fail). At this time, the server can refuse to assign the query statement to the data warehouse instance for execution.
[0083] When the server determines that the number of temporary tables or index views needed to be created to run the query statement does not exceed the preset second quantity threshold, the server can determine the load weight corresponding to the query statement based on the number of temporary tables or index views needed to be created to run the query statement, and determine the data warehouse instance allocated to the query statement based on the load weight corresponding to the query statement (the more temporary tables or index views needed to be created to run the query statement, the greater the load weight corresponding to the query statement) and the current load status of each data warehouse instance.
[0084] From the above content, it can be seen that the server can perform large-grained coarse screening based on the occupancy of computing resources and memory resources by each data warehouse instance that runs data query statements. Therefore, when it is determined that there is an abnormality in the data warehouse instance, each data query statement running on the data warehouse instance can be finely screened to locate abnormal data query statements based on the occupancy of computing resources and memory resources by each data query statement, thereby improving the detection efficiency of abnormal data query statements.
[0085] The above are one or more abnormality detection methods of this specification. Based on the same idea, this specification also provides a corresponding abnormality detection device, such as Figure 3 shown.
[0086] Figure 3 A schematic diagram of an abnormality detection device provided in this specification includes:
[0087] The acquisition module 301 is used to acquire each query statement;
[0088] An allocation module 302 is used to determine a data warehouse instance allocated to each query statement as a target data warehouse instance;
[0089] The monitoring module 303 is used to run the query statements through the target data warehouse instance, and monitor the indicator parameters generated when the target data warehouse instance runs the query statements as a whole, and the indicator parameters include: CPU occupancy rate and memory occupancy rate;
[0090] The query module 304 is used to query the indicator parameters corresponding to each query statement when the target data warehouse instance runs the query statements from the session information statistics table preset in the target data warehouse instance when at least one indicator parameter is detected to be abnormal. The session information statistics table is counted and updated in real time during the process of the target data warehouse instance running the query statements.
[0091] The detection module 305 is used to detect abnormal query statements from the query statements run by the target data warehouse instance according to the indicator parameters corresponding to each query statement.
[0092] Optionally, the monitoring module 303 is specifically used to call a preset operating system kernel interaction program through a preset monitoring interface to obtain from the operating system kernel the indicator parameters generated as a whole when the target data warehouse instance runs the query statements, so as to monitor the indicator parameters generated as a whole when the target data warehouse instance runs the query statements.
[0093] Optionally, for each indicator parameter of the target data warehouse instance, when it is determined that the indicator parameter exceeds a preset first parameter threshold and the time for which the indicator parameter exceeds the first parameter threshold exceeds a preset time threshold, it is determined that the indicator parameter is abnormal.
[0094] Optionally, the detection module 305 is specifically configured to determine, for each query statement, whether an indicator parameter corresponding to the query statement exceeds a preset second parameter threshold; if so, determine that the query statement is an abnormal query statement.
[0095] Optionally, the detection module 305 is specifically used to split the abnormal query statement to obtain abnormal query statement blocks; for each abnormal query statement block, parse each program code contained in the abnormal query statement block to obtain an abnormal detection result corresponding to the abnormal query statement block; according to the abnormal detection result corresponding to each abnormal query statement block, terminate the execution of each program code contained in the abnormal query statement block.
[0096] Optionally, the detection module 305 is specifically used to parse, for each abnormal query statement block, each program code contained in the abnormal query statement block to determine data query information corresponding to the program statement contained in the abnormal query statement block, and obtain an abnormality detection result corresponding to the abnormal query statement block based on the data query information corresponding to the program statement contained in the abnormal query statement block, wherein the data query information includes: index reference information, candidate data scanning information, and data grouping information.
[0097] Optionally, the allocation module 302 is specifically used to parse each query statement to determine the execution information corresponding to the query statement, the execution information including: the number of table links required to execute the query statement, the number of tables that need to be fully scanned to execute the query statement, and the number of temporary tables or index views that need to be created to execute the query statement; and determine the data warehouse instance assigned to the query statement as the target data warehouse instance based on the execution information corresponding to the query statement.
[0098] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 An anomaly detection method is provided.
[0099] This manual also provides Figure 4 The one shown corresponds to Figure 3 , Figure 4 A schematic diagram of the electronic device. Figure 4As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, this specification does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0100] For the improvement of a technology, it can be clearly distinguished whether it is a hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0101] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0102] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0103] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0104] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0105] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. 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.
[0106] 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.
[0107] 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.
[0108] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0109] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0110] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0111] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0112] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0113] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0114] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0115] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. An anomaly detection method, characterized in that: include: Get each query statement; Determine the data warehouse instance assigned to each query statement as the target data warehouse instance; Run the query statements through the target data warehouse instance, and monitor the overall index parameters generated when the target data warehouse instance runs the query statements, where the index parameters include: CPU occupancy rate and memory occupancy rate; When at least one indicator parameter is detected to be abnormal, the indicator parameters corresponding to each query statement when the target data warehouse instance runs the query statements are queried from the session information statistics table preset in the target data warehouse instance. The session information statistics table is counted and updated in real time during the process of the target data warehouse instance running the query statements. According to the indicator parameters corresponding to each query statement, abnormal query statements are detected from the query statements run by the target data warehouse instance.
2. The method according to claim 1, characterized in that The indicator parameters generated when the target data warehouse instance runs the query statements are monitored as a whole, including: Through a preset monitoring interface, a preset operating system kernel interaction program is called to obtain from the operating system kernel the indicator parameters generated as a whole when the target data warehouse instance runs the query statements, so as to monitor the indicator parameters generated as a whole when the target data warehouse instance runs the query statements.
3. The method according to claim 1, characterized in that For each indicator parameter of the target data warehouse instance, when it is determined that the indicator parameter exceeds a preset first parameter threshold and the time for which the indicator parameter exceeds the first parameter threshold exceeds a preset time threshold, it is determined that the indicator parameter is abnormal.
4. The method according to claim 1, characterized in that According to the indicator parameters corresponding to each query statement, abnormal query statements are detected from the query statements run by the target data warehouse instance, specifically including: For each query statement, determine whether the indicator parameter corresponding to the query statement exceeds a preset second parameter threshold; If so, it is determined that the query statement is an abnormal query statement.
5. The method according to claim 1, characterized in that The method further comprises: Splitting the abnormal query statement to obtain blocks of each abnormal query statement; For each abnormal query statement block, each program code contained in the abnormal query statement block is parsed to obtain an abnormality detection result corresponding to the abnormal query statement block; According to the abnormality detection result corresponding to each abnormal query statement block, the execution of each program code contained in the abnormal query statement block is terminated.
6. The method according to claim 5, characterized in that For each abnormal query statement block, each program code contained in the abnormal query statement block is parsed to obtain an abnormality detection result corresponding to the abnormal query statement block, specifically including: For each abnormal query statement block, each program code contained in the abnormal query statement block is parsed to determine the data query information corresponding to the program statement contained in the abnormal query statement block, and based on the data query information corresponding to the program statement contained in the abnormal query statement block, the abnormality detection result corresponding to the abnormal query statement block is obtained, and the data query information includes: index reference information, candidate data scanning information, and data grouping information.
7. The method according to claim 1, characterized in that Determining the data warehouse instance assigned to each query statement as the target data warehouse instance specifically includes: For each query statement, the query statement is parsed to determine the running information corresponding to the query statement, wherein the running information includes: the number of table links required to run the query statement, the number of tables that need to be fully scanned to run the query statement, and the number of temporary tables or index views that need to be created to run the query statement; According to the running information corresponding to the query statement, the data warehouse instance allocated for the query statement is determined as the target data warehouse instance.
8. An abnormality detection device, characterized in that: The device comprises: An acquisition module is used to acquire each query statement; An allocation module, used to determine a data warehouse instance allocated to each query statement as a target data warehouse instance; A monitoring module, used to run the query statements through the target data warehouse instance, and monitor the indicator parameters generated when the target data warehouse instance runs the query statements as a whole, the indicator parameters including: CPU occupancy rate and memory occupancy rate; A query module, configured to query the indicator parameters corresponding to each query statement when the target data warehouse instance runs the query statements from the session information statistics table preset in the target data warehouse instance when at least one indicator parameter is detected to be abnormal, wherein the session information statistics table is counted and updated in real time during the process of the target data warehouse instance running the query statements; The detection module is used to detect abnormal query statements from the query statements run by the target data warehouse instance according to the indicator parameters corresponding to each query statement.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
