I'm going to make host LLD from JSON-over-HTTP data. The issue looks quite simple, but.. I receive a SyntaxError from my Zabbix 6.4.8
and I have no idea whether the error relates to JS-preprocessing, the JSON, or just a bug.. or what I am doing wrong?
I've tested my preprocessing with https://www.jdoodle.com/ia/R5G
The JSON document passes validation on https://jsonformatter.org/json-parser/af2e0e, I pastebined it https://pastebin.com/raw/ijH5kacA and this URL is hardcoded in this test template:
Can you please check whats wrong?
Code:
Preprocessing failed for: [.. {.. "Id": "48edc41c-0000-0000-ac7b-58cc77c9092d",.. "Name": "F-12",.. "Type": "Farm...
1. Failed: SyntaxError: parse error (line 3)
I've tested my preprocessing with https://www.jdoodle.com/ia/R5G
The JSON document passes validation on https://jsonformatter.org/json-parser/af2e0e, I pastebined it https://pastebin.com/raw/ijH5kacA and this URL is hardcoded in this test template:
Code:
zabbix_export:
version: '6.4'
template_groups:
- uuid: ea8da0a2b67548b2984e3db9e32283e3
name: Templates/Test
host_groups:
- uuid: c0b64a45e6b344b38576b90e0823dfba
name: Test
templates:
- uuid: 7f897c9d7a894e709a1de601260ae373
template: 'Test Preprocessing failed SyntaxError'
name: 'Test Preprocessing failed SyntaxError'
groups:
- name: Templates/Test
discovery_rules:
- uuid: f759f7fa15c14a72895b293bcc3c8c8d
name: Houses
type: HTTP_AGENT
key: houses
host_prototypes:
- uuid: a5bdda6c16b8408ebe116cb34b824302
host: '{#LOCATION_ID}'
name: '{#LOCATION_NAME}'
group_links:
- group:
name: Test
url: 'https://pastebin.com/raw/ijH5kacA'
lld_macro_paths:
- lld_macro: '{#LOCATION_ID}'
path: $.Id
- lld_macro: '{#LOCATION_NAME}'
path: $.Name
preprocessing:
- type: JAVASCRIPT
parameters:
- |
// Get Houses Id and Name
var params = JSON.parse(value)
return JSON.stringify(params[0].Children.map((house) => ({"Id": house.Id, "Name": house.Name})))
- type: STR_REPLACE
parameters:
- /
- .
Comment