Hello all,

I am having trouble finding the right template for a Custom REST Sensor. I get a JSON response in the following format from an interface:

[
{
"server": "localhost",
"username":"\\\\localhost\c$\Users\Administrator",
}, "unit": "MB",
"usage":54.792147636413574}
,{
"server": "localhost"
, "username":"\\\\localhost\c$\Users\Administrator.AD",
}, "unit": "B",
"usage":54.792147636413574
}
]

where the number of different entries (2 in this example) is dynamic and sometimes more entries are returned. I have tried to work with this KB entry (https://helpdesk.paessler.com/en/support/solutions/articles/84810-dynamic-rest-custom-channel-name#reply-296379) and create my own template, but am completely unsuccessful so far. Maybe someone can give me a nudge in the right direction on how to implement this or if this is even possible?

Thanks a lot, PRTG91


Article Comments

Hello,

Thank you for your message.

To better help you here regarding the data you get, can you please tell us which information you would like to monitor with PRTG. Is the JSON response complete here ? If not, can you please provide the entire structure (without confidential information and reduced) as illustrated below:

{
...
key:[
{
"server": "localhost",
"username":"\\\\localhost\c$\Users\Administrator",
"unit": "MB",
"usage":54.792147636413574}
,{
"server": "localhost",
"username":"\\\\localhost\c$\Users\Administrator.AD",
"unit": "B",
"usage":54.792147636413574
}
]
}

Regards.


Oct, 2021 - Permalink

Hello @Florian Lesage,

yes the answer i posted above is complete. The number of Entries (how many servers) is dynamically so there can be 10 Entries like the one above but the format is 1:1 the Answer from the Server.

I want to monitor these fields:

- Servername ("server") - Username ("user") - Unit ("unit") - Usage ("usage")

Best Regards, Prtg91


Oct, 2021 - Permalink

Hello,

Thank you for the confirmation.

According to multiple JSON validator websites, I'm afraid that the JSON is invalid due characters not escaped properly in the paths provided by the key username and therefore can't be monitored with PRTG. Here is one of these websites where you can test it: https://jsonformatter.org/

To be valid, the JSON should look like the following:

[
	{
		"server": "localhost",
		"username": "\\\\localhost\\c$\\Users\\Administrator",
		"unit": "MB",
		"usage": 54.792147636413574
	},
	{
		"server": "localhost",
		"username": "\\\\localhost\\c$\\Users\\Administrator.AD",
		"unit": "B",
		"usage": 54.792147636413574
	}
]

Please, note that only the key usage could be monitored as well as this is a float value.

Regards.


Oct, 2021 - Permalink