Ad Widget

Collapse

Calculated item using foreach functions and an macro for filtering is not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Airler
    Junior Member
    • Nov 2024
    • 5

    #1

    Calculated item using foreach functions and an macro for filtering is not working

    Hi folks,
    I was already thinking about this a couple of hours without "success" but maybe someone can help me with this.

    We have a template created which is used by several hosts.
    All of these hosts have a (visible) hostname of the following schema: SRV-XY-123

    Now we have created an calculated item in this template which should the count of all hosts, which are in a specified group (My Group) AND have a specified tag (location_short:xy in our example; the xy is the middle part of the hostname the item "belongs to" - see host name schema).
    Therefore I created the following formular for this calculated item:
    Code:
    count(max_foreach(/*/zabbix[host,snmp,available]?[group="My Group" and tag="location_short:{{HOST.NAME}.iregsub(\"SRV-(\\w{,2})-\\d{3}\", \\1).lowercase()}"],1h))
    Unfortunatly the result of this formula is always 0.

    When I modify the formula on a single host to not use the macro in the filter, the item shows the correct count of hosts matching this search formula:
    Code:
    count(max_foreach(/*/zabbix[host,snmp,available]?[group="My Group" and tag="location_short:xy"],1h))
    Based on the Foreach functions documentation (Item filter syntax > Conditions expression) I escaped all backslashes and double quotes in the filter/macro with an additional backslash as described in the documentation (otherwise/without escaping I cannot even save the item configuration).

    The macro should be allowed in the formula and I should also be able to use macro functions here...

    Has anyone an idea what I am missing?

    We are using Zabbix 7.0.5

    Kind regards,
    Torben
    Last edited by Airler; 08-11-2024, 09:29.
Working...