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
Article Comments
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
Jul, 2018 - Permalink
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
Jul, 2018 - Permalink
Hi, yes, that would be fine so we can manage which servicegroupname we want to monitor.
Regards Michael
Jul, 2018 - Permalink
Alright. I'll come up with the template throughout the day and post it here :)
Kind regards,
Stephan Linke, Tech Support Team
Jul, 2018 - Permalink
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
Jul, 2018 - Permalink
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
Jul, 2018 - Permalink
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
Jul, 2018 - Permalink