Database monitoring method and device, electronic equipment and readable storage medium

By calculating the state change data in the current time window and historical time window of the database, internal problems of the database are discovered in advance, and the problem of insufficient risk monitoring of the database in the existing technology is solved, and timely early warning and problem handling of the database is realized.

CN119066044APending Publication Date: 2024-12-03SF TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310644425.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-31
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

The existing database monitoring methods mainly focus on system status and hardware resources, and lack monitoring of risks of non-state and hardware problems within the database, resulting in business losses.

Method used

By obtaining the status data of the current time window and the status data in the target historical time window, calculate the status change data, and if the change exceeds the threshold, an alarm prompt is issued to discover internal problems in the database in advance.

Benefits of technology

It realizes timely monitoring and early warning of internal database problems, avoiding business losses caused by database problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066044A_ABST
    Figure CN119066044A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database monitoring method and device, electronic equipment and a readable storage medium, and relates to the technical field of computers. According to the embodiment of the invention, after current state data of a to-be-monitored database in a current time window is obtained, target historical time windows matched with the current time window are determined according to a preset monitoring duration, and then target historical state data of the to-be-monitored database in each target historical time window are obtained; and determining state change data of the to-be-monitored database according to the current state data and the target historical state data in each target historical time window, and monitoring the to-be-monitored database according to the state change data. Through the state change data, the to-be-monitored database is monitored, and the state data with abnormal change can be found in advance, so that the problem of the state data in the database is found in advance, the problem is processed, the business problem of the database can be effectively prevented, and timely early warning of the database is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a database monitoring method, device, electronic device and readable storage medium. Background Art

[0002] With the development of the Internet and the popularization of mobile terminals, more and more enterprises are transforming towards informatization, and adopting online models for business processing and daily operations. Among them, the online model cannot do without the use of database storage. Therefore, the security and stability of the database will directly affect the operation of online business and the daily operation of the enterprise, so more attention needs to be paid to database monitoring and alarms.

[0003] At present, database monitoring and alarms are mostly focused on maintaining system conditions, status, hardware resources, etc., with less involvement in business monitoring. When non-status or hardware problem risks occur within the database, it may have already caused business losses. Therefore, more attention needs to be paid to the problem risks within the database and timely warnings need to be issued. Summary of the invention

[0004] Based on the above research, an embodiment of the present invention provides a database monitoring method, device, electronic device and readable storage medium to achieve timely monitoring of internal data of the database and early warning.

[0005] The embodiments of the present invention can be implemented in the following ways:

[0006] In a first aspect, an embodiment of the present invention provides a method for monitoring a database, comprising:

[0007] Obtain the current status data of the database to be monitored in the current time window;

[0008] Determine a target historical time window that matches the current time window according to a preset monitoring duration;

[0009] Obtaining target historical state data of the database to be monitored within each target historical time window, and determining state change data of the database to be monitored according to the current state data and the target historical state data within each target historical time window;

[0010] The database to be monitored is monitored according to the state change data.

[0011] In an optional implementation manner, determining the state change data of the to-be-monitored database according to the current state data and the target historical state data within each target historical time window includes:

[0012] Determine a first data indicator value of the current state data and a second data indicator value of the target historical state data within each of the target historical time windows; the data indicator values ​​include a maximum value and / or a median value;

[0013] The state change data of the database to be monitored is obtained according to the first data indicator value of the current state data and the second data indicator value of the target historical state data within each of the target historical time windows.

[0014] In an optional implementation, obtaining the state change data of the database to be monitored according to the first data indicator value of the current state data and the second data indicator value of the target historical state data in each target historical time window includes:

[0015] Determine first difference data between the first data indicator value and each of the second data indicator values, and determine second difference data between the first data indicator value and an average value of each of the second data indicator values;

[0016] The state change data of the database to be monitored is obtained according to the first difference data and the second difference data.

[0017] In an optional implementation manner, monitoring the database to be monitored according to the state change data includes:

[0018] For each first difference data in the state change data, compare the first difference data with a second data indicator value corresponding to the first difference data to obtain a first ratio corresponding to the first difference data;

[0019] Determine a second ratio of the second difference data to the first data indicator value;

[0020] The database to be monitored is monitored according to each of the first ratio and the second ratio.

[0021] In an optional implementation manner, monitoring the to-be-monitored database according to each of the first ratio and the second ratio includes:

[0022] If the second ratio and / or at least one of the first ratios is greater than a set change threshold, an alarm is issued to the database to be monitored.

[0023] In an optional implementation, the state data includes a data increment of a data table stored in the database to be monitored; and determining the state change data of the database to be monitored according to the current state data and the target historical state data within each target historical time window includes:

[0024] According to the data increment of the data table in the current time window and the data increment of the data table in each of the target historical time windows, an average data increment of the data table stored in the monitored database within the time length corresponding to the time window is obtained;

[0025] The average data increment of the data table stored in the database to be monitored within the time length corresponding to the time window is determined as the state change data of the database to be monitored.

[0026] In an optional implementation manner, monitoring the database to be monitored according to the state change data includes:

[0027] Determine, based on the state change data, a predicted time for the data stored in the database to be monitored to reach a capacity threshold;

[0028] According to the predicted duration, the data table stored in the database to be monitored is monitored.

[0029] In a second aspect, an embodiment of the present invention provides a monitoring device for a database, the monitoring device comprising a state data acquisition module, a history data acquisition module, a state change determination module and a monitoring module;

[0030] The status data acquisition module is used to acquire the current status data of the database to be monitored in the current time window;

[0031] The historical data acquisition module is used to determine a target historical time window that matches the current time window according to a preset monitoring duration;

[0032] The state change determination module is used to obtain the target historical state data within each target historical time window, and determine the state change data of the database to be monitored according to the current state data and the target historical state data within each target historical time window;

