Ad Widget

Collapse

How can I use parameters in HTTP agent based items for REST API based monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apulai
    Junior Member
    • Feb 2022
    • 4

    #1

    How can I use parameters in HTTP agent based items for REST API based monitoring

    Hello,

    I would like to monitor a system via REST API.

    I am putting together a template, with HTTP agent based items on it.

    The basic data collection is OK.

    Now I would like collect only the last notification from the source system, so I would need
    to add a filter to the HTTP / REST request.

    I could not really figure out how to use a user macro in the query fields.
    I thought this should work, and {$LAST_NOTIFICATION_ID} will be substituted, but it is not:

    Click image for larger version

Name:	zbx_item_macro1.png
Views:	886
Size:	12.9 KB
ID:	439873

    The macro is super simple:
    {$LAST_NOTIFICATION_ID} = 832

    Any advise here?

    --

    I would like to go also one step further:

    Between my items in this template there is a key called 'id', which gets updated OK.

    Click image for larger version

Name:	zbx_items.png
Views:	826
Size:	21.4 KB
ID:	439874

    In fact I would like to substitute the value of this id, into my http request. "id gt 'value of(nbunotification:id)'"

    Could not figure out how to do it.

    Your kind help would be really appreciated.

    Thanks
    Andras
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4811

    #2
    You cannot use other items value in key values...

    Comment

    • apulai
      Junior Member
      • Feb 2022
      • 4

      #3
      Hi Cyber,

      Yes that sounds totally logical: keys should be static.

      But this is not what I want to do:
      - I would like to use the value of a key in my query.

      Here is what I trying to accomplish:
      - after the first REST call key id holds the value 832.
      I look at it like vairable called id = 832

      - in my next REST call I would like to get only events where id is greater than 832.
      So in the HTTP params i expect something like: ?query="id gt 832"

      This is what I am trying to explain in the UI like this:
      http query:
      filter. := "id gt (value stored in variable or key called 'id') "

      Thanks,
      Hope I could explain it better.
      Pls try to help.

      Comment

      Working...