Ad Widget

Collapse

Zabbix Discovery rules for CXP results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reddysk
    Junior Member
    • Jan 2024
    • 8

    #1

    Zabbix Discovery rules for CXP results

    Hi Guys,

    we are using IVR application named CXP which has some webservices allow us to monitor status of the IVR application, i.e., #Total calls, rejected calls, active calls, list of instances, status of instance, ....

    I have Script item (queryGIVR-detailed.sh) returning a XML result. Right in the preprocessing I am converting the result to JSON.
    Dependent Item queryGIVR-detailed.sh: Instances details I am parsing JSON path $.result.serverInstances.serverInstance to get result array like:

    Code:
    [{"error":"None","queueErr":null,"startTime":"2024-04-21T01:19:48+0200","proxy":"Enabled","jmsEmbeddedBroker":"true","configuredPort":"8099","freeMemoryMB":"9107","infostoreErr":null,"contextCookies":"Enabled/Unavailable","abortedSessions":"7","rejectedSessions":"3","clusterID":"DefaultCluster","configuredSecurePort":null,"customDBLogging":"Enabled/Unavailable","detectedIP":"165.0.0.1","totalMemoryMB":"13204","finishedSessions":"1234","activeSessions":"10","reportingDBErr":null,"queueAvailable":"Enabled/N/A","usedMemoryMB":"4097","customDBErr":null,"status":"STARTED","systemDBLogging":"Enabled","master":"true","instanceName":"node123_8099","jmsMessagesSystem":"0","clusterMode":"network","totalSessions":"1254","jmsMessagesCustom":"0","contextCookieErr":null,"group":null,"infostoreMode":"Direct","configuredIP":"165.0.0.1"},{"error":"None","queueErr":null,"startTime":"2024-04-21T01:19:53+0200","proxy":"Enabled","jmsEmbeddedBroker":"true","configuredPort":"8100","freeMemoryMB":"9170","infostoreErr":null,"contextCookies":"Enabled/Unavailable","abortedSessions":"5","rejectedSessions":"0","clusterID":"DefaultCluster","configuredSecurePort":null,"customDBLogging":"Enabled/Unavailable","detectedIP":"165.0.0.1","totalMemoryMB":"13204","finishedSessions":"1097","activeSessions":"12","reportingDBErr":null,"queueAvailable":"Enabled/N/A","usedMemoryMB":"4034","customDBErr":null,"status":"STARTED","systemDBLogging":"Enabled","master":"false","instanceName":"node123_8100","jmsMessagesSystem":"0","clusterMode":"network","totalSessions":"1114","jmsMessagesCustom":"0","contextCookieErr":null,"group":null,"infostoreMode":"Direct","configuredIP":"165.0.0.1"},{"error":"None","queueErr":null,"startTime":"2024-04-21T01:20:00+0200","proxy":"Enabled","jmsEmbeddedBroker":"true","configuredPort":"8101","freeMemoryMB":"9692","infostoreErr":null,"contextCookies":"Enabled/Unavailable","abortedSessions":"2","rejectedSessions":"0","clusterID":"DefaultCluster","configuredSecurePort":null,"customDBLogging":"Enabled/Unavailable","detectedIP":"165.0.0.1","totalMemoryMB":"13204","finishedSessions":"685","activeSessions":"2","reportingDBErr":null,"queueAvailable":"Enabled/N/A","usedMemoryMB":"3512","customDBErr":null,"status":"STARTED","systemDBLogging":"Enabled","master":"false","instanceName":"node123_8101","jmsMessagesSystem":"0","clusterMode":"network","totalSessions":"689","jmsMessagesCustom":"0","contextCookieErr":null,"group":null,"infostoreMode":"Direct","configuredIP":"165.0.0.1"}]
    My plan is to take stats for each instance (node123_8099, node123_8100, node123_8101).

    I have created Discovery rule, dependent on Instances details: Instances, with these LLD macros:
    Click image for larger version

Name:	image.png
Views:	203
Size:	27.9 KB
ID:	482811
    No error is reported in the list so I suppose that it is working well.

    However I do not know how to continue.

    I wanted to create Item Prototype which will pick i.e. Status but getting error with Key.

    Click image for larger version

