Ad Widget

Collapse

LLD macro - JSONPath

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • verde
    Member
    • Jul 2021
    • 39

    #1

    LLD macro - JSONPath

    Hi,
    is this possible?

    In a discovery rule, I'm trying to configure a second item-prototype using a second LLD macro to extract items per sub-objects from a json string, below a sample.
    (The first item-prototype works well and collects the uptime info desired).

    The items from the second item-prototype have to be auto-discovered from to obtain this:

    Code:
    ItemName              : value-collected
    100 PUB db    :   2
    100 PUB http  :   8
    200 PUB dhcp:  1
    200 PUB db     :  3
    200 PUB ddns  :  1
    I'm trying to configure the second LLD macros to get its values from the objects inside a parent object, but it didn't work. Also, I tried that the second LLD macro depends on the first LLD macro but it didn't work either.
    Is that possible? any thoughts to achieve the expected items?

    The error I'm getting is: cannot substitute macro "{#PUB.NAME}": not found in value set

    Thanks,


    Configuration (image attached)

    LLD macros on discovery rule:
    Code:
    LLD macro -> JSONPath
    {#NODEID} -> $.nodeid
    {#PUB.NAME.2} -> $.[?(@.nodeid=='{#NODEID}')].pub.name
    {#PUB.NAME} -> $.pub.name
    Itemp-protype:
    Code:
    Name: {#NODEID} PUB {#PUB.NAME}
    
    Preprocessing:
    JSONPath ->  $.[?(@.nodeid=='{#NODEID}')].pub.[?(@.name=='{#PUB.NAME}')].y.first()

    jsonstring:
    [
    {
    "nodeid": 100,
    "uptime": 14,
    "pub": [
    {"name": "db", "y": 2},
    {"name": "http","y": 8}
    ],
    "priv": [
    {"name": "unknown","y": 6},
    {"name": "inhouse","y": 2}
    ]
    },{
    "nodeid": 200,
    "uptime": 76,
    "pub": [
    {"name": "dhcp", "y": 1},
    {"name": "db","y": 3}
    {"name": "ddns","y": 1}
    ],
    "priv": [
    {"name": "inhouse","y": 2}]
    }




    ]
    Attached Files
    Last edited by verde; 16-01-2022, 06:17.
Working...