[ZBX-22531] foreach function not getting data filtered by tag when tag uses a user macro in an item Created: 2023 Mar 16  Updated: 2023 May 18  Resolved: 2023 May 18

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: None
Affects Version/s: 6.2.7
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: diego-treitos Assignee: Karlis Salins
Resolution: Duplicate Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates ZBXNEXT-8362 Support Usermacro in foreach function... Open

 Description   

 

I have hosts with items (net.if.in and net.if.out) tagged with:{}

color = {$MACRO_COLOR}

The value of {$MACRO_COLOR} is assigned to the host owning the item net.if.in or net.if.out.

 

Then in a host different host, we have a calculated item that looks like this:

{{sum(last_foreach(/*/net.if.in[*]?[tag="color:green" and group="MyGroup1"]))}}

 

This displays the following error:

 

Cannot evaluate expression: no input data for function at "sum(last_foreach(/*/net.if.in[*]?[tag="color:green" and group="MyGroup1"]))"

 

HOWEVER

If I define the tag as:

color = "green"

instead of

color = {$MACRO_COLOR}

the calculated item works.

 

According to the documentation, I should be able to use user macros for tag values in items: https://www.zabbix.com/documentation/6.0/en/manual/config/tagging

 

So I guess that there is a bug evaluating the macros in the item tags.

 

 

 



 Comments   
Comment by Cicero França [ 2023 Mar 24 ]

the same happens in version 6.0.14.

when I test this function:
avg(last_foreach(/*/vmware.vm.cpu.usage.perf[\{$VMWARE.URL},\{$VMWARE.VM.UUID}]?[tag="\\{$CLIENT}"]))

the result is this:
Cannot evaluate expression: no input data for function at "avg(last_foreach(/*/vmware.vm.cpu.usage.perf[\{$VMWARE.URL},\{$VMWARE.VM.UUID}]?["client:ClientXX"]))"

"tag=" is removed from expression.

Comment by Karlis Salins [ 2023 May 18 ]

Hello.

There is a feature request for this functionality to be implemented: https://support.zabbix.com/browse/ZBXNEXT-8362

Please vote for it there and continue the discussion in that topic as well!

Best regards,
Karlis

Generated at Thu Apr 10 21:53:14 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.