Name:	image.png
Views:	88
Size:	26.4 KB
ID:	482812

    What I am doing wrong and is it possible to do it by this way at all?

    Thank you, Reddy
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    try status[{#INSTNAME}]

    Comment

    • reddysk
      Junior Member
      • Jan 2024
      • 8

      #3
      Thank you cyber. It is allowing me to save the prototype with this syntax in the key.
      I have aligned that with some naming convention to cxp.instance.status.[{#INSTNAME}].

      Anyway, it doesn't parse any value ... I have no clue where to setup the value I want to parse.

      I have setup the item to Dependent on the Instances details as mentioned on the screenshot above.
      But I do not know where to add the parsing of the Status value from the LLD variable {#INSTSTATUS}.

      I tried to add preprocessing to parse the value from JSON

      Click image for larger version  Name:	image.png Views:	0 Size:	7.1 KB ID:	482911
      But of course it fails because the status is 3 times there:
      Preprocessing failed for: [{"error":"None","queueErr":null,"startTime":"20 24-04-21T01:19:48+0200","proxy":"Enabled","jmsEmb...
      1. Failed: cannot extract value from json by path "$.status": no data matches the specified path
      Where I can parse the {#INSTSTATUS} which is already parsed by LLD?

      When I added the macro to description, it is parsed there.

      Click image for larger version

Name:	image.png
Views:	79
Size:	8.7 KB
ID:	482913
      Last edited by reddysk; 23-04-2024, 17:54.

      Comment

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

        #4
        Your preprocessing has to have some pointer towards the specific part of your json.. like, it needs to take status value from that object where your instance name is for example "node123_8099" as in you example json...
        Code:
        $[?(@.instanceName== '{#INSTSTATUS}')].status.first()
        I think this should work... but jsonpath has always given me headache..
        https://www.zabbix.com/documentation..._functionality
        $[?(@.name == 'Object')].price.first() Return the price field of the first object with name 'Object'.

        Comment


        • reddysk
          reddysk commented
          Editing a comment
          Thank you cyber for hint but it doesn't work in Zabbix.

          cannot extract value from json by path "$[?(@.instanceName=='{#INSTNAME}')].status.first()": no data matches the specified path

          neither without the "first" function

          cannot extract value from json by path "$[?(@.instanceName=='{#INSTNAME}')].status": no data matches the specified path

          when i tried the syntax on https://jsonpath.com/ this worked there: "$[?(@.instanceName=='node123_8099')].status".
          But as you can see in Zabbix doesn't. I suppose that there is a problem with the interpretation of the macro name in the condition because with the name 'node123_8099' it works even in Zabbix.

          I am trying to check if the Macro can be used in the condition at all.

        • reddysk
          reddysk commented
          Editing a comment
          I suppose, there has to by bug in Zabbix.

          I found samples with Macro in JSON Path conditions https://www.zabbix.com/documentation...ing_lld_macros
          And based on that it should works even in this format: "$[?(@.instanceName == {#INSTNAME})].status".

          But getting error: cannot extract value from json by path "$[?(@.instanceName == {#INSTNAME})].status": unsupported construct in jsonpath starting with: "{#INSTNAME})].status".

          With quotes or double quotes I will get: cannot extract value from json by path "$[?(@.instanceName == "{#INSTNAME}")].status": no data matches the specified path

          Have you same problem? I am on version 6.4.

        • reddysk
          reddysk commented
          Editing a comment
          I suppose that it is trying to make me mad

          I tried to use script method, so in Javascript I have wrote:

          val instanceDetail = '{#INSTSTATUS}';
          return instanceDetail;

          Based on the https://www.zabbix.com/documentation...ing/javascript the syntax is correct.
          But Zabbix is kidding me with: Cannot compile script: SyntaxError: unterminated statement (line 1)

          I suppose I need a break ... do not know why documented syntax doesn't work.
      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #5
        I am pretty sure there is something we both are just overlooking.. It would not be first time jsonpath causes me some dead braincells..

        Comment

        Working...