Ad Widget

Collapse

LLD with http agent master item and discovery on dependent item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DrMoe
    Junior Member
    • Apr 2023
    • 10

    #1

    LLD with http agent master item and discovery on dependent item

    Hi everyone,

    I am out of ideas and i would appreciate any kind of help


    I want to create a LLD from this below content available at an URL.

    1. I created a http agent master item (granit.api.master.item) which is storing this json. This is working correctly.


    Code:
    [
    {
    "name": "granit_check_1",
    "status": "OK",
    "metric": 1,
    "metric_array": {
    "value1": 1111,
    "value2": 1222
    }
    },
    {
    "name": "granit_check_2",
    "status": "OK",
    "metric": 2,
    "metric_array": {
    "value1": 2222,
    "value2": 2111
    }
    }
    ]


    ​2. I created a discovery rule (granit.api.dependent.discovery) as a dependent item on the http agent master item (granit.api.master.item) and i created a LLD macro


    Click image for larger version

Name:	LLD-rule.png
Views:	948
Size:	39.0 KB
ID:	463116

    Macro:

    Click image for larger version

Name:	LLD-rule.macro.png
Views:	896
Size:	23.1 KB
ID:	463117

    3.
    a) I created a test item prototype

    Click image for larger version

Name:	item.prototype.png
Views:	881
Size:	49.7 KB
ID:	463118


    and
    b) a preprocessing step

    Click image for larger version

Name:	item.prototype.preprocessing.png
Views:	902
Size:	26.6 KB
ID:	463119

    Now the problem:

    It keeps the bracket and the double quotes and therefore JSONPath is not finding the .status in the json. see the screenshot below

    How can i prevent the brackets und quotes from being used by zabbix ?
    What am i doing wrong?

    Incorrect item prototype:
    ["granit_check_1"].status

    Desired item_prototype:
    granit_check_1.status
    granit_check_1.metric

    Click image for larger version

