Ad Widget

Collapse

Macro Functions in Item Keys

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • florian.becker
    Junior Member
    • Mar 2023
    • 3

    #1

    Macro Functions in Item Keys

    Hello,

    I'm trying to setup SNMP monitoring for one of our Firewalls. The problem is that the Firewall returns non consistent names (from SNMP discovery) for VPN tunnels and constructing a unique item key is not possible. However a unique key can be constructed using regex. When trying to use macro functions in the item key I get the following error:

    Click image for larger version

Name:	image.png
Views:	606
Size:	13.1 KB
ID:	461028

    The same macro functions seems to work for the item name.​ Is this intended by Zabbix or am I missing something?
  • Answer selected by florian.becker at 14-03-2023, 15:51.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    If I managed to write it down correctly (would have been easier to copy.. hint-hint) then It saved it if it was written as..
    Code:
    vpn.tunnel.ipsec["{{#VPNTUNNEL}.regsub(\"(IPSEC-.*)(?:\{\d{1,3}\}\"),\1)}"]
    I was following example here https://www.zabbix.com/documentation...ros/lld_macros
    Note, that commas are not allowed in unquoted item key parameters, so the parameter containing a macro function has to be quoted.

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #2
      If I managed to write it down correctly (would have been easier to copy.. hint-hint) then It saved it if it was written as..
      Code:
      vpn.tunnel.ipsec["{{#VPNTUNNEL}.regsub(\"(IPSEC-.*)(?:\{\d{1,3}\}\"),\1)}"]
      I was following example here https://www.zabbix.com/documentation...ros/lld_macros
      Note, that commas are not allowed in unquoted item key parameters, so the parameter containing a macro function has to be quoted.

      Comment

      • florian.becker
        Junior Member
        • Mar 2023
        • 3

        #3
        Thank you so much! It works now

        Comment

        Working...