Yaml-based zero-code diagnostic rule configuration method, system, device and medium
By adopting a zero-code diagnostic rule configuration method based on YAML, the problem of high maintenance threshold for diagnostic rules in existing technologies is solved, enabling non-developers to efficiently maintain diagnostic rules and improving the flexibility and reliability of the system.
Patent Information
- Application Number
- CN202611324474.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-11-20
AI Technical Summary
Existing automotive diagnostic rule configuration methods have high maintenance barriers, making it difficult for non-developers to directly participate in the creation and modification of rules. Furthermore, traditional methods suffer from high coupling between rules and code and low update efficiency.
It adopts a zero-code diagnostic rule configuration method based on YAML. By reading the YAML rule file, parsing and generating rule objects, and performing field integrity and logical validity checks, it selects the rule objects in the enabled state for loading and matching detection, and supports hot loading and state management of rules.
It lowers the barrier to rule maintenance, improves the application flexibility and reliability of diagnostic rules, avoids system operation risks caused by configuration errors, and enables non-developers to maintain diagnostic rules efficiently.
Smart Images

Figure CN123137989A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automotive diagnostic technology, and in particular to a zero-code diagnostic rule configuration method, system, device and medium based on YAML. Background Technology
[0002] In automotive diagnostic systems, diagnostic rules are used to define how to identify problems from diagnostic logs, determine their severity, and provide solutions.
[0003] Existing diagnostic rule management methods mainly include hard-coded rules, database rules, proprietary format rules, and XML format rules. Hard-coded rules embed rules into program code, requiring recompilation and software redeployment for modification, and relying on developers for maintenance, leading to tight coupling between rules and code. Database rules store rules in a database, requiring maintenance personnel to possess specialized database knowledge, and suffer from limitations in table design and query efficiency, as well as difficulties in version control, when the rule structure is complex. Proprietary format rules and XML format rules suffer from verbose syntax, poor readability, and the need for specialized editing tools. In practical applications, diagnostic rule maintainers are typically after-sales engineers or technical support personnel who lack software programming skills.
[0004] In summary, the existing diagnostic rule configuration methods have a high maintenance threshold, making it difficult for non-developers to directly participate in the creation and modification of diagnostic rules. Summary of the Invention
[0005] Based on this, it is necessary to address the technical problems in existing technologies, such as high maintenance threshold for diagnostic rules, high coupling between rules and program code, low update efficiency due to the need to recompile the system to modify rules, and difficulty for non-developers to directly participate in rule management. Therefore, a zero-code diagnostic rule configuration method, system, device, and medium based on YAML is proposed.
[0006] Firstly, a zero-code diagnostic rule configuration method based on YAML is provided, the method comprising: Read the YAML rule files in the specified rule directory to obtain the target rule data, including metadata information and the rule body; The corresponding rule object is obtained by parsing the metadata information and the rule body, wherein the rule body includes a predefined condition type and the matching logic corresponding to the condition type; Perform field integrity and logical validity checks on the rule objects to obtain compliant rule objects that pass the checks and discard invalid rule objects that fail the checks. The compliance rule object is identified based on the persistently stored rule status information to obtain the execution rule object in the enabled state, and the execution rule object is loaded into memory. Obtain the diagnostic logs to be analyzed; based on the condition type in the rule object to be executed, call the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, output the corresponding diagnostic results based on the problem description and processing suggestions included in the rule object to be executed.
[0007] Optionally, the method further includes: maintaining a rule file index table and periodically scanning the rule directory; when a YAML rule file in the rule directory is detected to trigger a change condition, the read, verification, and loading into memory operations are re-executed only for the changed YAML rule file.
[0008] Optionally, the maintenance of the rule file index table and the periodic scanning of the rule directory, when a YAML rule file in the rule directory is detected to trigger a change condition, only the read, verification and loading into memory operations are re-executed for the changed YAML rule file. Specifically, this includes recording the file name, file path, file update time and file verification value of each YAML rule file in the rule directory through the rule file index table. During periodic scanning, the file update time and file checksum of the current file are compared with the records in the rule file index table to see if they are consistent. If they match, it is determined that the corresponding YAML rule file has not been changed, and no reload operation is performed; If there is a discrepancy, the corresponding YAML rule file is determined to have triggered a change condition, and the read, validation, and loading into memory operations are re-executed only for the YAML rule file that triggered the change condition.
[0009] Optionally, obtaining the corresponding rule object based on the metadata information and the rule body specifically includes: By parsing the metadata information, the unique identifier of the rule, the rule version number, and the publication status can be obtained; By parsing the rule body, the corresponding rule number, condition matching method, problem severity, and handling solution can be obtained; The predefined condition types are obtained according to the condition matching method. The condition types include single condition matching, combined condition matching, and nested condition matching.
[0010] Optionally, the step of performing field integrity and logical validity checks on the rule object to obtain a compliant rule object that passes the checks specifically includes: Perform a field integrity check on the rule object to determine if there are any missing required key fields. The required key fields include at least the rule number, rule name, condition definition, problem description, and processing suggestion. When the rule object does not have any missing required key fields, the field integrity check of the rule object is deemed to have passed, and a logical validity check is performed on the rule object. The logical validity check includes checking whether the severity is valid and whether the confidence level exceeds a preset range. If the rule object has missing required key fields, the field integrity check of the rule object is deemed to have failed. When both the field integrity check and the logical validity check of the rule object pass, the rule object is deemed to have passed the verification, and the compliance rule object is obtained. If the field integrity check of the rule object fails or the logical validity check fails, the rule object is deemed to have failed the validation, the rule object is discarded as an invalid rule object, and an error log is recorded.
[0011] Optionally, the step of identifying the status of the compliance rule object based on the persistently stored rule status information to obtain the execution-ready rule object in the enabled state specifically includes: Read the persistent storage rule status information from the local configuration file. The rule status information includes enabled, disabled, and draft status. Select compliance rule objects with the enabled status as the rule objects to be executed; For compliance rule objects that are in the disabled or draft state, they are masked during log diagnostic analysis and the corresponding matching logic is not executed.
[0012] Optionally, the step of invoking the corresponding matching logic based on the condition type in the rule object to be executed, and performing matching detection on the diagnostic log, specifically includes: When the condition type in the rule object to be executed includes single-condition matching, the diagnostic log is detected according to the single-condition configuration in the rule object to be executed. When the diagnostic log meets the single-condition configuration, it is determined to be a match hit. When the condition type in the rule object to be executed includes combined condition matching, the predefined logical relationship of the combined condition matching configuration is read, and the predefined logical relationship includes AND and OR relationships; when the predefined logical relationship is AND, all sub-conditions of the diagnostic log are matched and the match is determined to be successful after all sub-conditions are satisfied; when the predefined logical relationship is OR, each sub-condition of the diagnostic log is matched and the match is determined to be successful after any one sub-condition is satisfied. When the condition type in the rule object to be executed includes nested condition matching, the conditions at each level of the nested condition matching are obtained, and the diagnostic log is matched and calculated layer by layer in order from the inside out until the final matching result is obtained.
[0013] Secondly, a zero-code diagnostic rule configuration system based on YAML is provided, the system comprising: The parsing module is used to read YAML rule files in a specified rule directory to obtain target rule data including metadata information and rule body; and to parse the corresponding rule object according to the metadata information and rule body, wherein the rule body includes predefined condition types and matching logic corresponding to the condition types; The verification module is used to verify the field integrity and logical validity of the rule object, obtain compliant rule objects that pass the verification, and discard invalid rule objects that fail the verification. The loading module is used to identify the status of the compliance rule object based on the persistently stored rule status information, obtain the execution rule object in the enabled state, and load the execution rule object into memory; The diagnostic module is used to obtain diagnostic logs to be analyzed; according to the condition type in the rule object to be executed, it calls the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, it outputs the corresponding diagnostic results according to the problem description and processing suggestions included in the rule object to be executed.
[0014] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described YAML-based zero-code diagnostic rule configuration method.
[0015] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described YAML-based zero-code diagnostic rule configuration method.
[0016] Compared with existing technologies, this application avoids traditional hard-coding by reading and parsing YAML rule files in a specified rule directory to obtain rule objects that include condition types and matching logic. This allows maintenance personnel without programming skills to complete rule configuration. Subsequently, by strictly validating the field integrity and logical validity of the parsed rule objects and discarding invalid objects, rule data with abnormal format or logic is intercepted at the source, ensuring the quality of data entering the system. Finally, rule objects in the enabled state are selected based on the persistently stored rule status information and loaded into memory. Based on this, the diagnostic logs to be analyzed are matched and the results are output. This completes the closed loop from writing rules without code to the secure application of rules. While lowering the threshold for maintaining diagnostic rules, it effectively avoids system operation risks caused by configuration errors and improves the flexibility and reliability of diagnostic rule application. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] in: Figure 1 An application environment diagram of a YAML-based zero-code diagnostic rule configuration method in one embodiment; Figure 2 A flowchart illustrating a YAML-based zero-code diagnostic rule configuration method in one embodiment; Figure 3 A block diagram of a YAML-based zero-code diagnostic rule configuration system in one embodiment; Figure 4 This is a structural block diagram of a computer device in one embodiment. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] Figure 1 An exemplary system architecture is shown that can be applied to the real-time processing method or apparatus for automotive ECU data streams in this application.
[0021] Specifically, the system architecture includes: diagnostic terminal 100, cloud server 101, and target vehicle 102.
[0022] The target vehicle 102 is equipped with multiple Electronic Control Units (ECUs). When the vehicle is running normally or under after-sales inspection, each ECU of the target vehicle 102 will continuously generate and feed back ECU data streams, diagnostic response codes (such as NRC negative responses), or low-level logs in free text form according to the underlying diagnostic protocol (such as the UDS protocol).
[0023] The diagnostic terminal 100 can be a dedicated intelligent diagnostic instrument, a test laptop, or a mobile intelligent terminal used in after-sales service stores. The diagnostic terminal 100 establishes a communication connection with the target vehicle 102 via a wired interface (e.g., OBD-II, On-Board Diagnostics interface) or a wireless network (e.g., Bluetooth, Wi-Fi). During the interaction process, the diagnostic terminal 100 acts as a front-end network element for data acquisition and user interaction, used to read and collect diagnostic logs or ECU data streams generated by the target vehicle 102 in real time, and package them for uploading to the cloud server 101 via the communication network. Simultaneously, after-sales engineers or technical support personnel can use the text editor on the diagnostic terminal 100 to directly write or modify diagnostic rule files based on the built-in rule templates, and send them to the cloud server 101 for storage and updates.
[0024] The cloud server 101, serving as the central execution entity for diagnostic rule management and log analysis, can be implemented using a standalone server or a server cluster composed of multiple servers. In a specific implementation, the cloud server 101 maintains a designated rule directory. When it receives a YAML rule file uploaded or modified by the diagnostic terminal 100, the cloud server 101 reads the file by triggering a file change mechanism (hot reloading mechanism), parses it to generate a rule object in memory, and performs strict field integrity and logical validity checks. Then, the executed rule object, which passes the checks and is in an enabled state, is loaded into the analysis engine's memory. Subsequently, when the cloud server 101 receives diagnostic logs or ECU data streams uploaded by the diagnostic terminal 100, the analysis engine calls the corresponding matching logic for real-time detection based on the loaded rule object. Once a match is found, a diagnostic result including a problem description and handling suggestions is generated and sent to the diagnostic terminal 100. Finally, the diagnostic terminal 100 visualizes the diagnostic result on its display screen, guiding maintenance personnel to quickly locate the problem and take appropriate solutions.
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the application environment on which the embodiments of this application are based will be described in detail before introducing specific embodiments. The YAML-based zero-code diagnostic rule configuration method provided in the embodiments of this application can be applied to, for example... Figure 1 The application environment shown primarily includes a client and a server that communicate and interact via a network. The server, as the core system for vehicle diagnostic rule management and log analysis, is the main execution entity of the core method flow in this application embodiment. It can be implemented using a standalone server or a server cluster composed of multiple servers. The client, as a front-end network element node that directly interacts with users (such as after-sales engineers, technical support personnel, or testers) and collects vehicle data, can specifically be various personal computers, laptops, smartphones, tablets, and dedicated vehicle diagnostic equipment. In specific interactive collaboration, users can upload diagnostic logs to be analyzed via the client, or directly add and modify diagnostic rule files in YAML format via the client. The server, as the execution entity, reads the YAML rule files in the specified rule directory, parses them to obtain rule objects including condition types and matching logic, and performs strict field integrity and logical validity checks on them. Then, it loads the compliant rule objects that pass the checks and are in an enabled state into memory. Subsequently, the server obtains the diagnostic logs sent by the client, checks them according to the matching logic of the rule objects to be executed in memory, and generates a diagnostic result based on the problem description and handling suggestions included in the rule when a match is found. Finally, the diagnostic result is fed back to the client via the network for response display. Through the collaboration between the above network elements, this application optimizes the rule configuration process by utilizing the YAML format and hot loading mechanism, enabling non-technical personnel to complete the addition or adjustment of rules without modifying the program code, effectively avoiding system update interruptions caused by hard coding, and greatly improving the rule maintenance efficiency and operational reliability of the automotive diagnostic system.
[0026] Please see Figure 2 As shown, Figure 2 A flowchart illustrating a YAML-based zero-code diagnostic rule configuration method provided in this application embodiment includes the following steps: S1: Read the YAML rule file in the specified rule directory to obtain the target rule data, including metadata information and the rule body; Specifically, when starting up or performing an update, the system automatically reads the YAML rule files from the rule directory (such as general diagnostic rules, vehicle-specific rules, ECU-specific rules, or protocol-specific rule directories).
[0027] By reading the YAML file, its content is divided into two parts: metadata information and the main rules.
[0028] Diagnostic rules are defined using YAML format, which is more concise and readable than traditional hard-coded or XML formats. This allows technical support personnel or after-sales engineers to add or adjust rules without modifying the program code.
[0029] For example, after reading a YAML rule file, the metadata information is extracted, including the rule's unique identifier, rule name, creation time, update time, rule version number, publication status, default priority, and author information; at the same time, the rule body is extracted, including the specific rule number, condition matching method, problem severity, scope of impact, and handling plan. For example, the specific diagnostic conditions read are that an ECU returns a specific NRC negative response or the success rate of a command execution is lower than a set threshold.
[0030] S2: Based on the metadata information and the rule body, the corresponding rule object is obtained by parsing, wherein the rule body includes a predefined condition type and the matching logic corresponding to the condition type; Specifically, the read YAML rule content is parsed to generate the corresponding rule object.
[0031] To adapt to different diagnostic problem analysis scenarios, multiple condition types are predefined (such as NRC negative response matching, command execution status matching, timeout rate detection, success rate detection, keyword matching, vehicle model matching, and multi-condition combination matching).
[0032] Read the condition configuration in the rule body and call the corresponding matching logic according to the condition type.
[0033] By dynamically binding the parsed condition types to the underlying matching logic, the rule configuration and execution program are decoupled, and the algorithm supports AND, OR, and nested combined condition rules, which can adapt to extremely complex diagnostic scenarios.
[0034] For example, when the condition type in the rule object is NRC response matching, the corresponding matching logic is bound to it for subsequent checks to see if the corresponding response code exists in the log; when the condition type is success rate detection, the matching logic is bound to it for subsequent statistics on the success rate of command execution and to determine whether it is lower than the set threshold.
[0035] S3: Perform field integrity and logical validity checks on the rule objects to obtain compliant rule objects that pass the checks and discard invalid rule objects that fail the checks; Specifically, after generating the rule object, an integrity check is performed on the rule structure.
[0036] First, check if there are required fields such as rule number, rule name, condition definition, problem description, and handling suggestions; second, check the logic validity, including whether the severity is valid, whether the confidence level is out of range, whether the condition structure is correct, and whether the configuration format is abnormal.
[0037] By automatically checking the integrity of the rule structure and the parameter format, problems caused by human configuration errors can be effectively reduced, and erroneous rules can be prevented from affecting the normal operation of the entire system.
[0038] For example, when loading rules, if a rule object is found to be missing a problem description or handling suggestion field, or if its configured severity is found to be invalid or its confidence level is found to be out of range, the current rule will be considered invalid and discarded. At the same time, an error log will be recorded and the loading of the current rule will be skipped.
[0039] S4: Based on the persistently stored rule status information, identify the status of the compliance rule object, obtain the execution rule object in the enabled state, and load the execution rule object into memory; Specifically, it reads the status information saved in the local configuration file, where each rule corresponds to an independent status (including enabled, disabled, and draft status). It then performs status identification and loads only the rules in the enabled state into memory. When a rule is disabled or in draft mode, the corresponding rule will not be executed during log analysis.
[0040] The introduction of a state management mechanism facilitates the testing and maintenance of rules. The persistent storage of state information ensures that the previous rule state can be retained after the system restarts, reducing the impact of rule adjustments on online analysis results.
[0041] For example, when a newly configured diagnostic rule generates a large number of false alarms during actual operation, engineers can temporarily change the rule's status to disabled. During status identification, the rule will be read as disabled. After being masked, it will be re-marked as enabled and loaded after engineers have completed the subsequent adjustments and verifications.
[0042] S5: Obtain the diagnostic logs to be analyzed; according to the condition type in the rule object to be executed, call the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, output the corresponding diagnostic results according to the problem description and processing suggestions included in the rule object to be executed.
[0043] Specifically, the diagnostic logs to be analyzed are input into the pre-loaded rule object to be executed in memory. The detection is performed based on the matching logic bound in step S2 to determine whether the log hits the condition threshold set by the corresponding rule; once it does, the text information configured in the rule is extracted to generate the final diagnostic result output.
[0044] For example, when analyzing logs, the matching logic is invoked to find logs that meet conditions such as an ECU returning a specific NRC negative response, a command execution success rate being lower than a set threshold, or a vehicle model frequently experiencing communication timeouts, thus determining that a rule has been matched. Subsequently, the system extracts the problem description, cause analysis, handling suggestions, and solution information defined in the rule, integrates and outputs diagnostic results, and provides the after-sales team with intuitive troubleshooting guidance.
[0045] In this embodiment, technical support personnel, testers, or after-sales engineers can add or adjust rules by writing intuitive YAML files without having programming skills or modifying program code. This completely decouples diagnostic rules from the underlying code, lowers the threshold for rule maintenance, and achieves true zero-code rule management. At the same time, the closed-loop parsing, verification, and application mechanism ensures the efficient and stable operation of the diagnostic system.
[0046] In some embodiments, the method further includes: maintaining a rule file index table and periodically scanning the rule directory; when a YAML rule file in the rule directory is detected to trigger a change condition, only the read, verification, and loading into memory operations are re-executed on the changed YAML rule file, so as to achieve incremental hot updates of diagnostic rules without restarting the system.
[0047] Specifically, the rule file index table records the file name, file path, file update time, and file checksum of each YAML rule file in the rule directory. During periodic scanning, the file update time and file checksum of the current file are compared with the records in the rule file index table. If they match, it is determined that the corresponding YAML rule file has not been changed, and no reload operation is performed. If they do not match, it is determined that the corresponding YAML rule file has triggered a change condition, and the read, checksum, and load into memory operations are only re-executed for the YAML rule file that has triggered the change condition.
[0048] Traditional rule systems typically require a service restart after rule modifications; in real-world projects, this restart process can disrupt normal analysis tasks, especially with a large number of rules. Therefore, this application supports a hot-loading mechanism for rules, continuously monitoring changes to rule files in the rule directory (e.g., adding, modifying, or deleting rule files). The rule directory is periodically scanned, and rule changes are detected when file update times or checksums change.
[0049] To avoid frequent loading, you can also add update interval control, such as reloading only when the file's last modification time changes.
[0050] Incremental updates reduce the overhead of rule reloading. When a rule change is detected, the corresponding rule is automatically reloaded. The entire process does not require a system restart, reducing downtime during system maintenance.
[0051] In some embodiments, obtaining the corresponding rule object by parsing the metadata information and the rule body specifically includes: obtaining the rule's unique identifier, rule version number, and release status by parsing the metadata information; obtaining the corresponding rule number, condition matching method, problem severity, and handling solution by parsing the rule body; and obtaining a predefined condition type based on the condition matching method, wherein the condition type includes single condition matching, combined condition matching, and nested condition matching.
[0052] In actual operation, diagnostic rules come from a wide range of sources, including the experience of technical experts, feedback from after-sales service teams, analysis results of user complaints, and adaptation requirements for new vehicle models and new ECUs. After system startup, it automatically reads the YAML rule files in the rule directory. Rule files can be stored according to different categories, such as: general diagnostic rules, vehicle-specific rules, ECU-specific rules, and protocol-specific rules. The metadata information mainly describes the source of the rules and includes at least: a unique rule identifier (to ensure that rules in the rule base are not duplicated), rule name, creation time, update time, rule version number (to support rule upgrades and rollback management), publication status, default priority, and author information.
[0053] The classification and identification of rule files is achieved through a combination of two methods: one is based on the directory structure, where rule files are stored in different subdirectories according to their type. For example, rules / general / contains general rules applicable to all vehicle models, while rules / vehicle / contains vehicle-specific rules. The system can identify the classification based on the file's path when scanning the directory. The other method is to explicitly declare the classification through the category field in the metadata information of the YAML file. In practical applications, the metadata field has higher priority than the directory structure, thus allowing for flexible adjustment of rule classifications without modifying the underlying directory structure.
[0054] When parsing a specific rule file, the file content is first read into an in-memory dictionary structure (such as a Python dictionary) using a YAML parsing library. Then, according to the predefined field mapping relationship, the key-value pairs in the dictionary are assigned one by one to the corresponding attributes of the generated rule object (Rule object). For example, the id field in YAML is mapped to the rule_id attribute of the rule object.
[0055] In the underlying parsing process, after the YAML rule file is read, it is parsed using a standard Python YAML parsing library (such as PyYAML). The initial output is a nested dictionary and list structure. Building upon this, a set of entity classes is further encapsulated for object-oriented mapping. Specifically, the RuleConfig entity class is used as the top-level container, which includes fields such as metadata (metadata dictionary), conditions (a list of conditions, where each element is instantiated as a Condition object), problem_desc (problem description string), and solution (solution). Subsequent diagnostic analysis programs, when executing scheduling calls, directly access the specific rule content through the attributes of these entity objects, without needing to repeatedly parse the YAML file.
[0056] Metadata information is mainly used to describe the source of rules and includes at least: unique rule identifier (to ensure that rules in the rule base are not duplicated), rule name, creation time, update time, rule version number (to support rule upgrade and rollback management), publication status, default priority, and author information.
[0057] To adapt to different diagnostic problem analysis scenarios, this application supports more than 20 condition types, such as: NRC negative response matching, command execution status matching, timeout rate detection, success rate detection, keyword matching, vehicle model matching, and multi-condition combination matching. Specific conditions defined in the rule body include, for example: an ECU returns a specific NRC negative response; the success rate of a command execution is lower than a set threshold; a vehicle model frequently experiences communication timeouts; and specified keywords exist in the logs.
[0058] This application establishes a standardized rule structure specification. The YAML syntax is concise and highly readable. Technical support personnel or after-sales engineers do not need to modify the program logic. They can simply add rule files according to the specification to complete the extension. This not only facilitates version management and historical tracking, but also reduces the coupling between different modules.
[0059] In some embodiments, the step of performing field integrity and logical validity checks on the rule object to obtain compliant rule objects that pass the checks and discarding invalid rule objects that fail the checks specifically includes: performing a field integrity check on the rule object to determine whether the rule object has any missing required key fields, wherein the required key fields include at least rule number, rule name, condition definition, problem description, and processing suggestion; when the rule object does not have any missing required key fields, the field integrity check of the rule object is determined to have passed, and the rule object is further subjected to a logical validity check, wherein the logical validity check includes checking whether the severity is legal and whether the confidence level exceeds a preset range; when the rule object has any missing required key fields, the field integrity check of the rule object is determined to have failed; when both the field integrity check and the logical validity check of the rule object pass, the rule object is determined to have passed the checks, and the compliant rule object is obtained; when either the field integrity check or the logical validity check of the rule object fails, the rule object is determined to have failed the checks, the rule object is discarded as an invalid rule object, and an error log is recorded.
[0060] Since YAML files are manually written, an automatic integrity check is performed on the rule structure after parsing and generating the rule object. In addition to the required fields mentioned above, the check also verifies the correctness of the condition structure and the absence of any abnormal configuration formats. If any key fields are missing or other issues are found in the rule, it is considered invalid, an error log is logged, and the loading of the current rule is skipped.
[0061] Automatically checking for missing required fields, incorrect parameter formats, and valid severity levels during loading can prevent erroneous rules from affecting the entire system's operation and reduce problems caused by configuration errors.
[0062] In some embodiments, the step of identifying the status of the compliance rule objects based on the persistently stored rule status information to obtain the execution rule objects in the enabled state specifically includes: reading the persistently stored rule status information from the local configuration file, wherein the rule status information includes enabled state, disabled state, and draft state; filtering out the compliance rule objects with the enabled state as the execution rule objects; and masking the compliance rule objects with the disabled state or draft state during the log diagnostic analysis process, and not executing the corresponding matching logic.
[0063] To facilitate rule testing and maintenance, the system supports rule enabling and disabling management. Status information is saved to a local configuration file, and the previous rule state is retained after a system restart. For example, if a rule receives many false alarms, engineers can temporarily disable it and re-enable it after rule adjustments and verification.
[0064] This application supports persistent storage of the enabled / disabled status of rules, which can temporarily block unstable rules without deleting them, reducing the impact of rule adjustments on online analysis results.
[0065] In some embodiments, the step of calling the corresponding matching logic according to the condition type in the rule object to be executed to perform matching detection on the diagnostic log specifically includes: when the condition type in the rule object to be executed includes single-condition matching, detecting the diagnostic log according to the single-condition configuration in the rule object to be executed, and determining that the diagnostic log is a match when the single-condition configuration is met; when the condition type in the rule object to be executed includes combined-condition matching, reading the predefined logical relationship of the combined-condition matching configuration, the predefined logical relationship including AND and OR relationships; when the predefined logical relationship is AND, performing matching detection on all sub-conditions of the diagnostic log, and determining that the match is met after all sub-conditions are met; when the predefined logical relationship is OR, performing matching detection on each sub-condition of the diagnostic log, and determining that the match is met after any sub-condition is met; when the condition type in the rule object to be executed includes nested-condition matching, obtaining each level of the nested-condition matching, and performing matching calculation on the diagnostic log layer by layer in order from the inside out until the final matching result is obtained.
[0066] In practical analysis, a single condition is often insufficient to accurately locate the fault. By supporting multi-condition combination matching, complex algorithm rules are implemented. For example, it can be configured to satisfy multiple conditions simultaneously to implement the AND algorithm rule; or configured to satisfy any one of multiple conditions to implement the OR algorithm rule; and it also supports nested combination of conditions.
[0067] At the underlying implementation level, condition definition fields (such as the `conditions` field) in the YAML file are recursively constructed into a condition object tree during parsing. Nested conditions correspond to the inner nodes of the condition object tree, while specific basic matching conditions correspond to the leaf nodes of the condition object tree.
[0068] Using this object tree structure, calculations are performed according to predefined logical relationships: when configured as an AND relationship, multiple conditions must be met simultaneously, meaning the rule is matched only if all sub-conditions are satisfied; when configured as an OR relationship, any one of the multiple conditions must be met, meaning the rule is matched if any sub-condition is satisfied; for nested conditions, matching and calculation are performed layer by layer from leaf nodes to internal nodes (i.e., from inside to outside), ultimately obtaining the rule matching result. The parsed and constructed final rule object will be registered in the system's global rule manager for unified scheduling and execution by the diagnostic analysis module.
[0069] This application, through flexible analytical calculation of combined and nested conditions, can accurately adapt to more complex diagnostic scenarios, thereby improving the coverage and accuracy of fault analysis.
[0070] In some embodiments, the method further includes: pre-setting multiple commonly used rule templates, and after receiving a modification configuration operation based on the commonly used rule templates, generating a corresponding YAML rule file and saving it to the rule directory.
[0071] The maintainers of these rule templates are often technical support personnel and after-sales engineers, rather than software developers. To further lower the barrier to rule writing, several commonly used rule templates are built-in, such as: NRC error rule template, ECU no-response rule template, communication failure rule template, timeout detection rule template, and success rate anomaly rule template. When engineers create new rules, they only need to make simple modifications based on existing templates (such as changing the command number, NRC response code, problem description, and handling suggestions) to complete the rule writing, without having to write a complete rule from scratch.
[0072] Please see Figure 3 As shown, in one embodiment, a zero-code diagnostic rule configuration system based on YAML is provided, the system comprising: The parsing module 201 is used to read YAML rule files in a specified rule directory to obtain target rule data including metadata information and rule body; and to parse the corresponding rule object according to the metadata information and rule body, wherein the rule body includes predefined condition types and matching logic corresponding to the condition types; The verification module 202 is used to verify the field integrity and logical validity of the rule object, obtain compliant rule objects that pass the verification, and discard invalid rule objects that fail the verification. The loading module 203 is used to identify the status of the compliance rule object based on the persistently stored rule status information, obtain the execution rule object in the enabled state, and load the execution rule object into memory; The diagnostic module 204 is used to obtain the diagnostic logs to be analyzed; according to the condition type in the rule object to be executed, it calls the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, it outputs the corresponding diagnostic results according to the problem description and processing suggestions included in the rule object to be executed.
[0073] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When executed by the processor, the computer program implements the functions or steps of a YAML-based zero-code diagnostic rule configuration method.
[0074] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, performs the following steps: Read the YAML rule files in the specified rule directory to obtain the target rule data, including metadata information and the rule body; The corresponding rule object is obtained by parsing the metadata information and the rule body, wherein the rule body includes a predefined condition type and the matching logic corresponding to the condition type; Perform field integrity and logical validity checks on the rule objects to obtain compliant rule objects that pass the checks and discard invalid rule objects that fail the checks. The compliance rule object is identified based on the persistently stored rule status information to obtain the execution rule object in the enabled state, and the execution rule object is loaded into memory. Obtain the diagnostic logs to be analyzed; based on the condition type in the rule object to be executed, call the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, output the corresponding diagnostic results based on the problem description and processing suggestions included in the rule object to be executed.
[0075] This application avoids traditional hard-coding by reading and parsing YAML rule files from a specified rule directory to obtain rule objects that include condition types and matching logic. This allows maintenance personnel without programming skills to complete rule configuration. Subsequently, by strictly validating the field integrity and logical validity of the parsed rule objects and discarding invalid objects, rule data with abnormal format or logic is intercepted at the source, ensuring the quality of data entering the system. Finally, based on the rule status information stored in persistent storage, rule objects in the enabled state are selected and loaded into memory. Based on this, matching and testing of the diagnostic logs to be analyzed are performed, and the results are output. This completes the closed loop from writing rules without code to the secure application of rules. While lowering the threshold for maintaining diagnostic rules, it effectively avoids system operation risks caused by configuration errors and improves the flexibility and reliability of diagnostic rule application.
[0076] In one embodiment, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, performs the following steps: Read the YAML rule files in the specified rule directory to obtain the target rule data, including metadata information and the rule body; The corresponding rule object is obtained by parsing the metadata information and the rule body, wherein the rule body includes a predefined condition type and the matching logic corresponding to the condition type; Perform field integrity and logical validity checks on the rule objects to obtain compliant rule objects that pass the checks and discard invalid rule objects that fail the checks. The compliance rule object is identified based on the persistently stored rule status information to obtain the execution rule object in the enabled state, and the execution rule object is loaded into memory. Obtain the diagnostic logs to be analyzed; based on the condition type in the rule object to be executed, call the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, output the corresponding diagnostic results based on the problem description and processing suggestions included in the rule object to be executed.
[0077] This application avoids traditional hard-coding by reading and parsing YAML rule files from a specified rule directory to obtain rule objects that include condition types and matching logic. This allows maintenance personnel without programming skills to complete rule configuration. Subsequently, by strictly validating the field integrity and logical validity of the parsed rule objects and discarding invalid objects, rule data with abnormal format or logic is intercepted at the source, ensuring the quality of data entering the system. Finally, based on the rule status information stored in persistent storage, rule objects in the enabled state are selected and loaded into memory. Based on this, matching and testing of the diagnostic logs to be analyzed are performed, and the results are output. This completes the closed loop from writing rules without code to the secure application of rules. While lowering the threshold for maintaining diagnostic rules, it effectively avoids system operation risks caused by configuration errors and improves the flexibility and reliability of diagnostic rule application.
[0078] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0079] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0080] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0081] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A zero-code diagnostic rule configuration method based on YAML, characterized in that, The method includes: Read the YAML rule file in the specified rule directory to obtain the target rule data, including metadata information and the rule body; The corresponding rule object is obtained by parsing the metadata information and the rule body, wherein the rule body includes a predefined condition type and the matching logic corresponding to the condition type; Perform field integrity and logical validity checks on the rule objects, and designate rule objects that pass the checks as compliant rule objects and discard invalid rule objects that fail the checks. The compliance rule object is identified based on the persistently stored rule status information to obtain the execution rule object in the enabled state, and the execution rule object is loaded into memory. Obtain the diagnostic logs to be analyzed; based on the condition type in the rule object to be executed, call the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, output the corresponding diagnostic results based on the problem description and processing suggestions included in the rule object to be executed.
2. The zero-code diagnostic rule configuration method based on YAML according to claim 1, characterized in that, The method further includes: Maintain a rule file index table and periodically scan the rule directory; when a YAML rule file in the rule directory is detected to trigger a change condition, only the read, verify, and load-to-memory operations are re-executed on the changed YAML rule file.
3. The zero-code diagnostic rule configuration method based on YAML according to claim 2, characterized in that, The maintenance of the rule file index table and periodic scanning of the rule directory, when a YAML rule file in the rule directory is detected to have triggered a change condition, only the changed YAML rule file is re-executed for the read, verification, and loading into memory operations, specifically including: The rule file index table records the file name, file path, file update time, and file checksum of each YAML rule file in the rule directory; During periodic scanning, the file update time and file checksum of the current file are compared with the records in the rule file index table to see if they are consistent. If they match, it is determined that the corresponding YAML rule file has not been changed, and no reload operation is performed; If there is a discrepancy, the corresponding YAML rule file is determined to have triggered a change condition, and the read, validation, and loading into memory operations are re-executed only for the YAML rule file that triggered the change condition.
4. The zero-code diagnostic rule configuration method based on YAML according to claim 1, characterized in that, The step of parsing the corresponding rule object based on the metadata information and the rule body specifically includes: By parsing the metadata information, the unique identifier of the rule, the rule version number, and the publication status can be obtained; By parsing the rule body, the corresponding rule number, condition matching method, problem severity, and handling solution can be obtained; The predefined condition types are obtained according to the condition matching method. The condition types include single condition matching, combined condition matching, and nested condition matching.
5. The zero-code diagnostic rule configuration method based on YAML according to claim 1, characterized in that, The step of performing field integrity and logical validity checks on the rule object to obtain a compliant rule object that passes the checks specifically includes: Perform a field integrity check on the rule object to determine if there are any missing required key fields. The required key fields include at least the rule number, rule name, condition definition, problem description, and processing suggestion. When the rule object does not have any missing required key fields, the field integrity check of the rule object is deemed to have passed, and a logical validity check is performed on the rule object. The logical validity check includes checking whether the severity is valid and whether the confidence level exceeds a preset range. If the rule object has missing required key fields, the field integrity check of the rule object is deemed to have failed. When both the field integrity check and the logical validity check of the rule object pass, the rule object is deemed to have passed the verification, and the compliance rule object is obtained. If the field integrity check of the rule object fails or the logical validity check fails, the rule object is deemed to have failed the validation, the rule object is discarded as an invalid rule object, and an error log is recorded.
6. The zero-code diagnostic rule configuration method based on YAML according to claim 1, characterized in that, The step of identifying the status of the compliance rule object based on the persistently stored rule status information to obtain the execution-ready rule object in the enabled state specifically includes: Read the persistent storage rule status information from the local configuration file. The rule status information includes enabled, disabled, and draft status. Select compliance rule objects with the enabled status as the rule objects to be executed; For compliance rule objects that are in the disabled or draft state, they are masked during log diagnostic analysis and the corresponding matching logic is not executed.
7. The zero-code diagnostic rule configuration method based on YAML according to claim 1, characterized in that, The step of invoking the corresponding matching logic based on the condition type in the rule object to be executed, and performing matching detection on the diagnostic log, specifically includes: When the condition type in the rule object to be executed includes single-condition matching, the diagnostic log is detected according to the single-condition configuration in the rule object to be executed. When the diagnostic log meets the single-condition configuration, it is determined to be a match hit. When the condition type in the rule object to be executed includes combined condition matching, the predefined logical relationship configured for the combined condition matching is read, and the predefined logical relationship includes AND and OR relationships; When the predefined logical relationship is an AND relationship, the diagnostic log is subjected to matching detection of all sub-conditions, and is determined to be a match hit after all sub-conditions are satisfied; When the predefined logical relationship is an OR relationship, the diagnostic log is subjected to matching detection of each sub-condition, and is determined to be a match hit after any sub-condition is met; When the condition type in the rule object to be executed includes nested condition matching, obtain the conditions at each level of the nested condition matching; The diagnostic logs are matched and calculated layer by layer from the inside out until the final matching result is obtained.
8. A zero-code diagnostic rule configuration system based on YAML, characterized in that, The system includes: The parsing module is used to read YAML rule files in a specified rule directory to obtain target rule data including metadata information and rule body; and to parse the corresponding rule object according to the metadata information and rule body, wherein the rule body includes predefined condition types and matching logic corresponding to the condition types; The verification module is used to verify the field integrity and logical validity of the rule object, obtain compliant rule objects that pass the verification, and discard invalid rule objects that fail the verification. The loading module is used to identify the status of the compliance rule object based on the persistently stored rule status information, obtain the execution rule object in the enabled state, and load the execution rule object into memory; The diagnostic module is used to obtain diagnostic logs to be analyzed; according to the condition type in the rule object to be executed, it calls the corresponding matching logic to perform matching detection on the diagnostic logs; when a match is found, it outputs the corresponding diagnostic results according to the problem description and processing suggestions included in the rule object to be executed.
9. A computer device, characterized in that, The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the YAML-based zero-code diagnostic rule configuration method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the YAML-based zero-code diagnostic rule configuration method as described in any one of claims 1 to 7.