Name:	Result.png
Views:	877
Size:	95.1 KB
ID:	463120

    Any help or hints appreciated..
  • bolero
    Junior Member
    • Jul 2023
    • 2

    #2
    Hi there,


    Zabbix Version: 6.4

    currently we are struggling with the same issue. Failing at the item prototype step. {#MACRO} is escaped.


    we have a script that queries hotel room door battery states and sends them via zabbix_send as a payload to zabbix.

    I'm by far no expert on this field, but any help would be appreciated.

    Doc:


    Is there a way to change the outcome on item prototype preprocessing?


    Payload:
    Code:
    Schliessystem tesa.getAllDoorBattery [ {"door":"101","battery":40}, {"door":"102","battery":60}, {"door":"103","battery":40}, {"door":"104","battery":40}, {"door":"105","battery":60}, {"door":"106","battery":40}, {"door":"107","battery":60}, {"door":"108","battery":60}, {"door":"109","battery":60}, {"door":
    "110","battery":40}, {"door":"111","battery":40}, {"door":"112","battery":60}, {"door":"113","battery":40}, {"door":"114","battery":60}, {"door":"115","battery":40}, {"door":"116","battery":60}, {"door":"117","battery":60}, {"door":"118","battery":40}, {"door":"119","battery":60}, {"door":"120","battery":60}, {"door
    ":"121","battery":60}, {"door":"122","battery":60}, {"door":"123","battery":40}, {"door":"124","battery":40}, {"door":"125","battery":40}, {"door":"126","battery":40}, {"door":"127","battery":40}, {"door":"128","battery":60}, {"door":"129","battery":60}, {"door":"130","battery":40}, {"door":"131","battery":60}, {"do
    or":"132","battery":60}, {"door":"133","battery":40}, {"door":"134","battery":60}, {"door":"135","battery":60}, {"door":"136","battery":40}, {"door":"2-Netzwerktechnik","battery":60}, {"door":"201","battery":60}, {"door":"202","battery":40}, {"door":"203","battery":60}, {"door":"204","battery":60}, {"door":"205","ba
    ttery":20}, {"door":"206","battery":40}, {"door":"207","battery":40}, {"door":"208","battery":60}, {"door":"209","battery":40}, {"door":"210","battery":40}, {"door":"211","battery":40}, {"door":"212","battery":60}, {"door":"213","battery":60}, {"door":"214","battery":40}, {"door":"215","battery":60}, {"door":"216","
    battery":60}, {"door":"217","battery":60}, {"door":"218","battery":40}, {"door":"219","battery":40}, {"door":"220","battery":60}, {"door":"221","battery":60}, {"door":"222","battery":40}, {"door":"223","battery":60}, {"door":"224","battery":40}, {"door":"225","battery":40}, {"door":"226","battery":40}, {"door":"227"
    ,"battery":60}, {"door":"228","battery":60}, {"door":"229","battery":60}, {"door":"230","battery":40}, {"door":"231","battery":60}, {"door":"232","battery":60}, {"door":"233","battery":60}, {"door":"234","battery":60}, {"door":"235","battery":60}, {"door":"236","battery":60}, {"door":"237","battery":60}, {"door":"30
    1","battery":80}, {"door":"302","battery":60}, {"door":"303","battery":60}, {"door":"304","battery":40}, {"door":"305","battery":40}, {"door":"306","battery":40}, {"door":"307","battery":60}, {"door":"308","battery":80}, {"door":"309","battery":60}, {"door":"310","battery":60}, {"door":"311","battery":60}, {"door":"
    312","battery":60}, {"door":"313","battery":60}, {"door":"314","battery":40}, {"door":"315","battery":60}, {"door":"316","battery":60}, {"door":"317","battery":60}, {"door":"318","battery":60}, {"door":"319","battery":60}, {"door":"320","battery":90}, {"door":"321","battery":60}, {"door":"322","battery":60}, {"door"
    :"323","battery":90}, {"door":"324","battery":60}, {"door":"325","battery":60}, {"door":"326","battery":60}, {"door":"401","battery":60}, {"door":"AR.B1.1","battery":60}, {"door":"AR.B1.2","battery":60}, {"door":"AR.B1.3","battery":60}, {"door":"AR.B2.1","battery":60}, {"door":"AR.B2.2","battery":40}, {"door":"AR.B2
    .3","battery":80}, {"door":"AR.B2.4","battery":90}, {"door":"AR.B3.1","battery":60}, {"door":"AZ.EG","battery":100}, {"door":"AZ.KG","battery":100}, {"door":"AZ.OG1","battery":100}, {"door":"AZ.OG2","battery":100}, {"door":"AZ.OG3","battery":100}, {"door":"Haupteingang","battery":100}, {"door":"2","battery":90}, {"d
    oor":"Haupteingang_ALT","battery":60}, {"door":"K.A1.1","battery":60}, {"door":"K.A2.1","battery":40}, {"door":"K.A3.1","battery":60}, {"door":"K.B3.1","battery":100}, {"door":"L.B.3.1","battery":100}, {"door":"WL-GAR-EINFAHRT","battery":60}, {"door":"WL-GAR-UNTEN","battery":100}, {"door":"WR.B3.1","battery":100}, {
    "door":"test","battery":100}]
    ​
    key getAllDoorBattery is in the parent item.




    Item Prototype:




    Stuck at this point:

    ​​Click image for larger version

Name:	image.png
Views:	854
Size:	66.0 KB
ID:	467861

    Comment

    • bolero
      Junior Member
      • Jul 2023
      • 2

      #3
      Resolved by:
      https://www.zabbix.com/forum/zabbix-...jsonpath-nikto


      Appended .first() in the LLD Marco [...] and it worked.
      The result was apparently a array with one item in it and with the .first() its just the value without the brackets.

      DrMoe
      Try changing your LLD Macros to $..name.first() and $..status.first()

      maybe it helps.
      Last edited by bolero; 31-07-2023, 13:38.

      Comment

      • DrMoe
        Junior Member
        • Apr 2023
        • 10

        #4
        Originally posted by bolero
        Resolved by:
        https://www.zabbix.com/forum/zabbix-...jsonpath-nikto


        Appended .first() in the LLD Marco [...] and it worked.
        The result was apparently a array with one item in it and with the .first() its just the value without the brackets.

        DrMoe
        Try changing your LLD Macros to $..name.first() and $..status.first()

        maybe it helps.
        Thanks for your answer! i will try it soon!

        Comment

        Working...