[0033] The monitoring module is used to monitor the database to be monitored according to the state change data.

[0034] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for monitoring a database as described in any of the above embodiments is implemented.

[0035] In a fourth aspect, an embodiment of the present invention provides a readable storage medium, wherein the readable storage medium includes a computer program, and when the computer program is executed, the electronic device where the readable storage medium is located is controlled to execute the database monitoring method described in any of the above embodiments.

[0036] The database monitoring method, device, electronic device and readable storage medium provided by the embodiment of the present invention, after obtaining the current state data of the database to be monitored in the current time window, determine the target historical time window matching the current time window according to the preset monitoring duration, and then obtain the target historical state data of the database to be monitored in each target historical time window, determine the state change data of the database to be monitored according to the current state data and the target historical state data in each target historical time window, and monitor the database to be monitored according to the state change data. In this way, by monitoring the database to be monitored through the state change data, the state data with abnormal changes can be discovered in advance, thereby discovering the problems of the state data in the database in advance, and processing the problems, thereby effectively preventing business problems from occurring in the database and achieving timely early warning of the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The technical solution and other beneficial effects of the present application will be made apparent by describing in detail the specific implementation methods of the present application in conjunction with the accompanying drawings.

[0038] Figure 1 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.

[0039] Figure 2 A schematic flow chart of a method for monitoring a database provided in an embodiment of the present invention.

[0040] Figure 3 A block diagram of a monitoring device for a digital library provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0042] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0043] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or reference letters in different examples, and this repetition is for the purpose of simplification and clarity, which itself does not indicate the relationship between the various embodiments and / or settings discussed. In addition, the various specific processes and material examples provided by the present application, but those of ordinary skill in the art can appreciate the application of other processes and / or the use of other materials.

[0044] At present, the stability of the database is mostly maintained by operation and maintenance personnel or database management staff. Their work is basically to maintain the system conditions, status, hardware resources, etc., and they do not understand the business and internal data of the database. When non-status or hardware problem risks appear in the database, it may have caused business losses. Therefore, more attention needs to be paid to the problem risks within the database and timely warnings should be issued.

[0045] Based on the above research, an embodiment of the present invention provides a database monitoring method, device, electronic device and readable storage medium. After obtaining the current status data of the database to be monitored in the current time window, the target historical time window matching the current time window is determined according to the preset monitoring duration, and then the target historical status data of the database to be monitored in each target historical time window is obtained. According to the current status data and the target historical status data in each target historical time window, the state change data of the database to be monitored is determined, and the database to be monitored is monitored according to the state change data. In this way, by monitoring the database to be monitored through the state change data, the state data with abnormal changes can be discovered in advance, thereby discovering the problems of the state data in the database in advance and handling the problems, thereby effectively preventing business problems from occurring in the database and achieving timely early warning of the database.

[0046] See also Figure 1 , Figure 1 A schematic diagram of the structure of an electronic device provided in this embodiment. Figure 1 As shown, the electronic device 100 includes a monitoring device 10, a memory 20, a processor 30, and a communication unit 40. The memory 20, the processor 30, and the communication unit 40 are electrically connected to each other directly or indirectly to achieve signal transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0047] In this embodiment, the monitoring device 10 includes at least one software function module that can be stored in the memory 20 in the form of software or firmware. The processor 30 is used to execute the software function module stored in the memory 20. When the electronic device 100 is running, the processor 30 communicates with the memory 20 through a bus, and the processor 30 executes the software function module to implement the database monitoring method described in this embodiment.

[0048] Among them, the memory 20 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0049] The processor 30 is used to perform one or more functions described in this embodiment. In some embodiments, the processor 30 may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). By way of example only, the processor 30 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), an application specific instruction set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC) or a microprocessor, or any combination thereof.

[0050] For ease of description, only one processor is described in the electronic device 100. However, it should be noted that the electronic device 100 in this embodiment may also include multiple processors, so the steps performed by one processor described in this embodiment may also be performed jointly or individually by multiple processors. For example, if the processor of the electronic device performs step A and step B, it should be understood that step A and step B may also be performed jointly by two different processors or individually in one processor. For example, the processor performs step A and the second processor performs step B, or the processor and the second processor perform steps A and B together.

[0051] In this embodiment, the process definition method disclosed in any implementation manner may be applied to the processor 30 or implemented by the processor 30 .

[0052] The communication unit 40 is used to establish a communication connection between the electronic device 100 and other devices through a network, and to send and receive data through the network.

[0053] In some embodiments, the network may be any type of wired or wireless network, or a combination thereof. By way of example only, the network may include a wired network, a wireless network, a fiber optic network, a telecommunications network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, or a near field communication (NFC) network, or any combination thereof.

[0054] In this embodiment, the electronic device may be a terminal, a notebook, a tablet, an ultra-mobile personal computer (UMPC), a personal digital assistant (PDA), a physical server, or the like. This embodiment does not impose any restrictions on the specific type of the electronic device.

[0055] Understandably, Figure 1 The structure shown is for illustration only. The electronic device may also have Figure 1 More or fewer components than shown, or with Figure 1Different configurations are shown. Figure 1 The components shown may be implemented in hardware, software or a combination thereof.

[0056] based on Figure 1 This embodiment provides a database monitoring method. Figure 1 The electronic device shown in the figure performs the following detailed description of the steps of the database monitoring method provided in this embodiment. Figure 2 The database monitoring method provided in this embodiment includes steps S101 to S104.

[0057] Step S101: obtaining current status data of the database to be monitored in the current time window.

[0058] In this embodiment, the database to be monitored may be any database that needs to be monitored, wherein the database may be a relational database.

[0059] In this embodiment, the state data may be table information of a data table stored in the database, wherein the table information of the data table stored in the database includes, but is not limited to: the total number of data tables stored in the database, the total number of rows in each data table, the maximum ID of each database table, the number of rows added to each data table within a time window, and the number of rows added to each data table per month.

