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

Rest API Custom Template using Lookup

Votes:

0

Hey guys. I would like help. I have an API where I want to collect the status. Contacting the return is a string, I am using the lookup but it is giving the error: Could no evaluate channel value of Status: expected type string for parameter 0 but got []interface {} Following is the complete Json return: { "http_method":"GET", "results":[ { "name":"LBVDC", "ldap_server":"LDAPDomain", "type":"fsso", "status":"connected", "active_server":"10.0.74.1" }, { "name":"Local FSSO Agent", "ldap_server":"", "type":"fsso", "status":"connected", "active_server":"127.0.0.1" }, { "id":1, "server":"10.100.41.31", "ldap_server":"LDAPBenef", "type":"fsso-polling", "status":"disconnected" } ], "vdom":"Internet", "path":"user", "name":"fsso", "status":"success", "serial":"FG5H0E3917902163", "version":"v6.4.3", "build":1778 } Here is the template created: { "prtg": { "result": [ { "channel": "Status", "value":lookup($.results[:1].status, "disconnected", "connected") } ] } }

json-templet prtg rest-api

Created on May 27, 2021 11:46:12 AM



1 Reply

Votes:

0

Hello Artur,

Thank you for your message.

Can you tell me if the number of items returned in the array results is dynamic ? If not, then you can use the following template to monitor the item which has the couple property/value "id":1 :

{
   "prtg":{
      "result":[
         {
            "channel": "Status",
            "value": lookup($.results[2].status, "connected")
         }
      ]
   }
}

You have the possibility to define a lookup file in the template as well, if you desire to display connected/disconnected in the channel. To do so, you need to add "ValueLookup": "lookupID" like this.

{
   "prtg":{
      "result":[
         {
            "channel": "Status",
            "value": lookup($.results[2].status, "connected")m
            "ValueLookup": "lookupID"
         }
      ]
   }
}

Here is the manual regarding custom lookup: https://www.paessler.com/manuals/prtg/define_lookups

Regards.

Created on May 28, 2021 8:09:44 AM by  Florian Lesage [Paessler Support]

Last change on May 28, 2021 8:13:10 AM by  Florian Lesage [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.