Information query method, device and computer readable storage medium
By splitting the log information into terms and applying key information matching and word matching rules to calculate the weight value, the problem of incomplete log data acquisition in the big data platform is solved, query efficiency and accuracy are improved, and operation and maintenance costs are reduced. .
Patent Information
- Application Number
- CN202011554508.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-12-24
AI Technical Summary
In big data platforms, the amount of log data is large, and traditional key information matching methods are difficult to obtain all log data related to key information, resulting in inaccurate and time-consuming judgment by operation and maintenance personnel.
Split a single log information into multiple entries. According to the set key information matching rules and word matching rules, count the number of matches and matching degree between each log information and key information, calculate the weight value, and select the ones that meet the preset conditions. Log information is used as query results, sorted and filtered.
It improves the comprehensiveness and speed of log data acquisition, reduces the consumption of machine performance, and achieves accurate matching and rapid screening of key information.
Smart Images

Figure CN112685361B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data technology, and in particular to an information query method, device and computer-readable storage medium. Background Art
[0002] The big data platform was created to meet the various data requirements of enterprises. It can accommodate massive data and use the storage and computing power of computer clusters to process massive data. Not only has the performance been expanded, but its ability to handle large amounts of data streams has also been improved accordingly.
[0003] Since the platform is oriented to big data, there must be many components to process various types of data, which will cause operation and maintenance problems. The threshold for big data development is relatively high, so operation and maintenance is quite difficult. Many operation and maintenance personnel and even R&D personnel spend a lot of time on platform operation and maintenance. Generally, they will choose to check the logs in the server background to solve the problem, because this is the easiest way to find the problem.
[0004] However, the amount of log data stored in the server backend is very large, and it takes a lot of time to retrieve information. In order to improve the retrieval efficiency, the traditional method is to retrieve the logs required by the user by matching key information. However, the key information matching method may only find logs that are the same or almost similar to the key information. When the key information consists of multiple words, it is often impossible to obtain all the log data related to the key information according to the key information matching method, resulting in inaccurate judgments made by maintenance personnel based on the matched log data.
[0005] It can be seen that how to improve the comprehensiveness of log data acquisition is a problem that technical personnel in this field need to solve. Summary of the invention
[0006] The purpose of the embodiments of the present invention is to provide an information query method, device and computer-readable storage medium, which can improve the comprehensiveness of log data acquisition.
[0007] In order to solve the above technical problems, an embodiment of the present invention provides an information query method, comprising:
[0008] Split each log message in a single log into multiple entries;
[0009] When a log query instruction for key information is obtained, the number of key information matching times of each log information with the key information is counted according to the set key information matching rule;
[0010] According to the set word matching rules, the matching degree between each log information and all the keywords in the key information is counted;
[0011] The sum of the number of key information and the matching degree corresponding to each log information is used as the weight value of each log information; and the target log information whose weight value meets the preset conditions is selected as the query result.
[0012] Optionally, counting the matching degree of each log information with all keywords in the key information according to the set word matching rule includes:
[0013] Splitting the key information into keywords;
[0014] Searching for entries with the same keyword from each log message, and counting distance values between entries corresponding to adjacent keywords;
[0015] According to the corresponding relationship between the preset distance value and the matching degree, the matching degree between each log information and all the keywords in the key information is determined.
[0016] Optionally, after selecting the target log information whose weight value meets the preset condition as the query result, the method further includes:
[0017] According to the sum of the log level and the weight value of each target log information, each target log information is arranged in descending order.
[0018] Optionally, after selecting the target log information whose weight value meets the preset condition as the query result, the method further includes:
[0019] According to the log level of each target log information, each target log information is arranged in descending order.
[0020] Optionally, after selecting the target log information whose weight value meets the preset condition as the query result, the method further includes:
[0021] Determine whether there is similar log information with the same log level, the same entry and different date in the target log information;
[0022] If the target log information contains similar log information with the same log level, the same entry and different date, the similar log information is sorted in descending order according to the date, and the first and last log information of the similar log information are retained.
[0023] The embodiment of the present invention further provides an information query device, comprising a splitting unit, a first statistics unit, a second statistics unit and a serving unit;
[0024] The splitting unit is used to split each log information in a single log into multiple entries;
[0025] The first statistical unit is used to count the number of key information matching between each log information and the key information according to the set key information matching rule when the log query instruction of the key information is obtained;
[0026] The second statistical unit is used to count the matching degree between each log information and all keywords in the key information according to the set word matching rule;
[0027] The as unit is used to take the sum of the number of key information and the matching degree corresponding to each log information as the weight value of each log information; and select the target log information whose weight value meets the preset conditions as the query result.
[0028] Optionally, the second statistical unit includes a splitting subunit, a querying subunit and a determining subunit;
[0029] The splitting subunit is used to split the key information into keywords;
[0030] The query subunit is used to query the entries with the same keyword from each log information, and count the distance values between the entries corresponding to adjacent keywords;
[0031] The determination subunit is used to determine the matching degree between each log information and all the keywords in the key information according to the corresponding relationship between the preset distance value and the matching degree.
[0032] Optionally, a sorting unit is also included;
[0033] The sorting unit is used to arrange the target log information in descending order according to the sum of the log level and the weight value of each target log information.
[0034] Optionally, a sorting unit is also included;
[0035] The sorting unit is used to sort the target log information in descending order according to the log level of each target log information.
[0036] Optionally, it also includes a judging unit and a retaining unit;
[0037] The judging unit is used to judge whether there is similar log information with the same log level, the same entry and different date in the target log information;
[0038] The retaining unit is used to, if the target log information contains similar log information with the same log level, the same entry and different dates, sort the similar log information in descending order according to the date, and retain the first and last log information in the similar log information.
[0039] The embodiment of the present invention further provides an information query device, comprising:
[0040] Memory for storing computer programs;
[0041] A processor is used to execute the computer program to implement the steps of any one of the above information query methods.
[0042] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned information query methods are implemented.
[0043] It can be seen from the above technical solution that each log information in a single log is split into multiple entries; by splitting the content of the background log into standard entries, the speed of search and matching can be accelerated. When the log query instruction of the key information is obtained, the number of key information matching each log information with the key information is counted according to the set key information matching rule. Through the key information matching rule, accurate matching of the key information can be achieved. According to the set word matching rule, the matching degree of each log information with all keywords in the key information is counted. The word matching rule refers to the situation where the log information matches the keyword but there is a gap between the keywords. Through the word matching rule, the log information associated with the key information can be obtained more comprehensively. The sum of the number of key information and the matching degree corresponding to each log information is used as the weight value of each log information; the target log information whose weight value meets the preset conditions is selected as the query result. In this technical solution, by splitting the content of the background log into standard entries, the speed of search and matching can be accelerated, and the log information can be quickly screened through key information matching and word matching, which improves the comprehensiveness of log data acquisition. This implementation process can quickly complete the search for target log information with lower machine performance resources, and the consumption of machine performance is very low. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 A flowchart of an information query method provided by an embodiment of the present invention;
[0046] Figure 2 A schematic diagram of the structure of an information query device provided by an embodiment of the present invention;
[0047] Figure 3 A schematic diagram of the hardware structure of an information query device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0049] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0050] Next, an information query method provided by an embodiment of the present invention is introduced in detail. Figure 1 A flowchart of an information query method provided by an embodiment of the present invention, the method comprising:
[0051] S101: Split each log message in a single log into multiple entries.
[0052] For obtaining log information, in actual applications, you can find the path where Ambari background stores logs, because the path where Ambari stores logs of each component is written in a fixed location and will not change under normal circumstances. Therefore, in order to improve efficiency, the system can directly scan the path where logs are stored to obtain log information. The system will copy the current log information and save the log information generated by the background.
[0053] In the embodiment of the present invention, the log information generated by the system each time an operation task is executed can be regarded as a log. The processing method of each log is similar, and in the embodiment of the present invention, one log is used as an example for description.
[0054] Each log contains multiple log information. In the embodiment of the present invention, each log information can be split into multiple entries. In practical applications, in order to improve the search efficiency of the entries, all punctuation entries can be deleted, leaving only the entries containing data information.
[0055] S102: When a log query instruction for key information is obtained, the number of key information times that each log information matches the key information is counted according to the set key information matching rule.
[0056] The key information matching rule refers to retrieving the entries that are exactly the same as the key information in each log information. For a log information, each time an entry that is exactly the same as the key information appears, the key information count can be increased by 1. The number of entries that are exactly the same as the key information in the log information is the key information count that the log information matches the key information.
[0057] Through key information matching rules, accurate matching of key information can be achieved.
[0058] S103: According to the set word matching rule, the matching degree between each log information and all the keywords in the key information is counted.
[0059] The word matching rule refers to the situation where the log information matches the keywords but there are gaps between the keywords. Through the word matching rule, the log information associated with the key information can be obtained more comprehensively.
[0060] In practical applications, the key information can be split into keywords; the entries with the same keywords are searched from each log information, and the distance values between the entries corresponding to adjacent keywords are counted; based on the correspondence between the pre-set distance value and the matching degree, the matching degree of each log information and all the keywords in the key information is determined.
[0061] For example, if the key information is "open files", the key information can be split into two keywords "open" and "files". When the entries "open" and "files" exist in the log information, but the two entries are not continuous, that is, there are other entries between the two entries, the number of other entries can be used as the distance value between "open" and "files". In the specific implementation, the shorter the distance value between the two entries, the higher the matching degree, and the corresponding relationship between the distance value of different value ranges and the matching degree of different values can be set.
[0062] S104: The sum of the number of key information and the matching degree corresponding to each piece of log information is used as the weight value of each piece of log information.
[0063] In the embodiment of the present invention, in order to comprehensively consider the degree of fit between each log information and the key information, the sum of the number of key information times and the matching degree corresponding to each log information may be used as the weight value of each log information.
[0064] In practical applications, the weight value W of each log information can be calculated according to the following formula:
[0065] W=n+[1 / (L1+1)+…+1 / (Lm+1)];
[0066] Wherein, n represents the number of times the log information matches the key information; L1 to Lm represent different distance values between entries corresponding to adjacent keywords.
[0067] S105: Select target log information whose weight value meets the preset condition as the query result.
[0068] Taking the example that the shorter the distance value, the higher the matching degree, in actual application, the target log information with a weight value higher than a preset threshold value can be selected as the query result.
[0069] It can be seen from the above technical solution that each log information in a single log is split into multiple entries; by splitting the content of the background log into standard entries, the speed of search and matching can be accelerated. When the log query instruction of the key information is obtained, the number of key information matching each log information with the key information is counted according to the set key information matching rule. Through the key information matching rule, accurate matching of the key information can be achieved. According to the set word matching rule, the matching degree of each log information with all keywords in the key information is counted. The word matching rule refers to the situation where the log information matches the keyword but there is a gap between the keywords. Through the word matching rule, the log information associated with the key information can be obtained more comprehensively. The sum of the number of key information and the matching degree corresponding to each log information is used as the weight value of each log information; the target log information whose weight value meets the preset conditions is selected as the query result. In this technical solution, by splitting the content of the background log into standard entries, the speed of search and matching can be accelerated, and the log information can be quickly screened through key information matching and word matching, which improves the comprehensiveness of log data acquisition. This implementation process can quickly complete the search for target log information with lower machine performance resources, and the consumption of machine performance is very low.
[0070] In an embodiment of the present invention, after determining the target log information corresponding to the key information, the target log information can be arranged in descending order according to the sum of the log level and the weight value of each target log information, or arranged in descending order according to the log level of each target log information.
[0071] Log levels can include FATAL, ERROR, WARN, INFO, etc.
[0072] The higher the log level, the more important the log information is. By sorting the log information in order according to its importance, users can quickly obtain the most important log information.
[0073] Taking into account the fact that log information may be repeated in actual applications, after selecting the target log information whose weight value meets the preset conditions as the query result, it can be determined whether there is similar log information with the same log level, the same entry and different dates in the target log information; if there is similar log information with the same log level, the same entry and different dates in the target log information, it means that there is repeated log information. At this time, the similar log information can be sorted in descending order according to the date, and the first and last log information in the similar log information are retained.
[0074] In the embodiment of the present invention, when log information with different dates, log levels and the same entries is matched, only the first and last two log information may be retained, which can simplify the important log information and avoid incomplete data.
[0075] Figure 2 A schematic diagram of the structure of an information query device provided by an embodiment of the present invention includes a splitting unit 21, a first counting unit 22, a second counting unit 23 and a serving unit 24;
[0076] A splitting unit 21, used for splitting each log message in a single log into multiple entries;
[0077] The first statistical unit 22 is used to count the number of key information matching between each log information and the key information according to the set key information matching rule when the log query instruction of the key information is obtained;
[0078] The second statistical unit 23 is used to count the matching degree of each log information with all the keywords in the key information according to the set word matching rule;
[0079] As unit 24, it is used to take the sum of the number of key information and the matching degree corresponding to each log information as the weight value of each log information; and select the target log information whose weight value meets the preset conditions as the query result.
[0080] Optionally, the second statistical unit includes a splitting subunit, a querying subunit and a determining subunit;
[0081] Split subunits, used to split key information into keywords;
[0082] A query subunit is used to query the entries with the same keyword from each log message, and count the distance values between the entries corresponding to adjacent keywords;
[0083] The determination subunit is used to determine the matching degree between each log information and all the keywords in the key information according to the corresponding relationship between the preset distance value and the matching degree.
[0084] Optionally, a sorting unit is also included;
[0085] The sorting unit is used to sort each target log information in descending order according to the sum of the log level and the weight value of each target log information.
[0086] Optionally, a sorting unit is also included;
[0087] The sorting unit is used to sort the target log information in descending order according to the log level of each target log information.
[0088] Optionally, it also includes a judging unit and a retaining unit;
[0089] A judgment unit, used to judge whether there is similar log information with the same log level, the same entry and different date in the target log information;
[0090] The retaining unit is used to sort the same log information in descending order according to the date if there are similar log information with the same log level, the same entry and different dates in the target log information, and retain the first log information and the last log information in the same log information.
[0091] Figure 2 The description of the features in the corresponding embodiments can be found in Figure 1 The relevant descriptions of the corresponding embodiments will not be repeated here one by one.
[0092] It can be seen from the above technical solution that each log information in a single log is split into multiple entries; by splitting the content of the background log into standard entries, the speed of search and matching can be accelerated. When the log query instruction of the key information is obtained, the number of key information matching each log information with the key information is counted according to the set key information matching rule. Through the key information matching rule, accurate matching of the key information can be achieved. According to the set word matching rule, the matching degree of each log information with all keywords in the key information is counted. The word matching rule refers to the situation where the log information matches the keyword but there is a gap between the keywords. Through the word matching rule, the log information associated with the key information can be obtained more comprehensively. The sum of the number of key information and the matching degree corresponding to each log information is used as the weight value of each log information; the target log information whose weight value meets the preset conditions is selected as the query result. In this technical solution, by splitting the content of the background log into standard entries, the speed of search and matching can be accelerated, and the log information can be quickly screened through key information matching and word matching, which improves the comprehensiveness of log data acquisition. This implementation process can quickly complete the search for target log information with lower machine performance resources, and the consumption of machine performance is very low.
[0093] Figure 3A hardware structure diagram of an information query device 30 provided in an embodiment of the present invention includes:
[0094] A memory 31, used for storing computer programs;
[0095] The processor 32 is used to execute a computer program to implement the steps of the information query method as described in any of the above embodiments.
[0096] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the information query method described in any of the above embodiments are implemented.
[0097] The above is a detailed introduction to an information query method, device and computer-readable storage medium provided by an embodiment of the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
[0098] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0099] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Claims
1. An information query method, characterized in that: include: Split each log message in a single log into multiple entries; When a log query instruction for key information is obtained, the number of key information matching times of each log information and the key information is counted according to the set key information matching rules; The key information matching rule refers to retrieving the entries in each log message that are exactly the same as the key information; According to the set word matching rules, the matching degree between each log information and all the keywords in the key information is counted; The sum of the number of key information and the matching degree corresponding to each log information is used as the weight value of each log information; Select the target log information whose weight value meets the preset conditions as the query result; Determine whether there is similar log information with the same log level, the same entry and different date in the target log information; If the target log information contains similar log information with the same log level, the same entry and different date, the similar log information is sorted in descending order according to the date, and the first and last log information of the similar log information are retained; The method of counting the matching degree of each log information with all keywords in the key information according to the set word matching rule includes: Splitting the key information into keywords; Searching for entries with the same keyword from each log message, and counting distance values between entries corresponding to adjacent keywords; According to the corresponding relationship between the preset distance value and the matching degree, the matching degree between each log information and all the keywords in the key information is determined.
2. The information query method according to claim 1, characterized in that: After selecting the target log information whose weight value meets the preset condition as the query result, the following step further includes: According to the sum of the log level and the weight value of each target log information, each target log information is arranged in descending order.
3. The information query method according to claim 1, characterized in that: After selecting the target log information whose weight value meets the preset condition as the query result, the following step further includes: According to the log level of each target log information, each target log information is arranged in descending order.
4. An information query device, characterized in that: It includes split unit, first statistical unit, second statistical unit and as unit; The splitting unit is used to split each log information in a single log into multiple entries; The first statistical unit is used to count the number of key information matching between each log information and the key information according to the set key information matching rule when the log query instruction of the key information is obtained; The key information matching rule refers to retrieving the entries in each log message that are exactly the same as the key information; The second statistical unit is used to count the matching degree between each log information and all keywords in the key information according to the set word matching rule; The as unit is used to take the sum of the number of key information and the matching degree corresponding to each log information as the weight value of each log information; Select the target log information whose weight value meets the preset conditions as the query result; The second statistical unit includes a splitting subunit, a querying subunit and a determining subunit; The splitting subunit is used to split the key information into keywords; The query subunit is used to query the entries with the same keyword from each log information, and count the distance values between the entries corresponding to adjacent keywords; The determination subunit is used to determine the matching degree of each log information with all the keywords in the key information according to the corresponding relationship between the preset distance value and the matching degree; It also includes a judgment unit and a retention unit; The judging unit is used to judge whether there is similar log information with the same log level, the same entry and different date in the target log information; The retaining unit is used to, if the target log information contains similar log information with the same log level, the same entry and different dates, sort the similar log information in descending order according to the date, and retain the first and last log information in the similar log information.
5. An information query device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the information query method as claimed in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the information query method according to any one of claims 1 to 3 are implemented.