[0060] In an optional implementation manner, the database to be monitored may be actively called to obtain table information of a data table stored in the database to be monitored.

[0061] In an optional implementation, after obtaining the table information of the data table stored in the database to be monitored, the table information of the data table stored in the database to be monitored can be backed up and stored in the data collection module for subsequent calls. Optionally, the data collection module can be constructed based on a MySQL database.

[0062] In order to achieve comprehensive detection of the database, in an optional implementation, the state data may also include the operation state data of the database, wherein the operation state data of the database includes, but is not limited to, CPU usage, memory usage, bandwidth usage, number of database connections, number of SQL statements with long running time, number of database deadlocks, and number of error logs.

[0063] In an optional implementation, a software development kit (SDK) can be set to monitor and read the status of the server where the database is located, so as to obtain the operating status data of the database. Among them, the performance of the server where the database is located can be read through the instructions in the SDK, including data such as CPU usage, bandwidth usage, memory usage, and the number of database links. The log of the server where the database is located can be read through the instructions in the SDK to obtain information such as the number of SQL statements with a long running time, the number of deadlocks in the database, and the number of error logs.

[0064] It can be understood that the running status data of the database collected by the SDK can also be backed up and stored in the data collection module for subsequent calls.

[0065] In this embodiment, the time window is used to determine the frequency of collecting status data in the database, and the length of the time window can be set according to the needs of collecting data. For example, for the table information of the data table stored in the database to be monitored, the length of the time window can be set to 24 hours, that is, the electronic device can call the database to be monitored once every 24 hours, obtain the table information of the data table stored in the database to be monitored, and back up the table information of the data table stored in the database to be monitored to the data collection module. If the electronic device obtains the table information of the data table stored in the database to be monitored at 14:00, the current time window is from 14:00 of the previous day to 14:00 of the current day, and accordingly, the table information of the data table obtained is the table information from 14:00 of the previous day to 14:00 of the current day.

[0066] For another example, for the operating status data of the database to be monitored, the length of the time window can be set to 5 minutes, that is, the SDK reports the collected operating status data of the database to be monitored to the electronic device and the data collection module every 5 minutes. If the electronic device obtains the operating status data of the database to be monitored at 14:00, the current time window is the time window from 13:55 to 14:00, and accordingly, the acquired operating status data is the operating status data within the time window from 13:55 to 14:00.

[0067] Step S102: Determine a target historical time window that matches the current time window according to a preset monitoring duration.

[0068] The monitoring duration refers to the duration used to determine the change of status data. For example, if you want to determine the change of status data within a week, the monitoring duration is one week. For another example, if you want to determine the change of status data every day, the monitoring duration is 24 hours. For another example, if you want to determine the change of status data in a month, the monitoring duration can be one month.

[0069] In this embodiment, there may be multiple monitoring durations, and each monitoring duration corresponds to a different length of time.

[0070] When determining the target historical time window that matches the current time window based on the monitoring duration, the current time window can be backtracked based on the monitoring duration to obtain the target historical time window that matches the current time window. For example, if the monitoring duration is one week and the current time window is from 14:00 on April 10, 2023 to 14:05 on April 10, 2023, then the current time window is backtracked based on the monitoring duration to obtain the target historical time window that matches the current time window from 14:00 on April 3, 2023 to 14:05 on April 3, 2023.

[0071] For another example, if the monitoring duration is 24 hours and the current time window is from 14:00 on April 10, 2023 to 14:00 on April 11, 2023, then based on the monitoring duration, the current time window is traced back to obtain a target historical time window that matches the current time window, which is from 14:00 on April 9, 2023 to 14:00 on April 10, 2023.

[0072] It can be understood that if there are multiple monitoring durations, then based on the monitoring durations, there are multiple target historical time windows determined to match the current time window.

[0073] Step S103: Obtain target historical status data of the database to be monitored in each target historical time window, and determine the status change data of the database to be monitored according to the current status data and the target historical status data in each target historical time window.

[0074] Among them, after obtaining the target historical time window matching the current time window, the target historical status data in each target historical time window can be obtained.

[0075] Since the data collection module stores the state data collected in each time window, the target historical state data in each target historical time window can be obtained from the data collection module. Specifically, for each target historical time window, a query can be performed in the data collection module according to the time corresponding to the target historical time window to obtain the target historical state data of the target historical time window.

[0076] After obtaining the target historical status data in each target historical time window, the status data of the monitored database in the same time period in different time lengths is obtained. By comparing the status data of the same time period in different time lengths, the fluctuation of the monitored database in the same time period can be obtained.

[0077] In an optional implementation, when determining the state change data of the database to be monitored based on the current state data and the target historical state data in each target historical time window, the target historical state data in each target historical time window can be compared with the current state data in the current time window to obtain a comparison result of the target historical state data in each target historical time window and the current state data in the current time window. The comparison result of the target historical state data in each target historical time window and the current state data in the current time window is the state change data of the database to be monitored.

[0078] Optionally, the comparison result may be the difference between the target historical status data and the current status data. For example, the target historical status data in the target historical time window A is set to data a, the target historical status data in the target historical time window B is set to data b, the target historical status data in the target historical time window C is set to data c, and the current status data in the current time window D is set to data d. After comparing the target historical status data in each target historical time window with the current status data in the current time window, the comparison result of the target historical time window A and the current time window D is da, the comparison result of the target historical time window B and the current time window D is db, and the comparison result of the target historical time window C and the current time window D is dc.

[0079] Optionally, the comparison result may also be the ratio of the target historical status data to the current status data. For example, the target historical status data in the target historical time window A is set to data a, the target historical status data in the target historical time window B is set to data b, the target historical status data in the target historical time window C is set to data c, and the current status data in the current time window D is set to data d. After comparing the target historical status data in each target historical time window with the current status data in the current time window, the comparison result of the target historical time window A and the current time window D is d / a, the comparison result of the target historical time window B and the current time window D is d / b, and the comparison result of the target historical time window C and the current time window D is d / c.

