Ad Widget

Collapse

LLD Macro - JSONPath

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Noobz
    Senior Member
    • Jun 2020
    • 105

    #1

    LLD Macro - JSONPath

    I think I'm in need of using LLD Macros however I'm stuck before I start...
    What is the JSONPath? I have an understanding of what JSON is, the returned formatted data from Zabbix_get queries, but how do I know the path.to.node to use, how do I see the returned JSON from a query?

    The use case is working with the entitySensory and entity MIBs - I need to discover sensory items, values, and also discover their units and use a macro in the units field.

    Thanks
  • Noobz
    Senior Member
    • Jun 2020
    • 105

    #2
    Originally posted by splitek
    I've read the documentation on it and none of states how to actually see the JSON you're supposed to reference which is what my question is: " but how do I know the path.to.node to use, how do I see the returned JSON from a query? "

    I just want to see the JSON text so I know what to type in.

    Or am I missing something? Should I not need or be able view the JSON text?

    Comment

    • Noobz
      Senior Member
      • Jun 2020
      • 105

      #3
      I'm a bit lost on the work flow for this.
      All I want to do is create a discovery rule that discovers
      sensorNAME .1.3.6.1.2.1.47.1.1.1.1.2.0
      sensorVALUE: .1.3.6.1.2.1.99.1.1.1.4.0
      sensorUNITS: .1.3.6.1.2.1.99.1.1.1.6.0

      Then make an item prototype:
      {#sensorNAME}:#{sensorVALUE} with units {#sensorUNITS}

      This doesn't work using normal discovery, so from the very limited results of my googling, it seems that this is a job for LLD Macros.

      I have no idea how to format the $.path.to.node regarding the JSONPath part of the macro as I have no idea what the JSON data looks like. I think if I could see it, I could use the examples in the documentation to progress further.

      Am I on the right track, or should I not need to see the JSON data to do this?

      Comment

      • Noobz
        Senior Member
        • Jun 2020
        • 105

        #4
        So I just discovered that on a completely blank LLD Macro page you can press the test button and it generates the JSON data which can then be entered into an external formatting utility/script.

        So, the answer seems to just be, "hit the test button".

        Comment

        • Noobz
          Senior Member
          • Jun 2020
          • 105

          #5
          Some very minor progress happening here.
          I can construct a JSONPath statement:
          {#UNITS} => $.*.[{#ENTPHYSENSORUNITSDISPLAY}]
          to extract a list of units to use from the following discovery rule:
          discovery[{#ENTPHYSICALNAME},.1.3.6.1.2.1.47.1.1.1.1.7,{#ENT PHYSENSORUNITSDISPLAY},.1.3.6.1.2.1.99.1.1.1.6]

          however, I don't know how to match up the list to the item.

          I assume I need to somehow pass the SNMPINDEX to it, or regex the ENTPHYSICALNAME against the array but I have no idea how to integrate that into the JSONPath statement, or if I'm barking up the wrong tree.

          The other alternative is to make an item prototype for every different unit and preprocessing requirement, and just use LLD macros to filter them into types based on the ENTPHYSICALNAME?

          Comment

          Working...