Ad Widget

Collapse

API event.get in Zabbix 7.0

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Isaksson
    Junior Member
    • Apr 2024
    • 7

    #1

    API event.get in Zabbix 7.0

    Hello.
    I just upgraded Zabbix 6.4 to 7.0 and one thing that I noticed was that I receive error on one of my API calls.
    This is one example of what now fails but worked in 6.4

    Code:
    {"jsonrpc":"2.0","method":"event.get","params": {"selectHosts": ["host","name"], "objectids": ["24103"], "filter": {"clock": "1714395537"}}, "id": 1}
    The error that I received is this:
    Code:
    "error": {
    "code": -32602,
    "message": "Invalid params.",
    "data": "Invalid parameter \"/filter\": unexpected parameter \"clock\"."
    }
    So, the error messages is clear, and if I remove the filter then the call succeed, so my question is how should I use filter in Zabbix 7.0 API calls.
  • Answer selected by Isaksson at 11-07-2024, 15:58.
    Isaksson
    Junior Member
    • Apr 2024
    • 7

    Thanks for the reply, yeah I looked in the documentation and found that as well, but I did not see why that should cause this error.

    I just tried with source, object, objectid, acknowledged and value and that worked, but failed with clock and ns.

    In the documentation I see this, could that be the cause, Does not support properties of text data type
    Code:
    Return only those results that exactly match the given filter.
    
    Accepts an object, where the keys are property names, and the values are either a single value or an array of values to match against.
    
    Does not support properties of text [URL="https://www.zabbix.com/documentation/current/en/manual/api/reference_commentary#data-types"]data type[/URL].
    Edit:
    I just checked and clock is timestamp and ns is integer so no text data type.
    Last edited by Isaksson; 08-07-2024, 12:57.

    Comment


    • Isaksson
      Isaksson commented
      Editing a comment
      I tried to post a reply but it was Unapproved so I try to add a comment instead

      added a support case on this issue, the response was that
      - The event.get method does not support the "clock" field in filters. Instead, you can use the "time_from" and "time_till" parameters.

      And the case was closed so I could not comment on that, but I have to say that changes like this should be considered breaking changes and mentioned in the documentation.
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    https://www.zabbix.com/documentation...al/api/changes says:

    event
    ZBXNEXT-6974 event.get: Added strict validation of the method parameters.

    I don't see the error in your request though. If you try to filter with something else, do those fail as well?

    Markku

    Comment

    • Isaksson
      Junior Member
      • Apr 2024
      • 7

      #3
      Thanks for the reply, yeah I looked in the documentation and found that as well, but I did not see why that should cause this error.

      I just tried with source, object, objectid, acknowledged and value and that worked, but failed with clock and ns.

      In the documentation I see this, could that be the cause, Does not support properties of text data type
      Code:
      Return only those results that exactly match the given filter.
      
      Accepts an object, where the keys are property names, and the values are either a single value or an array of values to match against.
      
      Does not support properties of text [URL="https://www.zabbix.com/documentation/current/en/manual/api/reference_commentary#data-types"]data type[/URL].
      Edit:
      I just checked and clock is timestamp and ns is integer so no text data type.
      Last edited by Isaksson; 08-07-2024, 12:57.

      Comment


      • Isaksson
        Isaksson commented
        Editing a comment
        I tried to post a reply but it was Unapproved so I try to add a comment instead

        added a support case on this issue, the response was that
        - The event.get method does not support the "clock" field in filters. Instead, you can use the "time_from" and "time_till" parameters.

        And the case was closed so I could not comment on that, but I have to say that changes like this should be considered breaking changes and mentioned in the documentation.
    Working...