Ad Widget

Collapse

How to get array Index in LLD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thewball
    Junior Member
    • May 2021
    • 3

    #1

    How to get array Index in LLD

    Hi, I have data that is in an array of adapter names as follows:
    Code:
    "Network": {
    "NetDevice": [
    {
    "@attributes": {
    "Name": "eno2",
    "RxBytes": "0",
    "TxBytes": "0",
    "Err": "0",
    "Drops": "0"
    }
    },
    {
    "@attributes": {
    "Name": "eno1",
    "RxBytes": "82330091593",
    "TxBytes": "4474178174868",
    "Err": "0",
    "Drops": "7"
    }
    },
    {
    "@attributes": {
    "Name": "lo",
    "RxBytes": "243311573556",
    "TxBytes": "243311573556",
    "Err": "0",
    "Drops": "0"
    }
    }
    ]
    },
    Is there any way for me to get an array index in the LLD rules so I can properly reference the data?

    I have the following in my rule
    This is a dependent item on the main query.
    JSONPath: $.Network.NetDevice (This is part of a bigger query, and I know this part references this array
    LLD Macro:
    {#NAME} $.["@attributes"].Name
    (Ideally I would like to have {#ID} be the array index)

    And the following prototype:
    Preprocessing JSONPath: $.Network.NetDevice[<index>]["@attributes"].Drops

    I am getting an error with the index not being able to show the correct value. Do you know how I can get this working?

    Thank you!
    Last edited by thewball; 28-12-2021, 00:22.
Working...