[0080] Step S104: monitor the database to be monitored according to the state change data.

[0081] Optionally, the state change data may include a comparison result between the target historical state data in each target historical time window and the current state data in the current time window. After obtaining the state change data, the state change data may be compared with a preset change threshold to detect whether there is a comparison result that exceeds the change threshold. If so, it means that the current state data of the current time window of the monitored database has changed abnormally compared with the historical state data. If there is an abnormal change in the stored data table (such as the number of rows in the table increases too quickly), there is an abnormal risk.

[0082] For example, the state change data includes the comparison results of the target historical time window A and the current time window D, the comparison results of the target historical time window B and the current time window D, and the comparison results of the target historical time window C and the current time window D. When there is a target historical time window, such as the comparison result of the target historical time window A and the current time window D exceeds the change threshold, it means that the current state data of the current time window D of the monitored database is abnormal compared with the historical state data of the target historical time window A, and there is an abnormal risk in the monitored database.

[0083] When it is determined that there is an abnormal risk in the monitored database, an alarm can be triggered and the alarm information can be sent to the staff via email, text message, phone call and other communication methods to prompt the staff to deal with it in time, so as to achieve the effect of handling the problem in advance and avoid the occurrence of problems and business losses.

[0084] The database monitoring method provided in this embodiment, after obtaining the current state data of the database to be monitored in the current time window, determines the target historical time window matching the current time window according to the preset monitoring duration, and then obtains the target historical state data in each target historical time window, determines the state change data of the database to be monitored according to the current state data and the target historical state data in each target historical time window, and monitors the database to be monitored according to the state change data. In this way, through the state change data, the internal part of the database to be monitored is monitored emphatically, and the state data with abnormal changes can be discovered in advance, thereby discovering the problems of the state data in the database in advance, and processing the problems, thereby effectively preventing business problems from occurring in the database and achieving timely early warning of the database.

[0085] In order to realize real-time monitoring of the state of the database, in an optional implementation, an alarm threshold for real-time detection may be set for the current state data of the current time window obtained. Specifically, a corresponding alarm threshold may be set for each item in the obtained state data.

[0086] For example, when the status data is the table information of the data table stored in the database, the acquired status data includes the total number of tables of the data table stored in the database, the total number of rows of each data table, the maximum ID of each database table, the number of rows added to each data table within the time window, and the number of rows added to each data table per month. Then, an alarm threshold can be set for the total number of tables of the stored data table, the total number of rows of each data table, the maximum ID of each database table, the number of rows added to each data table per day, and the number of rows added to each data table per month. For any of the acquired data, if it exceeds the corresponding alarm threshold, an alarm can be issued.

[0087] For another example, when the status data includes the running status data of the database, the status data obtained includes CPU usage, memory usage, bandwidth usage, number of database connections, number of SQL statements with long running time, number of database deadlocks, and number of error logs, then an alarm threshold can be set for each of the CPU usage, memory usage, bandwidth usage, number of database connections, number of SQL statements with long running time, number of database deadlocks, and number of error logs. For example, for CPU usage, the threshold can be set to 70%, and an alarm can be issued when the CPU usage exceeds 70%. For memory usage, the threshold can be set to 80%, and an alarm can be issued when the memory usage exceeds 80%. In this way, for any item of status data obtained, if it exceeds its corresponding alarm threshold, an alarm can be issued.

[0088] Optionally, the alarm threshold for real-time detection set for status data can be set according to actual needs, and this embodiment does not make specific limitations. It can be understood that the alarm threshold set for real-time detection needs to be set reasonably to prevent failures. If the setting is unreasonable, when an alarm is issued based on the alarm threshold, it means that there is a problem with the database, which has already affected the business.

[0089] In order to realize early monitoring of the database status, in this embodiment, by obtaining the status data of the same time period in different time lengths, it is predicted whether there is a risk in the monitored database according to the change of the status data of the same time period in different time lengths, so as to discover the problems of the status data in the database in advance and deal with the problems.

[0090] In order to reduce the computational complexity and accurately obtain the change of the state data, in an optional implementation, the state change data of the database to be monitored can be obtained according to the data indicator values ​​of the state data of the same time period in different time periods. Based on this, in this embodiment, the process of determining the state change data of the database to be monitored according to the current state data and the target historical state data in each target historical time window can include steps a1 to a2.

[0091] Step a1: Determine a first data indicator value of current state data and a second data indicator value of target historical state data within each target historical time window.

[0092] Step a2: obtaining the state change data of the database to be monitored according to the first data indicator value of the current state data and the second data indicator value of the target historical state data in each target historical time window.

[0093] In this embodiment, the data indicator value may be a maximum value and / or an average value.

[0094] When the data indicator value is the maximum value, the first data indicator value of the current state data is determined by comparing all values ​​of the state data collected in the current time window for each state data to obtain the maximum value of the state data. For example, for the state data: the number of rows added in each table in the time window, assuming that in the current time window, the number of rows added in data table a is 20, 40, and 60, then for data table a, the maximum value of the number of rows added in the current time window is 60.

[0095] For another example, for status data: CPU usage, assuming that in the current time window, the collected CPU usage has values ​​of 50%, 40%, and 60%, then for the CPU usage, the maximum value in the current time window is 60%.

[0096] When the data indicator value is an average value, determining the first data indicator value of the current state data may be to average all values ​​of the state data collected in the current time window for each state data to obtain the average value of the state data.

[0097] For example, for status data: the number of rows added in each table within the time window. Assuming that in the current time window, the number of rows added in data table a is 20, 40, and 60, then for data table a, the average number of rows added in the current time window is 40.

