[ZBX-20579] No macro expansion in Template > Discovery rule > Item Prototype Created: 2022 Feb 15 Updated: 2022 Feb 17 Resolved: 2022 Feb 17 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Frontend (F), Server (S) |
Affects Version/s: | 5.4.10 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Tobias Großmann | Assignee: | Aleksandrs Petrovs-Gavrilovs |
Resolution: | Commercial support required | Votes: | 0 |
Labels: | discovery, item, macros, prototype, rule | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() ![]() |
Description |
Hi there, I want to create a discovery rule and items based on a JSON file. The file looks like this:
[ { "service":"app1", "status":"running" }, { "service":"app2", "status":"running" }, { "service":"app3", "status":"running" } ]
Based on that I and to create an item for each service which returns the status. I made those steps:
Now after this is done, I would expect to get something like
But it doesn't work because the item prototype isn't expanding the macros. This is what I get as error in the Discovery rules tab in the host: So why is it not expanding my macros?
I was already searching for that problem and I already find related problems with "Zabbix trapper" items - but it does not apply here |
Comments |
Comment by Tobias Großmann [ 2022 Feb 15 ] |
Somehow it changed my source code in the description... Here is the correct code: LDD Macros: {#SERVICENAME} > $[*].["service"] {#STATUS} > $[*].["status"] Key: something[{#SERVICENAME}] But the problem is still there! |
Comment by Aleksandrs Petrovs-Gavrilovs [ 2022 Feb 17 ] |
Hello, Could you please try to use this path in LLD macros: $.service $.status
Otherwise i don't see a bug here, please let me know if I am missing something. Best Regards, |
Comment by Tobias Großmann [ 2022 Feb 17 ] |
Ohhh, now it adds the Macros and expands them. That JSONPath is weird... Now with this error... Preprocessing failed for: [{"service":"app1","status":"running"},{"service":"app2","status":"running"},{"service":... 1. Failed: cannot extract value from json by path "$..[?(@.service == '{#SERVICE}')].status": no data matches the specified path ... I realized that I wrote "SERVICE" instead of "SERVICENAME" in the JSONPath. Now it works like charm! Thank you for your help!!! PS: I found no way to check if the LLD macros are extraced correctly. Do you know how I can do it? And in generall if those macros can be applied in the item prototypes? |
Comment by Aleksandrs Petrovs-Gavrilovs [ 2022 Feb 17 ] |
Glad it helped, overall most JSON path evaluators should work, if it's a custom JSON, I would recommend to take a look in the documentation: But I'm afraid this issue is out of context for this tracker. Please be advised that this section of the tracker is for bug reports only. The case you have submitted can not be qualified as one, so please reach out to [email protected] |