What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I get the REST Customer Sensor to monitor the number of nodes returned?

Votes:

0

Your Vote:

Up

Down

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://kb.paessler.com/en/topic/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.

channel rest rest-custom

Created on Dec 19, 2017 4:43:22 AM by  Jamie Imms (0) 1



3 Replies

Votes:

0

Your Vote:

Up

Down

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.

Created on Dec 19, 2017 1:33:54 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi Torsten, I am using the REST Custom Sensor

Created on Dec 20, 2017 12:32:21 AM by  Jamie Imms (0) 1

Last change on Dec 21, 2017 10:22:58 AM by  Luciano Lingnau [Paessler]



Votes:

0

Your Vote:

Up

Down

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]

Created on Dec 21, 2017 10:26:21 AM by  Luciano Lingnau [Paessler]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.