Ad Widget

Collapse

LLD macro with dependent item prototype

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yurtesen
    Senior Member
    • Aug 2008
    • 130

    #1

    LLD macro with dependent item prototype

    I have a data structure (if this is not the best structure for LLD, I can modify it)
    Code:
    [
      { "#SERVER": "server1", "#STATUS": 0 },
      { "#SERVER": "server2", "#STATUS": 0 },
      { "#SERVER": "server3", "#STATUS": 0 },
      { "#SERVER": "server4", "#STATUS": 0 }
    ]
    I am trying to make discovery rule for {#SERVER} and log the status {#STATUS}.

    In my template I have an item which fetches this data as raw data

    I have a discovery rule where the master item is this raw data item.

    I want to create item prototype for use per {#SERVER} using dependent item (dependent to raw data?). Not sure where to enter {#STATUS} in the item prototype itself?

    The manual example uses preprocessing. Do I use JSONPath? what should it look like?
    Last edited by yurtesen; 06-07-2020, 11:45.
  • gert.derouck
    Member
    • Jan 2020
    • 69

    #2
    LLD rules are used to discover stuff, not to monitor them at the same time.
    So in your case: the LLD rule detects the servers, so the JSON should only include the servers.
    Add an item prototype for collecting the status for each of the discovered servers.

    Success
    Gert

    Comment

    • yurtesen
      Senior Member
      • Aug 2008
      • 130

      #3
      gert.derouck thanks for the response. Zabbix documentation examples are not always very detailed. I have resolved the issue now and hopefully it may be useful to others.

      Code:
      {
        "values": {
          "server1":[ 1, "ERROR: Something went very wrong" ],
          "server2":[ 0, "OK: Things are fine" ],
          "server3":[ 0, "OK: Things are fine" ]
        },
        "lld": [
          { "{#SERVER}":"server1"},
          { "{#SERVER}":"server2"},
          { "{#SERVER}":"server3"}
        ]
      }
      and in discovery I use preprocessing to use
      Code:
      $.lld
      and in item prottype I use preprocessing item to get first numeric value
      Code:
      $.values['{#SERVER}'][0]
      and in item prottype for message I use:
      Code:
      $.values['{#SERVER}'][1]

      So I am able to use the same JSON for both detecting the servers and also for collecting data about their status/messages etc.

      Comment

      Working...