[ZBXNEXT-1568] Recursive macro resolution Created: 2013 Jan 13  Updated: 2024 Jun 19

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Server (S)
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Change Request Priority: Trivial
Reporter: Enrico Tröger Assignee: Unassigned
Resolution: Unresolved Votes: 29
Labels: macro, template
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Causes
Duplicate
is duplicated by ZBXNEXT-1982 Expand macros in user macros Closed

 Description   

It would be really nice if one could use macros as values for other macros.

In detail, I want to define a template macro {$SSH.IP} with a default value {HOST.IP1} on the template.
And for some hosts in this template, I want to override the {$SSH.IP} with the actual IP of the host if it doesn't match the configured agent interface IP ({HOST.IP1}).

Currently, the template macro value {HOST.IP1} is not resolved and passed directly to the item, which obviously fails. So, for now, I had to define the {$SSH.IP} macro on each of my hosts to get the item working.
Thus it would be very useful if macros would be resolved in macro values, even if it would be only non-user macros such as {HOST.IP1}.



 Comments   
Comment by Marc [ 2016 Aug 08 ]

ZBX-2866 should likely be implemented first

Comment by Sandis Neilands (Inactive) [ 2016 Oct 06 ]

The risk here is obviously with user macros that resolve to themselves. Note that such recursion might not be direct. Another difficulty could be with the implicit unquoting.

Comment by Alex Tomasello [ 2018 Jul 11 ]

I think that you can use zabbix macros as value of user macro.

I think in this case, you can prevent loop in recursion.

What do you think about?

Comment by Marco Hofmann [ 2019 Feb 25 ]

I tried the same today, with the "Template Virt VMware" where you have to define "{$URL}" on host level to resolve to "https://1.2.3.4/sdk". Now I thought I'm smart like @eht16 and resolve "{$URL}" to "https://{HOST.IP}/sdk" on template level. But sadly that won't resolve. Are there any plans to change the behavior of Zabbix in this way? Until then I have to set "{$URL}" on each and every host manually :-/

Comment by Vadims Kurmis [ 2019 Aug 14 ]

I want to use "{$URL}" = "https://{HOST.IP}/SDK" for my VMware ESX Template.

Zabbix should include nested macro support. This is very flexible and wanted functionality.

Grafana supports nested macros. This is a common thing for templating. And if Zabbix is based on templates, then should not cut down all the flexibility, if properly made recursion checks.

 

Comment by Jim [ 2019 Nov 11 ]

This feature would be really useful for me as well.

Comment by Aleksandrs Petrovs-Gavrilovs [ 2022 Mar 24 ]

It would be even better if we could pass LLD macro behind a user macro, for a greater host level LLD flexibility.

Comment by Matthew Steeves [ 2024 Apr 15 ]

My use case is:

{$SPECIAL.1} = asdf
{$SPECIAL.2} = qwerty
{$REGEX_ALL}  = {$SPECIAL.1}|{$SPECIAL.2}

{$REGEX_ALL} would be used within a trigger expression in a trigger prototype. 
When a need for {$SPECIAL.3} comes along, I could simply add it to the template and update the {$REGEX_ALL} macro.
Currently, I have to edit the trigger prototype, and then force a discovery on every host if I want the new macro to be seen immediately.

 

Comment by Nilesh Gupta [ 2024 Jun 19 ]

This feature would be really useful for me as well.

Generated at Mon Jun 30 09:39:46 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.