[ZBX-25143] User macros on calculated items are not accepted in host parameter Created: 2024 Aug 31 Updated: 2024 Nov 09 Resolved: 2024 Sep 01 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S), Templates (T) |
Affects Version/s: | 6.0.33 |
Fix Version/s: | None |
Type: | Incident report | Priority: | Trivial |
Reporter: | LivreAcesso.Pro | Assignee: | Zabbix Development Team |
Resolution: | Won't fix | Votes: | 0 |
Labels: | calculateditems, lastvalue, macro, templates, usermacro | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() ![]() |
Description |
Steps to reproduce:
Result: Works: last(/myHost/oltPonTxOpticalPower.[472907776]) Don't work: last(/{$MYHOST}/oltPonTxOpticalPower.[472907776]) Expected: |
Comments |
Comment by LivreAcesso.Pro [ 2024 Aug 31 ] |
I manage to get the value through an API call: { "jsonrpc": "2.0", "method": "item.get", "params": { "host": "{$MYHOST}", "search": { "key_": "oltPonTxOpticalPower.[{$MYHOSTPWID}]" } }, "auth": "{$API_TOKEN}", "id":{$MYHOSTPWID} } But the HTTP Agent call is overloading my server. |
Comment by Alexander Vladishev [ 2024 Sep 01 ] |
Zabbix does not support custom macros in this context. This is also reflected in the documentation.
|
Comment by LivreAcesso.Pro [ 2024 Sep 02 ] |
Thanks. Can I use any other function, or aggregate function, to select only one host? |
Comment by Alexander Vladishev [ 2024 Sep 02 ] |
In this case, you can use the macro {HOST.HOST} or omit the host name. Both of these approaches will work the same way: last(/{HOST.HOST}/oltPonTxOpticalPower.[472907776]) last(//oltPonTxOpticalPower.[472907776]) |
Comment by LivreAcesso.Pro [ 2024 Sep 02 ] |
Thanks.
{ "jsonrpc": "2.0", "method": "item.get", "params": { "host": "{$MYHOST}", "search": { "key_": "oltPonTxOpticalPower.[{$MYHOSTPWID}]" } }, "auth": "{$API_TOKEN}", "id":{$MYHOSTPWID} } The parent host is defined by {$MYHOST} macro. I have a host tag defined as {$MYHOST} too. |
Comment by Alexander Vladishev [ 2024 Sep 03 ] |
In this case, you need to explicitly specify the hostname. There are no other options. You can also vote for this functionality in ticket ZBXNEXT-8616. |
Comment by LivreAcesso.Pro [ 2024 Oct 01 ] |
Can I use a LLD to concatenate the item? |
Comment by Alexander Vladishev [ 2024 Oct 01 ] |
No, LLD macros cannot be used to concatenate the item key in a calculated item formula. However, in item prototypes, at least one such macro is required in the item key parameter. Here is an example of a formula that contains references to item prototypes: (last(//vfs.dev.read.time.rate[{#DEVNAME}])/(last(//vfs.dev.read.rate[{#DEVNAME}])+(last(//vfs.dev.read.rate[{#DEVNAME}])=0)))*1000*(last(//vfs.dev.read.rate[{#DEVNAME}]) > 0) |
Comment by LivreAcesso.Pro [ 2024 Nov 09 ] |
Details Cannot update item prototype Invalid parameter "/1/params": incorrect expression starting from "last(/{#OLT}/oltPonTxOpticalPower.[0])". |