Ad Widget

Collapse

JSONPath processing error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SanMonitor
    Member
    • Aug 2022
    • 48

    #1

    JSONPath processing error

    Hey guys,

    I'm quite new to Zabbix and am busy setting up the environment for our company but I have a problem in one of my templates with the JSONPath.
    I've never really worked intensively with JSON or JSONPath so I was hoping someone could help me out.

    For one of the applications we're monitoring I have a SNMP agent that returns a JSON file.
    Because it's via SNMP the JSON names are formatted as a macro, I can't change this (the SNMP OID discovery recuires a valid macro name).

    This is an example of the JSON:
    Code:
    [ {
    "{#SNMPINDEX}":"36.48",
    "{#CHANNELNAME}":"Channel_name05",
    "{#CHANNELRECEIVED}":"105",
    "{#CHANNELFILTERED}":"306",
    "{#CHANNELQUEUED}":"0",
    "{#CHANNELSENT}":"114",
    "{#CHANNELERROR}":"0",
    "{#CHANNELCONNECTION}":"",
    "{#CHANNELSTATE}":"STARTED",
    "{#CHANNELLASTMES}":"0"
    },
    
    {
    "{#SNMPINDEX}":"36.49",
    "{#CHANNELNAME}":"Channel_name03",
    "{#CHANNELRECEIVED}":"0",
    "{#CHANNELFILTERED}":"0",
    "{#CHANNELQUEUED}":"0",
    "{#CHANNELSENT}":"0",
    "{#CHANNELERROR}":"0",
    "{#CHANNELCONNECTION}":"",
    "{#CHANNELSTATE}":"STARTED",
    "{#CHANNELLASTMES}":"0"
    }
    ]
    Following these sources:
    Tutorial for LLD + dependent items from the same JSON : zabbix (reddit.com)
    Reduce Polling with Dependent Items and JSONPath - Zabbix.tips

    I defined two LLD macros in my discovery rule:

    Click image for larger version

Name:	image.png
Views:	390
Size:	8.5 KB
ID:	449471

    but,
    I'm now getting an error on Zabbix that it's not valid JSONPath.
    My idea is that it's having problems with the curled brackets in the object name but I've been googling for hours and can't find a way to get around this.
    Click image for larger version

Name:	image.png
Views:	332
Size:	4.8 KB
ID:	449472


    Any ideas?

  • SanMonitor
    Member
    • Aug 2022
    • 48

    #2
    Seems like I should've posted in this forum earlier because I found the solution minutes after posting this,
    all I had to do was add closed brackets to the JSONPath:

    Click image for larger version

Name:	image.png
Views:	400
Size:	13.7 KB
ID:	449491

    Maybe this'll be usefull to someone in the future.

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #3
      You need this LLD macros part, if you are assigning values from "ordinary" json to specific macros, like... "{#ID} → $.id".
      but you already have macros in that json, so you don't need to preprocess it and point to somekind of jsonpath element... It is already "preprocessed" to be used ... Think of different FS templates... specific agent items also return similar preprocessed json with all macros present, so you only have to use them, no need to additional macro assignment...

      Comment

      Working...