Ad Widget

Collapse

Is this the right use for LLD?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cstackpole
    Senior Member
    Zabbix Certified Specialist
    • Oct 2006
    • 225

    #1

    Is this the right use for LLD?

    Greetings,
    After tinkering around with this for a while now, I'm wondering if my plan needs to be re-evaluated.
    Running Zabbix 6.0.5.

    [Edit: please see post #3 for current request for help]

    # primary problem

    I have a bunch of devices that aren't things I can put an agent on. However, I can drop a sender on them and with a simple query I can return JSON with everything I need. I can also cron the Zabbix sender to give me the values on a somewhat regular basis.
    But, of course, things have to be challenging. Depending on what the device is doing it returns only relevant details. What I'd like to do is slurp in this JSON and per-host capture the metrics into items. Ideally, I'm applying the same template with all the same items/graphs/triggers to all the hosts but only seeing the relevant items on each host.
    So, here's my testing code:
    Code:
    {
      "hostname1": {
        "version": 1.0,
          "beverage": {
            "type": "tea",
            "temp": "hot",
            "total": 317
        },
        "received": 11
      }
    }
    Code:
    {
      "hostname2": {
        "version": 1.1,
          "beverage": {
            "type": "soda",
            "temp": "cold"
       },
       "car": {
          "make": "Mazda",
          "model": "RX-7",
          "generation": 1
          }
       }
    }
    Code:
    {
      "hostname3": {
        "version": 1.2,
          "car": {
          "make": "Chevy",
          "model": "Corvette",
          "generation": 6
        },
        "garage_space": 1
       }
    }
    From the three hosts, the ONLY TWO fields that are uniform and consistent are the hostname and the version. The first has a beverage, the second has a beverage but not the same fields and a car, the third has a car and a garage_space. The only information I don't actually care about is the hostname, because that will be passed to it from the Zabbix sender and I can filter that out easily enough on either end.

    What I was attempting to do was create a discovery rule then set dependent items based on what is discovered. However, once I've created the discovery item and I verify that I'm getting data into it, I can't seem to create a dependent item. When I create an item prototype, there is no drop down for dependent item.

    # secondary problem

    I thought maybe I'm doing this wrong. So I went over to the documentation: https://www.zabbix.com/documentation...ery-on-the-fly
    Well, that is not very clear is it? I'm sure it's fine for someone who knows what they are doing but for someone trying to figure it out then it isn't so helpful. But it looks rather close to what I would like to do so let's try it.

    I created a new template.
    I created an item called "Get zones" with the key get.zones, set the url to http://demo.nginx.com/api/3/http/server_zones (per the documentation), and set an update interval of 1h.
    Then I create a Discovery rule. Named it zones, type is dependent item, key is zones, set the master to "Get zones", click on Preprocessing and set the data per the documentation. If I run the "Test all steps", I verify that I am getting data through the javascript.

    Hooray! My host with this template is now getting this get.zones data! However, I'm not getting anything else. Just the one item. Makes sense because my discovery doesn't have any items yet.

    Back to the template, click on the Discovery rules, then the zones, then Item prototypes. Create item prototype. And now it doesn't matter what I put here because I'm in the exact same spot as before! There is no Dependent Item in the Type drop down!


    Therefore, I'm either doing both my initial goal AND the documentation wrong - or maybe I'm trying to go about solving this problem wrong (possibly both! :-D ).

    So my first question, is this a good case for LLD? Should I be trying to approach this from a different angle?

    My second question is, why doesn't this work? How am I supposed to create Dependent items from the Discovery filter?

    Thanks!
    Last edited by cstackpole; 02-06-2022, 23:01. Reason: Update where I need assistance.
  • cstackpole
    Senior Member
    Zabbix Certified Specialist
    • Oct 2006
    • 225

    #2
    At this point, I'd love to see this documentation actually work:


    I'd like to see all of these fields populated and the values captured. I'm pretty confident I can do what I'm after if I could get all of this example data to work. Anyone know if there is complete documentation available for this example?
    Thanks!

    Comment

    • cstackpole
      Senior Member
      Zabbix Certified Specialist
      • Oct 2006
      • 225

      #3
      Progress!! Sorta....
      So, I've got a better understanding of how to use the variables created in the template, but I still had to manually create too many items that may or may not exist (in the Nginx example, it's uniform and they always do exist but not in my use case). So, here's my template answer to the documentation question. I would greatly appreciate someone taking a look at how this could be improved. Dumping it as JSON because that seems to fit the theme of JSON URL agent. ;-)
      Thanks!
      Code:
      {
      "zabbix_export": {
      "version": "6.0",
      "date": "2022-06-02T19:10:36Z",
      "groups": [
      {
      "uuid": "6b26f15b315f43f49f66ca82223eb82d",
      "name": "Test"
      }
      ],
      "templates": [
      {
      "uuid": "9a2d6db4e56d471a8fbf1adf38b05fac",
      "template": "JSONtest",
      "name": "JSONtest",
      "groups": [
      {
      "name": "Test"
      }
      ],
      "items": [
      {
      "uuid": "ab599eed75544aa1a362c84b71f1a99f",
      "name": "Get data",
      "type": "HTTP_AGENT",
      "key": "jsontest.get_data",
      "delay": "1d",
      "trends": "0",
      "value_type": "CHAR",
      "url": "http://demo.nginx.com/api/3/http/server_zones"
      },
      {
      "uuid": "fe0e9e92ee714488a6f420496621737e",
      "name": "Filter zones",
      "type": "DEPENDENT",
      "key": "jsontest.get_zones",
      "delay": "0",
      "trends": "0",
      "value_type": "CHAR",
      "preprocessing": [
      {
      "type": "JAVASCRIPT",
      "parameters": [
      "output = Object.keys(JSON.parse(value)).map(function(zone){ \n return {\"{#NGINX_ZONE}\": zone}\n})\nreturn JSON.stringify({\"data\": output})"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      }
      ],
      "discovery_rules": [
      {
      "uuid": "0670b98ea3cd41c18ac580e092e9a2f1",
      "name": "nginx zones",
      "type": "DEPENDENT",
      "key": "jsontest.zones",
      "delay": "0",
      "item_prototypes": [
      {
      "uuid": "0dbcdf7cab994ef0bbe2b1883be1e017",
      "name": "{#NGINX_ZONE} discarded",
      "type": "DEPENDENT",
      "key": "jsontest.discarded[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].discarded"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "454b24fd6e8a411dbb3cc4ece63ea9bf",
      "name": "{#NGINX_ZONE} processing",
      "type": "DEPENDENT",
      "key": "jsontest.processing[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].processing"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "18e8c8054d004723b5079440cdc502ca",
      "name": "{#NGINX_ZONE} received",
      "type": "DEPENDENT",
      "key": "jsontest.received[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].received"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "0f1540930d39429f8977f43a187ef841",
      "name": "{#NGINX_ZONE} requests",
      "type": "DEPENDENT",
      "key": "jsontest.requests[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].requests"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "2cad93b1fabb428d83017dd6a72c8140",
      "name": "{#NGINX_ZONE} responses 1xx",
      "type": "DEPENDENT",
      "key": "jsontest.responses.1xx[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].responses.1xx"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "e96e089d4f954849b971f4da09203518",
      "name": "{#NGINX_ZONE} responses 2xx",
      "type": "DEPENDENT",
      "key": "jsontest.responses.2xx[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].responses.2xx"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "08a446fa7019461185f068c647a01ffe",
      "name": "{#NGINX_ZONE} responses 3xx",
      "type": "DEPENDENT",
      "key": "jsontest.responses.3xx[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].responses.3xx"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "82062b9609124ad3955c1436df738dab",
      "name": "{#NGINX_ZONE} responses 4xx",
      "type": "DEPENDENT",
      "key": "jsontest.responses.4xx[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].responses.4xx"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "955b1cc3e3d24bffa507404d47c56783",
      "name": "{#NGINX_ZONE} responses 5xx",
      "type": "DEPENDENT",
      "key": "jsontest.responses.5xx[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].responses.5xx"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "cf0dd74d7bde46139b8fe9e1db950b74",
      "name": "{#NGINX_ZONE} responses total",
      "type": "DEPENDENT",
      "key": "jsontest.responses.total[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].responses.total"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      },
      {
      "uuid": "49b4bf1ab3c34f4a85187cd526bc2173",
      "name": "{#NGINX_ZONE} sent",
      "type": "DEPENDENT",
      "key": "jsontest.sent[\"{#NGINX_ZONE}\"]",
      "delay": "0",
      "preprocessing": [
      {
      "type": "JSONPATH",
      "parameters": [
      "$.[\"{#NGINX_ZONE}\"].sent"
      ]
      }
      ],
      "master_item": {
      "key": "jsontest.get_data"
      }
      }
      ],
      "master_item": {
      "key": "jsontest.get_zones"
      }
      }
      ]
      }
      ]
      }
      }
      PS: Wow... the forum really likes to mess with the spacing... well good thing I chose JSON and not YAML! :-D

      Comment

      Working...