[ZBX-15966] {#LLDMACRO}.regsub not supported in key Created: 2019 Apr 10  Updated: 2024 Apr 10  Resolved: 2020 Apr 08

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Documentation (D)
Affects Version/s: 4.2.0
Fix Version/s: 5.0 (plan)

Type: Problem report Priority: Trivial
Reporter: Omni Flux Assignee: Marina Generalova
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Team D
Sprint: Sprint 63 (Apr 2020)

 Description   

Documentation leads me to believe regsub() should be supported in key field, but it is not.

Defining a key of 

mt.queue[sid.{{#NAME}.regsub("(.*)",\1)}]

results in a key of

mt.queue[sid.{ALPHA.regsub("(.*)",\1)}]

 

In the name field

{{#NAME}.regsub("(.*)",\1)}

results in

ALPHA

as expected.

 



 Comments   
Comment by Glebs Ivanovskis [ 2019 Apr 10 ]

Comma is not allowed in unquoted item key parameter, Zabbix interprets

mt.queue[sid.{{#NAME}.regsub("(.*)",\1)}]

as item mt.queue with two parameters:

sid.{{#NAME}.regsub("(.*)"

and

\1)}

Macros are resolved in each parameter independently, there is no surprise that it does not give the result you expect.

You need to quote the parameter like so:

mt.queue["sid.{{#NAME}.regsub(\"(.*)\",\1)}"]
Comment by Omni Flux [ 2019 Apr 10 ]

I see this is well documented now that you have supplied a link. Can we get an example in the LLD macros page that shows this?

Something like given
{#IFALIAS}=customername_1
Key:
net.if.cust"custid.{{#TARGET}.regsub(\".*_([0-9]+)\",\1)}"
 

Comment by Glebs Ivanovskis [ 2019 Apr 10 ]

That's a valid point. I hope that Zabbix team will listen to it.

You may also be interested in something like ZBXNEXT-3444.

Comment by Marina Generalova [ 2020 Mar 31 ]

Documentation updated:

Generated at Fri May 23 07:55:29 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.