Ad Widget

Collapse

How to select LLD Macro field/path if there is no variable name to specify

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lars ds
    Junior Member
    • Oct 2022
    • 18

    #1

    How to select LLD Macro field/path if there is no variable name to specify

    Title might not be entirely clear but the problem is quite specific. I want to create a discovery rule with the output shown here:
    Code:
    {
        "http_method": "GET",
        "results": {
            "ZABBIX_O365": {
                "": {
                    "status": "up",
                    "latency": 14.83416748046875,
                    "jitter": 2.5383334159851074,
                    "packet_loss": 0.0,
                    "packet_sent": 3053780,
                    "packet_received": 3052937
                }
            },
            "ZABBIX_INTERNET": {
                "": {
                    "status": "up",
                    "latency": 17.034366607666016,
                    "jitter": 3.6004993915557861,
                    "packet_loss": 0.0,
                    "packet_sent": 3052927,
                    "packet_received": 3052052
                }
            }
        },
        "vdom": "root",
        "path": "system",
        "name": "link-monitor",
        "action": "",
        "status": "success",
        "serial": "FGT60FTK",
        "version": "v7.0.9",
        "build": 444
    }​
    I need to create a macro that can be filled in with the values 'ZABBIX_0365' and 'ZABBIX_INTERNET'. These names won't be the same everytime so I cannot rely on filters or hardcodes values. Normally with jsonpath I would select a field and the LLD would figure out that for each value of that field it should fill in the macro. Since I Cannot select a field I am not able to fill in the LLD macro with these values. Any ideas on how to fix this?
  • Semiadmin
    Senior Member
    • Oct 2014
    • 1625

    #2
    In this case, you need a JS preprocessing:
    Code:
    output = Object.keys(JSON.parse(value)['results']).map(function(zabbix){
        return {"{#ZABBIX}":zabbix}
    })
    return JSON.stringify(output)​

    Comment

    • lars ds
      Junior Member
      • Oct 2022
      • 18

      #3
      Thanks SemiAdmin I will give this a try!

      Comment

      Working...