[ZBXNEXT-1893] support user macros for "Regexp" field of LLD rule Created: 2013 Sep 09  Updated: 2022 Jan 13  Resolved: 2022 Jan 13

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Server (S)
Affects Version/s: 2.0.8
Fix Version/s: None

Type: New Feature Request Priority: Minor
Reporter: Pavel Assignee: Unassigned
Resolution: Duplicate Votes: 11
Labels: lld, macros, regexps
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File v2.2.1rc1-lld-use-macros.patch    

 Description   

Sometimes I need to apply different filters for low-level discovery within the same template.
For example use different set of interfaces on the switches while discovery by ifName - "(xe|et)" on one switch and "(ge|xe)" on another.
I can set macro {$IFNAME_RE} for each switch but I cannot use it as regex in template. Pity.



 Comments   
Comment by Oleksii Zagorskyi [ 2013 Sep 09 ]

Moved to ZBXNEXT, again.
Please be careful next time

Comment by Oleksii Zagorskyi [ 2013 Sep 09 ]

hmm, currently is possible to redefine on host level the Filter macro and its value for templated LLD rules.
It should resolve your first two sentences.

or ... you are trying to use the user macro "{$IFNAME_RE}" as a value for the "Regexp" field in a LLD rule settings ?
According to https://www.zabbix.com/documentation/2.0/manual/appendix/macros/supported_by_location it's not supported.

I'm personally not very sure that would need to have such a possibility because as I said already we are allowed to redefine this value for templated rules.

Comment by Pavel [ 2013 Sep 09 ]

Usually I can tune and customize templated items/triggers on host level only by macros.
So I did not guess that I can redefine LLD filter on host level, sorry, I configure hosts mostly only by main tabs ("Host", "Templates", "Macros" etc).
Yes, redefining LLD filter at host level solve the issue, thanks.
Using macro as regex whould be bit more convenient but I'm not sure it should be implemented, this feature request has low priority as for me.

Comment by Oleksii Zagorskyi [ 2013 Sep 09 ]

Thanks, then I'm updating the issue summary to reflect exact idea.
Let's leave to someone else a chance to close this issue (if will be required)

Comment by richlv [ 2013 Sep 09 ]

sounds potentially useful to me, i'd leave this one open

Comment by Andrey Melnikov [ 2013 Dec 05 ]

Simple patch for v2.2

Comment by Tatapoum [ 2014 Aug 28 ]

Hi,
Could you include this patch in the next release ?
I see two advantages fot this feature :

  • it's always better to use macros than fixed values
  • if you modify the discovery rule in the template, the regex value could be overwritten on all hosts. If the customized regex rules were defined before at the host level, everything is lost. If you set a macro at the host level representing the regex filter, you can just use that.
Comment by Raymond Kuiper [ 2015 Sep 02 ]

Needing this also. I'd like to have a generic interface discovery rule in a template and target only the needed interfaces by supplying a macro on the host level.

One added request, can we keep the possibility to refer to a global regex from within the macro? That way I can use some globally defined sane defaults.

Comment by Valeriy Zabawski [ 2017 Sep 29 ]

Hello. Any updates?

Comment by Raymond Kuiper [ 2017 Sep 29 ]

Actually, this already sort of works in Zabbix 3.0.x (and probably above)!!

If you define a macro on a template like {$MY_LLD_FILTER} and make it's contents a regexp expression, you can then use that macro in the regexp field of the discovery filters. This allows for overriding the regexp on any l entities that link to this template (hosts and/or higher level templates).

What you unfortunately cannot do (AFAIK), is reference a global regexp from the filter, so you are limited to a single line of regexp and cannot do the more fancy things the global regexp logic allows you.

For me, this is fine in most cases as I can tune the macro on the hierarchical level where it is needed.

Comment by Raymond Kuiper [ 2017 Sep 29 ]

See slide 25 for an example:

https://www.zabbix.com/files/zabconf2016/raymond_kuiper-zen_and_the_art_of_zabbix_template_design.pdf

Comment by Alex Kalimulin [ 2022 Jan 13 ]

Supported since 2.3 (duplicate of ZBXNEXT-2256).

Generated at Thu Apr 25 22:04:18 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.