A big data log query method and device based on timed aggregation
By using the timing aggregation method in big data log query, building a query cache and estimating the query time interval, the problem of low query speed and hit rate of hundreds of millions of logs is solved, and high efficiency is achieved without changing the log storage method and database. Query performance.
Patent Information
- Application Number
- CN202411108873.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-08-13
AI Technical Summary
In the era of big data, log query speeds and hit rates on the order of hundreds of millions are difficult to meet user needs. Existing technologies are costly to migrate distributed databases or change databases, and query speeds fluctuate significantly. It is impossible to achieve this without changing log storage methods and databases. Improve query performance.
A big data log query method based on timed aggregation is used to form a query cache through aggregation logs. According to the query time interval input by the user, the matching query cache is selected for query, and the length of the next query time interval is estimated for re-aggregation and cyclic execution to improve query performance. Speed and hit rate.
It achieves a significant improvement in log query speed and hit rate of orders of magnitude over 100 million without changing the log storage method and database, enabling a single machine to achieve millisecond-level query times and improving the stability of query performance.
Smart Images

Figure CN118626448B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of log data processing, and in particular to a big data log query method and device based on timed aggregation. Background Art
[0002] Log data can be used in troubleshooting, monitoring, security, compliance, electronic evidence collection and many other areas. With the advent of the big data era, the number and types of logs are growing rapidly. When the number of query logs rises to tens of millions or hundreds of millions, the log query time may increase to several seconds or even tens of seconds, which cannot meet the user's usage needs. If you migrate a distributed database or change the current database to a cluster, you can greatly improve the computing power of the system, but the implementation cost is high. If you only use query cache, when the cache misses, the response speed will fluctuate significantly, which cannot meet the needs.
[0003] Therefore, we hope to significantly improve the query speed and hit rate of logs exceeding 100 million without changing the log storage method and log database. Summary of the invention
[0004] In view of the above-mentioned defects or deficiencies in the prior art, the present invention provides a big data log query method and device based on timed aggregation, which can greatly improve the log query speed and hit rate of more than 100 million levels without changing the log storage method and log database.
[0005] One aspect of the present invention provides a big data log query method based on timed aggregation, comprising:
[0006] Step 1: According to the timestamp of the real log, the real log is aggregated with different time intervals as the aggregation granularity to form a multi-level aggregate log with the same structure as the real log. Each level of aggregate log includes multiple aggregate logs.
[0007] Step 2: According to the query time interval currently input by the user, select the query cache with the best matching time range as the current query cache, query the stored aggregate logs in the current query cache and output the query results; wherein the query cache includes the aggregate logs and aggregate log IDs within the predetermined time interval;
[0008] Step 3: The starting point of the time interval with the highest user query frequency is used as the starting point of the time interval for the user's next query, and the length of the time interval for the user's next query is estimated. The aggregated log is aggregated again according to the estimated result, and the aggregated log and the aggregated log ID obtained by the re-aggregation are stored in multiple new query caches used by the user's next query;
[0009] The above steps 2 and 3 are executed repeatedly until the user stops searching.
[0010] Furthermore, the estimating the time interval length of the user's next query includes: calculating the time interval length of the user's next query according to the following formula: :
[0011] = ;
[0012] ;
[0013] n P) ;
[0014] in, Indicates the reference value of the time interval length for the user's next query. The initial value of is 0; represents the first empirical coefficient, (0,1); Indicates the length of the time interval that the user is currently querying; Indicates the length of the time interval that the user is currently querying The offset from the reference value of the time interval length queried last time; represents the second empirical coefficient, (0,1); max() means taking the maximum value; Indicates the minimum value of the aggregation granularity in the query cache; n represents the third empirical coefficient.
[0015] Furthermore, it also includes:
[0016] When the time from the user's first query time to the current query time meets the update condition of the query cache, the query cache excludes the aggregate log ID that does not meet the query time requirement, and / or adds a new aggregate log ID that meets the query time requirement.
[0017] Furthermore, it also includes:
[0018] If the query time interval t1 input by the user is greater than the maximum aggregation granularity t2 in the multi-level aggregation log, the query is first performed from the aggregation log corresponding to the maximum aggregation granularity t2. If a hit is found, the query is then performed from the aggregation log corresponding to the larger aggregation granularity containing the t1-t2 time interval. If a hit is not found, the query is performed from the aggregation log corresponding to the smaller aggregation granularity containing the t1-t2 time interval until the query is completed;
[0019] If the missed time interval is smaller than the minimum aggregation granularity of the aggregate log, the query is directly performed in the real log.
[0020] Furthermore, it also includes:
[0021] When the real log corresponding to the aggregate log is changed, the aggregate logs at all levels and the query cache corresponding to the real log are updated.
[0022] Another aspect of the present invention further provides a big data log query device based on timed aggregation, comprising:
[0023] The aggregation log generation module is configured to aggregate the real logs according to the timestamps of the real logs and with different time intervals as aggregation granularities, to form a multi-level aggregation log with the same structure as the real logs, where each level of aggregation log includes multiple aggregation logs;
[0024] The first query module is configured to select a query cache with the best time range as the current query cache according to the query time interval currently input by the user, query the stored aggregate logs in the current query cache and output the query result; wherein the query cache includes the aggregate logs and aggregate log IDs within the predetermined time interval;
[0025] The second query module is configured to use the starting point of the time interval with the highest user query frequency as the starting point of the time interval for the user's next query, and estimate the length of the time interval for the user's next query, re-aggregate the aggregated log according to the estimation result, and store the re-aggregated aggregated log and the aggregated log ID into multiple new query caches used by the user's next query;
[0026] The loop execution module is configured to loop execute the first query module and the second query module until the user stops the query.
[0027] Furthermore, the second query module calculates the time interval length of the user's next query according to the following formula: :
[0028] = ;
[0029] ;
[0030] n P) ;
[0031] in, Indicates the reference value of the time interval length for the user's next query. The initial value of is 0; represents the first empirical coefficient, (0,1); Indicates the length of the time interval that the user is currently querying; Indicates the length of the time interval that the user is currently querying The offset from the reference value of the time interval length queried last time; represents the second empirical coefficient, (0,1); max() means taking the maximum value; Indicates the minimum value of the aggregation granularity in the query cache; n represents the third empirical coefficient.
[0032] Furthermore, it also includes:
[0033] The update module is configured to exclude the aggregate log ID that does not meet the query time requirement and / or add a new aggregate log ID that meets the query time requirement when the time from the user's first query time to the current query time meets the update condition of the query cache.
[0034] Furthermore, the first query module is further configured to:
[0035] If the query time interval t1 input by the user is greater than the maximum aggregation granularity t2 in the multi-level aggregation log, the query is first performed from the aggregation log corresponding to the maximum aggregation granularity t2. If a hit is found, the query is then performed from the aggregation log corresponding to the larger aggregation granularity containing the t1-t2 time interval. If a hit is not found, the query is performed from the aggregation log corresponding to the smaller aggregation granularity containing the t1-t2 time interval until the query is completed;
[0036] If the missed time interval is smaller than the minimum aggregation granularity of the aggregate log, the query is directly performed in the real log.
[0037] Furthermore, the update module is further configured to:
[0038] When the real log corresponding to the aggregate log is changed, the aggregate logs at all levels and the query cache corresponding to the real log are updated.
[0039] The present invention provides a big data log query method and device based on timed aggregation, which makes the query performance more stable by using a query cache composed of aggregated logs rather than a direct query cache of real logs. The data source can be switched at any time and the time granularity of the aggregated cache can be changed without changing the original query conditions and logic, which greatly improves the query speed and hit rate, and enables a single machine to achieve log query time of more than 100 million levels within milliseconds. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0041] Figure 1It is a flowchart of a big data log query method based on timed aggregation provided by an embodiment of the present application;
[0042] Figure 2 It is a structural diagram of a big data log query device based on timed aggregation provided by an embodiment of the present application;
[0043] Figure 3 It is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0046] It should be understood that although the terms first, second, third, etc. may be used to describe the acquisition modules in the embodiments of the present invention, the acquisition modules should not be limited to these terms. These terms are only used to distinguish the acquisition modules from each other.
[0047] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0048] It should be noted that the directional words such as "upper", "lower", "left", and "right" described in the embodiments of the present invention are described at the angles shown in the drawings and should not be understood as limiting the embodiments of the present invention. In addition, in the context, it should also be understood that when it is mentioned that an element is formed "on" or "under" another element, it can not only be formed directly "on" or "under" another element, but also be formed "on" or "under" another element indirectly through an intermediate element.
[0049] In order to significantly improve the log query speed and hit rate of more than 100 million orders of magnitude without changing the log storage method and log database, the embodiment of the present application provides a big data log query method based on timed aggregation, which mainly includes log aggregation logic, aggregated log query logic and log update logic. Among them, the aggregation logic mainly includes the generation, storage and modification of aggregated logs; the query logic mainly includes accessing the query cache, querying the aggregated logs, querying the real logs, etc.; the log update is to write new real logs to the log system, which will affect the aggregated logs and generate the corresponding system behavior logic.
[0050] The following technical terms appear in the embodiments of the present application, and their meanings are explained here:
[0051] (1) Real logs: various logs generated by the server. This embodiment uses ES logs as an example.
[0052] (2) Aggregate log: The log obtained by aggregating ES logs. The structure of the aggregate log is exactly the same as the real log.
[0053] (3) Query cache: a cache used for query. In this embodiment, it is a product of re-aggregating the aggregated log. The query cache stores the ID of the aggregated log and can be rolled over at any time.
[0054] See also Figure 1 The present embodiment provides a big data log query method based on timed aggregation, which includes the following steps:
[0055] Step S101 , according to the timestamp of the real log, the real log is aggregated with different time intervals as the aggregation granularity to form a multi-level aggregated log with the same structure as the real log, and each level of aggregated log includes multiple aggregated logs.
[0056] Specifically, the real log of the system has at least one timestamp, that is, the timestamp of writing, and the log is divided into different ranges according to the timestamp. In order to hit a wider range of aggregation, this embodiment sets up multi-level aggregation logs, such as monthly aggregation, daily aggregation, hourly aggregation, and minute aggregation to form four levels of aggregation logs. Each level of aggregation processing will be performed through different aggregation tasks, so the aggregation logs at each level will not interfere with each other.
[0057] The following example illustrates this. Each query item maintains a zset-type redis key. If there are 10 query items, 10 redis key-values are maintained. For different application scenarios, multiple key-values can be maintained for different users. When the number of users is n, the number of key-values maintained is 10×n. Zset saves the Score as a timestamp, and the Value as multiple aggregated logs of aggregated json information. When there are multi-level aggregations, a zset-type redis-key is maintained for each query item and each level of time dimension.
[0058] This embodiment aggregates real logs based on time, and the time range of the search can be modified arbitrarily. At the same time, the structure of the aggregated log is exactly the same as that of the real log, so it is possible to splice and aggregate multiple logs. Users can customize the aggregation method, for example, for different types of log fields, such as Boolean type, topn type, integer type, etc., perform different aggregation methods such as XOR operation, AND operation, topn statistics, integer accumulation, etc.
[0059] This embodiment is based on the query of the time range. Under the condition that the structure of the aggregated log is ensured to be the same as that of the real log, the aggregated log can be re-aggregated or spliced with aggregated logs or real logs of different levels, which greatly improves the real-time and robustness of the system.
[0060] Step S102, according to the query time interval currently input by the user, select the query cache with the best matching time range as the current query cache, query the stored aggregate logs in the current query cache and output the query results; wherein the query cache includes the aggregate logs and aggregate log IDs within the predetermined time interval.
[0061] Specifically, in order to solve the pressure of single-point storage of aggregate logs and provide the ability to concurrently access aggregate logs, this embodiment will distribute and store aggregate logs generated based on real logs. In step S101, the aggregate logs have been logically partitioned by time, so the partitions that actually store the aggregate logs can also continue to use this feature. Since the probability of concurrently accessing aggregate logs with continuous time is very high during actual queries, this embodiment can bring about a huge improvement in query performance by partitioning the aggregate logs according to the time starting point. The following example illustrates that, assuming that the time ranges of the three aggregate logs are [0,20], [20,40], and [40,60], and there are two storage nodes, the partition range of the storage node can be set to 40, that is, the first and second aggregate logs are placed in storage node 1, and the third aggregate log is placed in node 2.
[0062] Furthermore, the query cache in this embodiment is the product of re-aggregating the aggregate log, which is somewhat different from the aggregate log. It also stores the aggregate log and the ID of the aggregate log, and can be rolled over at any time. Different from the key cache in the usual sense, the query cache in this embodiment is saved based on the time range. A cache will store more than one or more aggregate log IDs at the same time. These aggregate log IDs can come from aggregate logs of different levels. For example, aggregate logs counted by month and aggregate logs counted by day can appear in a query cache.
[0063] In this step, according to the query time interval currently input by the user, the query cache with the best matching time range is selected as the current query cache, the aggregate log stored in the current query cache is queried and the query result is output.
[0064] Furthermore, if the query time interval t1 entered by the user is greater than the maximum aggregation granularity t2 in the multi-level aggregation log, the query is first performed from the aggregation log corresponding to the maximum aggregation granularity t2, and after a hit, the query is then performed from the aggregation log corresponding to the larger aggregation granularity containing the t1-t2 time interval. If a hit is not found, the query is performed again from the aggregation log corresponding to the smaller aggregation granularity containing the t1-t2 time interval until the query is completed. If the missed time interval is smaller than the minimum aggregation granularity of the aggregation log, the query is performed directly in the real log because the aggregation log cannot be hit.
[0065] Furthermore, this embodiment will preset n query caches for each user, each query cache
[0066] The query cache will maintain a When the time scrolling reaches the trigger condition for query cache update, all query caches must determine whether the time range of the aggregate logs in the current cache still meets the range of the current cache. If it does not meet the range, exclude it, and if it needs to be added, query the aggregate log again.
[0067] The following example illustrates this. Assume that there is a query cache A, and the actual time range of the query cache is The duration is 600s, or 10 minutes. Query cache A records the aggregate log IDs from the 0th to the 600th second. There are two possibilities:
[0068] (1) After one minute has passed, this time window needs to record the aggregate log from 60s to 660s. Assuming that the aggregate log granularity is 60s, the first aggregate log ID in the cache becomes invalid, and the aggregate log from 60s to 660s is obtained.
[0069] (2) As users continue to query, it starts to change. For example, it becomes 720s. Then the current time range is from 0s to 720s. Two more aggregate logs need to be queried.
[0070] It should be noted that the starting point of the time range of each query cache is the starting point of the first query. When querying, the length of the hit time interval will be judged to determine which query cache to select.
[0071] Furthermore, the query cache may not be able to meet the needs. Usually, there will be some small fragmented intervals left or when the query cache is invalidated / updated, it is necessary to query the multi-level aggregation logs. This involves the question of how to improve the query efficiency of the fragmented interval. The following example is used to illustrate:
[0072] Assume that the query request time interval is [10, 21], and the query cache hit is [10, 20], then the remaining fragments refer to the time interval [20, 21]. If the query cache fails (for example, the log is updated, which will set the query cache in the interval as expired), it is considered a miss. At this time, you need to query the multi-level aggregate log. The query rules are as follows:
[0073] Assume that the aggregate log time interval is [0, 100], and the aggregate log is divided into two levels of aggregation, with each 50 as a unit, or each 10 as a unit. Assume that the interval to be queried is [0, 60]. According to the above two levels, the aggregate interval [0, 50] is first found. Since the interval [50, 100] does not meet the query conditions, the next level of aggregation is searched, and the time interval [50, 60] is found. The recursion is terminated and the query result is returned. In other words, if the remaining unhit time interval fragment is [20, 21], this time interval must first be searched for the time interval [0, 50]. If it does not meet the conditions, then the time interval [20,30] is searched. If it still does not meet the conditions, it is returned normally. If the remaining fragment interval is smaller than the smallest aggregation granularity of the aggregate log, it means that the result cannot be queried in the aggregate log. At this time, the real log is directly queried.
[0074] The above query process first calculates the large time interval that is hit, and then calculates the smaller time interval until the recursion ends. Finally, all the large and small intervals in the query process are added to the query queue, and these aggregated logs are queried concurrently. Finally, if no hit is found, the real log is directly queried. The above query method can greatly improve the query efficiency and hit rate.
[0075] Furthermore, when the real log corresponding to the aggregate log changes, the aggregate logs and query caches at all levels corresponding to the real log are updated. In other words, when the real log changes, the aggregate log based on time needs to be changed together. Specifically, when the real log is written, an asynchronous task will be triggered to check the corresponding aggregate logs and query caches at all levels and update the corresponding aggregate.
[0076] For example, a query cache of [0, 20] is generated based on the user's continuous queries. Now the old log [0, 40] is suddenly written. That is, the real log content in the interval [0, 40] has changed, which will invalidate the query cache [0, 20] and the first-level aggregation of [0, 50], as well as the second-level aggregations of [0,10], [10,20], [20,30], and [30,40]. At this time, the corresponding aggregation logs need to be updated.
[0077] Step S103, taking the starting point of the time interval with the highest user query frequency as the starting point of the time interval for the user's next query, and estimating the length of the time interval for the user's next query, re-aggregating the aggregated log according to the estimation result, and storing the re-aggregated aggregated log and the aggregated log ID into multiple new query caches used by the user's next query;
[0078] This step estimates the user's query time interval, caches the interval according to the estimated query time interval, caches the most frequently accessed time interval, and waits for access during the next query, and maintains the possible query range of the user internally. It should be pointed out that the starting point of the time interval with the highest user query frequency should be a rolling value. For example, if the starting point of the query ten seconds ago is A, ten seconds later this starting point will roll over to A + 10s.
[0079] Furthermore, the length of the time interval for the user's next query The estimation is achieved by the following method:
[0080] = ;
[0081] ;
[0082] n P) ;
[0083] in, Indicates the reference value of the time interval length for the user's next query. The initial value of is 0;
[0084] represents the first empirical coefficient, (0,1);
[0085] Indicates the length of the time interval that the user is currently querying. For example, if you want to query logs within a day, It is 1×24×60×60, the unit is seconds;
[0086] Indicates the length of the time interval that the user is currently querying The offset from the reference value of the time interval length queried last time;
[0087] represents the second empirical coefficient, (0,1);
[0088] max() means taking the maximum value;
[0089] Indicates the minimum value of the aggregation granularity in the query cache;
[0090] n represents the third empirical coefficient;
[0091] It is the actual time range of the query cache. The actual time range cannot be smaller than the minimum aggregation granularity of the aggregate log. Otherwise, the aggregate log cannot be searched.
[0092] Step S104, looping through the above steps S102 and S103 until the user stops searching.
[0093] The log query method of this embodiment is actually tested. The WAF device stores a total of 10 billion access logs for seven days. It is necessary to maintain 10 query items for different sites. At this time, 10×n+10 redis key-value pairs need to be maintained. The measured memory usage does not exceed 20MB, and the impact on memory is negligible. When maintaining multi-level aggregated logs, the memory prediction will reach k×20MB, where k is the number of levels. Since the scheduled task will prioritize backward aggregation logs by default, according to the principle of time locality, the probability of accessing new data is higher, which can make the range of the aggregate cache account for a higher proportion of the entire query range. With multiple visits by users, the query window will gradually stabilize. When users upgrade the WAF software normally, they will not perceive the introduction of the aggregate cache, but can clearly perceive the improvement in query speed. The specific improvement value depends on the set aggregation granularity and the amount of data in the original real log, but the actual measurement has at least 10 times the query speed improvement.
[0094] See also Figure 2Another embodiment of the present invention further provides a big data log query device 200 based on timed aggregation, including an aggregated log generation module 201, a first query module 202, a second query module 203 and a loop execution module 204. The log query device 200 can execute the big data log query method based on timed aggregation in the method embodiment.
[0095] Specifically, the log query device 200 includes:
[0096] The aggregate log generation module 201 is configured to aggregate the real logs according to the timestamps of the real logs with different time intervals as aggregation granularity to form a multi-level aggregate log with the same structure as the real log, and each level of aggregate log includes multiple aggregate logs;
[0097] The first query module 202 is configured to select a query cache with the best time range as the current query cache according to the query time interval currently input by the user, query the stored aggregate logs in the current query cache and output the query result; wherein the query cache includes the aggregate logs and aggregate log IDs within the predetermined time interval;
[0098] The second query module 203 is configured to use the starting point of the time interval with the highest user query frequency as the starting point of the time interval for the next user query, and estimate the length of the time interval for the next user query, re-aggregate the aggregated log according to the estimation result, and store the re-aggregated aggregated log and the aggregated log ID into multiple new query caches used by the next user query;
[0099] The loop execution module 204 is configured to loop execute the first query module and the second query module until the user stops the query.
[0100] Furthermore, the second query module 203 calculates the time interval length of the user's next query according to the following formula: :
[0101] = ;
[0102] ;
[0103] n P) ;
[0104] in, Indicates the reference value of the time interval length for the user's next query. The initial value of is 0; represents the first empirical coefficient, (0,1); Indicates the length of the time interval that the user is currently querying; Indicates the length of the time interval that the user is currently querying The offset from the reference value of the time interval length queried last time; represents the second empirical coefficient, (0,1); max() means taking the maximum value; Indicates the minimum value of the aggregation granularity in the query cache; n represents the third empirical coefficient.
[0105] Furthermore, it also includes:
[0106] The update module is configured to exclude the aggregate log ID that does not meet the query time requirement and / or add a new aggregate log ID that meets the query time requirement when the time from the user's first query time to the current query time meets the update condition of the query cache.
[0107] Furthermore, the first query module 202 is further configured to:
[0108] If the query time interval t1 input by the user is greater than the maximum aggregation granularity t2 in the multi-level aggregation log, the query is first performed from the aggregation log corresponding to the maximum aggregation granularity t2. If a hit is found, the query is then performed from the aggregation log corresponding to the larger aggregation granularity containing the t1-t2 time interval. If a hit is not found, the query is performed from the aggregation log corresponding to the smaller aggregation granularity containing the t1-t2 time interval until the query is completed;
[0109] If the missed time interval is smaller than the minimum aggregation granularity of the aggregate log, the query is directly performed in the real log.
[0110] Furthermore, the update module is further configured to:
[0111] When the real log corresponding to the aggregate log is changed, the aggregate logs at all levels and the query cache corresponding to the real log are updated.
[0112] It should be noted that the big data log query device 200 based on timed aggregation provided in this embodiment corresponds to a technical solution that can be used to execute each method embodiment. Its implementation principle and technical effect are similar to the method and will not be repeated here.
[0113] Figure 3 This is a schematic diagram of the structure of an electronic device 300 provided in another embodiment of the present invention, and the electronic device 300 is used to implement the big data log query method based on timed aggregation in the method embodiment. The electronic device 300 in the embodiment of the present invention may include but is not limited to a WAF device. Figure 3The electronic device 300 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0114] like Figure 3 As shown, the electronic device 300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 to a random access memory (RAM) 303 to implement the method of the embodiment of the present invention. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0115] Typically, the following devices may be connected to the I / O interface 305: an input device 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 308 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 309. The communication device 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Figure 3 The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0116] The above description is only a preferred embodiment of the present invention. Those skilled in the art should understand that the scope of disclosure involved in the present invention is not limited to the technical solution formed by a specific combination of the above technical features, but also should cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present invention (but not limited to) to form a technical solution.
Claims
1. A big data log query method based on timed aggregation, It is characterized in that include: Step 1: According to the timestamp of the real log, the real log is aggregated with different time intervals as the aggregation granularity to form a multi-level aggregate log with the same structure as the real log. Each level of aggregate log includes multiple aggregate logs. Step 2: According to the query time interval currently input by the user, select the query cache with the best matching time range as the current query cache, query the stored aggregate logs in the current query cache and output the query results; wherein the query cache includes the aggregate logs and aggregate log IDs within the predetermined time interval; Step 3: The starting point of the time interval with the highest user query frequency is used as the starting point of the time interval for the user's next query, and the length of the time interval for the user's next query is estimated. The aggregated log is aggregated again according to the estimated result, and the aggregated log and the aggregated log ID obtained by the re-aggregation are stored in multiple new query caches used by the user's next query; The estimating the time interval length of the next query of the user includes: calculating the time interval length of the next query of the user according to the following formula: : = ; ; n P) ; in, Indicates the reference value of the time interval length for the user's next query. The initial value of is 0; represents the first empirical coefficient, (0,1); Indicates the length of the time interval that the user is currently querying; Indicates the length of the time interval that the user is currently querying The offset from the reference value of the time interval length queried last time; represents the second empirical coefficient, (0,1); max() means taking the maximum value; Indicates the minimum value of the aggregation granularity in the query cache; n represents the third empirical coefficient; The above steps 2 and 3 are executed repeatedly until the user stops searching.
2. According to the big data log query method based on timed aggregation according to claim 1, It is characterized in that Also includes: When the time from the user's first query time to the current query time meets the update condition of the query cache, the query cache excludes the aggregate log ID that does not meet the query time requirement, and / or adds a new aggregate log ID that meets the query time requirement.
3. According to the big data log query method based on timed aggregation according to claim 2, It is characterized in that Also includes: If the query time interval t1 input by the user is greater than the maximum aggregation granularity t2 in the multi-level aggregation log, the query is first performed from the aggregation log corresponding to the maximum aggregation granularity t2. If a hit is found, the query is then performed from the aggregation log corresponding to the larger aggregation granularity containing the t1-t2 time interval. If a hit is not found, the query is performed from the aggregation log corresponding to the smaller aggregation granularity containing the t1-t2 time interval until the query is completed; If the missed time interval is smaller than the minimum aggregation granularity of the aggregate log, the query is directly performed in the real log.
4. According to the big data log query method based on timed aggregation according to claim 3, It is characterized in that Also includes: When the real log corresponding to the aggregate log is changed, the aggregate logs at all levels and the query cache corresponding to the real log are updated.
5. A big data log query device based on timed aggregation, It is characterized in that include: The aggregation log generation module is configured to aggregate the real logs according to the timestamps of the real logs and with different time intervals as aggregation granularities, to form a multi-level aggregation log with the same structure as the real logs, where each level of aggregation log includes multiple aggregation logs; The first query module is configured to select a query cache with the best time range as the current query cache according to the query time interval currently input by the user, query the stored aggregate logs in the current query cache and output the query result; wherein the query cache includes the aggregate logs and aggregate log IDs within the predetermined time interval; The second query module is configured to use the starting point of the time interval with the highest user query frequency as the starting point of the time interval for the user's next query, and estimate the length of the time interval for the user's next query, re-aggregate the aggregated log according to the estimation result, and store the re-aggregated aggregated log and the aggregated log ID into multiple new query caches used by the user's next query; The second query module is further configured to calculate the time interval length of the user's next query according to the following formula: : = ; ; n P) ; in, Indicates the reference value of the time interval length for the user's next query. The initial value of is 0; represents the first empirical coefficient, (0,1); Indicates the length of the time interval that the user is currently querying; Indicates the length of the time interval that the user is currently querying The offset from the reference value of the time interval length queried last time; represents the second empirical coefficient, (0,1); max() means taking the maximum value; Indicates the minimum value of the aggregation granularity in the query cache; n represents the third empirical coefficient; The loop execution module is configured to loop execute the first query module and the second query module until the user stops the query.
6. A big data log query device based on timed aggregation according to claim 5, It is characterized in that Also includes: The update module is configured to exclude the aggregate log ID that does not meet the query time requirement and / or add a new aggregate log ID that meets the query time requirement when the time from the user's first query time to the current query time meets the update condition of the query cache.
7. A big data log query device based on timed aggregation according to claim 6, It is characterized in that The first query module is further configured to: If the query time interval t1 input by the user is greater than the maximum aggregation granularity t2 in the multi-level aggregation log, the query is first performed from the aggregation log corresponding to the maximum aggregation granularity t2. If a hit is found, the query is then performed from the aggregation log corresponding to the larger aggregation granularity containing the t1-t2 time interval. If a hit is not found, the query is performed from the aggregation log corresponding to the smaller aggregation granularity containing the t1-t2 time interval until the query is completed; If the missed time interval is smaller than the minimum aggregation granularity of the aggregate log, the query is directly performed in the real log.
8. A big data log query device based on timed aggregation according to claim 7, It is characterized in that The update module is further configured to: When the real log corresponding to the aggregate log is changed, the aggregate logs at all levels and the query cache corresponding to the real log are updated.
Citation Information
Patent Citations
Multi-application log aggregation query system and method
CN115017126A
Method and device for acquiring equipment state information, equipment and readable storage medium
CN117093555A
Log secure storage and efficient query method based on block chain
CN117235810A
Performance optimization method based on real-time data statistics of query large data volume result set
CN117573734A
Index query method and device, index statistical method and device, equipment and storage medium
CN118410076A
