Ad Widget

Collapse

Web content triggers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mangirdas
    Junior Member
    • Nov 2019
    • 8

    #1

    Web content triggers

    Hello,

    I would like to get some assistance with web page content trigger
    I read all of this forum, but didn't find any working solution

    My web page content looks:
    Code:
     {"status":"UP","details":{"db":{"status":"UP","details":{"database":"MySQL","hello":1}}}}
    and I am creating web.page.regexp where I have to get error when one of those status <>UP
    So, current trigger which I am testing from command line looks okay
    Code:
    zabbix_agentd -t 'web.page.regexp[my.server,/health,8080,\"status"\:\"(\w*)]'
    web.page.regexp[my.server,/health,8080,\"status"\:\"(\w*)] [s|"status":"UP]
    but when I am starting create trigger I am always getting "Incorrect Item key"
    I tried those triggers:
    Code:
    {my.server:web.page.regexp[my.server,/health,8080,\"status"\:\"(\w*)].str(UP)}=0
    Code:
    {my.server:web.page.regexp[my.server,"/health",8080,("status")(:)("UP")]}
    Any help would be really appreciated.

  • 1berto
    Senior Member
    • Sep 2018
    • 182

    #2
    How are you retrieving this page? Http agent? I think that it can read the response as JSON

    Comment

    • Mangirdas
      Junior Member
      • Nov 2019
      • 8

      #3
      I retrieving this page with Web scenario and yes it response as JSON code, but I didn't find anything regarding with JSON in here https://www.zabbix.com/documentation...gers/functions

      Comment

      • gofree
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2017
        • 400

        #4
        maybe http agent for json parsing ( with jsonpath preprocessing ) - only drawback to webscenario is that you'll not get the response times

        Comment

        • Mangirdas
          Junior Member
          • Nov 2019
          • 8

          #5
          Hi. Yes http agent Item is my key to success. Now I can get all values from my page. thank you!

          Now need to understand Preprocessing steps with JSON

          For example I chosen JSONPath with Parameters: $.status and got:
          cannot extract value from json by path "$.status": JSONPath query must start with the root object/element $.

          Finally I managed everything
          Preprocessing looks like->
          Name -> JSONPath
          Parameters -> $.status
          Checked on Custom on fail
          Set value to DOWN

          and trigger
          {my_web:test.diff()}=1
          Last edited by Mangirdas; 19-12-2019, 11:14.

          Comment

          Working...