[ZBXNEXT-5927] Using built-in macros in JavaScript and regular expression preprocessing Created: 2020 Apr 30 Updated: 2024 Jun 25 |
|
Status: | Reopened |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | Server (S) |
Affects Version/s: | 4.4.8 |
Fix Version/s: | None |
Type: | New Feature Request | Priority: | Trivial |
Reporter: | Stefano Enrico Mendola | Assignee: | Zabbix Support Team |
Resolution: | Unresolved | Votes: | 39 |
Labels: | javascript, macro, preprocessing, regularexpression | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Issue Links: |
|
Description |
Hi, For example, it would be nice to use {HOST.HOST} in regular expression preprocessing, var hostname = ZabbixMacro.get("{HOST.HOST}"); One use case where I encountered this limitation is the following: |
Comments |
Comment by Stefano Enrico Mendola [ 2020 Apr 30 ] |
At the moment, the workaround I'm using is: >adding a User Macro to the host template |
Comment by dimir [ 2020 Sep 18 ] |
Re-opening as it appeared to not be duplicate. This issue is specifically about built-in macros. |
Comment by dimir [ 2020 Sep 18 ] |
Usermacros support was added in |
Comment by dimir [ 2020 Sep 18 ] |
FYI, there is no term "supported macros". On this page https://www.zabbix.com/documentation/current/manual/appendix/macros/supported_by_location the supported means "what we support out-of-the box". Sometimes we call them "built-in". |
Comment by Stefano Enrico Mendola [ 2020 Sep 18 ] |
Hi @dimir, thanks for the clarification and for re-opening this issue. Wouldn't it be nice to let the community know about this nomenclature? Should I open a separated documentation issue for this? Cheers |
Comment by dimir [ 2020 Sep 18 ] |
martins-v what do you think? |
Comment by Dimitri Bellini [ 2020 Oct 27 ] |
News about this feature on Zabbix v.5.2? Thanks |
Comment by Matthew Steeves [ 2021 Feb 24 ] |
Just want to throw our use-case into the mix as well: I would really like to be able to know the hostname from within a low-level discovery rule. Being able to use it within a Javascript pre-processing step in an LLD rule would give me the ability to assign it to an LLD Macro, and then reference that macro in Filters and Overrides. This would allow me to write one template that acts differently depending on whether the host is a production host or a dev host. Example:
Steps:
(Outside the scope of this request, but best case scenario (easiest) would be if I could use HOST.NAME directly on the "left-side" of a Filter or Override condition within a LLD rule, instead of first having to assign the "built-in" macro to an LLD macro, and then reference the LLD macro.) |
Comment by Nick [ 2022 Mar 28 ] |
I have the same issue when using lld for host prototypes, want to use built-in macros (like: {HOST.CONN}) in JavaScript preprocessing. Another way, is it possible to set a user macro value with built-in macro? For example, {$XXX_CFG_HOST}: {HOST.CONN}, but that doesn't work either. |
Comment by David [ 2024 Jan 09 ] |
I have run into this limitation trying to use {HOST.NAME} macro within a JSONPath call in preprocessing. +1 Vote for this. |
Comment by Denis Dion [ 2024 Apr 25 ] |
I too have run into this problem and had to use the workaround of using a user macro. I do not understand why user macros work but the built-in not. +1 at least vote for this. |
Comment by Ushakov.Stanislav [ 2024 Jun 25 ] |
This feature is really important. Right now, I have to use all kinds of scripts for the API to attach a custom macro to a node with the network node name. Then, I need to pass that macro for JavaScript preprocessing in LLD. If built-in macros were supported directly in preprocessing, it would make things so much easier. |