[0098] For another example, for the status data: CPU usage, assuming that in the current time window, the collected CPU usage has values ​​of 50%, 40%, and 60%, then for the CPU usage, the average value in the current time window is 50%.

[0099] Correspondingly, the second data indicator value of the target historical status data within each target historical time window is also obtained in the same manner, which will not be elaborated here.

[0100] After obtaining the first data indicator value of the current status data and the second data indicator value of the target historical status data within each target historical time window, the status change data of the database to be monitored can be obtained based on the first data indicator value of the current status data and the second data indicator value of the target historical status data within each target historical time window.

[0101] In order to comprehensively and timely discover the possible risks of the database to be monitored, in this embodiment, according to the first data indicator value of the current state data and the second data indicator value of the target historical state data in each target historical time window, the state change data of the database to be monitored is obtained, including:

[0102] Determine first difference data between the first data indicator value and each second data indicator value, and determine second difference data between the first data indicator value and an average value of each second data indicator value;

[0103] The state change data of the database to be monitored is obtained according to the first difference data and the second difference data.

[0104] Among them, the first data indicator value of the current state data can be subtracted from the second data indicator value of the target historical state data in each target historical time window to obtain the first difference data between the first data indicator value of the current state data and the second data indicator value of the target historical state data in each target historical time window.

[0105] For example, for status data: the number of rows added in each table within the time window, assuming that in the current time window, the first indicator value of the number of rows added to data table a is 40, the second indicator value of the number of rows added to data table a in the target historical time window A is 30, the second indicator value of the number of rows added to data table a in the target historical time window B is 40, and the second indicator value of the number of rows added to data table a in the target historical time window C is 50. After subtraction, the first difference data between the first indicator value of the number of rows added to data table a and the second data indicator value of the target historical time window A is 10, the first difference data with the second data indicator value of the target historical time window B is 0, and the first difference data with the second data indicator value of the target historical time window C is -10.

[0106] Among them, when determining the second difference data between the first data indicator value and the average value of each second data indicator value, the second data indicator value of the target historical status data in each target historical time window can be averaged to obtain the average value of the second data indicator value of the target historical status data in each target historical time window, and then the first data indicator value and the average value are differenced to obtain the second difference data between the first data indicator value and the average value of each second data indicator value.

[0107] For example, for status data: the number of rows added to each table within the time window, assuming that in the current time window, the first indicator value of the number of rows added to data table a is 40, the second indicator value of the number of rows added to data table a in the target historical time window A is 30, the second indicator value of the number of rows added to data table a in the target historical time window B is 40, and the second indicator value of the number of rows added to data table a in the target historical time window C is 50. After averaging the second indicator values ​​in each target historical window, the average value is 40. The difference between the first indicator value and the average value is calculated, and the second difference data is 0.

[0108] After obtaining the first difference data between the first data indicator value and each second data indicator value, and the second difference data between the first data indicator value and the average value of each second data indicator value, the first difference data and the second difference data can be determined as the state change data of the database to be monitored, that is, in this embodiment, the state change data includes the difference data between the first data indicator value of the current state data and the second data indicator value of the target historical state data in each target historical time window, and the difference data between the first data indicator value of the current state data and the average value of the second data indicator value of the target historical state data in each target historical time window.

[0109] After obtaining the state change data of the database to be monitored, the database to be monitored can be monitored according to the state change data of the database to be monitored.

[0110] In this embodiment, the process of monitoring the database to be monitored according to the state change data may include steps b1 to b3.

[0111] Step b1: for each first difference data in the state change data, compare the first difference data with the second data indicator value corresponding to the first difference data to obtain a first ratio corresponding to the first difference data.

[0112] Step b2: Determine a second ratio of the second difference data to the first data indicator value.

[0113] Step b3: Monitor the database to be monitored according to the first ratio and the second ratio.

[0114] Among them, for each first difference data in the state change data, the first difference data is compared with the second data index value corresponding to the first difference data, that is, the ratio is calculated, and the first ratio corresponding to the first difference data can be obtained. For example, the first index value of the state data of the current time window A is a, the second index value of the state data of the target historical time window B is b, and the second index value of the state data of the target historical time window C is c. The first difference data of the first index value a of the state data of the current time window A and the second index value b of the state data of the target historical time window B is ab, and the first difference data of the first index value a of the state data of the current time window A and the second index value c of the state data of the target historical time window C is ac.

[0115] For the first difference data ab, the corresponding second data indicator value is b, then the first ratio corresponding to the first difference data is (ab) / b; for the first difference data ac, the corresponding second data indicator value is c, then the first ratio corresponding to the first difference data is (ac) / c.

[0116] In this embodiment, the first ratio corresponding to each first difference data represents the ratio-to-ratio between the current state data of the current time window and the target historical state data of the target historical time window corresponding to the first difference data.

[0117] This embodiment determines the month-on-month data of the current status data of the current time window and the target historical status data of each target historical time window. Based on the month-on-month data of the current status data of the current time window and the target historical status data of each target historical time window, the fluctuation of the current status data of the current time window relative to the status data of the same period in different time periods can be accurately obtained.

[0118] In this embodiment, the second difference data is compared with the first data indicator value, that is, the ratio is calculated to obtain the second ratio of the second difference data to the first data indicator value. For example, the first indicator value of the state data of the current time window A is a, the second indicator value of the state data of the target historical time window B is b, the second indicator value of the state data of the target historical time window C is c, and the second indicator value of the state data of the target historical time window D is d. The average value of each second indicator value is (b+c+d) / 3, the second difference data between the first data indicator value and the average value of each second data indicator value is (a-(b+c+d) / 3), and the second ratio of the second difference data to the first data indicator value is (a-(b+c+d) / 3) / a.

