Alarm notification methods, devices, equipment and storage media
By configuring event templates, dynamic rule engines, and task state machines, the structure and notification strategies of the alarm system are decoupled, solving the problems of fixed event models and single notification strategies in existing technologies, and realizing flexible adaptation and efficient notification of the alarm system.
Patent Information
- Application Number
- CN202611219263.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-12
- Publication Date
- 2026-11-10
Smart Images

Figure CN123074906A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information processing technology, and in particular to an alarm notification method, apparatus, device and storage medium. Background Technology
[0002] With the rapid development of IoT, cloud computing, and big data technologies, enterprise-level information systems need to monitor the operational status of massive amounts of devices, services, and business metrics in real time, and promptly notify operations and maintenance personnel to handle any anomalies. As a key component of the operations and maintenance system, the alarm notification system typically includes functions such as: collecting monitoring data, determining whether alarm conditions have been triggered, and sending alarm information to relevant personnel via SMS, email, instant messaging tools, and other channels.
[0003] Current methods for managing hormones typically involve periodically collecting device data using monitoring probes, writing the data to a time-series database or message queue, and then having an alarm engine determine whether to trigger an alarm based on hard-coded threshold conditions, sending notifications through fixed channels. However, these methods suffer from rigid event models, limited rule expression capabilities, and simplistic notification strategies.
[0004] Therefore, how to enable alarm systems to adapt to new alarm event types without relying on changes in hard-coded logic is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0005] This application provides an alarm notification method, apparatus, device, and storage medium to address the problem of how to enable an alarm system to adapt to new alarm event types without relying on changes in hard-coded logic.
[0006] In a first aspect, embodiments of this application provide an alarm notification method, including:
[0007] Receive alarm event messages and parse them to obtain the event template code of the alarm event messages;
[0008] The corresponding event template and field parameters are obtained according to the event template code, and each field in the alarm event message is verified according to the field parameters.
[0009] Obtain the alarm policy associated with the event template encoding, map the fields in the alarm event message to a script execution context according to the field parameters, run the filtering rules of the alarm policy as a dynamic script in the context, and determine whether the alarm event hits the alarm policy.
[0010] When the alarm event matches the alarm policy, a notification task is generated according to the notification rules associated with the alarm policy;
[0011] The notification task is scheduled, and the notification channel is determined and the notification is sent through the notification template associated with the notification task.
[0012] In one possible implementation, the step of obtaining the corresponding event template and field parameters according to the event template encoding and validating each field in the alarm event message according to the field parameters includes:
[0013] Check whether the alarm event message contains the value corresponding to the field code; if it does not exist, the verification fails.
[0014] The validation will fail if the value type matches the field type in the field parameter.
[0015] When the field parameter contains a regular expression, the value is validated using regular expression matching; if no match is found, the validation fails.
[0016] If any of the above checks fails, the alarm event message is discarded.
[0017] In one possible implementation, the step of mapping fields in the alarm event message to a script execution context based on the field parameters, and running the filtering rules of the alarm policy as a dynamic script in the context, includes:
[0018] Construct a binding variable context by using the field codes of each field as variable names and the field values as variable values;
[0019] The filtering rules are compiled into an executable script and run in the context of the bound variables.
[0020] In one possible implementation, the notification rule is any one of the following: direct notification type, cumulative notification type, interval notification type, and interval cumulative notification type;
[0021] The notification task has a state, which transitions between a no-notification state, a notifyable state, a notified state, and a task-completed state. Different notification rule types correspond to different state transition paths.
[0022] In one possible implementation, the cumulative notification type includes cumulatively counting notification tasks that are currently in an unnotified state under the alarm policy, and updating the status of the notification task to a notifyable state when the cumulative count reaches a cumulative count threshold.
[0023] In the interval notification type, the notification task is managed within the configured notification interval duration, and when the notification task times out, the status of the notification task is set to task completion status.
[0024] In the interval cumulative notification type, the window cumulative count is performed within the configured cumulative time window, and a notification is triggered when the window cumulative count threshold is reached. If the window cumulative count has not reached the window cumulative count threshold when the cumulative time window ends, the count is reset and the next window is entered.
[0025] In one possible implementation, scheduling the notification task includes:
[0026] The query identifies notification tasks that are in a notification-ready state, sorts them by alarm level from highest to lowest, and submits them to the thread pool for asynchronous execution.
[0027] In one possible implementation, determining the notification channel and sending the notification through the notification template associated with the notification task includes:
[0028] Obtain the notification template associated with the notification task, wherein the notification template contains a notification type;
[0029] Select the corresponding notification handler based on the notification type;
[0030] After rendering the field values in the alarm event message according to the configuration of the notification template, it is sent through the notification processor.
[0031] Secondly, embodiments of this application provide an alarm notification device, including:
[0032] The receiving module is used to receive alarm event messages and parse them to obtain the event template encoding of the alarm event messages;
[0033] The verification module is used to obtain the corresponding event template and field parameters according to the event template encoding, and to verify each field in the alarm event message according to the field parameters.
[0034] The acquisition and determination module is used to acquire the alarm policy associated with the event template code, map the fields in the alarm event message to a script execution context according to the field parameters, run the filtering rules of the alarm policy as a dynamic script in the context, and determine whether the alarm event hits the alarm policy.
[0035] The generation module is used to generate a notification task according to the notification rules associated with the alarm policy when the alarm event matches the alarm policy.
[0036] The scheduling and notification module is used to schedule the notification task and determine the notification channel to send the notification through the notification template associated with the notification task.
[0037] In one possible implementation, the verification module specifically includes:
[0038] Check whether the alarm event message contains the value corresponding to the field code; if it does not exist, the verification fails.
[0039] The validation will fail if the value type matches the field type in the field parameter.
[0040] When the field parameter contains a regular expression, the value is validated using regular expression matching; if no match is found, the validation fails.
[0041] If any of the above checks fails, the alarm event message is discarded.
[0042] In one possible implementation, the acquisition and determination module specifically includes:
[0043] Construct a binding variable context by using the field codes of each field as variable names and the field values as variable values;
[0044] The filtering rules are compiled into an executable script and run in the context of the bound variables.
[0045] In one possible implementation, the notification rule is any one of the following: direct notification type, cumulative notification type, interval notification type, and interval cumulative notification type;
[0046] The notification task has a state, which transitions between a no-notification state, a notifyable state, a notified state, and a task-completed state. Different notification rule types correspond to different state transition paths.
[0047] In one possible implementation, the cumulative notification type includes cumulatively counting notification tasks that are currently in an unnotified state under the alarm policy, and updating the status of the notification task to a notifyable state when the cumulative count reaches a cumulative count threshold.
[0048] In the interval notification type, the notification task is managed within the configured notification interval duration, and when the notification task times out, the status of the notification task is set to task completion status.
[0049] In the interval cumulative notification type, the window cumulative count is performed within the configured cumulative time window, and a notification is triggered when the window cumulative count threshold is reached. If the window cumulative count has not reached the window cumulative count threshold when the cumulative time window ends, the count is reset and the next window is entered.
[0050] In one possible implementation, the scheduling notification module is specifically used for:
[0051] The query identifies notification tasks that are in a notification-ready state, sorts them by alarm level from highest to lowest, and submits them to the thread pool for asynchronous execution.
[0052] In one possible implementation, the scheduling notification module is further specifically used for:
[0053] Obtain the notification template associated with the notification task, wherein the notification template contains a notification type;
[0054] Select the corresponding notification handler based on the notification type;
[0055] After rendering the field values in the alarm event message according to the configuration of the notification template, it is sent through the notification processor.
[0056] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0057] The memory stores computer-executed instructions;
[0058] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0059] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0060] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0061] The alarm notification method, apparatus, device, and storage medium provided in this application receive alarm event messages and parse them to obtain the event template code of the alarm event messages. Based on the event template code, the corresponding event template and field parameters are obtained, and each field in the alarm event message is validated according to the field parameters. An alarm policy associated with the event template code is obtained. Based on the field parameters, the fields in the alarm event message are mapped to a script execution context. The filtering rules of the alarm policy are run as a dynamic script in the context to determine whether the alarm event matches the alarm policy. When the alarm event matches the alarm policy, a notification task is generated according to the notification rules associated with the alarm policy, the notification task is scheduled, and the notification channel is determined by the notification template associated with the notification task to send the notification. The above method, through the coordinated operation of event template configuration, dynamic script rules, and task scheduling mechanism, achieves end-to-end configurable processing of alarm events from access to notification. This allows new alarm types to be adapted without modifying the source code. Simultaneously, dynamic rule execution, multiple convergence strategies, and priority scheduling ensure the flexibility of rule expression, the accuracy and controllability of notifications, and the timely delivery of high-priority alarms. Attached Figure Description
[0062] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0063] Figure 1 Flowchart of the alarm notification method provided in this application Figure 1 ;
[0064] Figure 2 Flowchart of the alarm notification method provided in this application Figure 2 ;
[0065] Figure 3 Flowchart of the alarm notification method provided in this application Figure 3 ;
[0066] Figure 4 Flowchart of the alarm notification method provided in this application Figure 4 ;
[0067] Figure 5 A schematic diagram of the alarm notification device provided in this application;
[0068] Figure 6 A schematic diagram of the structure of the electronic device provided in this application.
[0069] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0070] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0071] With the rapid development of IoT, cloud computing, and big data technologies, enterprise-level information systems need to monitor the operational status of massive amounts of devices, services, and business metrics in real time, and promptly notify operations and maintenance personnel to handle anomalies. As a key component of the operations and maintenance system, the alarm notification system typically includes functions such as collecting monitoring data, determining whether alarm conditions are triggered, and sending alarm information to relevant personnel via SMS, email, instant messaging tools, etc. Existing methods usually involve periodically collecting device data through monitoring probes, writing the data to a time-series database or message queue, and having the alarm engine determine whether an alarm is triggered based on hard-coded threshold conditions, then sending notifications through fixed channels. However, the above methods suffer from rigid event models, limited rule expression capabilities, and simplistic notification strategies. Therefore, how to enable alarm systems to adapt to new alarm event types without relying on changes in hard-coded logic is a pressing technical problem that needs to be solved in this field.
[0072] To address the aforementioned issues, this application provides an alarm notification method, apparatus, device, and storage medium, resolving core problems in existing technologies such as fixed event models, limited rule expression, and simplistic notification strategies. Specifically, monitoring probes periodically collect device data, which is then written to a time-series database or message queue. An alarm engine determines whether to trigger an alarm based on hard-coded threshold conditions and sends a notification through a fixed channel (such as SMS or a communication robot). However, this method suffers from fixed event models, limited rule expression capabilities, and a simplistic notification strategy. Introducing a visual configuration interface allows users to define alarm conditions and notification actions using graphical tools. Typical examples include open-source tools and some commercial platforms. However, its limitations include poor event model scalability, insufficient rule flexibility, and a lack of hierarchical management of notification strategies. Considering the above problems, the inventors investigated whether the flexibility, scalability, and intelligent management of the alarm system could be achieved through the collaborative design of configurable event templates, dynamic rule engines, and multi-type notification strategies. Specifically, the structure, rule logic, and notification strategies of alarm events are decoupled from the code. Flexible definition and real-time adjustment of business rules are achieved through database configuration and dynamic script execution. At the same time, task state machines and priority queues are introduced to optimize notification scheduling, thereby solving the core problems of rigid event models, limited rule expression, and single notification strategies in existing technologies.
[0073] The alarm notification method provided in this application embodiment is mainly used in an alarm system, which consists of the following modules:
[0074] (1) Event access module: responsible for receiving original alarm messages from message channels such as MQTT, and parsing out the event number, event template code, event occurrence time, site identifier and event message body.
[0075] (2) Event Template Management Module: Responsible for maintaining event templates and field parameters, and providing metadata for event validation and rule filtering.
[0076] (3) Alarm policy management module: responsible for maintaining alarm policies. Each policy is associated with an event template, a set of filtering rules, a set of notification rules and several notification templates.
[0077] (4) Rule Engine Module: Responsible for dynamically compiling the filtering rules into dynamic scripts and executing them to determine whether the event hits the policy.
[0078] (5) Notification Task Management Module: Responsible for generating and updating notification tasks according to notification rules and maintaining the task state machine.
[0079] (6) Notification scheduling module: responsible for scanning notifiable tasks and submitting them to the thread pool for execution according to priority.
[0080] (7) Notification Channel Module: Responsible for selecting the corresponding notification handler according to the notification type, rendering the notification content and calling the third-party interface to send the notification.
[0081] (8) Notification Log Module: Responsible for recording the content, result and reason for failure of each notification attempt, and supporting retrying upon failure.
[0082] (9) Data cleaning module: responsible for cleaning up expired events, notification tasks and notification logs according to the configured cycle, and controlling storage costs.
[0083] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0084] Figure 1 Flowchart of the alarm notification method provided in this application Figure 1 ,like Figure 1 As shown, the method specifically includes:
[0085] S101: Receive alarm event messages and parse them to obtain the event template code of the alarm event messages.
[0086] This step receives the original alarm event from the message channel, extracts the core identifier for subsequent process routing and configuration query, and encodes the event template to associate the alarm event with the system configuration.
[0087] Specifically, the system receives fault alarm messages pushed by each station by listening to the MQTT message channel. Taking a battery swapping station as an example, it listens for fault alarm messages pushed by the MQTT of each station, parses out the station identifier SSN code, deserializes the message body, and extracts key information.
[0088] The following information was extracted from the original alarm message:
[0089] Event ID (msgId): A unique identifier used for subsequent deduplication checks;
[0090] Event template encoding: used for routing to the corresponding event template configuration;
[0091] Event occurrence time: Records the actual time the alarm occurred;
[0092] Site identifier (SSN): Identifies the site from which the alarm originated;
[0093] Event message body: contains specific field data of the alarm event (such as device temperature, voltage, current and other indicator values).
[0094] The above information is assembled into an EvtDTO object, which serves as the data carrier for subsequent processes.
[0095] S102: Obtain the corresponding event template and field parameters according to the event template code, and verify each field in the alarm event message according to the field parameters.
[0096] This step uses event template metadata to drive the validation of alarm event messages, ensuring that the event data entering subsequent processes is complete and correctly formatted, preventing illegal or abnormal events from entering subsequent processing, and ensuring system data quality.
[0097] Specifically, check whether the alarm event message contains the value corresponding to the field code. If it does not exist, the validation fails. Determine whether the value type matches the field type in the field parameter. If they do not match, the validation fails. When the field parameter contains a regular expression, use regular expression matching to validate the value. If they do not match, the validation fails. If any of the above validations fail, the alarm event message is discarded.
[0098] S103: Obtain the alarm policy associated with the event template encoding, map the fields in the alarm event message to the script execution context according to the field parameters, run the filtering rules of the alarm policy as a dynamic script in the context, and determine whether the alarm event matches the alarm policy.
[0099] This step executes configurable filtering rules through a dynamic script engine to determine whether the current alarm event meets the triggering conditions of the alarm policy, thereby enabling dynamic expansion of rule expression capabilities and support for complex logic combinations.
[0100] Specifically, query the alarm policy table (alarm_stg) for a list of alarm policies that are associated with the current event template code and are currently enabled. For each policy, perform the following checks sequentially:
[0101] (1) Quiet period judgment: If the current time is within the quiet period configured by the strategy, then skip the strategy.
[0102] (2) Default rule judgment: If the filtering rule of the strategy is the default rule (i.e. unconditional matching), then the strategy will be directly matched.
[0103] (3) Dynamic script filtering: call GroovyScriptHandler to execute rule filtering. Specifically, construct a binding variable context by using the field code of each field as the variable name and the field value as the variable value, compile the filtering rules into a dynamic script and run it in the binding variable context.
[0104] S104: When an alarm event matches an alarm policy, a notification task is generated according to the notification rules associated with the alarm policy.
[0105] This step transforms the handling of alarm events from "instantaneous synchronous sending" to "task-based asynchronous processing," by generating stateful notification tasks, laying the foundation for subsequent scheduling, convergence, retry, and lifecycle management.
[0106] Specifically, for each policy that is hit in S103, the task is submitted to the thread pool for asynchronous execution. The processor manager calls the corresponding processor to generate the notification task based on the notification rule type (NotifyRuleType) of the policy.
[0107] There are four types of notification rules, and different strategies can be configured with different convergence methods. Specifically, the notification rule can be any one of the following: direct notification type, cumulative notification type, interval notification type, and interval cumulative notification type. The notification task has a state, which transitions between the unnotified state, the notifyable state, the notified state, and the task completed state. Different notification rule types correspond to different state transition paths.
[0108] Specifically, in the cumulative notification type, notification tasks in the current alarm policy that are in the unnotified state are cumulatively counted. When the cumulative count reaches the cumulative count threshold, the status of the notification task is updated to the notifyable state. In the interval notification type, notification tasks are managed within the configured notification interval duration. When a notification task times out, the status of the notification task is set to the task completed state. In the interval cumulative notification type, window cumulative count is performed within the configured cumulative time window, and a notification is triggered when the window cumulative count threshold is reached. If the window cumulative count has not reached the window cumulative count threshold when the cumulative time window ends, the count is reset and the next window is entered.
[0109] For example:
[0110] (1) Direct notification: After an event hits the policy, a notification task with a status of can_notify is created directly. The task records the event number, alarm level, policy number, notification template set, and rule type. This task can be consumed and a notification sent in the next round of notification scheduling.
[0111] (2) Cumulative Notifications (count): First, attempt to increment the count of notification tasks with the current policy status of not_notify and rule type count; when the count reaches or exceeds the alarm_total threshold, automatically update the task status to can_notify. If there are no tasks to be counted, create a new not_notify task with an initial count of 1, and record the first alarm time and the total count threshold.
[0112] (3) Interval Notification: Attempts to update interval notification tasks with the current status of can_notify or did_notify under the current policy: If the task status is did_notify and the current event time has exceeded end_time, then the task status is set to dead (task completed), thus allowing the creation of new tasks in the next round; otherwise, only the update_time of the task is updated. If there is no task that can be updated, then a new can_notify task is created, recording the start time as the current event time and the end time as the start time plus the configured interval in minutes.
[0113] (4) Interval Count: Combining interval and cumulative logic, the number of times an event arrives within the interval time window is accumulated. When the accumulated number reaches the threshold, a notification is triggered. If the threshold is not reached when the window ends, no notification is given and the next window is entered.
[0114] S105: Schedule notification tasks, determine the notification channel to send notifications through the notification template associated with the notification task.
[0115] This step schedules and executes notificationable tasks in an orderly manner according to priority. It selects notification channels and renders notification content through a template-driven approach before sending, thereby achieving fine-grained scheduling and management of notification tasks and decoupling templates from channels.
[0116] Specifically, the system queries notification tasks that are in a notifyable state, sorts them by alarm level from high to low, submits them to the thread pool for asynchronous execution, retrieves the notification template associated with the notification task, selects the corresponding notification handler based on the notification type, renders the field values in the alarm event message according to the configuration of the notification template, and then sends them through the notification handler.
[0117] The alarm notification method provided in this application receives alarm event messages and parses them to obtain the event template code of the alarm event messages. Based on the event template code, it obtains the corresponding event template and field parameters, and verifies each field in the alarm event message according to the field parameters. It then obtains the alarm policy associated with the event template code, maps the fields in the alarm event message to a script execution context based on the field parameters, runs the filtering rules of the alarm policy as a dynamic script in the context, determines whether the alarm event matches the alarm policy, and when the alarm event matches the alarm policy, generates a notification task according to the notification rules associated with the alarm policy, schedules the notification task, and determines the notification channel to send the notification through the notification template associated with the notification task. This method, through the coordinated operation of event template configuration, dynamic script rules, and task scheduling mechanisms, achieves end-to-end configurable processing of alarm events from access to notification. This allows new alarm types to be adapted without modifying the source code. Simultaneously, dynamic rule execution, multiple convergence strategies, and priority scheduling ensure the flexibility of rule expression, the accuracy and controllability of notifications, and the timely delivery of high-priority alarms.
[0118] Figure 2 Flowchart of the alarm notification method provided in this application Figure 2 ,like Figure 2 As shown, based on the above embodiment, step S102 specifically includes:
[0119] S201: Check whether the alarm event message contains the value corresponding to the field code. If it does not exist, the verification fails.
[0120] This step ensures that the alarm event message contains the necessary fields defined in the event template, preventing null value exceptions or logical errors during subsequent rule engine execution due to missing fields, and ensuring system stability.
[0121] Specifically, the process iterates through the set of fields associated with the event template. For the current field, it searches for the key-value pair corresponding to the field code in the alarm event message body (Payload). If the field code is not found in the message body, it means that the original alarm event did not report data for that field. At this point, the validation item is deemed to have failed, an error log is recorded (e.g., "Field [xxx] does not exist"), and the validation step is terminated.
[0122] S202: Determine if the value type matches the field type in the field parameter. If they do not match, the validation fails.
[0123] This step verifies that the data types of each field in the alarm event message are consistent with the types defined in the event template. This prevents the rule engine script from executing abnormally or producing incorrect judgment results due to incorrect data types, and ensures the type security of event data.
[0124] Specifically, retrieve the field type (fieldType) configured in the field parameters. Field types include, but are not limited to, basic types such as String, Integer, Double, and List.
[0125] Use Java's type checking mechanism to perform type matching and determination on field values:
[0126] If the field type is String, check if the value is a string type;
[0127] If the field type is Integer, check if the value is an integer type;
[0128] If the field type is Double, check if the value is a double-precision floating-point number.
[0129] If the field type is List, check if the value is a list / array type.
[0130] If the type of the actual value does not match the type of the declared field, the system determines that the validation item fails, records an error log (such as "Field [xxx] type mismatch, expected [Integer], actual [String]"), and terminates the validation step.
[0131] S203: When a field parameter contains a regular expression, use regular expression matching to validate the value. If there is no match, the validation fails.
[0132] This step uses regular expressions to validate the field values, ensuring that they conform to the expected business format specifications (such as time format, encoding format, IP address format, etc.). Data with abnormal formats is intercepted before entering the rule engine, thus improving data quality.
[0133] Specifically, it checks whether a regular expression is configured in the field parameters of the current field. If a regular expression is configured, it retrieves the regular expression string and uses Java's Pattern.matches method to match the string form of the field value with the regular expression.
[0134] Regular expressions can be flexibly defined according to business needs, for example:
[0135] Configure the site code field in the format ^[AZ]{2}[0-9]{4}$ to ensure that the site code consists of two uppercase letters and four numbers;
[0136] Configure the time field with the format ^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$ to ensure that the time field conforms to the standard time format;
[0137] Configure regular expressions for the IP address field to format the IP address.
[0138] If a field value does not meet the regular expression validation rules, the validation item is deemed to have failed, an error log is recorded (e.g., "Field [xxx] regular expression validation failed, value [yyy] does not match regular expression [zzz]"), and the validation step is terminated.
[0139] S204: If any of the above checks fails, the alarm event message will be discarded.
[0140] This step serves as the closing action in the verification process, ensuring that only legitimate events that have passed all three verifications can proceed to subsequent processing steps. This prevents illegal or abnormal events from consuming system resources and safeguards system security and data quality.
[0141] Specifically, the results of the triple checks S201, S202, and S203 are comprehensively evaluated. If any of the above checks fails, the following operations are performed:
[0142] Record error logs: Write information such as the field code of the failed verification, the reason for the failure, the event number and the original message body into the system log to facilitate the operation and maintenance personnel to troubleshoot problems and trace data.
[0143] Discard the alarm event message: This event will not enter the subsequent event storage, policy matching, task generation and notification sending process to avoid invalid data polluting the system;
[0144] No retry or compensation: If the verification failure is due to a quality issue with the data itself, no retry mechanism will be triggered.
[0145] Only events that pass all three checks are allowed to proceed to the S103 (policy matching and rule filtering) stage for further processing.
[0146] The alarm notification method provided in this application checks whether the alarm event message contains a value corresponding to a field code. If it does not exist, the verification fails. It then determines whether the value type matches the field type in the field parameters; if they do not match, the verification fails. When the field parameters contain regular expressions, regular expression matching is used to verify the value; if they do not match, the verification fails. If any of the above verifications fail, the alarm event message is discarded. This method, through a triple verification mechanism driven by event template metadata, intercepts and discards alarm events with incomplete structures, incorrect types, or non-compliant formats before they enter the rule engine, ensuring data quality and system stability in subsequent processing.
[0147] Figure 3 Flowchart of the alarm notification method provided in this application Figure 3 ,like Figure 3As shown, based on the above embodiments, step S103 specifically includes:
[0148] S301: Construct a binding variable context by using the field codes of each field as variable names and the field values as variable values.
[0149] This step converts structured alarm event data into a variable environment that can be directly recognized by dynamic scripts, enabling filtering rules to directly reference event fields using natural variable names, thus achieving dynamic decoupling between event data structure and rule logic.
[0150] Specifically, after the S102 verification passes, the system retrieves the list of fields defined in the event template, along with the field codes for each field and their corresponding actual values in the current alarm event message. Then, it iterates through these fields, using the field codes as variable names and the field values as variable values, to dynamically construct the binding variable context required by the executable script engine.
[0151] For example, alarm event messages may contain fields such as device temperature, device status, and CPU usage. The system binds the field code temperature and its value 85, the field code status and its value "overheat", and the field code cpu_usage and its value 92.5 to variables that can be recognized by the executable script. This allows these fields to be directly referenced as variable names during subsequent script execution without additional parsing or mapping.
[0152] S302: Compile the filtering rules into an executable script and run it in the context of the bind variable.
[0153] This step converts the readable filtering rules configured by operations and maintenance personnel into executable code in real time, runs it in the context of bound variables, and returns the hit results, realizing the dynamic execution of complex alarm logic. Rules can be changed without modifying the source code or restarting the system.
[0154] Specifically, it retrieves the filtering rule text configured in the alarm policy. This rule text is written in a preset syntax and supports complete expression syntax, including arithmetic comparisons (greater than, less than, equal to), logical operations (AND, OR, NOT), and parenthesis precedence combinations, etc.
[0155] All variable names referenced in the filtering rules are pre-bound in the bound variable context built by S301, so the script can directly reference them without additional declaration.
[0156] Subsequently, the rule text is dynamically compiled into an executable script at runtime, without the need for pre-compilation or system restart. For already compiled scripts, a caching mechanism can be used to avoid repeated compilation, thereby improving execution efficiency.
[0157] After compilation, the script is executed within the binding variable context built by S301. The engine parses the actual values of the variables from the binding context to participate in expression evaluation. Upon completion, the script returns a boolean value: true indicates that the current alarm event meets the filtering criteria and matches the alarm policy; false indicates that the filtering criteria are not met, the policy is not matched, and the process continues to match the next policy.
[0158] The alarm notification method provided in this application constructs a bound variable context by using the field codes of each field as variable names and the field values as variable values. The filtering rules are compiled into an executable script and run within the bound variable context. This method dynamically maps event fields to script variables and compiles and executes filtering rules in real time, enabling the expression and modification of alarm policy rules without modifying the source code, thus achieving dynamically configurable execution of complex logic.
[0159] Figure 4 Flowchart of the alarm notification method provided in this application Figure 4 ,like Figure 4 As shown, based on the above embodiments, step S105 specifically includes:
[0160] S401: Query notification tasks with a notification status of "can be notified", sort them by alarm level from high to low, and submit them to the thread pool for asynchronous execution.
[0161] This step periodically scans for notification tasks that have met the triggering conditions, prioritizes high-level alarms for processing, and uses an asynchronous thread pool to decouple notification sending from the main process, avoiding blocking subsequent event processing.
[0162] Specifically, at startup, a thread pool based on a blocking queue is initialized, along with two timed scheduling threads: one responsible for scanning for notifiable tasks and the other responsible for scanning for already notified tasks.
[0163] The thread responsible for notifiable tasks performs a scan at a fixed frequency (e.g., once per second): querying the notification task table for all notification tasks with a status of can_notify (notifiable).
[0164] After retrieving the list of tasks that can be notified, the system sorts the task list:
[0165] First sorting dimension: Sort by alarm level from highest to lowest (Critical > Alarm > Notification) to ensure that the highest level alarms are notified first;
[0166] The second sorting dimension: When alarm levels are the same, they are sorted by the time of occurrence from earliest to latest to ensure that earlier events are handled first.
[0167] After sorting, the notification task objects are submitted one by one to the thread pool for asynchronous execution. Because of this asynchronous execution, the notification sending process does not block the main process's event reception and rule filtering, ensuring the system's throughput under high concurrency scenarios.
[0168] S402: Retrieve the notification template associated with the notification task.
[0169] This step retrieves the notification template corresponding to the current notification task, and obtains the notification type and content format configuration from it. This provides a basis for subsequent selection of notification channels and rendering of notification content, and realizes the separate management of notification content and business data.
[0170] Specifically, when the notification task is generated in S104, the alarm policy number is recorded in the notification task. During the notification scheduling and execution phase, several notification templates associated with the alarm policy are queried based on the policy number in the notification task.
[0171] Each notification template is pre-configured with the following information:
[0172] Notification type: Identifies the notification channel corresponding to this template, such as email, SMS, telephone, etc.;
[0173] Content template: Defines the format and structure of the notification content, including fixed text content and replaceable variable placeholders;
[0174] Template name and description: To facilitate identification and management by operations and maintenance personnel in the configuration interface.
[0175] An alarm policy can be associated with multiple notification templates, and the same alarm event can be sent through multiple channels. The system retrieves all notification templates associated with a policy at once based on the policy number recorded in the notification task, and then executes the subsequent sending process for each notification template separately.
[0176] S403: Select the corresponding notification handler based on the notification type.
[0177] This step dynamically routes notifications to the corresponding notification handlers based on the notification type, enabling pluggable expansion of notification channels. When adding a new channel, there is no need to modify the existing code; only the corresponding handler implementation class needs to be added, thus decoupling the notification template from the notification channel.
[0178] Specifically, the built-in HandlerManager manages all registered notification handlers (INotifyHandler). Each notification handler implements a unified sending interface and indicates the notification types it supports.
[0179] Extract the notification type field (notify_type) from the notification template obtained from S402, use the currently selected notification type as the query condition, and let the processor manager search for and return processor instances that support the type from the list of registered processors.
[0180] If the notification type is email, then return the email notification handler;
[0181] If the notification type is SMS, then return to the SMS notification processor;
[0182] If the notification type is telephone, then return the telephone notification handler.
[0183] If no handler supporting the notification type is found, an error log is logged and the notification template's sending process is terminated. Because the handler manager uses a pluggable design pattern, when a new notification channel needs to be added, simply create a new handler class that implements the INotifyHandler interface and register it with the manager; no changes to existing code are required.
[0184] S404: After rendering the field values in the alarm event message according to the configuration of the notification template, send it through the notification processor.
[0185] This step dynamically populates the specific data of the alarm event into the notification template, generates alarm notification content that is readable by operations and maintenance personnel, and sends it through the processor of the target channel to achieve effective delivery of alarm information.
[0186] Specifically, the content template in the notification template obtained by S402 is merged and rendered with the actual field values in the alarm event message. The content template has preset fixed text and variable placeholders, and the variable placeholders correspond one-to-one with the field codes defined in the event template.
[0187] For example, the content configured in the notification template is:
[0188] "Site {ssn} triggered an alert at {time} with the current value of {metric_name} being {value}. Please handle this promptly."
[0189] Replace the placeholders in the template with the actual values of the corresponding fields in the alarm event message to generate the final notification message body.
[0190] After rendering is complete, the selected notification handler in S403 is invoked to send the rendered notification content through the corresponding third-party interface. Taking communication software as an example, the handler encapsulates the rendered text content into a communication software text message format and pushes it by calling the configured communication software robot URL. The system uses a synchronous HTTP client to send requests and configures a retry strategy through the retry framework, performing a maximum of 3 retries in case of sending errors. If it still fails, the reason for failure is recorded.
[0191] Regardless of whether the notification is successful or not, the notification content, sending result, reason for failure, and notification time will be written to the alarm notification log table to provide data support for subsequent problem tracing and statistical analysis.
[0192] The alarm notification method provided in this application obtains the notification template associated with the notification task, selects the corresponding notification processor according to the notification type, renders the field values in the alarm event message according to the configuration of the notification template, and sends it through the notification processor. The above method achieves fine-grained scheduling of alarm tasks through timed scanning and priority sorting, and combines template-driven channel dynamic routing and content rendering mechanisms to achieve flexible configuration and retry guarantee for multi-channel notifications.
[0193] Figure 5 A schematic diagram of the alarm notification device provided in this application is shown below. Figure 5 As shown, the alarm notification device 50 specifically includes:
[0194] The receiving module 51 is used to receive alarm event messages and parse them to obtain the event template encoding of the alarm event messages;
[0195] The verification module 52 is used to obtain the corresponding event template and field parameters according to the event template encoding and to verify each field in the alarm event message according to the field parameters.
[0196] The judgment module 53 is used to obtain the alarm policy associated with the event template encoding, map the fields in the alarm event message to the script execution context according to the field parameters, run the filtering rules of the alarm policy as a dynamic script in the context, and determine whether the alarm event hits the alarm policy.
[0197] The generation module 54 is used to generate a notification task according to the notification rules associated with the alarm policy when the alarm event hits the alarm policy.
[0198] The scheduling notification module 55 is used to schedule notification tasks and determine the notification channel to send notifications based on the notification template associated with the notification task.
[0199] In one possible implementation, the verification module 52 specifically includes:
[0200] Check if the alarm event message contains the value corresponding to the field code; if it does not exist, the verification fails.
[0201] The validation will fail if the data type of the value matches the field type in the field parameter.
[0202] When a field parameter contains a regular expression, the value is validated using regular expression matching; if no match is found, the validation fails.
[0203] If any of the above checks fails, the alarm event message is discarded.
[0204] In one possible implementation, the determination module 53 specifically includes:
[0205] Construct a binding variable context by using the field codes of each field as variable names and the field values as variable values;
[0206] Compile the filtering rules into an executable script and run it in the context of the bind variable.
[0207] In one possible implementation, the notification rule is any one of the following: direct notification type, cumulative notification type, interval notification type, and interval cumulative notification type;
[0208] Notification tasks have states, which transition between unnotified, notifyable, notified, and task completed states. Different notification rule types correspond to different state transition paths.
[0209] In one possible implementation, in the cumulative notification type, the notification tasks whose status is not notified under the current alarm policy are cumulatively counted, and when the cumulative count reaches the cumulative count threshold, the status of the notification task is updated to the notifyable status.
[0210] In the interval notification type, notification tasks are managed within the configured notification interval duration, and the status of the notification task is set to task completion when the notification task times out.
[0211] In the interval cumulative notification type, the window cumulative count is performed within the configured cumulative time window, and a notification is triggered when the window cumulative count threshold is reached. If the window cumulative count has not reached the window cumulative count threshold when the cumulative time window ends, the count is reset and the next window is entered.
[0212] In one possible implementation, the scheduling notification module 55 is specifically used for:
[0213] The query identifies notification tasks that are in a notification-ready state, sorts them by alarm level from highest to lowest, and submits them to the thread pool for asynchronous execution.
[0214] In one possible implementation, the scheduling notification module 55 is further specifically used for:
[0215] Retrieve the notification template associated with the notification task. The notification template includes the notification type.
[0216] Select the corresponding notification handler based on the notification type;
[0217] After rendering the field values in the alarm event message according to the configuration of the notification template, it is sent through the notification processor.
[0218] The alarm notification device provided in this embodiment can execute the alarm notification method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0219] Figure 6 A schematic diagram of the structure of the electronic device provided in this application. Figure 6 As shown, the electronic device 600 provided in this embodiment includes at least one processor 601 and a memory 602. Optionally, the electronic device 600 further includes a communication component 603. The processor 601, memory 602, and communication component 603 are connected via a bus 604.
[0220] In a specific implementation, at least one processor 601 executes computer execution instructions stored in memory 602, causing at least one processor 601 to perform the above-described method.
[0221] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0222] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0223] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0224] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0225] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0226] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0227] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0228] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0229] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0230] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0231] In addition, the functional units in the various embodiments of the present invention can be integrated into a processor, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0232] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0233] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0234] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. An alarm notification method, characterized in that, include: Receive alarm event messages and parse them to obtain the event template code of the alarm event messages; The corresponding event template and field parameters are obtained according to the event template code, and each field in the alarm event message is verified according to the field parameters. Obtain the alarm policy associated with the event template encoding, map the fields in the alarm event message to a script execution context according to the field parameters, run the filtering rules of the alarm policy as a dynamic script in the context, and determine whether the alarm event hits the alarm policy. When the alarm event matches the alarm policy, a notification task is generated according to the notification rules associated with the alarm policy; The notification task is scheduled, and the notification channel is determined and the notification is sent through the notification template associated with the notification task.
2. The method according to claim 1, characterized in that, The step of obtaining the corresponding event template and field parameters according to the event template encoding and validating each field in the alarm event message according to the field parameters includes: Check whether the alarm event message contains the value corresponding to the field code; if it does not exist, the verification fails. The validation will fail if the value type matches the field type in the field parameter. When the field parameter contains a regular expression, the value is validated using regular expression matching; if no match is found, the validation fails. If any of the above checks fails, the alarm event message is discarded.
3. The method according to claim 1, characterized in that, The step of mapping fields in the alarm event message to a script execution context based on the field parameters, and running the filtering rules of the alarm policy as a dynamic script in the context, includes: Construct a binding variable context by using the field codes of each field as variable names and the field values as variable values; The filtering rules are compiled into an executable script and run in the context of the bound variables.
4. The method according to claim 1, characterized in that, The notification rule is any one of the following: direct notification type, cumulative notification type, interval notification type, and interval cumulative notification type; The notification task has a state, which transitions between a no-notification state, a notifyable state, a notified state, and a task-completed state. Different notification rule types correspond to different state transition paths.
5. The method according to claim 4, characterized in that, In the cumulative notification type, the notification tasks whose status is not notified under the current alarm policy are cumulatively counted. When the cumulative count reaches the cumulative count threshold, the status of the notification task is updated to the notifyable status. In the interval notification type, the notification task is managed within the configured notification interval duration, and when the notification task times out, the status of the notification task is set to task completion status. In the interval cumulative notification type, the window cumulative count is performed within the configured cumulative time window, and a notification is triggered when the window cumulative count threshold is reached. If the window cumulative count has not reached the window cumulative count threshold when the cumulative time window ends, the count is reset and the next window is entered.
6. The method according to claim 1, characterized in that, The scheduling of the notification task includes: The query identifies notification tasks that are in a notification-ready state, sorts them by alarm level from highest to lowest, and submits them to the thread pool for asynchronous execution.
7. The method according to claim 1, characterized in that, The step of determining the notification channel and sending the notification through the notification template associated with the notification task includes: Obtain the notification template associated with the notification task, wherein the notification template contains a notification type; Select the corresponding notification handler based on the notification type; After rendering the field values in the alarm event message according to the configuration of the notification template, it is sent through the notification processor.
8. An alarm notification device, characterized in that, include: The receiving module is used to receive alarm event messages and parse them to obtain the event template encoding of the alarm event messages; The verification module is used to obtain the corresponding event template and field parameters according to the event template encoding, and to verify each field in the alarm event message according to the field parameters. The acquisition and determination module is used to acquire the alarm policy associated with the event template code, map the fields in the alarm event message to a script execution context according to the field parameters, run the filtering rules of the alarm policy as a dynamic script in the context, and determine whether the alarm event hits the alarm policy. The generation module is used to generate a notification task according to the notification rules associated with the alarm policy when the alarm event matches the alarm policy. The scheduling and notification module is used to schedule the notification task and determine the notification channel to send the notification through the notification template associated with the notification task.
9. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 7.
