Data consistency analysis method and device, equipment and storage medium
By extracting event correlations and expected models from log data, the data consistency between microservice applications is analyzed in real time, which solves the problem of poor real-time performance of end-of-day reconciliation in the existing technology and achieves faster data consistency detection and deal with.
Patent Information
- Application Number
- CN202311337527.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-16
- Publication Date
- 2024-10-18
AI Technical Summary
Existing data consistency analysis methods mainly rely on day-end reconciliation and have poor real-time performance, resulting in delayed problem discovery and inability to detect and handle data inconsistencies in a timely manner, affecting the accuracy and reliability of business processing.
By obtaining the log data of the business system, reading the event expectation model, building event correlation relationships, querying the event data of benchmark applications and expected applications, analyzing data consistency, and using self-learning calculations and event expectation models to achieve higher real-time data Consistency analysis.
It improves the real-time nature of data consistency analysis, detects data errors in a timely manner, reduces the risk of customer complaints and transaction errors, and improves the reliability and efficiency of the business system.
Smart Images

Figure CN118796845A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data consistency analysis method, device, equipment and storage medium. Background Art
[0002] Distributed architecture is a must-have architecture for large projects, and is also the underlying foundation of emerging technologies such as cloud native and Serverless. In order to improve the overall performance, reliability, and R&D efficiency of business systems, they are usually split into more independent application modules according to business or function. A complete business system consists of multiple microservice applications, which are integrated externally and decentralized and independent internally. A complete transaction usually runs through various microservice applications, generating unique data in each application, and there is a certain inevitable connection between these data. In this decentralized data storage form, there is a risk in confirming the result of an external request based on the data status of any application. Only the overall consistency of the data can objectively reflect the correctness of business processing. Therefore, it is necessary to ensure the data consistency between various microservice applications, especially for data such as orders and capital changes generated by core businesses, and strong consistency audits must be performed to ensure consistency.
[0003] However, the existing method for data consistency is mainly through end-of-day reconciliation, which has poor real-time performance and a delay in discovering problems. Summary of the invention
[0004] The main purpose of the present invention is to provide a data consistency analysis method, device, equipment and storage medium, aiming to solve the technical problems that the existing data consistency method is mainly through end-of-day reconciliation, which has poor real-time performance and delayed problem discovery.
[0005] To achieve the above object, the present invention provides a data consistency analysis method, which comprises:
[0006] Obtaining log data of the business system, and reading the event expectation model to obtain an event association relationship, where the event association relationship is an association relationship between a benchmark application and an expected application;
[0007] Query the log data according to the event association relationship to obtain event data of the benchmark application;
[0008] querying the log data according to the event data of the benchmark application to obtain the event data of the expected application;
[0009] The data consistency between the reference application and the expected application is analyzed based on the event data of the reference event and the event data of the expected application.
[0010] Optionally, analyzing the data consistency between the benchmark application and the expected application according to the event data of the benchmark event and the event data of the expected application includes:
[0011] Obtaining an expectation expression of an expectation setting from the event expectation model;
[0012] Filling the event data of the benchmark event and the event data of the expected application into the expected expression to obtain an expected result;
[0013] The data consistency between the benchmark application and the expected application is analyzed according to the corresponding relationship between the expected result and the data consistency.
[0014] Optionally, after analyzing the data consistency between the benchmark application and the expected application according to the corresponding relationship between the expected result and the data consistency, the method further includes:
[0015] Find the processing method corresponding to the expected result, and find the processing method corresponding to the data consistency result;
[0016] The result processing is performed respectively according to the processing method corresponding to the expected result and the processing method corresponding to the data consistency result.
[0017] Optionally, before analyzing the data consistency between the reference application and the expected application according to the event data of the reference event and the event data of the expected application, the method further includes:
[0018] Read the event expectation model to obtain a time window;
[0019] Accordingly, analyzing the data consistency between the reference application and the expected application according to the event data of the reference event and the event data of the expected application includes:
[0020] When the current time satisfies the time window, data consistency between the reference application and the expected application is analyzed according to the event data of the reference event and the event data of the expected application.
[0021] Optionally, before obtaining the log data of the business system and reading the event expectation model to obtain the event association relationship, the process further includes:
[0022] Obtain log data from business systems;
[0023] Calculate event association relationships in a self-learning manner based on the log data;
[0024] An event anticipation model is constructed based on the event association relationship.
[0025] Optionally, the self-learning calculation of event association relationships according to the log data includes:
[0026] Obtaining a baseline application log and an expected application log from the log data;
[0027] Grouping the benchmark application log and the expected application log according to the request ID to obtain log records of the same context;
[0028] Traversing the key-value pairs in the log records, grouping them according to the values of the key-value pairs, extracting keywords with the same values, and establishing an association relationship list;
[0029] Setting a corresponding association quality coefficient for the association relationship in the association relationship list, and calculating the association quality of the association relationship according to the association quality coefficient value;
[0030] The association relationship list is updated according to the association quality to obtain event association relationships.
[0031] Optionally, constructing an event anticipation model based on the event association relationship includes:
[0032] Building expected configuration items based on the target attributes, where the expected configuration items include at least one of expected relationship type, expected setting, expected result, data consistency, time window, and processing method;
[0033] An event expectation model is constructed according to the event association relationship and the expected configuration items.
[0034] In addition, to achieve the above object, the present invention also proposes a data consistency analysis device, the data consistency analysis device comprising:
[0035] An acquisition module is used to acquire log data of a business system, and read an event expectation model to obtain an event association relationship, where the event association relationship is an association relationship between a benchmark application and an expected application;
[0036] A query module, configured to query the log data according to the event association relationship to obtain event data of the benchmark application;
[0037] The query module is further used to query the log data according to the event data of the benchmark application to obtain the event data of the expected application;
[0038] An analysis module is used to analyze data consistency between the reference application and the expected application based on the event data of the reference event and the event data of the expected application.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also proposes a data consistency analysis device, which includes a memory, a processor, and a data consistency analysis program stored in the memory and executable on the processor, and the data consistency analysis program is configured to implement the data consistency analysis method described above.
[0040] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a data consistency analysis program is stored, and when the data consistency analysis program is executed by a processor, the data consistency analysis method as described above is implemented.
[0041] The present invention discloses obtaining log data of a business system, reading an event expectation model, obtaining an event association relationship, wherein the event association relationship is an association relationship between a benchmark application and an expected application, querying log data according to the event association relationship, obtaining event data of the benchmark application, querying log data according to the event data of the benchmark application, obtaining event data of the expected application, and analyzing data consistency between the benchmark application and the expected application according to the event data of the benchmark event and the event data of the expected application; because the present invention extracts elements describing data consistency from log data with higher real-time performance and determines data consistency results, the problem of delayed discovery of data errors in day-end reconciliation is improved, thereby improving the real-time performance of data consistency analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a structural diagram of a data consistency analysis device for a hardware operating environment involved in an embodiment of the present invention;
[0043] Figure 2 This is a flow chart of a first embodiment of a method for analyzing data consistency according to the present invention;
[0044] Figure 3 This is a flow chart of a second embodiment of the data consistency analysis method of the present invention;
[0045] Figure 4 A schematic diagram of a microservice architecture of an embodiment of a data consistency analysis method of the present invention;
[0046] Figure 5 A schematic diagram of the relationship between requests, applications, and events in an embodiment of a data consistency analysis method of the present invention;
[0047] Figure 6 A schematic diagram of the log management system architecture of an embodiment of a data consistency analysis method of the present invention;
[0048] Figure 7 This is a schematic diagram of event definition in an embodiment of a method for analyzing data consistency according to the present invention;
[0049] Figure 8 A self-learning event association calculation method according to an embodiment of a data consistency analysis method of the present invention;
[0050] Fig. 9 This is a schematic diagram of event association and prediction of an embodiment of a data consistency analysis method of the present invention;
[0051] Fig.10 It is a flowchart of the third embodiment of the data consistency analysis method of the present invention;
[0052] Fig.11 A schematic diagram of the expected calculation process of an embodiment of the data consistency analysis method of the present invention;
[0053] Fig.12 It is a structural block diagram of the first embodiment of the data consistency analysis device of the present invention.
[0054] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0055] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0056] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of a data consistency analysis device for a hardware operating environment involved in an embodiment of the present invention.
[0057] like Figure 1 As shown, the data consistency analysis device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The wired interface of the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable memory (Non-volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0058] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the data consistency analysis device, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0059] like Figure 1 As shown, the memory 1005 identified as a computer storage medium may include an operating system, a network communication module, a user interface module, and a data consistency analysis program.
[0060] exist Figure 1 In the data consistency analysis device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the user device; the data consistency analysis device calls the data consistency analysis program stored in the memory 1005 through the processor 1001, and executes the data consistency analysis method provided by the embodiment of the present invention.
[0061] Based on the above hardware structure, an embodiment of the data consistency analysis method of the present invention is proposed.
[0062] Reference Figure 2 , Figure 2 The figure is a flow chart of the first embodiment of the data consistency analysis method of the present invention, and the first embodiment of the data consistency analysis method of the present invention is proposed.
[0063] It should be understood that distributed architecture is a must-use architecture for large projects and is also the underlying foundation of emerging technologies such as cloud native and Serverless. In order to improve the overall performance, reliability, and R&D efficiency of business systems, they are usually split into more independent application modules according to business or function. A complete business system consists of multiple microservice applications, which are integrated externally and decentralized and independent internally. A complete transaction usually runs through various microservice applications, generating unique data in each application, and there is a certain inevitable connection between these data. In this decentralized data storage form, it is risky to confirm the result of an external request based on the data status of any application. Only the overall consistency of the data can objectively reflect the correctness of business processing. Therefore, it is necessary to ensure the data consistency between various microservice applications, especially for data such as orders and capital changes generated by core businesses, and strong consistency audits must be performed to ensure consistency.
[0064] The current method to ensure data consistency between applications is mainly through end-of-day reconciliation. End-of-day reconciliation is mainly based on DB and reconciliation files. The reconciliation application checks each item and the total amount, and performs other automatic or manual processing when discrepancies are found. The advantage of end-of-day reconciliation is that it is more accurate and efficient. Therefore, reconciliation is a common way and the final guarantee to ensure data consistency between applications or systems.
[0065] Although the end-of-day reconciliation can ensure strong consistency, the disadvantage is that the time point of discovering differences is too late, and it is impossible to discover the difference data in time and alert the technical staff to deal with the data inconsistency. If the difference data is not handled in time, it may lead to customer complaints, amplified transaction processing confusion, and even increased financial losses. Therefore, it is very necessary to discover system anomalies and data inconsistencies as early as possible.
[0066] The advantages of microservice architecture prompt the business system to be designed to be composed of micro-applications with smaller granularity, resulting in an increase in the request chain, making it more difficult to ensure global consistency and complex technical implementation. This is why the mainstream currently adopts the final consistency design instead of the global transaction component. Since it is impossible to control consistency in the real-time operation link, it is very necessary to monitor the consistency of data offline. Based on this concept, this embodiment designs a set of calculation models based on log data without adding additional system overhead and is not affected by the increase of microservice applications. It constructs an event and expected judgment model to achieve a method for quasi-real-time inspection of data consistency between microservice applications, so as to achieve the purpose of analyzing application operation, data consistency, production environment business logic monitoring and data anomaly discovery. The advantages are reflected in the following three aspects: 1. Realize quasi-real-time calculation; 2. Not only can observe the normal situation of applications and between applications, but also observe abnormal situations; 3. Through the perspective of process data, it can calculate clear conclusions and disprove the consistency of data.
[0067] In a first embodiment, the data consistency analysis method includes:
[0068] Step S10: Obtain log data of the business system, and read the event expectation model to obtain event association relationships, where the event association relationships are association relationships between the benchmark application and the expected application.
[0069] It is understandable that the executor of this embodiment can be a data consistency analysis device with data processing, network communication and program running functions, such as a computer, or other electronic devices that can achieve the same or similar functions, and this embodiment does not limit this.
[0070] It should be understood that when developers write code, they output log data describing event information of the business system after key operations are completed.
[0071] Example: A complete log includes:
[0072] {
[0073] "log_time":"2023-05-16 17:11:26,845", / / Log generation time
[0074] "log_level":"INFO", / / Log level
[0075] "log_host_ip":"172.24.34.28", / / log generation host ip
[0076] "log_app": trade, / / application name for log generation
[0077] "action":" / v1 / account / balance / mainAccount", / / Function point for generating logs
[0078] "log_source_app":, / / Application name of the request source
[0079] "log_request_id":"REG1223050717105391822", / / Request ID (generated by the ingress gateway and passed between microservice applications)
[0080] "log_thread_id":"p-nio-8050-exec-4", / / The thread number of the business application processing request event
[0081] "orderId":"202305160000002", / / Business application order number
[0082] "externalOrderNo":"JD202305160000002", / / Order number of the external system
[0083] "orderStatus":"SUCCESS", / / Status recorded in the business application
[0084] "transAmount":858.76 / / Transaction data, such as amount
[0085] ... / / Other transaction data
[0086] }
[0087] It can be understood that according to the definition of the event expectation model, the event expectation model includes benchmark applications, expected applications, event association relationships, expected settings, data consistency, expected result processing methods, time windows, etc.
[0088] For example:{
[0089] Base application APP_BASE: App1, Base event definition: E_BASE_Def(orderId),
[0090] Expected application APP_EPT: App2, expected event definition: E_EPT_Def(orderNo),
[0091] Relationship: E_RELATION(App1.orderId==App2.orderNo),
[0092] Expected: [{P:app1.E&&app2.E,P_RESULT:{Y:Consistent}},{P:app1.orderStatus==“SUCCESS”&&app2.accountStatus==“1”,P_RESULT:{Y:Consistent}}],
[0093] Time window: {3min}
[0094] }
[0095] Step S20: querying the log data according to the event association relationship to obtain event data of the benchmark application.
[0096] It is understandable that the scheduled task scans the event expectation model configuration table once a minute, obtains an event configuration record, organizes ES query statements according to the keywords configured in the benchmark event definition, queries the log data set, and extracts the keyword values to generate grouped data. The grouped data format is [{log_request_id: request id, log_thread: thread number, log_time: timestamp, K1: V1, K2: V2,...},{log_request_id: request id, log_thread: thread number, log_time: timestamp, K1: V1, K2: V2,...}].
[0097] Step S30: querying the log data according to the event data of the benchmark application to obtain the event data of the expected application.
[0098] It should be understood that according to the configuration table of the expected event model, the benchmark event grouping data is traversed, the ES query statement is organized, the benchmark event grouping data value is used as a condition, the log data of the expected event of the same request is queried, the keyword value is extracted, and the expected event data group is generated. The expected calculation unit is called and the benchmark event and the expected event grouping data are input.
[0099] The grouped data format of expected events: [{log_request_id: request id, log_thread: thread number, log_time: timestamp, K1: V1, K2: V2, ...}, {log_request_id: request id, log_thread: thread number, log_time: timestamp, K1: V1, K2: V2, ...}].
[0100] Step S40: analyzing data consistency between the reference application and the expected application based on the event data of the reference event and the event data of the expected application.
[0101] It can be understood that analyzing the data consistency between the baseline application and the expected application based on the event data of the baseline event and the event data of the expected application can be by comparing the event data of the baseline event with the event data of the expected application, and analyzing the data consistency between the baseline application and the expected application based on the comparison result.
[0102] In this embodiment, the log data of the business system is obtained, and the event expectation model is read to obtain the event association relationship, where the event association relationship is the association relationship between the benchmark application and the expected application, the log data is queried according to the event association relationship to obtain the event data of the benchmark application, the log data is queried according to the event data of the benchmark application to obtain the event data of the expected application, and the data consistency between the benchmark application and the expected application is analyzed according to the event data of the benchmark event and the event data of the expected application; because the present invention extracts the elements describing the data consistency from the log data with higher real-time performance and determines the consistency result of the data, it improves the problem of untimely discovery of data errors in the end-of-day reconciliation, thereby improving the real-time performance of the data consistency analysis.
[0103] Reference Figure 3 , Figure 3 This is a flow chart of the second embodiment of the data consistency analysis method of the present invention. Figure 2 The first embodiment shown provides a second embodiment of the data consistency analysis method of the present invention.
[0104] In the second embodiment, before step S10, the method further includes:
[0105] Step S01: Obtain log data of the business system.
[0106] It should be understood that in order to facilitate subsequent data consistency analysis and improve the efficiency of data consistency analysis, in this embodiment, an event expectation model is pre-built based on the log data of the business system, and then the event expectation model is built based on the event association relationship.
[0107] It is understandable that social activities are composed of events, and there are various direct or indirect connections between events. We usually describe a complete event from the key dimensions of time, place, people, process, and results. By describing these five elements, observers can have a clearer understanding of the process and results of the event, and thus better understand the significance and impact of the event.
[0108] For ease of understanding, refer to Figure 4 and Figure 5 This is for illustration only, but not for limitation of the present invention. Figure 4 This is a schematic diagram of a microservice architecture of an embodiment of a data consistency analysis method of the present invention. Figure 5 A schematic diagram of the relationship among requests, applications, and events in an embodiment of a method for analyzing data consistency according to the present invention. Figure 4 In the field of software systems, in a closed environment with strong correlation, when event A occurs, a series of predictable events such as B, C, D, etc. must occur. There is a certain consistency between these events (for example, they all occur within a time window or have a certain feature, or are expected to achieve a certain clear result, etc.). In a related and time-series business processing chain, there must be a logical consistency relationship between events in quantitative data. This consistency relationship is reflected in other logical relationships such as relevance, existence, timeliness, equality, and conformity. For example, the following examples:
[0109] 1. If event E1 occurs in application A, then event E2 will inevitably occur in application A;
[0110] 2. If event E1 occurs in application A, event E2 will inevitably occur in application B;
[0111] 3. If event E1 occurs in application A, then event E3 will inevitably occur in application B, event E4 will inevitably occur in application C, and so on;
[0112] 4. If event E1 occurs in application A, then event E2 must occur in application B and the data element of A.E1 is equal to the data element of B.Event2;
[0113] 5. ...
[0114] It can also be Figure 5 The example shown is not limited to this embodiment.
[0115] The business system designed by microservice application architecture is a relatively closed environment composed of multiple applications. A request from the outside will stimulate the calling process between microservice applications in the business system. The request runs through part or the entire business system and triggers a series of events. At the same time, there are sequence and time constraints in time. In a business system designed by microservice architecture, each microservice application will generate log data, and these log data naturally have the consistency described above. First, the root cause of the event that prompts each application to generate log data is the same external event. Second, the R&D personnel of each application need to output key operation information to facilitate the observation and analysis of program operation. Third, the log data describes the various dimensions of the event, including time, place, person, content, process, result, etc., providing a basis for analyzing data consistency. However, the connection between log content is loose. Developers only care about the log line data of the code logic they care about, and do not care about the connection between logs, especially across applications. Therefore, it is necessary to design an algorithm to mine log connections, build event association relationships, and meet the requirements of consistency analysis.
[0116] Based on this idea, it is very meaningful for the observation system to implement an automatic detection mechanism to perceive the occurrence of events and the expected behavior of event characteristics in a short period of time, such as cross-application data consistency verification, auxiliary analysis of the R&D process, and anomaly detection during production operation.
[0117] There are usually two angles to observe events. One is to take the subject as the benchmark, observe a series of events that occur in the subject itself, and analyze the consistency of events from a single application. The other is to take the event as the benchmark, observe the reactions of each participating subject to the same event, and analyze the consistency of events between multiple applications. Take the payment scenario of the mall system as an example, as follows:
[0118] 1. Microservice application-user output log: 2023-05-07 17:11:20,817 Zhang's account number: CUSTOMER-001=CusAccount-001; merchant account: Merchant-001=MerAccount-001.
[0119] 2. Microservice application-transaction output log: 2023-05-07 17:11:20,946 The customer with user ID: Customer-001 placed an order to purchase a product from merchant Merchant-001, product number: SPBH-001, price: 123 yuan, payment method: account, order number: Order-001.
[0120] 3. Microservice application-account output log: 2023-05-07 17:11:21,109 account CusAccount-001 transferred 123 yuan to merchant MerAccount-001.
[0121] 4. Microservice application-notification output log: 2023-05-07 17:11:20,246 The merchant Merchant-001 was notified for the first time that the order status of Order-001 is Success.
[0122] Through the log analysis of the above four microservice applications, from the perspective of each application itself, the output logs are the content that the application itself cares about most, that is, what events have been completed in its own module. If we string together the logs of each module in chronological order and data features, it fully meets the set of events that must occur for a complete business (accepting payment requests-obtaining other basic information of the transaction subject-creating payment orders-initiating deductions-notifying the merchant system of payment results). When all events meet expectations, it can be determined that the order data between the three applications of transaction, accounting, and notification is consistent.
[0123] For ease of understanding, refer to Figure 6 This is for illustration only, but not for limitation of the present invention. Figure 6 This is a log management system architecture diagram of an embodiment of the data consistency analysis method of the present invention. In the figure, the average time consumed by the generation, collection, analysis and storage of the log is 30-60S. This time difference is a prerequisite for achieving quasi-real-time analysis of data consistency. The efficiency of manually querying logs and analyzing each application log through Kibana and Grafana is too low. The design of the monitoring platform focuses more on observing the occurrence of independent events of a single application (i.e., triggering an alarm based on a certain data item compared with a preset threshold), and lacks observation of the logical relationship between events. In this case, an independent processing unit is designed to realize the expected and consistency analysis of events and data with correlation relationships triggered by business requests in each application. If the situation does not meet expectations, the monitoring alarm platform can inform the relevant person to handle it within a reasonable time window. The higher the quality of the log data, the more accurate the consistency matching, the higher the timeliness of the analysis and processing, the faster and more accurate the notification of the difference situation, and the faster the technical personnel can locate and solve the problem.
[0124] For ease of understanding, refer to Figure 7 This is for illustration only, but not for limitation of the present invention. Figure 7This is a schematic diagram of event definition for an embodiment of the data consistency analysis method of the present invention. In the figure, the event in this case refers to a log containing event elements. A complete event can be described by one or more logs. When an event includes multiple logs, they must be in the same context, that is, app, request_id, and thread_id are the same. Keywords are elements that describe events and are variables in logs. Feature values refer to constant definitions, such as error codes, states, specific description information, etc. For example:
[0125] One log contains all event elements:
[0126] {
[0127] "log_time":"2023-05-16 17:11:26,845", / / Log generation time
[0128] "log_level":"INFO", / / Log level
[0129] "log_host_ip":"172.24.34.28", / / log generation host ip
[0130] "log_app": trade, / / application name for log generation
[0131] "action":" / v1 / account / balance / mainAccount", / / Function point for generating logs
[0132] "log_source_app":, / / Application name of the request source
[0133] "log_request_id":"REG1223050717105391822", / / Request ID (generated by the ingress gateway and passed between microservice applications)
[0134] "log_thread_id":"p-nio-8050-exec-4", / / thread number
[0135] "orderId":"202305160000002", / / Order number
[0136] "externalOrderNo":"JD202305160000002", / / External order number
[0137] "orderStatus":"SUCCESS", / / status
[0138] "transAmount":858.76 / / Transaction data, such as amount
[0139] ... / / Other transaction data
[0140] }
[0141] For ease of understanding, reference is also made to Table 1 for explanation, but the present invention is not limited thereto.
[0142] Table 1
[0143]
[0144]
[0145] Step S02: Calculate event association relationships in a self-learning manner based on the log data.
[0146] It should be understood that event association refers to the association between the benchmark application and the expected application based on the event model. This association is described by the business data items (key values) in the log. If the value of a certain keyword is the same in the log lines of two applications, the keyword (key) may have an association relationship. The probability value of this possibility is calculated based on the number of requests. The larger the probability value, the closer the connection between the events. The more associations there are, the closer the event relationship is. Based on this principle, a probability value of more than 95% can be identified as a strongly associated event. If the conditions for calculation are met, the consistency of the data can be observed and analyzed.
[0147] Furthermore, in order to improve the accuracy of event association relationships, the step S02 includes: obtaining a baseline application log and an expected application log from the log data; grouping the baseline application log and the expected application log according to the request ID to obtain log records of the same context; traversing the key-value pairs in the log records, grouping them according to the values of the key-value pairs, extracting keywords with the same values, and establishing an association relationship list; setting a corresponding association quality coefficient for the association relationship in the association relationship list, and calculating the association quality of the association relationship according to the association quality coefficient value; updating the association relationship list according to the association quality to obtain event association relationships.
[0148] The configuration items of event association include: baseline application, baseline event definition, expected application, expected event definition, and event association relationship.
[0149] 1. Base application (BASE_APP): The benchmark for expectation or data consistency analysis, usually an application with a calling and called relationship through which the request passes.
[0150] 2. Baseline event definition: one or more logs described by one or more keywords and feature values.
[0151] 3. Expected Application (EPT_APP): Corresponding to the benchmark application, it is another subject of the expectation. If the request processing process is application A calling application B, choosing A as the benchmark usually means predicting events after (future) event A or data consistency, while choosing B as the benchmark usually means predicting events before (data consistency) event B.
[0152] 4. Expected event definition: one or more logs described by one or more keywords and feature values.
[0153] 5. Event association relationship: The association relationship between events is realized by keywords, which is similar to the association SQL of the database, such as Table1.Field1=Table2.Field2, which clearly describes the connection between the event subjects. The baseline event and the expected event are both single events or sub-events. This item associates the baseline event with the expected event to describe a larger event. Usually, keywords with high uniqueness are selected, such as the order number that marks the business record. At the same time, the more keywords are selected, the more accurate the association. For example 1: "Application A.orderId&&Application B.orderNo" means: the log in which orderId appears in the log of application A is associated with the log in which orderNo appears in the log of application B, and when the value of A.orderId = the value of B.orderNo, then the log lines describe the same event source.
[0154] For ease of understanding, refer to Figure 8 This is for illustration only, but not for limitation of the present invention. Figure 8 This is a self-learning event association calculation method of an embodiment of the data consistency analysis method of the present invention. In the figure, the self-learning event association calculation method includes the following steps:
[0155] 1. Group the logs according to request_id and obtain the log records of the same context for analysis.
[0156] 2. Traverse all business data items (key: value), group them according to Value, extract keys with the same value, establish a list of associations, and maintain an association quality coefficient ref (base_app.key, ept_app.key) for each pair of associations. When each request has a key that satisfies the association, the quality coefficient of the corresponding relationship is +1. After this step, a networked association diagram is formed, which brings together the interim results of all application logs on the call chain describing the same event during the processing of a request.
[0157] 3. Calculate the association quality P(ref) = association quality coefficient value / total number of requests / 100%.
[0158] 4. Filter out weakly associated keys (below 95%) and create or update the consistency association table.
[0159] 5. Extract all keywords and values from events (log records) with associated relationships and maintain them in the event expectation model for use in expectation setting selection.
[0160] 6. This process completes the establishment of event association relationships through self-learning.
[0161] Step S03: constructing an event anticipation model based on the event association relationship.
[0162] It can be understood that constructing an event expectation model based on event association relationships can be to construct expected configuration items based on target attributes, and the expected configuration items include at least one of the expected relationship type, expected settings, expected results, data consistency, time window and processing method; constructing an event expectation model based on event association relationships and expected configuration items.
[0163] It should be understood that through self-learning, a highly stable set of associated event relationships (expected events and benchmark events) between various applications is established. Based on other attributes other than associated events, logical judgments (expected settings) that meet one's own expectations are constructed to calculate whether the inherent connection of business data on associated events meets expectations, and then analyze data consistency relationships. Expected configuration items include expected relationship type, expected settings, expected results and data consistency, time windows, and processing methods.
[0164] For ease of understanding, refer to Fig. 9 This is for illustration only, but not for limitation of the present invention. Fig. 9 This is a schematic diagram of event association and prediction of an embodiment of the data consistency analysis method of the present invention. In the figure, expected relationship: describes four types of expectations, including existence, conformity, equality, and timeliness.
[0165] Expected setting: Based on a single event or multiple events with a correlation, make a logical relationship judgment that complies with the pre-designed business rules based on the relationship between the elements of the event (keywords or characteristic values). Expected reflects the user's subjective prediction, while consistency describes the objective data relationship.
[0166] Expected result: Each expected logic has a clear result (true, false). If it is true, the expectation is met, and if it is false, it does not meet the expectation. Each result can be set with a corresponding processing method.
[0167] Data consistency results: When the expected logic is to analyze data consistency, when the expectations are met or not met, a clear conclusion of data consistency and inconsistency is expressed. Four situations can be configured: data consistency when expectations are met, data inconsistency when expectations are not met, data consistency when expectations are not met, and data inconsistency when expectations are met. The first two are used to make expectations for normal situations, and the last two are used to make expectations for abnormal situations.
[0168] Processing method: Set reasonable processing solutions for expected results and data consistency results, including 1 silent, 2 notification, 3 alarm, 4 recalculation, 5 export event, 6 trigger a request, etc.
[0169] Time window: specifies the life cycle of an event. Events that occur beyond the life cycle are meaningless. When there is a time constraint between related events, a time window can be added to the expectation. The expectation is meaningful only when the event occurs within the time window. The time window value includes: none, x seconds, x minutes, x hours, x days, a certain day, and a certain time period. When representing seconds, minutes, hours, and days, a negative value can be set to indicate that the expected event occurs before the benchmark event.
[0170] For example, if X is expected to occur when E1 occurs, E2 will occur and the time window is 30s, it means that events E1 and E2 will occur within 30s. If X is expected to occur when E1 occurs, E2 will occur and the time window is -60s, it means that E2 occurred within 60s before event E1.
[0171] For ease of understanding, reference is made to Table 2 for explanation, but the present invention is not limited thereto. Table 2 is an event expectation model table:
[0172] Table 2
[0173]
[0174]
[0175] In this embodiment, an event expectation model is constructed in advance based on the log data of the business system, and then the event expectation model is constructed based on the event association relationship, so as to facilitate the subsequent data consistency analysis and improve the efficiency of the data consistency analysis.
[0176] Reference Fig.10 , Fig.10 This is a flow chart of the third embodiment of the data consistency analysis method of the present invention. Figure 2 The first embodiment shown provides a third embodiment of the data consistency analysis method of the present invention.
[0177] In the third embodiment, the step S40 includes:
[0178] Step S401: obtaining an expected expression of expected settings from the event expectation model.
[0179] It should be understood that in order to improve the accuracy of data consistency analysis, in this embodiment, an expected expression of the expected setting is obtained from the event expectation model, the event data of the benchmark event and the event data of the expected application are filled into the expected expression to obtain the expected result, and the data consistency between the benchmark application and the expected application is analyzed based on the corresponding relationship between the expected result and the data consistency.
[0180] Step S402: Fill the event data of the benchmark event and the event data of the expected application into the expected expression to obtain an expected result.
[0181] Step S403: analyzing the data consistency between the benchmark application and the expected application according to the corresponding relationship between the expected result and the data consistency.
[0182] For ease of understanding, refer to Fig.11 This is for illustration only, but not for limitation of the present invention. Fig.11 This is a schematic diagram of the expected calculation process of an embodiment of the data consistency analysis method of the present invention. In the figure, data is grouped according to the benchmark event and the expected event, and filled into the expected expression of the expected setting, and the result of the logical expression is calculated. If the logical result is true, it means that the expectation is met, and if the result is false, it means that the expectation is not met. Then, according to the correspondence between the expected result and the data consistency, the data consistency result is calculated. The data format of the calculation result: EPT_RESULT = [{EPT_EXP: expected expression, EPT_EXP_RESULT:{"boolean":"true|false","MT|UMT":"SAME|DIFF"}, TODO:[how to process the expected result, how to process the data consistency result]},{...}].
[0183] Furthermore, in order to avoid congestion, before step S40, it also includes: reading the event expectation model to obtain a time window; accordingly, step S40 includes: when the current time satisfies the time window, analyzing the data consistency between the benchmark application and the expected application based on the event data of the benchmark event and the event data of the expected application.
[0184] It should be understood that before analyzing the data consistency between the benchmark application and the expected application based on the event data of the benchmark event and the event data of the expected application, if a time window is set, it is first determined whether the time window is met. If not, the operation is suspended (generating a scheduled task).
[0185] It can be understood that expected calculation refers to the process of calculating expected results and data consistency results based on associated events and event expectation models. It mainly includes the following functional items:
[0186] Task processing: Decompose the expected configuration of events into multiple separate task units, put them into the task queue, and process them concurrently. Multiple request data will be matched within the scanning window of the benchmark event. Each request is assigned a Task task to be processed separately, and multiple orders are calculated concurrently. Events that do not arrive in the time window are set in the scheduled task queue and delayed execution.
[0187] Event extraction: According to the definition of the benchmark application and benchmark event, it is converted into an ES query request, and the log data of the benchmark event is queried from ES. Then, combined with the expected application, expected event definition, and event association relationship, an ES query request is created to obtain the log data of the expected event from ES.
[0188] Event preprocessing: validity of event data, whether the association relationship is matched successfully (matched to the event), expected expression check and expected expression variable replacement converted into program logic expression, etc.
[0189] Expected calculation: Calculate the logical results, data consistency results and corresponding processing methods of all expected expressions in sequence.
[0190] Store expected results: store expected results, generate consistency report data, generate statistical data, etc.;
[0191] Console UI: Provides WEB services for technical personnel to manage event expectation configuration, query consistency analysis results, handle differences, view statistical data (expectation and consistency statistics), and observe the overall operation of the consistency analysis unit through the UI.
[0192] In the third embodiment, after step S40, the method further includes:
[0193] Step S50: searching for a processing method corresponding to the expected result, and searching for a processing method corresponding to the data consistency result.
[0194] It should be understood that in order to improve processing efficiency, in this embodiment, the processing method corresponding to the expected result is automatically searched, and the processing method corresponding to the data consistency result is searched, and the result processing is performed separately according to the processing method corresponding to the expected result and the processing method corresponding to the data consistency result.
[0195] Step S60: performing result processing respectively according to the processing method corresponding to the expected result and the processing method corresponding to the data consistency result.
[0196] In the specific implementation, according to the expected results (whether the expectations are met, whether the data is consistent), the processing is performed according to the preset processing method. Result processing includes the processing of expected results and the processing of data consistency results. The processing methods of expected results and data consistency results are obtained from EPT_RESULT, and they are processed separately, first processing the expected results and then processing the data consistency results. The processing methods include: 1 silent, 2 notification, 3 alarm, 4 recalculation, 5 export event, 6 trigger HTTP request, and the default is silent.
[0197] This case extracts and models log data, designs event- and expectation-based model units, and combines the existing log management system architecture to implement strong correlation logic analysis between applications in the business system designed with microservice architecture, and calculate data consistency. The present invention improves the difficulty and low efficiency of observing data consistency in the entire link of the R&D process, and improves the real-time performance of business logic and data consistency between production environment analysis applications. Specifically, it solves the following problems:
[0198] 1. The real-time performance of the end-of-day reconciliation is poor, and problems are discovered late. In this case, by designing an independent calculation model and a real-time window, the elements describing data consistency are extracted from the more real-time logs during system operation, and the consistency results of the data are determined, thus improving the problem of delayed discovery of data errors during the end-of-day reconciliation.
[0199] 2. Currently, automated testing can only verify whether the results of the interface (point) meet expectations, but lacks means to observe the business logic and data consistency of each application through which the request passes, and mainly relies on manual log and DB checking. The design of this case can improve the efficiency and correctness of testers in testing data analysis.
[0200] 3. The current monitoring management platform is basically based on logs, SQL, and interface implementation. The advantage is that it can monitor specific alarm points well, such as observing the appearance of an abnormal event sign, or the frequency and number of events that occur over a period of time, but it lacks cross-application observation on the request chain. The design of this case realizes the observation of business logic and data consistency on the cross-application call chain and enriches the alarm scenarios. This feature is not available in current monitoring platform systems.
[0201] 4. A complete business system under the microservice application architecture is designed with multiple applications, each corresponding to an independent database, which makes it difficult to check data consistency by writing SQL (authority issues, high technical costs, and increased DB pressure). This case makes full use of the advantages of business system logs, such as centralized storage, no authority issues, and analysis without increasing system overhead, to develop a solution for global observation of application status and data consistency. The design model of this case can adapt to consistency analysis between any applications, overcoming the complexity and poor versatility of the strong logic implementation solution of the reconciliation system.
[0202] In addition, refer to Fig.12 The embodiment of the present invention further provides a data consistency analysis device, the data consistency analysis device comprising:
[0203] The acquisition module 10 is used to acquire the log data of the business system, and read the event expectation model to obtain the event association relationship, where the event association relationship is the association relationship between the benchmark application and the expected application;
[0204] A query module 20, configured to query the log data according to the event association relationship to obtain event data of the benchmark application;
[0205] The query module 20 is further used to query the log data according to the event data of the benchmark application to obtain the event data of the expected application;
[0206] The analysis module 30 is used to analyze the data consistency between the reference application and the expected application according to the event data of the reference event and the event data of the expected application.
[0207] In this embodiment, the log data of the business system is obtained, and the event expectation model is read to obtain the event association relationship, where the event association relationship is the association relationship between the benchmark application and the expected application, the log data is queried according to the event association relationship to obtain the event data of the benchmark application, the log data is queried according to the event data of the benchmark application to obtain the event data of the expected application, and the data consistency between the benchmark application and the expected application is analyzed according to the event data of the benchmark event and the event data of the expected application; because the present invention extracts the elements describing the data consistency from the log data with higher real-time performance and determines the consistency result of the data, it improves the problem of untimely discovery of data errors in the end-of-day reconciliation, thereby improving the real-time performance of the data consistency analysis.
[0208] Other embodiments or specific implementations of the data consistency analysis device of the present invention can refer to the above-mentioned method embodiments and will not be described in detail here.
[0209] In addition, an embodiment of the present invention further proposes a storage medium, on which a data consistency analysis program is stored. When the data consistency analysis program is executed by a processor, the data consistency analysis method as described above is implemented.
[0210] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0211] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0212] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0213] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A data consistency analysis method, characterized in that: The data consistency analysis method comprises: Obtaining log data of the business system, and reading the event expectation model to obtain an event association relationship, where the event association relationship is an association relationship between a benchmark application and an expected application; Query the log data according to the event association relationship to obtain event data of the benchmark application; querying the log data according to the event data of the benchmark application to obtain the event data of the expected application; The data consistency between the reference application and the expected application is analyzed based on the event data of the reference event and the event data of the expected application.
2. The data consistency analysis method according to claim 1, characterized in that: The analyzing the data consistency between the reference application and the expected application according to the event data of the reference event and the event data of the expected application comprises: Obtaining an expectation expression of an expectation setting from the event expectation model; Filling the event data of the benchmark event and the event data of the expected application into the expected expression to obtain an expected result; The data consistency between the benchmark application and the expected application is analyzed according to the corresponding relationship between the expected result and the data consistency.
3. The data consistency analysis method according to claim 2, characterized in that: After analyzing the data consistency between the reference application and the expected application according to the corresponding relationship between the expected result and the data consistency, the method further includes: Find the processing method corresponding to the expected result, and find the processing method corresponding to the data consistency result; The result processing is performed respectively according to the processing method corresponding to the expected result and the processing method corresponding to the data consistency result.
4. The data consistency analysis method according to claim 1, characterized in that: Before analyzing the data consistency between the reference application and the expected application according to the event data of the reference event and the event data of the expected application, the method further includes: Read the event expectation model to obtain a time window; Accordingly, analyzing the data consistency between the reference application and the expected application according to the event data of the reference event and the event data of the expected application includes: When the current time satisfies the time window, data consistency between the reference application and the expected application is analyzed according to the event data of the reference event and the event data of the expected application.
5. The data consistency analysis method according to any one of claims 1 to 4, characterized in that: The process of obtaining the log data of the business system, reading the event expectation model, and obtaining the event association relationship also includes: Obtain log data from business systems; Calculate event association relationships in a self-learning manner based on the log data; An event anticipation model is constructed based on the event association relationship.
6. The data consistency analysis method according to claim 5, characterized in that: The self-learning calculation of event association relationships according to the log data includes: Obtaining a baseline application log and an expected application log from the log data; Grouping the benchmark application log and the expected application log according to the request ID to obtain log records of the same context; Traversing the key-value pairs in the log records, grouping them according to the values of the key-value pairs, extracting keywords with the same values, and establishing an association relationship list; Setting a corresponding association quality coefficient for the association relationship in the association relationship list, and calculating the association quality of the association relationship according to the association quality coefficient value; The association relationship list is updated according to the association quality to obtain event association relationships.
7. The data consistency analysis method according to claim 5, characterized in that: The constructing of an event anticipation model based on the event association relationship includes: Building expected configuration items based on the target attributes, where the expected configuration items include at least one of expected relationship type, expected setting, expected result, data consistency, time window, and processing method; An event expectation model is constructed according to the event association relationship and the expected configuration items.
8. A data consistency analysis device, characterized in that: The data consistency analysis device comprises: An acquisition module is used to acquire log data of a business system, and read an event expectation model to obtain an event association relationship, where the event association relationship is an association relationship between a benchmark application and an expected application; A query module, configured to query the log data according to the event association relationship to obtain event data of the benchmark application; The query module is further used to query the log data according to the event data of the benchmark application to obtain the event data of the expected application; An analysis module is used to analyze data consistency between the reference application and the expected application based on the event data of the reference event and the event data of the expected application.
9. A data consistency analysis device, characterized in that: The data consistency analysis device includes: a memory, a processor, and a data consistency analysis program stored in the memory and executable on the processor. When the data consistency analysis program is executed by the processor, the data consistency analysis method according to any one of claims 1 to 7 is implemented.
10. A storage medium, characterized in that: The storage medium stores a data consistency analysis program, and when the data consistency analysis program is executed by the processor, the data consistency analysis method according to any one of claims 1 to 7 is implemented.
