Hello all. We have Zabbix 5.0 LTS.
We obtain the following JSON data through a REST service:
We are using the following Preprocesing JSONPath:
And tried the following LLD Macros:
But neither works to assign the content of each element obtained in the JSON to a LLD macro.
(*) We have also tried using the rule without "first()" and "$.first()", but it discovers a single element whose macro value is ["host1","host2","host3","host4"].
How can I get the data for each element contained in the "availableHostnames" attribute so that each one creates a discovered item?
Tested combinations:
I attach test host: zbx_export_TEST LLD.xml
Thank you very much for your help.
We obtain the following JSON data through a REST service:
Code:
{
"content": [
{
"type": "TYPE",
"availableHostnames": [
"host1",
"host2",
"host3",
"host4"
]
}
]
}
Code:
$.content[?(@.type == "TYPE")].availableHostnames.first()
Code:
$.first() (0 items generated) $.[*] (0 items generated) $.. (error parsing JSONPath) $. (error parsing JSONPath)
(*) We have also tried using the rule without "first()" and "$.first()", but it discovers a single element whose macro value is ["host1","host2","host3","host4"].
How can I get the data for each element contained in the "availableHostnames" attribute so that each one creates a discovered item?
Tested combinations:
- Preprocessing step (JSONPath): $.content[?(@.type == "TYPE")].availableHostnames.first()
- LLD Macro {#TEST} (result):
- $. (Cannot process LLD macro "{#TEST}": jsonpath was unexpectedly terminated.).
- $.. (Cannot process LLD macro "{#TEST}": jsonpath was unexpectedly terminated.).
- $.first() (0 items created)
- (0 items created)Code:
$.[*]
- LLD Macro {#TEST} (result):
- Preprocessing step (JSONPath): $.content[?(@.type == "TYPE")].availableHostnames
- LLD Macro {#TEST} (result):
- (1 item created):Code:
$.[*]
- Ping ["host1","host2","host3","host4"] (icmpping["["host1","host2","host3","host4"]"])
- $.first() (1 item created):
- Ping host1 (icmpping[host1])
- LLD Macro {#TEST} (result):
I attach test host: zbx_export_TEST LLD.xml
Thank you very much for your help.
) so you probably should refer to inner one in LLD path as $.[0]. At least if I test here
Comment