[ZBX-23171] Trigger expression with a macro with regular expression context don't resolve at Problems screen Created: 2023 Jul 28  Updated: 2024 Nov 21  Resolved: 2024 Oct 03

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 5.0.43, 6.0.19, 6.0.33, 6.4.18, 7.0.3
Fix Version/s: 5.0.45rc1, 6.0.35rc1, 6.4.20rc1, 7.0.5rc1, 7.2.0alpha1

Type: Problem report Priority: Major
Reporter: Oleg Kostikov Assignee: Eliza Sekace
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 7.5h
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2023-07-31 at 09.48.22.png     PNG File Screenshot 2023-07-31 at 09.48.44.png     PNG File server-frontend-macro-resolving.png    
Issue Links:
Causes
caused by ZBXNEXT-3205 Add support for wildcards and / or gl... Closed
Duplicate
is duplicated by ZBX-25123 Macro set at template level generates... Closed
Team: Team B
Sprint: S24-W36/37, S24-W38/39, S24-W40/41
Story Points: 1

 Description   

1. Create a user macro with regular expression context, for example:

{$VFS.FS.PUSED.MAX.CRIT:regex:"^\/u0[1-9]+"}

2. Wait for the trigger firing
3. Try to see Event details at Problems
4. Result:

preg_match(): Unknown modifier '0' [tr_events.php:171 → make_trigger_details() → CMacrosResolverHelper::resolveTriggerExpressions() → CMacrosResolver->resolveTriggerExpressions() → CMacrosResolverGeneral->getUserMacros() → CMacrosResolverGeneral->getHostUserMacros() → CMacrosResolverGeneral->getHostUserMacros() → CMacrosResolverGeneral->getHostUserMacros() → preg_match() in include/classes/macros/CMacrosResolverGeneral.php:2647]


 Comments   
Comment by Edgar Akhmetshin [ 2023 Jul 31 ]

Hello Oleg,

Could you please also provide macro/trigger configuration and values you have, if configured only as described not able to reproduce using Docker/Alpine/6.0.19.

Regards,
Edgar

Comment by Oleg Kostikov [ 2023 Aug 03 ]

Hello, Elina and Edgar.
I apologize for the delay in responding, it turned out that php 7.2.24 was on one of the zabbix-server nodes.
After upgrading to 8.0.27, the error became more definite:

preg_match(): Unknown modifier 'v' [tr_events.php:171 → make_trigger_details() → CMacrosResolverHelper::resolveTriggerName() → CMacrosResolverHelper::resolveTriggerNames() → CMacrosResolver->resolveTriggerNames() → CMacrosResolver->resolveTriggerExpressions() → CMacrosResolverGeneral->getUserMacros() → CMacrosResolverGeneral->getHostUserMacros() → preg_match() in include/classes/macros/CMacrosResolverGeneral.php:2647]

It can be assumed that the front swears at the escaping / in the regexp.
Indeed, the macro

{$VFS.FS.FREE.MIN.WARN:regex:"^\/var\/log$"}

causes a problem, but the macro

{$VFS.FS.FREE.MIN.WARN:regex:"^/var/log$"} 

does not.
At the same time, the trigger works with both macros.
Both options are found in the documentation https://www.zabbix.com/documentation/6.0/en/manual/config/macros/user_macros_context
{$LOW_SPACE_LIMIT:regex:"^/tmp$"}
{$LOW_SPACE_LIMIT:regex:"^\/[a-z]+$"}

But PCRE2 and PCRE assume slash escaping.

Comment by Alexander Vladishev [ 2024 Aug 27 ]

This error is indeed caused by the escape character. The '/' is not a special character and does not need to be escaped.

However, such errors should not appear in the interface under any circumstances. We will fix this. Additionally, we will update the documentation to remove the escaping of slashes in the regular expression examples.

Thanks for the report, Oleg_Kostikov. The development team is now handling it.

Comment by Eliza Sekace [ 2024 Sep 06 ]

Implemented in development branch feature/ZBX-23171-5.0

Comment by Martins Valkovskis [ 2024 Sep 13 ]

Updated documentation:

  • User macros with context: 5.0, 6.0, 6.4, 7.0, 7.2 (macro example no longer contains escaping of '/')
Comment by Eliza Sekace [ 2024 Sep 18 ]

Fixed in development branches:

Comment by Alexander Vladishev [ 2024 Oct 03 ]

Available in versions:

Generated at Sat May 03 07:19:46 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.