I'm trying to use the Rest Custom sensor (along with a sensor template) to pull some data from a JSON feed but it's failing to do with with "Invalid character 'N' looking for beginning of value body".

Now this is a fair cop as some of the JSON values are strings but not in quotes... eg. the 'NaN' value in the middle of:

{ "Collected Data": 6449.0, "Instance Name": NaN, "Time Stamp": "2020-05-29:11-47-40" }

While I realise this is where the mistake lies it's coming from a VMWare product and they're not likely to change it any time soon. I was wondering if there was a simple work-around? Maybe PRTG can be made to just ignore this and parse the file anyway... as the rest of it is fine and should be queryable... or do I have to somehow pre-process the file to find/replace the error (which is identically repeated throughout the file)?

Any assistance gratefully received.


Article Comments

Hello,

I'm afraid there's no nativ solution or known simple workaround in this case. :/ The JSON needs to be valid for PRTG to process it.


Jun, 2020 - Permalink

Thank you very much for your reply Timo. I had a feeling that might be the case. Would you have any advise as to how the file might be pre-processed? I can imagine that a little powershell script could do a find/replace to put quotes around all instances of 'NaN' but is there a way a sensor can be made to run a script before performing its scan?


Jun, 2020 - Permalink

A sensor cannot directly be made to run a script before running a scan, you can however use a second Custom EXE sensor or windows automated tasks for example to run the script automatically. It might also be helpful to Set Specific Points in Time as a Scanning Time for Sensors.


Jun, 2020 - Permalink

Thank you for the advise Timo. I'll give it a try (while I have a call logged with VMWare to investigate).


Jun, 2020 - Permalink