bigcyy opened a new issue, #3220: URL: https://github.com/apache/hertzbeat/issues/3220
### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior There is a bug in `RealTimeAlertCalculator` during threshold rule filtering. Specifically, when an alert expression is associated with only one instance (e.g., `redis1`), unassociated instances (e.g., `redis2`) are **not properly filtered out** and still get passed to the Jexl engine for evaluation. ## Root Cause The issue is caused by a mismatch between the format of the expression generated by the frontend and the regex used by the backend to detect instance. **Frontend behavior:** The frontend generates expressions like: ```text equals(__instance__, "99992324230") ``` Note the **space between the comma and the opening quote**. **Backend behavior:** The backend regex used for matching: ```java equals\(__instance__,"(\d+)"\) ``` does **not account for optional whitespace**, which causes `.find()` to fail. As a result, the fallback condition is triggered: ```java return true; ``` This leads to **all instances being accepted**, regardless of whether they were explicitly bound.    ### Expected Behavior Only instances explicitly matched by the expression should be evaluated. Unbound instances (i.e., those not matching any condition like equals(__instance__, "982923424230")) should be filtered out and not passed to the Jexl engine, even if the expression contains whitespace after the comma. ### Steps To Reproduce 1. Create an alert rule associated with only one instance (e.g., redis1). 2. Let the frontend generate the expression: equals(__instance__, "982923424230"). 3. Observe that unassociated instances (e.g., redis2, redis3) are still processed by the alert calculator. ### Environment ```markdown HertzBeat version(s): ``` ### Debug logs _No response_ ### Anything else? _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
