Ad Widget

Collapse

JSONPATH and the caret (^) support

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RobZ_68
    Junior Member
    • Jul 2022
    • 1

    #1

    JSONPATH and the caret (^) support

    Hi everybody.

    Zabbix Server 6.0.6.

    Please consider this JSON otuput:

    Code:
    {
    "hasMore": false,
    "data": [{
    "id": "12345",
    "brikId": "12345",
    "status": "OK",
    "ipAddress": "192.168.0.1",
    "supportTunnel": {
    "isTunnelEnabled": false,
    "port": 0,
    "enabledTime": "2022-05-11T09:07:19.000Z",
    "lastActivityTime": "2022-05-11T09:07:19.000Z",
    "inactivityTimeoutInSeconds": 0,
    "errorMessage": "Tunnel closed due to inactivity"
    },
    "hasUnavailableDisks": false,
    "hostname": "host1"
    }, {
    "id": "23456",
    "brikId": "23456",
    "status": "OK",
    "ipAddress": "192.168.0.2",
    "supportTunnel": {
    "isTunnelEnabled": true,
    "port": 0,
    "enabledTime": "2021-09-27T14:03:34.000Z",
    "lastActivityTime": "2021-09-28T13:04:33.000Z",
    "inactivityTimeoutInSeconds": 0,
    "errorMessage": "Tunnel closed due to inactivity"
    },
    "hasUnavailableDisks": false,
    "hostname": "host2"
    }
    ],
    "total": 2
    }
    I'd like to have the IP address (ipAddress) of items with the isTunnelEnabled = true.

    The following JSONPATH rule does work when tested with http://jsonpath.com/ as it returns the expected "192.168.0.2":

    $.data.[?(@.isTunnelEnabled == true)].^ipAddress

    Please notice the "^" (caret) to retrieve a value in the outer item.

    This does not seem to be supported in Zabbix's JSONPATH implementation (https://www.zabbix.com/documentation..._functionality).

    Any way to get this value from JSON preprocessing?

    Another question; if an JSON preprocessing returns an empty string (which could be OK), is there a way to handle it?

    Thanks,
    Roberto
  • Colttt
    Senior Member
    Zabbix Certified Specialist
    • Mar 2009
    • 878

    #2
    my not very useful, but I would try that with a LLD rule and a filter on $.data.supportTunnel.isTunnelEnabled
    Debian-User

    Sorry for my bad english

    Comment

    Working...