What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

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

Create Channels dynamically based on JSON-Objects

Votes:

0

We want to monitor a loadbalancer via REST-API (Rest-Custom Sensor) and get a JSON Response like the following:

{
    "errorcode": 0,
    "message": "Done",
    "severity": "NONE",
    "servicegroup": [
        {
            "servicegroupname": "placeholder-text",
            "state": "ENABLED",
            "servicetype": "HTTP",
            "servicegroupmember": [
                {
                    "servicegroupname": "placeholder-text?SERVER01?80",
                    "port": 0,
                    "avgsvrttfb": "0",
                    "primaryipaddress": "x.x.x.64",
                    "primaryport": 80,
                    "servicetype": "HTTP",
                    "state": "UP",
                    "totalrequests": "3193139",
                    "requestsrate": 0,
                    "totalresponses": "3193031",
                    "responsesrate": 0,
                    "totalrequestbytes": "591593610",
                    "requestbytesrate": 10,
                    "totalresponsebytes": "3171602975",
                    "responsebytesrate": 26,
                    "curclntconnections": "1",
                    "surgecount": "0",
                    "cursrvrconnections": "6",
                    "svrestablishedconn": "6",
                    "curreusepool": "5",
                    "maxclients": "0"
                },
                {
                    "servicegroupname": "placeholder-text?SERVER02?80",
                    "port": 0,
                    "avgsvrttfb": "0",
                    "primaryipaddress": "x.x.x.65",
                    "primaryport": 80,
                    "servicetype": "HTTP",
                    "state": "DOWN",
                    "totalrequests": "3336147",
                    "requestsrate": 0,
                    "totalresponses": "3336045",
                    "responsesrate": 0,
                    "totalrequestbytes": "624119084",
                    "requestbytesrate": 0,
                    "totalresponsebytes": "3301098120",
                    "responsebytesrate": 0,
                    "curclntconnections": "0",
                    "surgecount": "0",
                    "cursrvrconnections": "0",
                    "svrestablishedconn": "0",
                    "curreusepool": "0",
                    "maxclients": "0"
                },
                {
                    "servicegroupname": "placeholder-text?SERVER10?80",
                    "port": 0,
                    "avgsvrttfb": "0",
                    "primaryipaddress": "x.x.x.73",
                    "primaryport": 80,
                    "servicetype": "HTTP",
                    "state": "DOWN",
                    "totalrequests": "2820384",
                    "requestsrate": 0,
                    "totalresponses": "2820282",
                    "responsesrate": 0,
                    "totalrequestbytes": "813913148",
                    "requestbytesrate": 0,
                    "totalresponsebytes": "2561866400",
                    "responsebytesrate": 0,
                    "curclntconnections": "0",
                    "surgecount": "0",
                    "cursrvrconnections": "0",
                    "svrestablishedconn": "0",
                    "curreusepool": "0",
                    "maxclients": "0"
                }
            ]
        }
    ]
}

We want to create the channels dynamically based on the number of members (servicegroupname) and the channels should have the name from the value "servicegroupname", these are the backend webservernames and the monitored value "requestrate" for example. How can we achieve this without creating a channel manually for every backend server. We want to reuse this template for other loadbalances services as well with more or less backend webservers.

We tried to build a query like this, but got no luck so far:

{
	"prtg": {
		"result": [{
				"unit": "Count",
				"value": {"host " + servicegroup.servicegroupmember[#0].servicegroupname: $.servicegroup.servicegroupmember[*].requestrate}
			}, ]
	}
}

Regards

json jsonpath rest-custom

Created on Jul 20, 2018 2:27:14 PM



8 Replies

Votes:

0

Hi there,

This should be possible using so-called mappings; I assume that you can define the servicegroupname in the API call and then get all corresponding servicegroupmembers?


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 23, 2018 7:57:26 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi, yes this is possible an leads to the posted JSON-Object earlier which is the response for a specific servicegroupname.

The details we are struggling with are: - A servicegroup "servicegroupname" can have multiple "servicegroupmembers" which we want to monitor and we want that the channels for each servicegroupmember are detected an created in the custom-REST-Sensor as channels.

Regards Michael

Created on Jul 23, 2018 8:13:24 AM



Votes:

0

But the caveat is that you need to add a sensor for a servicegroupname and it will be scanned accordingly for its servicegroupmember(s). Would that be fine with you?


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 23, 2018 8:28:27 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi, yes, that would be fine so we can manage which servicegroupname we want to monitor.

Regards Michael

Created on Jul 23, 2018 8:31:30 AM



Votes:

0

Alright. I'll come up with the template throughout the day and post it here :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 24, 2018 8:53:00 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Michael,

This is the corresponding line:

{
  "prtg": {
    "result": [
      {
        "value": { #1: $..({ @.servicegroupname : @.primaryport}).* }
      }
    ]
  }
}

Add other channels as you please with the corresponding channel settings :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 24, 2018 3:34:09 PM by  Stephan Linke [Paessler Support]



Votes:

0

Hi, that did the trick. That was exactly what I needed!

Thank you a lot!

Created on Jul 25, 2018 9:16:01 AM



Votes:

0

Nice that it's working :) Another example, if you require different naming schemes:

{
  "prtg": {
    "result": [
      {
        "value": {
            "["+ #1 +"]" + " primaryport": $..({ @.servicegroupname : @.primaryport}).*, 
            "["+ #1 +"]" + " totalrequests": $..({ @.servicegroupname : @.totalrequests}).*,
            "["+ #1 +"]" + " requestsrate": $..({ @.servicegroupname : @.requestsrate}).*,
            "["+ #1 +"]" + " totalresponses": $..({ @.servicegroupname : @.totalresponses}).*,
            "["+ #1 +"]" + " responsesrate": $..({ @.servicegroupname : @.responsesrate}).*,
            "["+ #1 +"]" + " totalrequestbytes": $..({ @.servicegroupname : @.totalrequestbytes}).*,
        }  
      }
    ]
  }
}

#1 always contains the servicegroupmembe property value.


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 25, 2018 9:22:21 AM by  Stephan Linke [Paessler Support]

Last change on Jul 25, 2018 10:59:33 AM by  Stephan Linke [Paessler Support]




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.