[0119] In this embodiment, since the second difference data is calculated based on the first data indicator value and the average value of each second data indicator value, the second difference data combines the status data of the same period in different periods, and the second ratio of the second difference data to the first data indicator value reflects the fluctuation of the status data of the current time window relative to the average value of the status data of the same period in different periods.

[0120] In this embodiment, the fluctuation of the current status data of the current time window relative to the status data of the same period in different periods reflects the difference in data from a single time period, and the fluctuation of the current status data of the current time window relative to the average value of the status data of the same period in different periods reflects the difference from the overall data of multiple time periods. Therefore, based on the first ratio and the second ratio, the current status data of the current time window can be determined from the difference in a single time period and the overall difference in multiple time periods, so that a more comprehensive analysis can be made as to whether there is any abnormality in the status data of the current time window.

[0121] After obtaining the first ratio of each first difference data to the first data indicator value, and the second ratio of the second difference data to the first data indicator value, the database to be monitored can be monitored according to each first ratio and the second ratio.

[0122] In an optional implementation, a weighted average of the first ratios and the second ratios may be performed to obtain a target ratio, and the target ratio may be compared with a set change threshold. When the target ratio is greater than the set change threshold, it indicates that the status data of the monitored data has undergone an abnormal change, and there may be risks, and an alarm is issued.

[0123] In order to achieve the purpose of avoiding the problem in advance, in this embodiment, the step of monitoring the database to be monitored according to each first ratio and the second ratio may also include:

[0124] If the second ratio and / or at least one of the first ratios is greater than the set change threshold, an alarm is issued to the monitored database.

[0125] Among them, after obtaining the first ratio of each first difference data to the first data indicator value, and the second ratio of the second difference data to the first data indicator value, each first ratio can be compared with the set change threshold, and the second ratio can be compared with the set change threshold.

[0126] When at least one ratio exceeds the set change threshold, it indicates that the current state data of the current time window has changed significantly relative to the state data of the same period in history, and there may be business risks. When the second ratio exceeds the set change threshold, it indicates that the current state data of the current time window has changed significantly relative to the average state data of the same period in history, and there may be business risks.

[0127] Therefore, when the second ratio and / or at least one first ratio exceeds the set change threshold, an alarm is triggered. In this way, when an abnormal change occurs compared to any historical time period and when an abnormal change occurs compared to the average value of the historical time period, an alarm can be triggered, thereby discovering problems with status data in the database in advance from all aspects, thereby achieving the purpose of avoiding problems in advance.

[0128] It should be noted that the setting change threshold can be set according to demand, and this embodiment does not make specific restrictions. Optionally, the setting change threshold in this embodiment can be 50%. In order to facilitate the staff to intuitively obtain the alarm details, in an optional implementation, the electronic device may also include a display unit, which provides a display interface for the display unit. After the alarm prompt is triggered, all alarm prompts can be displayed on the display interface, so that the staff can intuitively obtain the alarm prompt.

[0129] In an optional implementation, the display unit can also be used to display current status data obtained in the current time window, such as CPU usage, memory usage, the number of rows in each table, the maximum number of rows that can be reached, and daily, monthly, and daily increment values.

[0130] The database monitoring method provided in this embodiment obtains status data of the same time period in different time lengths, and predicts whether there is a risk in the database to be monitored based on the changes in data indicator values ​​of the status data in the same time period in different time lengths. Problems with the status data in the database can be discovered in advance and the problems can be processed to achieve the purpose of avoiding the problems in advance.

[0131] Considering that the storage capacity of the data table stored in the database is limited, when the capacity of the data table is used up, it will cause business collapse. Therefore, in this embodiment, the data increment of the data table stored in the database can also be monitored to avoid the situation where the capacity of the data table is used up. Based on this, in this embodiment, the state data of the database also includes the data increment of the data table stored in the database. By obtaining the data increment of the data table stored in the database in different time windows, the data table of the database can be monitored according to the data increment of the data table stored in the database in different time windows.

[0132] In an optional embodiment, after obtaining the data increments of the data table in the current time window and the data increments of the data table in each target historical time window, the data increments of the data table in the current time window and the data increments of the data table in each target historical time window can be input into a preset detection model. The detection model is used to perform feature processing on the data increments of the data table in the current time window and the data increments of the data table in each target historical time window, and the predicted duration for the data table stored in the monitored database to reach the capacity threshold is predicted. Then, based on the predicted duration, the data table in the database is monitored.

[0133] Among them, the detection model can be constructed based on a recurrent neural network and trained through supervised or unsupervised training methods.

[0134] To reduce complexity and improve efficiency, in this embodiment, the step of determining the state change data of the database to be monitored according to the current state data and the target historical state data in each target historical time window may include steps d1 to d2.

[0135] Step d1: according to the data increment of the data table in the current time window and the data increment of the data table in each target historical time window, the average data increment of the data table stored in the monitored database in the time window is obtained.

[0136] Step d2: Determine the average data increment of the data table stored in the database to be monitored in the time window as the state change data of the database to be monitored.

[0137] The data increment of the data table may be an increment of the number of rows of the data table or an increment of the number of columns of the data table.

[0138] When the average data increment of the data table stored in the monitored database within the time length corresponding to the time window is obtained based on the data increment of the data table in the current time window and the data increment of the data table in each target historical time window, the data increment of the data table in the current time window and the data increment of the data table in each target historical time window can be added to obtain the total increment, and then the total number of time windows of the current time window and each target historical time window is determined. According to the ratio of the total increment to the total number of time windows, the average data increment of the data table stored in the monitored database in the time window can be obtained.

[0139] For example, taking 24 hours as the length of the time window, determining the average daily data increment of the data table within a week is used as an example to illustrate. Assuming that the monitoring time is 24 hours, 48 ​​hours, 72 hours, 96 hours, 120 hours, 144 hours and 168 hours respectively, there are 7 target historical time windows obtained based on the monitoring time, that is, each day in the current week is a target historical time window, then the daily average data increment of the data table stored in the monitored database is avg_inc = (inc1+inc2+..+inc7) / 7; wherein inc1, inc2, .., inc7 are the data increments of the target historical time windows respectively.

