Log processing method and device, electronic equipment and storage medium
By using time period-based filters to filter logs in log processing, the problem of inflexible log processing and difficulty in collecting useful data in the existing technology is solved, and efficient and flexible log processing and data offloading are achieved.
Patent Information
- Application Number
- CN202410926546.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-10-01
AI Technical Summary
Existing technologies require a large amount of hardware support and repeated code when processing logs, making the processing process inflexible, making it difficult to adjust processing strategies in real time, and making it difficult to collect useful data in logs flexibly and efficiently.
By obtaining the logs generated by the upstream terminal, filtering the logs using filters based on logs in adjacent time periods, quickly filtering out duplicate logs, determining filtering rules based on the data in the target fields, extracting and forwarding useful field data, and achieving Efficient diversion.
It achieves high efficiency and flexibility in log processing, quickly filters out duplicate logs, improves log processing efficiency and data collection accuracy, and reduces the burden on computing resources.
Smart Images

Figure CN118733577A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a log processing method, device, electronic device and storage medium. Background Art
[0002] Usually, network devices, operating systems, and service programs will generate logs when they are running. The logs include information such as the user's operation behavior and operation time. By analyzing the logs, developers can improve the operating service quality of network devices, operating systems, and service programs.
[0003] At present, common log collection processing methods, for example, use Flink or Strom, on this basis, the log data is circulated and the format is compressed, and then stored in the distributed file system (Hadoop Distributed File System, HDFS) in real time. Since HDFS needs to run on general hardware, in related technologies, in order to improve the speed of processing real-time collected logs, a large amount of hardware equipment support is required, and in the process of processing logs, different levels of the database need to be involved. For example, the cleaning of logs needs to be processed at the data operation (Operational Data Store, ODS) layer and the data detail (Data Warehouse Detail, DWD) layer. Therefore, the entire log processing process requires a lot of repeated code, which ultimately leads to poor agility of the log processing process and is not convenient for real-time adjustment of the log processing strategy. Based on this, how to flexibly and efficiently collect useful data in logs is an urgent problem to be solved. Summary of the invention
[0004] In view of this, embodiments of the present application provide a log processing method, device, electronic device, computer-readable storage medium, and computer program product, which can efficiently and flexibly collect useful data in logs.
[0005] The present application provides a log processing method, including:
[0006] Acquire a first log generated by an upstream terminal, wherein the first log includes field data corresponding to a plurality of first preset fields one by one;
[0007] Using at least one first log filter to filter the first log, wherein the first log filter is constructed according to a second log generated by an upstream terminal acquired in a first time period, the acquisition time of the second log is earlier than the acquisition time of the first log, and the acquisition time of the first log is within the first time period;
[0008] When the filtering result of the filtering process is that the object is not filtered out, obtaining a filtering rule corresponding to the field data of the first target field according to the field data of the first target field in the plurality of first preset fields, wherein the filtering rule includes the second preset field and the address information corresponding to the second preset field;
[0009] The field data corresponding to the second preset field is obtained in the first log, and the field data of the second preset field is sent according to the address information corresponding to the second preset field.
[0010] Optionally, according to the method of the embodiment of the present application, the first time period includes sub-time periods corresponding to the first log filters one by one, and there is no time overlap between different sub-time periods; each first log filter is generated based on the feature information of each second log obtained in its corresponding sub-time period;
[0011] Using at least one first log filter to filter the first log includes:
[0012] Obtain characteristic information of the first log;
[0013] Calculate the index value of the feature information of the first log according to the index calculation function corresponding to the first log filter;
[0014] Determine a filtering result of the filtering process according to the index value of each second log feature information included in the first log filter and the index value of the feature information of the first log;
[0015] Wherein, when each second log characteristic information is inconsistent with the characteristic information of the first log, the filtering result of the filtering process is that it is not filtered out.
[0016] Optionally, according to the method of the embodiment of the present application, after obtaining the filtering result, the method further includes:
[0017] When the filtering result of the filtering process is that the log is not filtered out, updating the target log filter in the first log filter according to the index value of the characteristic information of the first log;
[0018] The acquisition time of the first log is within the sub-time period corresponding to the target log filter.
[0019] Optionally, according to the method of the embodiment of the present application, obtaining characteristic information of the first log includes:
[0020] The field data corresponding to the third preset field is obtained from the plurality of first preset fields to obtain characteristic information of the first log.
[0021] Optionally, according to the method of the embodiment of the present application, before obtaining the filtering rule corresponding to the field data of the first target field, the method further includes:
[0022] Get the newly added filtering rules in the rule database;
[0023] The newly added filtering rules are stored in the preset data storage space.
[0024] Optionally, according to the method of the embodiment of the present application, obtaining a newly added filtering rule in the rule database includes:
[0025] In response to the rule database receiving the rule write operation and generating a newly added filtering rule, the newly added filtering rule in the rule database is read based on flink CDC to obtain the newly added filtering rule.
[0026] The present application provides a log processing device, including:
[0027] An acquisition module, configured to acquire a first log generated by an upstream terminal, wherein the log includes a plurality of first preset fields, and each first preset field includes field data;
[0028] a processing module, configured to filter the first log using at least one first log filter, wherein the first log filter is constructed according to a second log generated by an upstream terminal and acquired in a first time period, the acquisition time of the second log is earlier than the acquisition time of the first log, and the acquisition time of the first log is within the first time period;
[0029] The processing module is further used to obtain, when the filtering result of the filtering processing is that the object is not filtered out, a filtering rule corresponding to the field data of the first target field according to the field data of the first target field in the plurality of first preset fields, wherein the filtering rule includes the second preset field and the address information corresponding to the second preset field;
[0030] The processing module is further used to obtain field data corresponding to the second preset field in the first log, and send the field data of the second preset field according to the address information corresponding to the second preset field.
[0031] An embodiment of the present application provides an electronic device, which includes a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the steps of the above method are implemented.
[0032] An embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the steps of the above method are implemented.
[0033] An embodiment of the present application provides a computer program product, which includes computer program instructions. When the computer program instructions are executed by a processor, the steps of the above method are implemented.
[0034] By adopting the embodiment of the present application, the first log generated by the upstream terminal is obtained, and the first log is filtered by using the first log filter constructed based on the logs in the adjacent time period, so that the duplicate logs existing in the first time period can be quickly and efficiently filtered out. Subsequently, in the case where the first log is not filtered out, the filtering rules used to process the first log can be flexibly determined in combination with the field data of the first target field in the first log, and then the field data of the second preset field that needs to be forwarded is extracted in the first log according to the filtering rules of the first log, and the field data of the second preset field is forwarded, which can not only efficiently and flexibly collect useful logs in the log, but also realize efficient diversion of the first log. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following briefly introduces the drawings in the embodiments of the present application.
[0036] Figure 1 It is a schematic diagram of the system architecture of an embodiment of the present application.
[0037] Figure 2 It is a flowchart of the log processing method of an embodiment of the present application.
[0038] Figure 3 It is a schematic diagram of the relationship between the first time period and the sub-time periods provided in the embodiment of the present application.
[0039] Figure 4 It is another architectural diagram of the log processing system provided in an embodiment of the present application.
[0040] Figure 5 It is a structural block diagram of the log processing device of an embodiment of the present application.
[0041] Figure 6 It is a schematic diagram of an electronic device used to implement the log processing method of an embodiment of the present application. DETAILED DESCRIPTION
[0042] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that the purpose of providing these embodiments is to make the principles and spirit of the present application clearer and more thorough, so that those skilled in the art can better understand and implement the principles and spirit of the present application. The exemplary embodiments provided herein are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments herein, all other embodiments obtained by ordinary technicians of the art without creative work are within the scope of protection of this application.
[0043] Embodiments of the present application relate to terminal devices and / or servers. Those skilled in the art will appreciate that the embodiments of the present application may be implemented as a system, apparatus, device, method, computer-readable storage medium, or computer program product. Therefore, the present disclosure may be specifically implemented as at least one of the following forms: complete hardware, complete software, or a combination of hardware and software. According to the embodiments of the present application, the present application claims protection for a log processing method, apparatus, electronic device, computer-readable storage medium, and computer program product.
[0044] It should be noted that the acquisition, storage, use, and processing of data in the embodiments of the present application are in compliance with the relevant provisions of national laws and regulations.
[0045] Figure 1 A schematic diagram of a system architecture of an embodiment of the present application is shown. Figure 1 As shown, the system includes a terminal device 102 and a server 104. Among them, the terminal device 102 may include at least one of the following: a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart TV, various wearable devices, an augmented reality AR device, a virtual reality VR device, and the like. A client may be installed on the terminal device 102. For example, the client may be a client that specifically performs a specific function (such as an application app), or a client that is embedded with a variety of application applets (different functions), or a client that logs in through a browser. The user may operate on the terminal device 102. For example, the user may open the client installed on the terminal device 102 and input instructions through the client operation, or the user may open the browser installed on the terminal device 102 and input instructions through the browser operation. Some of the user's operating behaviors at the terminal 102 may be recorded in a log.
[0046] The log generated by the terminal 102 may include, for example, the following information: recruitment service interfaces such as websites, applications, or applets for enterprises and other employers that the recruiter may access through the terminal device 102, the input and modification of recruitment information in the recruitment service interface by the terminal device 102 during use; for example, the length of time the recruiter views resumes in the resume browsing interface through the terminal 102. The user of the terminal 102 may also be a job seeker, and thus, the log generated by the terminal 102 may include, for example, application interfaces, web pages, etc. viewed by the job seeker, job information viewed by the job seeker, etc., which are not listed here one by one.
[0047] The server 104 is a device for processing logs. The logs processed by the server 104 can be directly obtained from the terminal 104, or from a third-party log management platform ( Figure 1The third-party log management platform is obtained (not shown), wherein the third-party log management platform is, for example, the Sensors log management platform, etc., and there is no specific restriction on the log management platform.
[0048] After acquiring the log, the server 104 can filter the first log by using the first log filter constructed based on the logs in the adjacent time period, and can quickly and efficiently filter out the duplicate logs existing in the first time period. Subsequently, in the case where the first log is not filtered out, the filtering rules for the first log can be flexibly determined in combination with the field data of the first target field in the first log, and then the field data of the second preset field that needs to be forwarded is extracted from the first log according to the filtering rules of the first log, and the field data of the second preset field is forwarded. In this way, efficient diversion of the first log is achieved, and useful data in the log is efficiently and flexibly collected.
[0049] In this document, terms such as first, second, third, etc. are only used to distinguish one entity (or operation) from another entity (or operation), but not to require or imply any order or relationship between these entities (or operations).
[0050] The following is a brief description of the concepts and technical terms that may be involved in the embodiments of the present application.
[0051] Figure 2 A flow chart of a log processing method according to an embodiment of the present application is shown, and the method includes the following steps 201 to 204 .
[0052] Step 201, obtaining a first log generated by an upstream terminal, wherein the first log includes field data corresponding to a plurality of first preset fields one by one;
[0053] Step 202: Use at least one first log filter to filter the first log, wherein the first log filter is constructed according to a second log generated by an upstream terminal acquired in a first time period, the acquisition time of the second log is earlier than the acquisition time of the first log, and the acquisition time of the first log is within the first time period;
[0054] Step 203, when the filtering result of the filtering process is that the object is not filtered out, obtaining a filtering rule corresponding to the field data of the first target field according to the field data of the first target field in the plurality of first preset fields, wherein the filtering rule includes the second preset field and the address information corresponding to the second preset field;
[0055] Step 204: Obtain field data corresponding to the second preset field in the first log, and send the field data of the second preset field according to the address information corresponding to the second preset field.
[0056] The above steps are described in detail below in conjunction with specific embodiments, as shown below.
[0057] In relation to the above step 201, the server is a device with data processing capabilities and is used to execute the log processing method provided in the embodiment of the present application to achieve efficient and flexible log processing.
[0058] Optionally, the server can be communicatively connected with one or more upstream terminals, and the first log generated by the upstream terminal can be directly transmitted to the server for processing by the server; in another optional embodiment, a third-party log service platform can obtain the first log generated by one or more upstream terminal services, and then the server can read the first log from the third-party log service platform in real time.
[0059] Optionally, a Kafka message queue can be established between the third-party log service platform and the server. The third-party log server platform puts the logs generated by the upstream terminal into the Kafka message queue in sequence to facilitate the service to process the logs generated by the upstream terminal in chronological order.
[0060] Exemplarily, the first log may include a plurality of field data corresponding to the first preset fields one by one. The first preset fields include but are not limited to project category, unique primary key, generation time, event type, application version, device model, position identification, etc.
[0061] After obtaining the first log, the first log may be filtered, which involves the above step 202, and a log filter for filtering the first log, that is, the first log filter, is determined in combination with the acquisition time of the first log.
[0062] Exemplarily, the acquisition time of the first log may refer to the time when the server reads the first log. It is understandable that, in the case of a communication connection between the server and the first terminal, the time when the server reads the first log is the time when the server receives the first log. In the case where the server obtains the log through a third-party log service platform, the time when the server reads the first log may be the time when the low log is put into the message queue.
[0063] In the embodiment of the present application, the first log filter is constructed based on the second log generated by the upstream terminal acquired in the first time period, the acquisition time of the second log is earlier than the acquisition time of the first log, and the acquisition time of the first log is within the first time period, that is, the second log is a log acquired before the first log. For example, the first time period is from 8:00 to 10:10, wherein the acquisition time of the first log may be 10:05, and the acquisition time of the second log is within the time period from 8:00 to 10:05.
[0064] Since the acquisition time of the first log is within the first time period, the first time period is also the adjacent time period of the acquisition time of the first log. By acquiring the second log generated in the adjacent time period, a first log filter is constructed to filter the first log. Since the amount of data involved in this step is small, it is possible to quickly determine whether the first log is a duplicate log. For example, in the event of an abnormal freeze in a business server, frequent data requests, connection retries, and other events may occur between the upstream terminal and the business server, resulting in a large number of duplicate and useless logs. According to the log processing method provided in the embodiment of the present application, it is possible to effectively filter out duplicate data.
[0065] It can be understood that, in the case where the first log is a duplicate log, the first log can be directly filtered out.
[0066] If the first log filter does not include the same log as the first log, the result of filtering the first log based on the first log filter is that the first log is not filtered out, and then the first log can continue to be processed.
[0067] In step 203 and step 204, the first log includes field data corresponding to a plurality of first preset fields. The server can search for field data of the first target field in the first log, wherein the first target field is, for example, an event type field, and obtains a filtering rule corresponding to the field data in combination with the specific field data in the first target field. For example, in a job recruitment service platform, the event type field includes field data such as job short exposure events, application click events, and the like.
[0068] In an embodiment of the present application, different field data included in the first target field may correspond to different filtering rules. The filtering rule may include a second preset field and address information corresponding to the second preset field. The field data corresponding to the second preset field is data that needs to be forwarded.
[0069] The address information of the second preset field may be a message queue established with downstream consumers. The number of downstream consumers may include one or more, and the specific consumers may be set according to the application requirements of the log.
[0070] After obtaining the filtering rule corresponding to the field data of the first target field, the server can extract the field data of the second preset field that needs to be forwarded from the first log according to the filtering rule, and forward the field data of the second preset field according to the address information corresponding to the second preset field. In this way, not only the useful data in the field is flexibly collected, but also the useful field data in the first log is efficiently diverted, thereby improving the processing efficiency of the log.
[0071] Optionally, the filtering rule may also include a preset field for filtering out field data. For ease of description, the preset field for filtering out field data is referred to as a fourth preset field. Exemplarily, the fourth preset field includes but is not limited to a preset field for log collection by a third log service platform and a preset field for log collection by a terminal device.
[0072] The server can search for field data corresponding to the fourth preset field in the first preset field according to the filtering rule, and after finding the field data corresponding to the fourth preset field, can delete the field data corresponding to the fourth preset field, thereby improving the processing efficiency of the log data.
[0073] In some embodiments of the present application, in order to further improve the efficiency of log processing and the accuracy of finding duplicate logs, optionally, the first time period includes sub-time periods corresponding to the first log filters one by one, and there is no time overlap between different sub-time periods; each first log filter is generated based on the characteristic information of each second log obtained in its corresponding sub-time period.
[0074] Specifically, in the process of filtering the first log using at least one first log filter, the steps include: obtaining characteristic information of the first log; calculating the index value of the characteristic information of the first log according to the index calculation function corresponding to the first log filter; and determining the filtering result of the filtering process according to the index value of each second log characteristic information included in the first log filter and the index value of the characteristic information of the first log.
[0075] Wherein, when each second log characteristic information is inconsistent with the characteristic information of the first log, the filtering result of the filtering process is that it is not filtered out.
[0076] Specifically, the first time period may include one or more sub-time periods.
[0077] In the case where the first time period includes a sub-time period, the time length of the first time period is equal to the time length of the sub-time period.
[0078] In the case where the first time period includes multiple sub-time periods, exemplarily, Figure 3 is a schematic diagram of the relationship between the first time period and the sub-time period provided in the embodiment of the present application, combined with Figure 3 The first time period T1 includes multiple sub-time periods, and the multiple sub-time periods are t1, t2, t3, ..., tN-1, tN, respectively, where N is a positive integer, and there is no time overlap between the sub-time periods.
[0079] The time length of the sub-time period can be a preset fixed length. For example, the time length of a sub-time period can be 10 minutes. The value of N can also be set according to actual application requirements. For example, N can be set to 12. Taking this as an example, the time length of the first time period is 120 minutes.
[0080] In some optional embodiments, after obtaining the first log, the time selection range of the second log can be defined by a fixed time period in combination with a preset number of sub-time periods and a preset length of the sub-time periods, or by adaptively dividing the time periods.
[0081] The fixed time period method, for example, pre-sets the time length, time start point, and time end point of each sub-time period. Continuing with the example of a sub-time period of 10 minutes, the pre-set sub-time periods are, for example, 9:01-9:10, 9:11-9:20, 9:21-9:30, 9:31-9:40, 9:41-9:50, 9:51-10:00, 10:01-10:10, etc. Exemplarily, if N=6, when the first log filter is determined based on a fixed time period, after obtaining the first log, the sub-time period in which the first log is obtained can be determined first. For example, the first log acquisition time is 10:05, which is within the sub-time period of 10:01-10:10. A log filter is generated based on the sub-time period of 10:01-10:10 as the first log filter for filtering the first log, and the log filters generated corresponding to the five sub-time periods before 10:01-10:10 are obtained as the first log filter for filtering the first log.
[0082] Based on the fixed time period, the sub-time periods are divided and the log filters corresponding to the sub-time periods are generated. The log filters corresponding to each sub-time period can be easily reused, which can reduce the computational burden of establishing log filters in real time, save computing resources, and filter logs quickly and accurately.
[0083] Optionally, the method of adaptively dividing the time period, for example, takes the acquisition time of the first log as the time end point, and takes N sub-time periods forward. Continuing to take the time length of a sub-time period as 10 minutes and N=6 as an example, after obtaining the first log, the acquisition time of the first log is determined to be 10:05, and it is used as the time end point. The first time period is 9:06-10:05, and the N sub-time periods are: 9:06-9:15, 9:16-9:25, 9:26-9:35, 9:36-9:45, 9:46-9:55, 9:56-10:05. By adaptively dividing the time period, the log filter is established through implementation, which is conducive to improving the accuracy of log filtering.
[0084] In some embodiments, in order to effectively reduce the amount of calculation in generating log filters and filtering logs, each log filter can be generated according to the characteristic information of each log obtained in its corresponding sub-time period. For example, the field data corresponding to some preset fields in the log can be used as the characteristic information of the log, or the log can be parsed through a preset characteristic calculation model to output the characteristic information of the log.
[0085] Corresponding to each sub-time period, the second log obtained in the sub-time period is obtained, and the characteristic information of the second log is obtained, and then the log filter corresponding to the sub-time period is generated in combination with the characteristic information. Optionally, the field data corresponding to the third preset field is pre-set as the characteristic information of the log, and the number of the third preset fields can be one or more. Optionally, the third preset field includes but is not limited to project category, unique primary key, generation time, event type, etc.
[0086] In some embodiments, obtaining characteristic information of the first log may specifically include: obtaining field data corresponding to a third preset field from a plurality of first preset fields to obtain characteristic information of the first log. Based on this, when the first filter is used to filter the first log, the amount of data processing can be effectively reduced, the calculation speed can be increased, and the processing efficiency of the log can be improved.
[0087] Exemplarily, the data structure of the log filter can be a probabilistic data structure, so as to efficiently query whether there are duplicate logs, and insert the log into the log filter when it is determined that there are no duplicate logs. Optionally, the log filter can be a Bloom filter generated based on the characteristic information of the second log.
[0088] Specifically, taking a first log filter as an example, one or more index calculation functions are set in the first log filter, and the index calculation function can be a hash function, for example. After the characteristic information of each second log is calculated by the hash function, the index value of the characteristic information of the second log is obtained, and the index value is recorded in the first log filter. It can be understood that if the number of corresponding index calculation functions set in the first log filter is multiple, then the characteristic information of the second log corresponds to multiple index values.
[0089] The first log filter includes a bit vector or a bit list of length M. Taking the bit list as an example, in the bit list of length M, each position is 0 or 1, wherein based on the index value of the characteristic information of the second log, the position corresponding to the index value is set to "1".
[0090] After obtaining the characteristic information of the first log, the index value of the characteristic information of the first log is calculated according to the index calculation function corresponding to the first log filter, and the value of the position corresponding to the index value of the characteristic information of the first log is determined in the bit list of the first log filter, thereby quickly generating a filtering result for filtering the first log.
[0091] Specifically, if the corresponding position of the index value of the characteristic information of the first log is 1, it means that there may be a second log that is consistent with the first log. Accordingly, the first log can be filtered out.
[0092] If the index value corresponding to the position of the characteristic information of the first log is 0, it means that there is no duplication in the first log, that is, each characteristic information of the second log is inconsistent with the characteristic information of the first log. Based on this, the filtering result of the filtering process of the first log is not filtered out.
[0093] According to the log processing method provided in the embodiment of the present application, repeated first logs existing in the first time period can be quickly and efficiently filtered out, effectively reducing the number of useless logs generated downstream.
[0094] In some embodiments of the present application, after obtaining the filtering processing result, the method also includes: when the filtering result of the filtering processing is not filtered out, when the filtering result of the filtering processing is not filtered out, updating the target log filter in the first log filter according to the index value of the characteristic information of the first log; wherein the acquisition time of the first log is within the sub-time period corresponding to the target log filter.
[0095] For example, taking the acquisition time of the first log as 10:05, the sub-time periods are divided based on a fixed time short manner, each sub-time period is 10 minutes long, and the sub-time period corresponding to the target log filter is 10:01-10:10. Thus, the target log filter is updated based on the index value of the characteristic information of the first log. The update method is, for example, to set the forensic position corresponding to the index value of the characteristic information of the first log to position 1.
[0096] According to the embodiment of the present application, by updating the log filter based on the characteristic information of the newly added first log, real-time updating of the log filter is achieved, especially for the logs obtained by the corresponding server later, which is conducive to improving the accuracy of filtering duplicate logs.
[0097] In some embodiments of the present application, involving the above-mentioned steps 203 and 204, when the first log is not filtered out, the filtering rules used to process the first log can be flexibly determined in combination with the field data of the first target field in the first log, and then the first log can continue to be filtered according to the filtering rules of the first log.
[0098] Optionally, the filtering rules corresponding to the field data can be updated according to the actual application requirements of the log. In order to simplify the updating process of the filtering rules, before obtaining the filtering rules corresponding to the field data of the first target field, the embodiment of the present application may also include the following steps: obtaining the newly added filtering rules in the rule database; storing the newly added filtering rules in the preset data storage space.
[0099] Exemplarily, the rule database is used to store the filtering rules corresponding to the log data. When the filtering rules need to be updated, it is only necessary to add the newly added filtering rules to the rule database.
[0100] Optionally, the rule database can be a database of a relational database management system, and there is a message channel between the server and the rule database. Based on the message channel, the server can read the newly added filtering rules in the rule database in real time, and store the newly added filtering rules in a preset data storage space, so that the execution unit in the server can read the filtering rules corresponding to the field data in the data storage space when executing the log processing method, and filter the log according to the filtering rules.
[0101] Since the filtering rules correspond to the field data one by one, when the newly added filtering rules corresponding to the field data are inconsistent with the existing filtering rules, the newly added filtering rules can be used to update the existing rules. Therefore, every time the log needs to be filtered, the latest filtering rules can be used in time to filter the log.
[0102] In addition, the newly added filtering rules can also be the filtering rules added corresponding to the new field data, thereby, the filtering logic of the log can be flexibly adjusted, which is conducive to quickly adapting to different log application scenarios.
[0103] As a specific example, obtaining the newly added filtering rules in the rule database may specifically include the following steps: in response to the rule database receiving a rule write operation and generating the newly added filtering rules, reading the newly added filtering rules in the rule database based on flink CDC to obtain the newly added filtering rules.
[0104] Exemplary, combined Figure 4 Another architecture diagram of the log processing system shown in the figure, the rule database 41 based on the relational database management system can specifically be a MySQL database, and the message channel between the server and the rule database can be a Kafka message queue.
[0105] After receiving the write operation, the rule database obtains the newly added filter rules, and accordingly, the newly added filter rules are added to the Kafka message queue. The server can capture data changes in the message channel by configuring the flink CDC technology, that is, read the newly added filter rules in the rule database through the message channel.
[0106] According to the embodiment of the present application, the updating process of the filtering rules is effectively simplified, which facilitates the flexible adjustment of the filtering logic of the log and is conducive to quickly adapting to different log application scenarios.
[0107] As a specific embodiment, Figure 4 As shown, the log processing system in the server may include one or more execution units. Optionally, the newly added filtering rules may be notified to each execution unit by broadcasting, so that each execution unit can read the newly added filtering rules.
[0108] Continue to combine Figure 4 As shown, the server 42 can obtain the first log generated by the upstream terminal from the third-party log service platform 43, and filter the first log according to the characteristic information of the first log by using the first log filter constructed based on the log in the adjacent time period. If the first log is a duplicate log, it can be quickly and efficiently filtered out during this filtering process. If there is no duplicate log in the first log, then, combined with the field data of the first target field in the first log, the filtering rules used to process the first log can be flexibly determined, and then according to the filtering rules of the first log, the field data of the second preset field that needs to be forwarded is extracted in the first log, and the field data of the second preset field is forwarded, so that the downstream data consumers 44 can all obtain the required log data, thereby not only efficiently and flexibly collecting useful logs in the log, but also realizing efficient diversion of the first log.
[0109] The above describes the implementation methods and advantages of the embodiments of the present application through multiple embodiments. The following describes the specific processing process of the embodiments of the present application in detail with reference to specific examples.
[0110] Corresponding to the method embodiment of the present application, the present application also provides a log processing device, such as Figure 5 As shown, the log processing device 500 includes:
[0111] An acquisition module 501 is used to acquire a first log generated by an upstream terminal, wherein the log includes a plurality of first preset fields, and each first preset field includes field data;
[0112] The processing module 502 is configured to filter the first log using at least one first log filter, wherein the first log filter is constructed according to a second log generated by an upstream terminal and acquired in a first time period, the acquisition time of the second log is earlier than the acquisition time of the first log, and the acquisition time of the first log is within the first time period;
[0113] The processing module 502 is further configured to obtain, when the filtering result of the filtering processing is that the object is not filtered out, a filtering rule corresponding to the field data of the first target field according to the field data of the first target field in the plurality of first preset fields, wherein the filtering rule includes the second preset field and the address information corresponding to the second preset field;
[0114] The processing module 502 is further configured to obtain field data corresponding to the second preset field in the first log, and send the field data of the second preset field according to the address information corresponding to the second preset field.
[0115] In some embodiments, the first time period includes sub-time periods corresponding to the first log filters one by one, and there is no time overlap between different sub-time periods; each first log filter is generated based on the characteristic information of each second log obtained in its corresponding sub-time period;
[0116] The acquisition module 501 is further used to acquire characteristic information of the first log;
[0117] The processing module 502 is further configured to calculate the index value of the feature information of the first log according to the index calculation function corresponding to the first log filter;
[0118] The processing module 502 is further used to determine a filtering result of the filtering process according to the index value of each second log feature information included in the first log filter and the index value of the feature information of the first log;
[0119] Wherein, when each second log characteristic information is inconsistent with the characteristic information of the first log, the filtering result of the filtering process is that it is not filtered out.
[0120] In some embodiments, the processing module 502 is further configured to update the target log filter in the first log filter according to the index value of the feature information of the first log when the filtering result of the filtering process is that the log is not filtered out;
[0121] The acquisition time of the first log is within the sub-time period corresponding to the target log filter.
[0122] In some embodiments, the acquisition module 501 is further used to acquire field data corresponding to a third preset field from a plurality of first preset fields to obtain characteristic information of the first log.
[0123] In some embodiments, the acquisition module 501 is further used to acquire a newly added filtering rule in the rule database;
[0124] The processing module 502 is further configured to store the newly added filtering rule in a preset data storage space.
[0125] In some embodiments, the processing module 502 is further used to generate a new filtering rule in response to the rule database receiving a rule write operation, and to obtain the new filtering rule based on flink CDC reading the new filtering rule in the rule database.
[0126] It can be understood that the log processing device of the embodiment of the present application can correspond to the execution entity of the data synchronization method provided by the embodiment of the present application. The specific details of the operation and / or function of each module / unit of the log processing device can be found in the description of the corresponding parts of the data synchronization method provided by the above-mentioned embodiment of the present application. For the sake of brevity, they will not be repeated here.
[0127] The electronic device in the embodiment of the present application may be a user terminal device, a server, other computing devices, or a cloud server. Figure 6 A schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application is shown. The electronic device may include a processor 601 and a memory 602 storing computer program instructions. When the processor 601 executes the computer program instructions, the process or function of any of the above-mentioned embodiments of the method is implemented.
[0128] Specifically, the processor 601 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application. The memory 602 may include a large-capacity memory for data or instructions. For example, the memory 602 may be at least one of the following: a hard disk drive (HDD), a read-only memory (ROM), a random access memory (RAM), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, a universal serial bus (USB) drive or other physical / tangible memory storage device. For another example, the memory 602 may include a removable or non-removable (or fixed) medium. For another example, the memory 602 may be inside or outside the integrated gateway disaster recovery device. The memory 602 may be a non-volatile solid-state memory. In other words, the memory 602 usually includes a tangible (non-transitory) computer-readable storage medium (such as a memory device) encoded with computer-executable instructions, and when the software is executed (such as executed by one or more processors), the operation described in the method of the embodiment of the present application can be performed. The processor 601 implements the process or function of any method in the above embodiments by reading and executing the computer program instructions stored in the memory 602.
[0129] In one example, Figure 6 The electronic device shown may also include a communication interface 603 and a bus 610. Among them, the processor 601, the memory 602, and the communication interface 603 are connected through the bus 610 and complete the communication between each other. The communication interface 603 is mainly used to realize the communication between each module, device, unit and / or device in the embodiment of the present application. The bus 610 includes hardware, software or both, and can couple the components of the online data traffic billing device to each other. For example, the bus may include at least one of the following: an accelerated graphics port (AGP) or other graphics bus, an enhanced industrial standard architecture (EISA) bus, a front-end bus (FSB), a hypertransport (HT) interconnect, an industrial standard architecture (ISA) bus, an infinite bandwidth interconnect, a low pin count (LPC) bus, a memory bus, a micro channel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a video electronics standard association local (VLB) bus or other suitable buses. The bus 610 may include one or more buses. Although the embodiments of the present application describe or illustrate a specific bus, the embodiments of the present application may consider any suitable bus or interconnection method.
[0130] In combination with the method in the above embodiments, an embodiment of the present application also provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the process or function of any method in the above embodiments is implemented.
[0131] In addition, an embodiment of the present application further provides a computer program product, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the process or function of any one of the methods in the above embodiments is implemented.
[0132] The above exemplarily describes the flowcharts and / or block diagrams of the methods, devices, systems and computer program products of the embodiments of the present application, and describes the relevant various aspects. It should be understood that each box or combination thereof in the flowchart and / or block diagram can be implemented by computer program instructions, or by dedicated hardware that performs a specified function or action, or by a combination of dedicated hardware and computer instructions. For example, these computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to form a machine that enables these instructions executed by such a processor to enable the implementation of the functions / actions specified in each box or combination thereof in the flowchart and / or block diagram. Such a processor can be a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.
[0133] The functional blocks shown in the structured block diagram of the embodiment of the present application can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc.; when implemented in software, it is a program or code segment used to perform the required task. The program or code segment can be stored in a memory, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0134] It should be noted that the present application is not limited to the specific configurations and processes described above or shown in the figures. The above is only a specific implementation mode of the present application. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the described system, device, module or unit can refer to the corresponding process in the method embodiment without further description. It should be understood that the scope of protection of the present application is not limited to this. Any technician familiar with the technical field can think of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and these modifications or substitutions should be included in the scope of protection of the present application.
Claims
1. A log processing method, characterized in that: include: Obtaining a first log generated by an upstream terminal, wherein the first log includes field data corresponding one-to-one to a plurality of first preset fields; Filtering the first log using at least one first log filter, wherein the first log filter is constructed based on a second log generated by the upstream terminal and obtained during a first time period, the second log being obtained earlier than the first log, and the first log being obtained within the first time period; If the filtering result of the filtering process is that the content is not filtered out, obtaining, based on the field data of the first target field among the plurality of first preset fields, a filtering rule corresponding to the field data of the first target field, wherein the filtering rule includes a second preset field and address information corresponding to the second preset field; The field data corresponding to the second preset field is obtained in the first log, and the field data of the second preset field is sent according to the address information corresponding to the second preset field.
2. The method according to claim 1, characterized in that The first time period includes sub-time periods corresponding to the first log filters one by one, and different sub-time periods do not overlap in time; each first log filter is generated based on feature information of each second log obtained in its corresponding sub-time period; The filtering the first log using at least one first log filter includes: Obtaining characteristic information of the first log; Calculating an index value of the feature information of the first log according to an index calculation function corresponding to the first log filter; determining a filtering result of the filtering process according to an index value of each piece of the second log feature information included in the first log filter and an index value of the feature information of the first log; Wherein, when the characteristic information of each second log is inconsistent with the characteristic information of the first log, the filtering result of the filtering process is that the log is not filtered out.
3. The method according to claim 2, characterized in that After obtaining the filtering result, the method further includes: If the filtering result of the filtering process is that the log is not filtered out, updating the target log filter in the first log filter according to the index value of the feature information of the first log; The acquisition time of the first log is within the sub-time period corresponding to the target log filter.
4. The method according to claim 2, characterized in that The obtaining characteristic information of the first log includes: Field data corresponding to a third preset field is obtained from the plurality of first preset fields to obtain characteristic information of the first log.
5. The method according to claim 1, wherein Before obtaining the filtering rule corresponding to the field data of the first target field, the method further includes: Get the newly added filtering rules in the rule database; The newly added filtering rules are stored in a preset data storage space.
6. The method according to claim 5, characterized in that The newly added filtering rules in the acquisition rule database include: In response to the rule database receiving the rule write operation and generating the newly added filtering rule, the newly added filtering rule in the rule database is read based on flinkCDC to obtain the newly added filtering rule.
7. A log processing device, characterized in that: include: An acquisition module, configured to acquire a first log generated by an upstream terminal, wherein the log includes a plurality of first preset fields, and each of the first preset fields includes field data; a processing module, configured to filter the first log using at least one first log filter, wherein the first log filter is constructed based on a second log generated by the upstream terminal and acquired during a first time period, the acquisition time of the second log is earlier than the acquisition time of the first log, and the acquisition time of the first log is within the first time period; The processing module is further configured to, when a filtering result of the filtering processing is that the object is not filtered out, obtain, based on the field data of the first target field among the plurality of first preset fields, a filtering rule corresponding to the field data of the first target field, wherein the filtering rule includes a second preset field and address information corresponding to the second preset field; The processing module is further configured to obtain field data corresponding to the second preset field in the first log, and send the field data of the second preset field according to address information corresponding to the second preset field.
8. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; and when the electronic device executes the computer program instructions, the method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The method comprises computer program instructions, which implement the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
Data processing method and device and electronic equipment
CN109656901A
Log information processing method and device
CN112887114A
Log data processing method and device, distributed computing system and storage medium
CN113342748A
Log filtering method and device
CN115658443A
Server log storage method and device, storage medium and electronic device
CN116662285A
