Search code examples
templatesmacroszabbix

User macros in Zabbix trapper name & key


I can't add user custom macros in templated zabbix trappers' name & key, getting this error:

Invalid key "nginx_50x_error-{$MACROS}" for item "Nginx: nginx 50x errors on {$MACROS}" on "Template_app_nginx": incorrect syntax near "{$MACROS}".

How can I use custom host-macros in templated zabbix trappers? Tnx.


Solution

  • Documentation: https://www.zabbix.com/documentation/2.4/manual/appendix/macros/supported_by_location

    Macro is not allowed in the item key; that's the reason of "invalid key" error:

    nginx_50x_error-{$MACROS}
    

    Fortunately, macro is allowed in the item key parameters (Item key parameters - column 7) - and this will be your solution:

    nginx_50x_error[{$MACROS}]