[ZBX-16018] Context based macro - text is seen as logical OR function Created: 2019 Apr 17  Updated: 2024 Apr 10  Resolved: 2019 May 18

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Documentation (D), Frontend (F)
Affects Version/s: 4.0.6
Fix Version/s: 4.0.8rc1, 4.2.2rc1, 4.4.0alpha1, 4.4 (plan)

Type: Problem report Priority: Minor
Reporter: Twan K. Assignee: Andrejs Verza
Resolution: Fixed Votes: 0
Labels: expressions, macro, macrocontext, trigger
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Redhat VM


Attachments: PNG File Screenshot 2019-04-18 at 16.15.15.png     PNG File Screenshot 2019-04-18 at 16.15.34.png     JPEG File Zabbix.jpg    
Team: Team B
Sprint: Sprint 52 (May 2019)
Story Points: 1

 Description   

Scenario: Discovering temperature sensors on a Cisco switch using SNMP. I want to use context based macro's so that i can set a different temperature limit for all sensors.

However with the discovered values (Temperature sensor names) i get some odd results.

Trigger prototype configuration
The macro {#SENSOR_NAME} is discovered with the discovery rule.

temperature.entity"{#SENSOR_NAME}".last() > {$MAX_TEMP:"{#SENSOR_NAME}"}

Discovered names

This all works great in the template expression constructor. However when i run the discovery rule i get the following values for {#SENSOR_NAME} back:

Switch 1 - WS-C3850-48T - Temp inlet Sensor 0
Switch 1 - WS-C3850-48T - Temp Outlet Sensor 0

The discovered triggers looks like this:

temperature.entity["Switch 1 - WS-C3850-48T - Temp inlet Sensor 0"].last() > {$MAX_TEMP:"Switch 1 - WS-C3850-48T - Temp inlet Sensor 0"}

However the expression constructor shows why the trigger is failing.

It seems like the last 2 letters of the word "sensor" are being treated as a logical OR.

The formal stuff:

Steps to reproduce:

  1. Making an trigger prototype using a context based macro with a value that ends / has the text "or"

Result:

  1. The trigger will use the text "or" as logical OR operator

Expected:

  1. The trigger expression would be valid with only 1 operation

 

It this behavior intentional, am i formatting the expression wrong, it there a workaround (other than using the SNMPINDEX in the key and context macro) or am i dealing with a bug here?

Thanks in advance.



 Comments   
Comment by Twan K. [ 2019 Apr 17 ]

Initially i created this bug report under the "new features" project. I've closed that one and made a new one in the correct project.

Comment by Edgar Akhmetshin [ 2019 Apr 18 ]

Hello Twan,

Thank you for reporting the issue. Looks like an error with parsing, i'm able to reproduce:

Confirmed.

Regards,
Edgar

Comment by Edgar Akhmetshin [ 2019 Apr 18 ]

However, the documentation states the restriction - the following characters are allowed in the macro names: A-Z, 0-9, ,. Macro context is specified using rules similar to item key parameters: 0-9a-zA-Z-.

Is it possible to get the name of the sensor in a short way regarding this rules?

Regards,
Edgar

Comment by Twan K. [ 2019 Apr 18 ]

Hi Edgar,

Yes i can also use the SNMPINDEX value in the macro. This isn't pretty but will work for sure.

Thanks for the troubleshooting thus far.

  • Twan
Comment by richlv [ 2019 Apr 18 ]

The quoted line does not appear in the documentation page, it was likely merged from the macro and item pages.
Notice how it says "rules similar to item key parameters" - not item keys.

Comment by Glebs Ivanovskis [ 2019 Apr 18 ]

Macro context is specified using rules similar to item key parameters: 0-9a-zA-Z-.

Where is it said that item key parameters have this restriction? When quoted, macro context can contain any Unicode characters except double quotes, which should be escaped.

Comment by Glebs Ivanovskis [ 2019 Apr 18 ]

Actually, this is a 100% Frontend issue, Server will process the expression correctly. Please fix the Components. As a workaround - simply stop using trigger expression wizard.

Comment by Edgar Akhmetshin [ 2019 Apr 18 ]

Glebs,

It's not clear from the documentation which part from the item key description page will used for the context macro and or characters from macro context are recognized as logical OR.

Regards,
Edgar

Comment by Glebs Ivanovskis [ 2019 Apr 18 ]

I disagree, documentation says:

Technically, macro context is specified using rules similar to item key parameters

Perhaps, "parameters" should be part of the link text and the link itself should point to https://www.zabbix.com/documentation/current/manual/config/items/item/key#key_parameters to be less ambiguous.

Comment by Twan K. [ 2019 Apr 19 ]

After some more testing i can confirm that its a frontend bug, not server / database related. The configuration with a custom macro it seems to be working perfectly in the background

Comment by Andrejs Verza [ 2019 May 10 ]

Resolved in development branch feature/ZBX-16018-4.0.

Comment by Andrejs Verza [ 2019 May 15 ]

Fixed in:

  • 4.0.8rc1 219f94c
  • 4.2.2rc1 f46e396, 68a0b34
  • 4.4.0alpha1 (master) 338bac5, 9b46be8
Generated at Wed Jul 02 08:11:06 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.