Hello,

We are using PRTG Version 17.4.33.3283+ and we have a lot of different websites we like to monitor with the REST Custom Sensor...

our websites response the health status in JSON like this but all with different services we like to check:

{"meta":{"status":["OK","NOK"],"statusCode":[0,-1]},"data":{"lastUpdated":"2018-04-30T06:53:32.962Z","overall":"OK","overallCode":0,"bundles":{"group":"OK","numTotal":242,"numActive":239,"numInstalled":0,"numResolved":3,"numFailure":0},"services":{"group":"OK","sismedia":"OK","solr":"OK","kachelmann":"OK","geotracks":"OK"}}}

so we did a JSON File in the custom file path to look for all services and convert the status from OK or NOK to 0 and 1

 {
    "prtg": {
      "result": [
        {
          "channel": "Status" ,
          "value": $.meta.statusCode
        },
        {
          "channel": "Overall",
          "value": $.data.overallCode
        },
        {
          "value": {lookup($.data.services.*, "OK", "NOK")}
        }
      ]
    }
  }

sadly , we get back an error could not load config: invalid character '$' looking for beginning of value

someone have an idea what we are doing wrong?

Thank you


Article Comments

Hi there,

Please note that the sensor got updated in the recent versions which also changed the definition templates. You are currently using the new syntax, which will not work with the old sensor. Therefore please upgrade PRTG to a more recent version (better the most recent) and the template should work fine.

Best regards.


Apr, 2018 - Permalink

thanks for reply! is there a way to use it in the old version? is the manual archived for the old version? we could not upgrade actually (need to test before with my colleagues from the pbx team)


Apr, 2018 - Permalink

Hi there,

You should be able to find the old documentation within your webinterface under:

/help/rest_custom_sensor.htm


Best regards.


Apr, 2018 - Permalink

awesome! thanks alot...

just struggling with Comparators,,, i like to have dynamic channel but without one string "group" done this so far:

"channel": "{data.bundles(?"!= 'data.bundles.group'")}",

any idea?


Apr, 2018 - Permalink

Hi there,

Could you post the monitored JSON and explain what you want to achieve or what you want to monitor specifically?

Best regards.


Apr, 2018 - Permalink

This is my json, who i like to Monitor:

{
"meta":
	{ 
		"status":["OK","NOK"],
		"statusCode":[0,-1]
	},
		"data":
	{
		"lastUpdated":"2017-12-11T13:33:08.039Z",
		"overall":"OK",
		"overallCode":0,
		"bundles":
			{
				"group":"OK",
				"numTotal":240,
				"numActive":237,
				"numInstalled":0,
				"numResolved":3,
				"numFailure":0
			},
		"services":
			{
				"group":"OK",
				"sismedia":"OK",
				"solr":"OK",
				"kachelmann":"OK",
				"geotracks":"OK"
			}
	}
}

And my Template Looks like this

   {
  "Text": "status",
	"prtg": {
	  "description" : 
	{
      "device": "Stringcheck",
      "comment": "For PRTG Version 17.4.33.3283"
    },
      "result": [
        {
          "channel": "Overall",
          "value": "data.overallCode"
        },
		{
          "channel": "Last Updated",
          "value": "duration({data.lastUpdated}, now())"
        },
	{
		  "channel": "Group Bundles Status",
          "value": "lookup({data.bundles.group}, 'OK')"
		},
			{
		  "channel": "Bundles numTotal",
          "value": "{data.bundles.numTotal}"
		},
		{
		  "channel": "Bundles numActive",
          "value": "{data.bundles.numActive}"
		},
				{
		  "channel": "Bundles numInstalled",
          "value": "{data.bundles.numInstalled}"
		},
				{
		  "channel": "Bundles numResolved",
          "value": "{data.bundles.numResolved}"
		},
				{
		  "channel": "Bundles numFailure",
          "value": "{data.bundles.numFailure}"
		},
		{
		  "channel": "{data.services}",
          "value": "lookup('OK')"
		}
      ]
    }
  }

Actually i'm struggling at 2 Points: - i like to have the string "bundles" dynamicly but there is Group who Returns an OK and the others are number... in my Code above i changed it to seperated channels because i have no idea how to make a filter in this case

- where i struggle most is on the "Services" part... i like to have them dynamic because in future we like to Monitor different Websites allways whit the same template... the site will respone OK or NOK so i tried to do a dynamic channel with a lookup function that check if the Service is ok (0) or NOK (-1)


Apr, 2018 - Permalink

Hi there,

I added the template in the newest version of PRTG and the sensor is created fine including the dynamic channels for the "services"-part. As mentioned, we can't really support the older version as the newer ones have further options and works better overall. It might be also the case that you have to touch the template again, once it is working with the older version.

I would recommend to setup a trial with the latest version of PRTG and creating the sensor within this trial/freeware so you can see if it works better now with the new documentation:
https://www.paessler.com/download/prtg-download

Best regards.


May, 2018 - Permalink

i came back here because i'm testing on a newer version... i have following json response:

{
	"meta":
	{
		"status":
		[
			"OK","NOK"
		],
		"statusCode":[0,-1]},
		"data":
			{
			"lastUpdated":"2018-09-11T10:54:54.043Z",
			"overall":"OK",
			"overallCode":0,
			"bundles":
				{
					"group":"OK",
					"numTotal":236,
					"numActive":233,
					"numInstalled":0,
					"numResolved":3,
					"numFailure":0
				}			,
			"services":
				{
					"group":"OK",
					"sismedia":"OK",
					"solr":"OK",
					"kachelmann":"OK",
					"geotracks":"OK"
				}
			}
}

and this prtg rest custom sensor json template:

{
    "prtg": {
      "result": [
        {
          "channel": "Status" ,
          "value": $.meta.statusCode
        },
        {
          "channel": "Overall",
          "value": $.data.overallCode
        },
        {
          "value": {lookup($.data.services.*, "OK", "NOK")}
        }
      ]
    }
  }

in my eyes it looks good, but my dynamic "data.services" Channels get following error:

Parsing error: { "prtg": { "result": [ { "channel": "Status" , "value": $.meta.statusCode }, { "channel": "Overall", "value": $.data.overallCode }, { "value": {lookup($.data.services.*, "OK", "NOK")} } ] } } :14:9 - 14:10 unexpected "}" while scanning extensions.


Sep, 2018 - Permalink

Hi there,

I might have found the reason, why did you put the curly brackets around the lookup? Please try:

{
    "prtg": {
      "result": [
        {
          "channel": "Status" ,
          "value": $.meta.statusCode
        },
        {
          "channel": "Overall",
          "value": $.data.overallCode
        },
        {
          "value": lookup($.data.services.*, "OK", "NOK")
        }
      ]
    }
  }

Does that work?

Best regards.


Sep, 2018 - Permalink

I tested it and get following error now:

Could no evaluate channel value: expected type string for parameter 0 but got []interface {}.


Sep, 2018 - Permalink

Hi there,

Now I get what you try. Unfortunately, that is not possible as the following part you request is not an array:

		"services": {
			"group": "OK",
			"sismedia": "OK",
			"solr": "OK",
			"kachelmann": "OK",
			"geotracks": "OK"
		}

Therefore PRTG can't iterate through these items and they need to be specified one by one.

Best regards.


Sep, 2018 - Permalink