Hi,

I want PRTG to monitor an API (via a GET) and have a channel plot the number of results returned, so I can track licensing restrictions.

So when I run the query on day 1, the JSON returned would be like:

[ { "id": "1001", "value": "Lorem" }, { "id": "1002", "value": "ipsum" } ]

And the value plotted in the Channel should be 2.

On day 2, the JSON returned would be:

[ { "id": "1001", "value": "Lorem" }, { "id": "1002", "value": "ipsum" }, { "id": "1003", "value": "dolor" } ]

And the value plotted in the Channel should be 3.

I tried doing a node count with the HTTP XML/REST Value, but according to https://helpdesk.paessler.com/en/support/solutions/articles/32703-parse-json-array it is unable to parse valid JSON arrays.

I imagine this would have something to do with a REST configuration file, but I'm not sure how to do counts in that.


Article Comments

Dear Jamie,

Thank you for the KB-Post. Which exact sensor are you using here? Bear in mind, values have to be numerical for PRTG. It cannot use string results.

best regards.


Dec, 2017 - Permalink

Hi Torsten, I am using the REST Custom Sensor


Dec, 2017 - Permalink

Hello Jamie,
thank you for your reply.

According to the responsible developer this is doable with something like the following template:

{
  "prtg": {
    "description" : {
      "device": "rest_test",
      "query": "https://jsonplaceholder.typicode.com/todos.json",
      "comment": "Demo Demo"
    },
    "result": [
     {
          "channel": "Total count" ,
          "value": len($.*),
          "unit": "Count"
    }
    ]
  }
}
len()returns the count of entries and he just have to use the root element with $.* for all elements

For a complete list of functions that can be used in the sensor please refer to:

Best Regards,
Luciano Lingnau [Paessler Support]


Dec, 2017 - Permalink