Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-7997

LLD preprocessing improvement for JSON APIs

XMLWordPrintable

    • Icon: Change Request Change Request
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 6.0.9
    • Server (S)
    • None
    • Zabbix 6.0 Training

      While working with JSON-based APIs I noticed that creating LLD rules for them is needlessly complicated.

       

      HTTP agent gives me a JSON, so the natural way to preprocess it is to use JSONpath. This works very well and carries me most of the way, giving me output like:

      ["value1", "value2", "value3"]

       
      However, there is no obvious way to make the final step: converting this JSONpath output to something LLD would accept.

      [{"key":"value1"}, {"key":"value2"}, {"key":"value3}"]

       


       

      Currently I work this around by a sequence of STR_REPLACE rules like this:

          [    ->    [{"key":
          ,    ->    },{"key":
          ]    ->    }]
      

       

      The alternative would be to use javascript, but I feel that the required JSON-parsing and JSON-serializing boilerplate obscures the otherwise simple transformation too much.

       

      For JQ this would be a trivial and self-explanatory task, needing just a few characters:

      jq 'map({"key": .})'

       


       

      I see at least three ways to do this: Maybe create a special processing step just for this transformation? Maybe change LLD so it accepts arrays like ["value1", "value2", "value3"] and makes the values available as {#LLDVALUE}? Maybe just support JQ, although that feels too heavy? But those are just examples. All I know that it feels needlessly complicated as-is.

       

            wiper Andris Zeila
            user185953 user185953
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: