[ZBX-21088] JSONPath cannot get keys instead of value Created: 2022 May 20 Updated: 2024 Apr 10 Resolved: 2022 Jun 13 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 6.0.3, 6.0.4 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Anonymouse | Assignee: | Konstantins Prutkovs (Inactive) |
Resolution: | Won't fix | Votes: | 0 |
Labels: | lld, macros | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() |
Team: |
Description |
Hello, I have a 1110 line JSON that I am referencing via an LLD Discovery Rule. There is an array in the JSON that is 3 elements long with a bunch of subsequent segments. Here is a snippet of my JSON, the array, keys, and segments I am referring to... Ultimately I want to grab the keys of each element [0,1,2]. I found I can accomplish this with *~ here... Here is a picture of it working in jsonpath.com... Here I am using it as an LLD Macro... But I get the following error message: Cannot process LLD macro "{#MACRO}": unsupported construct in jsonpath starting with: "~]". Is this a bug or limitation in Zabbix? Is there a different way to accomplish this? |
Comments |
Comment by Aigars Kadikis [ 2022 May 26 ] |
Thank you for reaching out. I can confirm that following input data: { "data": [ { "attr": { "name": "hello", "radio_bands": [ { "enabled_alarms": "1C00", "transceiver": 45.0 }, { "enabled_alarms": "1C00", "transceiver": 45.0 }, { "enabled_alarms": "0C00", "transceiver": 51.0 } ] } } ] } with JSONPath:
$..[?(@.name=="hello")].radio_bands[*~]
Works under https://jsonpath.com/ but does not work with Zabbix 6.0.4 JSONPath preprocessing engine: |
Comment by Anonymouse [ 2022 May 31 ] |
Try it with JSONPath:
$..[?(@.name=="hello")].radio_bands.*~
|
Comment by Konstantins Prutkovs (Inactive) [ 2022 Jun 13 ] |
Anonymouse aigars.kadikis it is possible to get the keys of the array elements with JsonPath in Zabbix. Namely:
$..[?(@.name=="hello")].radio_bands.*~
As per documentation of Zabbix:
This is the case as we do not support JsonPath Plus specification, but we do support the ~ extension. |