Hello, I'm creating a sensor using Rest Custom to capture the information through JsonPath expression. I noticed that when I create a template to filter the result of a line that contains separator "-" PRTG cannot bring the result, it seems that the character "-" breaks the index. Is there a parameter to prevent PRTG from understanding the "-" as a separator? I already tried: " ", ' ', { }, [ ] but none worked. Here are the details of the sensor I'm trying to create: Input:

{
  "http_method":"GET",
  "revision":"2c2bdb3c2febfa34863b8339b441a074",
  "results":[
    {
      "name":"port0",
      "q_origin_key":"port0",
      "vdom":"root",
      "vrf":0,
      "cli-conn-status":0,
      "fortilink":"disable",
      "switch-controller-source-ip":"outbound",
      "mode":"static",
      "client-options":[
      ],
      "distance":5,
      "priority":1,
      "dhcp-relay-interface-select-method":"auto",
      "dhcp-relay-interface":"",
      "dhcp-relay-service":"disable",
      "dhcp-relay-ip":"",
      "dhcp-relay-link-selection":"0.0.0.0",
      "dhcp-relay-request-all-server":"disable",
      "dhcp-relay-type":"regular",
      "dhcp-relay-agent-option":"enable",
      "dhcp-classless-route-addition":"enable",
      "management-ip":"0.0.0.0 0.0.0.0",
      "ip":"0.0.0.0 255.255.255.0",
      "allowaccess":"ping https ssh snmp speed-test",
      "gwdetect":"disable",
      "ping-serv-status":0,
      "detectserver":"",
      "detectprotocol":"ping",
      "ha-priority":1,
      "fail-detect":"disable",
      "fail-detect-option":"link-down",
      "fail-alert-method":"link-down",
      "fail-action-on-extender":"soft-restart",
      "fail-alert-interfaces":[
      ],
      "dhcp-client-identifier":"",
      "dhcp-renew-time":0,
      "ipunnumbered":"0.0.0.0",
      "username":"",
      "pppoe-unnumbered-negotiate":"enable",
      "password":"",
      "idle-timeout":0,
      "detected-peer-mtu":0,
      "disc-retry-timeout":1,
      "padt-retry-timeout":1,
      "service-name":"",
      "ac-name":"",
      "lcp-echo-interval":5,
      "lcp-max-echo-fails":3,
      "defaultgw":"enable",
      "dns-server-override":"enable",
      "dns-server-protocol":"cleartext",
      "auth-type":"auto",
      "pptp-client":"disable",
      "pptp-user":"",
      "pptp-password":"",
      "pptp-server-ip":"0.0.0.0",
      "pptp-auth-type":"auto",
      "pptp-timeout":0,
      "arpforward":"enable",
      "ndiscforward":"enable",
      "broadcast-forward":"disable",
      "bfd":"global",
      "bfd-desired-min-tx":250,
      "bfd-detect-mult":3,
      "bfd-required-min-rx":250,
      "l2forward":"disable",
      "icmp-send-redirect":"enable",
      "icmp-accept-redirect":"enable",
      "reachable-time":30000,
      "vlanforward":"disable",
      "stpforward":"disable",
      "stpforward-mode":"rpl-all-ext-id",
      "ips-sniffer-mode":"disable",
      "ident-accept":"disable",
      "ipmac":"disable",
      "subst":"disable",
      "macaddr":"",
      "substitute-dst-mac":"00:00:00:00:00:00",
      "speed":"auto",
      "status":"up",
      "netbios-forward":"disable",
      "wins-ip":"0.0.0.0",
      "type":"physical",
      "dedicated-to":"none",
      "trust-ip-1":"0.0.0.0 0.0.0.0",
      "trust-ip-2":"0.0.0.0 0.0.0.0",
      "trust-ip-3":"0.0.0.0 0.0.0.0",
      "trust-ip6-1":"::\/0",
      "trust-ip6-2":"::\/0",
      "trust-ip6-3":"::\/0",
      "mtu-override":"disable",
      "mtu":1500,
      "ring-rx":0,
      "ring-tx":0,
      "wccp":"disable",
      "netflow-sampler":"disable",
      "sflow-sampler":"disable",
      "drop-overlapped-fragment":"disable",
      "drop-fragment":"disable",
      "src-check":"enable",
      "sample-rate":2000,
      "polling-interval":20,
      "sample-direction":"both",
      "explicit-web-proxy":"disable",
      "explicit-ftp-proxy":"disable",
      "proxy-captive-portal":"disable",
      "tcp-mss":0,
      "inbandwidth":0,
      "outbandwidth":0,
      "egress-shaping-profile":"",
      "ingress-shaping-profile":"",
      "disconnect-threshold":0,
      "spillover-threshold":0,
      "ingress-spillover-threshold":0,
      "weight":0,
      "interface":"",
      "external":"disable",
      "vlan-protocol":"8021q",
      "vlanid":0,
      "forward-domain":0,
      "remote-ip":"0.0.0.0 0.0.0.0",
      "member":[
      ],
      "lacp-mode":"active",
      "lacp-ha-slave":"enable",
      "system-id-type":"auto",
      "system-id":"00:00:00:00:00:00",
      "lacp-speed":"slow",
      "min-links":1,
      "min-links-down":"operational",
      "algorithm":"L4",
      "link-up-delay":50,
      "priority-override":"enable",
      "devindex":5,
      "vindex":0,
      "description":"",
      "alias":"WAN",
      "security-mode":"none",
      "captive-portal":0,
      "security-mac-auth-bypass":"disable",
      "security-external-web":"",
      "security-external-logout":"",
      "replacemsg-override-group":"",
      "security-redirect-url":"",
      "auth-cert":"",
      "auth-portal-addr":"",
      "security-exempt-list":"",
      "security-groups":[
      ],
      "ike-saml-server":"",
      "device-identification":"disable",
      "device-user-identification":"enable",
      "lldp-reception":"enable",
      "lldp-transmission":"vdom",
      "lldp-network-policy":"",
      "estimated-upstream-bandwidth":7792,
      "estimated-downstream-bandwidth":15522,
      "measured-upstream-bandwidth":7792,
      "measured-downstream-bandwidth":15522,
      "bandwidth-measure-time":1656709947,
      "monitor-bandwidth":"disable",
      "vrrp-virtual-mac":"disable",
      "vrrp":[
      ],
      "role":"wan",
      "snmp-index":4,
      "secondary-IP":"disable",
      "secondaryip":[
      ],
      "preserve-session-route":"disable",
      "auto-auth-extension-device":"disable",
      "ap-discover":"enable",
      "fortilink-neighbor-detect":"fortilink",
      "ip-managed-by-fortiipam":"disable",
      "managed-subnetwork-size":"256",
      "fortilink-split-interface":"enable",
      "internal":0,
      "fortilink-backup-link":0,
      "switch-controller-access-vlan":"disable",
      "switch-controller-traffic-policy":"",
      "switch-controller-rspan-mode":"disable",
      "switch-controller-mgmt-vlan":4094,
      "switch-controller-igmp-snooping":"disable",
      "switch-controller-igmp-snooping-proxy":"disable",
      "switch-controller-igmp-snooping-fast-leave":"disable",
      "switch-controller-dhcp-snooping":"disable",
      "switch-controller-dhcp-snooping-verify-mac":"disable",
      "switch-controller-dhcp-snooping-option82":"disable",
      "dhcp-snooping-server-list":[
      ],
      "switch-controller-arp-inspection":"disable",
      "switch-controller-learning-limit":0,
      "switch-controller-nac":"",
      "switch-controller-dynamic":"",
      "switch-controller-feature":"none",
      "switch-controller-iot-scanning":"disable",
      "swc-vlan":0,
      "swc-first-create":0,
      "color":0,
      "tagging":[
      ],
      "eap-supplicant":"disable",
      "eap-method":"",
      "eap-identity":"",
      "eap-password":"",
      "eap-ca-cert":"",
      "eap-user-cert":"",
      "ipv6":{
        "ip6-mode":"static",
        "nd-mode":"basic",
        "nd-cert":"",
        "nd-security-level":0,
        "nd-timestamp-delta":300,
        "nd-timestamp-fuzz":1,
        "nd-cga-modifier":"0065636473612D776974682D73686132",
        "ip6-dns-server-override":"enable",
        "ip6-address":"::\/0",
        "ip6-extra-addr":[
        ],
        "ip6-allowaccess":"",
        "ip6-send-adv":"disable",
        "icmp6-send-redirect":"enable",
        "ip6-manage-flag":"disable",
        "ip6-other-flag":"disable",
        "ip6-max-interval":600,
        "ip6-min-interval":198,
        "ip6-link-mtu":0,
        "ra-send-mtu":"enable",
        "ip6-reachable-time":0,
        "ip6-retrans-time":0,
        "ip6-default-life":1800,
        "ip6-hop-limit":0,
        "autoconf":"disable",
        "unique-autoconf-addr":"disable",
        "interface-identifier":"::",
        "ip6-prefix-mode":"dhcp6",
        "ip6-upstream-interface":"",
        "ip6-delegated-prefix-iaid":0,
        "ip6-subnet":"::\/0",
        "ip6-prefix-list":[
        ],
        "ip6-delegated-prefix-list":[
        ],
        "dhcp6-relay-service":"disable",
        "dhcp6-relay-type":"regular",
        "dhcp6-relay-ip":"",
        "dhcp6-client-options":"",
        "dhcp6-prefix-delegation":"disable",
        "dhcp6-information-request":"disable",
        "dhcp6-iapd-list":[
        ],
        "cli-conn6-status":0,
        "vrrp-virtual-mac6":"disable",
        "vrip6_link_local":"::",
        "vrrp6":[
        ]
      }
    }
  ],
  "vdom":"XXX",
  "path":"XXXX",
  "name":"interface0",
  "mkey":"port0",
  "status":"success",
  "http_status":200,
  "serial":"0000000000000",
  "version":"v0.0.0",
  "build":0000

} template in PRTG:

