Greetings,
I'm looking for help on how to generate sensors from the Aerohive REST API. I have this dataset and I want to use the REST Sensor in PRTG
I'd like each sensor to have the "hostName" as the name and the "clients" as the value for the sensor.
[
{
"audit": "Matched",
"hostName": "AP20",
"alarm": "Cleared",
"interfaceIp": "192.168.3.94",
"externalIp": "xxx.xxx.xxx.xxx",
"topologyName": "Our Address",
"nodeId": "9CXX1234BFXX",
"connection": true,
"deviceMode": "Portal",
"clients": 0,
"upTime": "1 Days, 18 Hrs 7 Mins 45 Secs",
"hiveOS": "HiveOS 6.6r1b.2338",
"deviceFunciton": "AP",
"appSignature": "4.0.8",
"countryCode": "(840) United States",
"defaultGateWay": "192.168.1.20",
"dhcpClient": "Enabled",
"discoveryTime": "09-03-2014 12:11:58",
"eth0LLDPPort": "37(interface alias)",
"eth0LLDPSysId": "e055:xxxx:xxxx(mac address)",
"eth0LLDPSysName": "Coreswitch2",
"eth1LLDPPort": "-",
"eth1LLDPSysId": "-",
"eth1LLDPSysName": "-",
"hive": "Out_Hive",
"inOrOutDoor": "Indoor",
"location": "B-2nd Floor",
"mgtVlan": "1",
"nativeVlan": "1",
"netmask": "255.255.248.0",
"networkPolicy": "Our Policy",
"serialNumber": "02301407XXXXX",
"wifi0Channel": "1",
"wifi0Power": "11 dBm",
"wifi0RadioProfile": "radio_ng0",
"wifi1Channel": "44",
"wifi1Power": "20 dBm",
"wifi1RadioProfile": "radio_ac0",
"hwmodel": "AP230"
},
{
"audit": "Matched",
"hostName": "AP21",
"alarm": "Cleared",
"interfaceIp": "192.168.3.94",
"externalIp": "xxx.xxx.xxx.xxx",
"topologyName": "Our Address",
"nodeId": "9CXX1234BFXX",
"connection": true,
"deviceMode": "Portal",
"clients": 4,
"upTime": "1 Days, 18 Hrs 7 Mins 26 Secs",
"hiveOS": "HiveOS 6.6r1b.2338",
"deviceFunciton": "AP",
"appSignature": "4.0.8",
"countryCode": "(840) United States",
"defaultGateWay": "192.168.1.20",
"dhcpClient": "Enabled",
"discoveryTime": "09-03-2014 15:31:40",
"eth0LLDPPort": "40(interface alias)",
"eth0LLDPSysId": "e055:3dfc:55f2(mac address)",
"eth0LLDPSysName": "Coreswitch2",
"eth1LLDPPort": "-",
"eth1LLDPSysId": "-",
"eth1LLDPSysName": "-",
"hive": "Our_Hive",
"inOrOutDoor": "Indoor",
"location": "B-2nd Floor",
"mgtVlan": "1",
"nativeVlan": "1",
"netmask": "255.255.248.0",
"networkPolicy": "Our Policy",
"serialNumber": "02301407090105",
"wifi0Channel": "11",
"wifi0Power": "11 dBm",
"wifi0RadioProfile": "radio_ng0",
"wifi1Channel": "149",
"wifi1Power": "20 dBm",
"wifi1RadioProfile": "radio_ac0",
"hwmodel": "AP230"
}
]
Article Comments
hi jason , can you please share the result of the template and hes output , i really need to verify which filed and how you present it .
will be great help , thx, Dor.
Jun, 2018 - Permalink
So in my case, I have REST Query return below JSON and I want to create a template so that sensor has values for name, connectionType, connectionStatus, ingressBytesTransferred, and egressBytesTransferred.
{ "name": "GATEWAYA-CORPNET", "id": "/subscriptions/0if966538-zxxc-1tl0-qz2t-yn750x36pvn/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/connections/GATEWAYA-CORPNET", "etag": "W/\"lscitbit6-4xhq-cpik-5ne1-b4gh8vg41og\"", "type": "Microsoft.Network/connections", "location": "westus", "properties": { "provisioningState": "Succeeded", "resourceGuid": "chov25ovl-blrw-j5lo-zg9p-3drw1869azf", "virtualNetworkGateway1": { "id": "/subscriptions/0if966538-zxxc-1tl0-qz2t-yn750x36pvn/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/virtualNetworkGateways/GATEWAYA" }, "localNetworkGateway2": { "id": "/subscriptions/0if966538-zxxc-1tl0-qz2t-yn750x36pvn/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/localNetworkGateways/CORPNET" }, "connectionType": "IPsec", "routingWeight": 0, "sharedKey": "zvxx5z1gqadn8fglcdj6vx9nh2znwsaa", "enableBgp": false, "usePolicyBasedTrafficSelectors": false, "ipsecPolicies": [], "connectionStatus": "Connected", "ingressBytesTransferred": 6934594856, "egressBytesTransferred": 11377914688 } }
How do I accomplish this? I am having issue with unit and value in my template. Here is my template.
{
"prtg": {
"description" : {
"device": "Azure Virtual Network Gateway Connection",
"query": "GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}?api-version=2018-04-01",
"comment": "Documentation is on https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections/get"
},
"result": [
{
"channel": "ingressBytesTransferred",
"unit": "BytesBandwidth",
"value": $.properties.ingressBytesTransferred
},
{
"channel": "egressBytesTransferred",
"unit": "BytesBandwidth",
"value": $.properties.ingressBytesTransferred
},
{
"channel": "connectionType",
"unit": "custom",
"CustomUnit": (string),
"value": $.properties.connectionType
}
]
}
}
Aug, 2018 - Permalink
Well, PRTG cannot evaluate strings, you'll need to use lookups instead:
{ "channel": "connectionType", "unit": "count", "lookup": "name.of.your.lookup" "value": lookup($.properties.connectionType, "enter", "all", "available","connection","types") }
According to the value, it will be 0 to x, depending on how many values are possible. Additionally, you'll need to reference the lookup accordingly:
https://www.paessler.com/manuals/prtg/define_lookups
Aug, 2018 - Permalink
Can you please validate my syntax? I am getting a parsing error when creating a sensor. Following is my template
azure.VirtualNetworkGatewayConnection.template
{ "prtg": { "description" : { "device": "Azure Virtual Network Gateway Connection", "query": "GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}?api-version=2018-04-01", "comment": "Documentation is on https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections/get" }, "result": [ { "channel": "ingressBytesTransferred", "unit": "BytesBandwidth", "value": $.properties.ingressBytesTransferred }, { "channel": "egressBytesTransferred", "unit": "BytesBandwidth", "value": $.properties.ingressBytesTransferred }, { "channel": "connectionType", "unit": "count", "lookup": "azure.VirtualNetworkGatewayConnection.connectionType", "value": lookup($.properties.connectionType, "Ipsec", "Vnet2Vnet", "ExpressRoute", "VPNClient") }, { "channel": "connectionStatus", "unit": "count", "lookup": "azure.VirtualNetworkGatewayConnection.connectionStatus", "value": lookup($.properties.connectionStatus, "Unknown", "Connecting", "Connected" and "NotConnected") } ] } }
And my lookup files are as following...
azure.VirtualNetworkGatewayConnection.connectionStatus.ovl
<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionStatus" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="Connected" value="0"> The connection has successfully connected. </SingleInt> <SingleInt state="Connecting" value="1"> The connection is connected. </SingleInt> <SingleInt state="NotConnected" value="2"> The connection is not connected. </SingleInt> <SingleInt state="Unknown" value="3"> The connection is in unknown state. </SingleInt> </Lookups> </ValueLookup>
azure.VirtualNetworkGatewayConnection.connectionType.ovl
<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionType" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="Ipsec" value="0"> This is a site-to-site IPSec vpn connection. </SingleInt> <SingleInt state="Vnet2Vnet" value="1"> This is a vnet-to-vnet vpn connection. </SingleInt> <SingleInt state="ExpressRoute" value="2"> This is a ExpressRoute vpn connection. </SingleInt> <SingleInt state="VPNClient" value="3"> This is a Point-to-Site vpn connection. </SingleInt> </Lookups> </ValueLookup>
Aug, 2018 - Permalink
Two mistakes were made:
- it's valuelookup instead of value in the .template file
- The channel lookup of the connectionStatus channel needs to be this:
"value": lookup($.properties.connectionStatus, "Unknown", "Connecting", "Connected", "NotConnected")
You have added an and, which doesn't belong there ;)
Kind regards,
Stephan Linke, Tech Support Team
Aug, 2018 - Permalink
Do you mean valuelookup instead of lookup or valuelookup instead of value? Also in the Aerohive dataset above, if I wanted to get the "hiveOS": "HiveOS 6.6r1b.2338" value, it would be a same issue as mine where PRTG cannot evaluate strings, correct?
Aug, 2018 - Permalink
After using following for connectionStatus…
{ "channel": "connectionType", "unit": "count", "valuelookup": "azure.VirtualNetworkGatewayConnection.connectionType", "value": lookup($.properties.connectionType, "Ipsec", "Vnet2Vnet", "ExpressRoute", "VPNClient") }
I still get Could not create channel connectionType: expected number but got IPsec (string). error
Aug, 2018 - Permalink
Both of my lookups are stored in lookups\custom folder and after refreshing Load Lookups and File Lists in PRTG Admin Tools the lookup files are not loading.
My lookup files syntax is simple copy/paste modification of the original prtg lookup files
<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionStatus" desiredValue="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="Connected" value="2"> Connected </SingleInt> <SingleInt state="Connecting" value="1"> Connecting </SingleInt> <SingleInt state="NotConnected" value="0"> NotConnected </SingleInt> <SingleInt state="None" value="3"> Unknown </SingleInt> </Lookups> </ValueLookup>
<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionType" desiredValue="-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="IPSec" value="-1"> IPSec </SingleInt> <SingleInt state="Vnet2Vnet" value="1"> Vnet2Vnet </SingleInt> <SingleInt state="ExpressRoute" value="2"> ExpressRoute </SingleInt> <SingleInt state="VPNClient" value="3"> VPNClient </SingleInt> </Lookups> </ValueLookup>
Aug, 2018 - Permalink
What actual error do you get within the Sensor? What does your whole .template look like? I actually meant valuelookup instead of just lookup :)
Kind regards,
Stephan Linke, Tech Support Team
Aug, 2018 - Permalink
My .template looks like this...
azure.VirtualNetworkGatewayConnection.template
{ "prtg": { "description" : { "device": "Azure Virtual Network Gateway Connection", "query": "GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}?api-version=2018-04-01", "comment": "Documentation is on https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections/get" }, "result": [ { "channel": "ingressBytesTransferred", "unit": "BytesBandwidth", "value": $.properties.ingressBytesTransferred }, { "channel": "egressBytesTransferred", "unit": "BytesBandwidth", "value": $.properties.ingressBytesTransferred }, { "channel": "connectionType", "unit": "count", "valueLookup": "azure.VirtualNetworkGatewayConnection.connectionType", "value": lookup($.properties.connectionType,"IPsec", "Vnet2Vnet", "ExpressRoute", "VPNClient") }, { "channel": "connectionStatus", "unit": "count", "valueLookup": "azure.VirtualNetworkGatewayConnection.connectionStatus", "value": lookup($.properties.connectionStatus, "Unknown", "Connecting", "Connected", "NotConnected") } ] } }
azure.VirtualNetworkGatewayConnection.connectionType.ovl
<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionType" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="IPSec" value="0"> IPSec </SingleInt> <SingleInt state="Vnet2Vnet" value="1"> Vnet2Vnet </SingleInt> <SingleInt state="ExpressRoute" value="2"> ExpressRoute </SingleInt> <SingleInt state="VPNClient" value="3"> VPNClient </SingleInt> </Lookups> </ValueLookup>
azure.VirtualNetworkGatewayConnection.connectionStatus.ovl
<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="azure.VirtualNetworkGatewayConnection.connectionStatus" desiredValue="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="NotConnected" value="0"> NotConnected </SingleInt> <SingleInt state="Connecting" value="1"> Connecting </SingleInt> <SingleInt state="Connected" value="2"> Connected </SingleInt> <SingleInt state="Unknown" value="3"> Unknown </SingleInt> </Lookups> </ValueLookup>
I don't get an error. I just can't reload the lookup to get the right value in PRTG console. All I get is 2 for connectionStatus and 0 or 1 for connectionType. I want PRTG to show GatewayConnectionName, ConnectionStatus, ConnectionType, ingressBytesTransferred and egressBytesTransferred.
Aug, 2018 - Permalink
Hi Jason,
You need to create a template that contains the definition of the data you want to retrieve:
Keep in mind that you might need to take of authentication with a token maybe, see here the documentation of the Aerohive REST API.
Kind regards,
Erhard
Feb, 2018 - Permalink