For greater flexibility, Zabbix supports user macros, which can be defined on global, template and host level. These macros have a special syntax: {$MACRO}.
The macros can be used in:
The following characters are allowed in the macro names: A-Z , 0-9 , _ , .
Zabbix substitutes macros according to the following precedence:
In other words, if a macro does not exist for a host, Zabbix will try to find it in the host templates of increasing depth. If still not found, a global macro will be used, if exists.
If Zabbix is unable to find a macro, the macro will not be substituted.
To define user macros, go to the corresponding locations in the frontend:
Most common use cases of global and host macros:
Use of host-level macro in the “Status of SSH daemon” item key:
net.tcp.service[ssh,,{$SSH_PORT}]
This item can be assigned to multiple hosts, providing that the value of {$SSH_PORT} is defined on those hosts.
Use of host-level macro in the “CPU load is too high” trigger:
{ca_001:system.cpu.load[,avg1].last()}>{$MAX_CPULOAD}
Such a trigger would be created on the template, not edited in individual hosts.
Use of two macros in the “CPU load is too high” trigger:
{ca_001:system.cpu.load[,avg1].min({$CPULOAD_PERIOD})}>{$MAX_CPULOAD}
Note that a macro can be used as a parameter of trigger function, in this example function min().