[0140] After obtaining the average data increment of the data table stored in the monitored database in the time window, the average data increment of the data table stored in the monitored database in the time window can be determined as the state change data of the monitored database, and the monitored database is monitored based on the state change data.

[0141] Optionally, in this embodiment, the step of monitoring the database to be monitored according to the state change data may include:

[0142] According to the state change data, the predicted time for the data stored in the monitored database to reach the capacity threshold is determined.

[0143] According to the predicted duration, the data table stored in the monitored database is monitored.

[0144] Among them, after obtaining the state change data, the average data increment of the data table stored in the monitored database in the time window can be obtained. According to the state change data, the predicted time length of the data table stored in the monitored database to reach the capacity threshold is determined, that is, according to the average data increment of the data table stored in the monitored database in the time window, the predicted time length of the data table stored in the monitored database to reach the capacity threshold is determined.

[0145] In this embodiment, the capacity threshold is the maximum amount of data that can be stored in the data table.

[0146] In an optional implementation, the current amount of stored data and the capacity threshold corresponding to the auto-increment key in the data table can be obtained. For the auto-increment key in the data table, if the key type is int, the capacity threshold is set to max_length_int; if the key type is bigint, the capacity threshold is set to max_length_bigint.

[0147] After obtaining the current storage data volume and capacity threshold corresponding to the auto-increment key in the data table, the current storage data volume and capacity threshold corresponding to the auto-increment key in the data table are subtracted to obtain the target data volume that can be stored corresponding to the current auto-increment key. Then, based on the target data volume and the average data increment of the data table in the time window, the number of time windows required to reach the target data volume is obtained. Based on the number of time windows and the length of the time window, the predicted time for the data table stored in the monitored database to reach the capacity threshold can be predicted.

[0148] After the predicted duration is obtained, the data table stored in the monitoring database can be monitored according to the predicted duration. Optionally, when the predicted duration is less than the set duration threshold, it means that the capacity of the data table is almost consumed. Therefore, when the predicted duration is less than the set duration threshold, a data table capacity alarm can be issued.

[0149] In an optional implementation, after obtaining the average data increment of the data table stored in the monitored database in the time window, the storage data volume of the data table stored in the monitored database in the next time window can be predicted based on the average data increment and the storage data volume of the current data table, and then a judgment is made as to whether the storage data volume in the next time window exceeds the set storage threshold. If it exceeds the set storage threshold, it indicates that the storage capacity of the data table is about to be consumed, and then a data table capacity alarm is issued.

[0150] In an optional implementation, after the alarm is triggered, the alarm information (alarm database, data table name, incremental data, predicted duration, etc.) of the alarm can be displayed on the display interface, so that the staff can intuitively obtain the alarm information, as shown in Table 1.

[0151] Table 1

[0152]

[0153] The database monitoring method provided in this embodiment obtains the data increment of the data table stored in the database in different time windows, predicts the predicted time for the data table to reach the capacity threshold according to the data increment of the data table stored in the database in different time windows, and then monitors the data table stored in the monitored database according to the predicted time. In this way, by monitoring the increment of the table, most of the blind spots of monitoring are supplemented, and the loss caused by the self-increment of the table can be effectively prevented, and the problem of running out of rows in the data table, which leads to the overflow of the integer range at the code level, can be avoided.

[0154] Based on the same inventive concept, please refer to Figure 3 The embodiment of the present invention also provides a database monitoring device 10, which is applied to Figure 1The electronic device shown consists of Figure 1 The electronic device shown performs, as Figure 3 As shown, the monitoring device 10 provided in the embodiment of the present invention includes a state data acquisition module 11 , a history data acquisition module 12 , a state change determination module 13 and a monitoring module 14 .

[0155] The status data acquisition module 11 is used to acquire the current status data of the database to be monitored in the current time window.

[0156] The historical data acquisition module 12 is used to determine a target historical time window that matches the current time window according to a preset monitoring duration.

[0157] The state change determination module 13 is used to obtain the target historical state data of the database to be monitored in each target historical time window, and determine the state change data of the database to be monitored according to the current state data and the target historical state data in each target historical time window.

[0158] The monitoring module 14 is used to monitor the database to be monitored according to the state change data.

[0159] In an optional implementation manner, the state change determination module 13 is used to:

[0160] Determine a first data indicator value of the current state data and a second data indicator value of the target historical state data within each target historical time window; wherein the data indicator value includes a maximum value and / or an average value.

[0161] The state change data of the database to be monitored is obtained according to the first data indicator value of the current state data and the second data indicator value of the target historical state data in each target historical time window.

[0162] In an optional implementation manner, the state change determination module 13 is used to:

[0163] Determine first difference data between the first data indicator value and each second data indicator value, and determine second difference data between the first data indicator value and an average value of each second data indicator value;

[0164] The state change data of the database to be monitored is obtained according to each of the first difference data and the second difference data.

[0165] In an optional embodiment, the monitoring module 14 is used to:

[0166] For each first difference data in the state change data, compare the first difference data with a second data indicator value corresponding to the first difference data to obtain a first ratio corresponding to the first difference data;

[0167] Determine a second ratio of the second difference data to the first data indicator value;

[0168] The database to be monitored is monitored according to each first ratio and the second ratio.

[0169] In an optional embodiment, the monitoring module 14 is used to:

[0170] If the second ratio and / or at least one of the first ratios is greater than the set change threshold, an alarm is issued to the monitored database.

[0171] In an optional implementation, the state data includes data increments in a data table stored in the database to be monitored; the state change determination module 13 is used to:

[0172] According to the data increment of the data table in the current time window and the data increment of the data table in each target historical time window, the average data increment of the data table stored in the monitored database within the time length corresponding to the time window is obtained.