{
   "prtg":{
      "result":[
         {
            "channel": "1",
	    "value":$.results[0].estimated-upstream-bandwidth
         }    	 
      ]
 
  }
}

Result Test CMD in PRTG Server:

rest.exe https://0.0.0.0:0000/api/v2/cmdb/system/interface/port0?access_token=XXXXXXXXX C:\Users\user\Desktop\speedtest.template -tlsignore -debug
could no evaluate channel value of 1: unknown key estimated

Note: When I use the same expression on https://jsonpath.com/ the result is shown normally.

Example of when the line observed does not have the "-" in the same Input: Template in PRTG:

{
   "prtg":{
      "result":[
         {
            "channel": "1",
	    "value":$.results[0].mtu
         }    	 
      ]
 
  }
}

Result Test CMD in PRTG Server:

rest.exe https://0.0.0.0:0000/api/v2/cmdb/system/interface/port0?access_token=XXXXXXXXXX C:\Users\user\Desktop\speedtest.template -tlsignore -debug
{
  "prtg": {
    "result": [
      {
        "channelid": 0,
        "Value": 18,
        "Unit": "TimeResponse",
        "ShowChart": 0,
        "ShowTable": 0
      },
      {
        "channel": "1",
        "Value": 1500
      }
    ]
  }
}

Article Comments

Hello,

For elements containing a hyphen you need to escape it using square brackets e.g. [hyphened-value] as mentioned in the manual in the section JSON Path.
Your sample: "value":$.results[0].estimated-upstream-bandwidth Modified to use square brackets: "value":$[results[0]]["estimated-upstream-bandwidth"]


Kind regards,
Johannes Beyerlein, Technical Support Team


Jul, 2022 - Permalink