[0173] The average data increment of the data table stored in the database to be monitored within the time length corresponding to the time window is determined as the state change data of the database to be monitored.

[0174] In an optional embodiment, the monitoring module 14 is used to:

[0175] Determine the predicted time for the data stored in the monitored database to reach the capacity threshold based on the state change data;

[0176] According to the predicted duration, the data table stored in the monitored database is monitored.

[0177] The monitoring device for a database provided by an embodiment of the present invention, after obtaining the current state data of the database to be monitored in the current time window, determines the target historical time window matching the current time window according to the preset monitoring duration, and then obtains the target historical state data of the database to be monitored in each target historical time window, and determines the state change data of the database to be monitored according to the current state data and the target historical state data in each target historical time window, and monitors the database to be monitored according to the state change data. In this way, by monitoring the database to be monitored through the state change data, the state data with abnormal changes can be discovered in advance, thereby discovering the problems of the state data in the database in advance, and processing the problems, and then effectively preventing business problems from occurring in the database, and realizing timely early warning of the database.

[0178] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the monitoring device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.

[0179] Based on the above, this embodiment provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the database monitoring method of any of the aforementioned embodiments is implemented.

[0180] The readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0181] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the readable storage medium described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.

[0182] In summary, the database monitoring method, device, electronic device and readable storage medium provided by the embodiments of the present invention, after obtaining the current status data of the database to be monitored in the current time window, determine the target historical time window that matches the current time window according to the preset monitoring duration, and then obtain the target historical status data of the database to be monitored in each target historical time window, and determine the state change data of the database to be monitored according to the current status data and the target historical status data in each target historical time window, and monitor the database to be monitored according to the state change data. In this way, by monitoring the database to be monitored through the state change data, the state data with abnormal changes can be discovered in advance, thereby discovering the problems of the state data in the database in advance, and processing the problems, thereby effectively preventing business problems from occurring in the database and achieving timely early warning of the database.

[0183] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0184] The above is a detailed introduction to a database monitoring method, device and electronic device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the technical solution and its core idea of ​​the present application. Ordinary technicians in this field should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or replace some of the technical features therein with equivalents; and these modifications or replacements do not make the essence of the corresponding technical solution deviate from the scope of the technical solution of the embodiments of the present application.

Claims

1. A database monitoring method, characterized in that: The method comprises: Obtain the current status data of the database to be monitored in the current time window; Determine a target historical time window that matches the current time window according to a preset monitoring duration; Obtaining target historical state data of the database to be monitored within each target historical time window, and determining state change data of the database to be monitored according to the current state data and the target historical state data within each target historical time window; The database to be monitored is monitored according to the state change data.

2. The monitoring method according to claim 1, characterized in that: The step of determining the state change data of the database to be monitored according to the current state data and the target historical state data within each target historical time window includes: Determine a first data indicator value of the current state data and a second data indicator value of the target historical state data within each of the target historical time windows; wherein the data indicator values ​​include a maximum value and / or an average value; The state change data of the database to be monitored is obtained according to the first data indicator value of the current state data and the second data indicator value of the target historical state data within each of the target historical time windows.

3. The monitoring method according to claim 2, characterized in that: The step of obtaining the state change data of the database to be monitored according to the first data indicator value of the current state data and the second data indicator value of the target historical state data within each target historical time window includes: Determine first difference data between the first data indicator value and each of the second data indicator values, and determine second difference data between the first data indicator value and an average value of each of the second data indicator values; The state change data of the database to be monitored is obtained according to the first difference data and the second difference data.

4. The monitoring method according to claim 3, characterized in that: The monitoring of the database to be monitored according to the state change data includes: For each first difference data in the state change data, compare the first difference data with a second data indicator value corresponding to the first difference data to obtain a first ratio corresponding to the first difference data; Determine a second ratio of the second difference data to the first data indicator value; The database to be monitored is monitored according to each of the first ratio and the second ratio.

5. The monitoring method according to claim 4, characterized in that: The monitoring of the to-be-monitored database according to each of the first ratio and the second ratio includes: If the second ratio and / or at least one of the first ratios is greater than a set change threshold, an alarm is issued to the database to be monitored.

6. The monitoring method according to claim 1, characterized in that: The state data includes data increments of a data table stored in the database to be monitored; the state change data of the database to be monitored is determined according to the current state data and the target historical state data in each target historical time window, including: According to the data increment of the data table in the current time window and the data increment of the data table in each of the target historical time windows, an average data increment of the data table stored in the monitored database within the time length corresponding to the time window is obtained; The average data increment of the data table stored in the database to be monitored within the time length corresponding to the time window is determined as the state change data of the database to be monitored.

7. The monitoring method according to claim 6, characterized in that: The monitoring of the database to be monitored according to the state change data includes: Determine, based on the state change data, a predicted time for the data stored in the database to be monitored to reach a capacity threshold; According to the predicted duration, the data table stored in the database to be monitored is monitored.

8. A database monitoring device, characterized in that: The monitoring device includes a state data acquisition module, a historical data acquisition module, a state change determination module and a monitoring module; The status data acquisition module is used to acquire the current status data of the database to be monitored in the current time window; The historical data acquisition module is used to determine a target historical time window that matches the current time window according to a preset monitoring duration; The state change determination module is used to obtain the target historical state data of the database to be monitored within each target historical time window, and determine the state change data of the database to be monitored according to the current state data and the target historical state data within each target historical time window; The monitoring module is used to monitor the database to be monitored according to the state change data.

9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the database monitoring method according to any one of claims 1 to 7 when executing the computer program.

10. A readable storage medium, characterized in that: The readable storage medium includes a computer program, and when the computer program is executed, the electronic device where the readable storage medium is located is controlled to execute the database monitoring method according to any one of claims 1 to 7.