Documentation/API issue: host.update with proxy_hostid returns success but does not assign proxy in Zabbix 7.0.x; working solution requires host.massupdate with proxyid

XMLWordPrintable

    • Type: Documentation task
    • Resolution: Unresolved
    • Priority: Trivial
    • None
    • Affects Version/s: 7.0.25rc1, 7.4.9rc1
    • Component/s: API (A), Proxy (P)

      n Zabbix versions 7.0.x (tested on 7.0.19), the API method host.update with the parameter proxy_hostid does not actually assign a proxy to a host, despite returning a successful result:

       ({ "hostids": ["..."] }). 
      

      This issue makes it impossible to automatically
      assign a proxy to a host via API using the documented method. The web interface, however, works correctly.

      This problem is likely related to the architectural change in Zabbix 7.0 where proxies were moved to a separate database table . This change also affected other parts of the API, such as the proxy.get method where the field host was replaced with name .

      Steps to Reproduce

      Use any Zabbix 7.0.x instance with a valid API token (Super Admin role).

      Create or have an existing host ID, e.g., "12132".

      Have an existing proxy ID, e.g., "7".

      Execute a host.update API call to assign the proxy:
      zapi.host.update(hostid="12132", proxy_hostid="7")

      or via JSON-RPC:

      {
          "jsonrpc": "2.0",
          "method": "host.update",
          "params": {
              "hostid": "12132",
              "proxy_hostid": "7"
          },
          "auth": "YOUR_TOKEN",
          "id": 1
      }
      

      The API returns a successful response:

      {
          "jsonrpc": "2.0",
          "result": {
              "hostids": ["12132"]
          },
          "id": 1
      }
      

      Check the host's configuration via the API or web interface. The host will not be assigned to the proxy. It will remain on the server.

      Environment

      Zabbix version: 7.0.19

      OS: Linux (any)

      API Client: py-zabbix, direct JSON-RPC calls

      Expected Behavior
      The API should either:

      a) Assign the proxy correctly, or

      b) Return an appropriate error message explaining why the proxy could not be assigned.

      Actual Behavior

      The API returns a success message, but the host's configuration remains unchanged. This is misleading and makes it impossible to automate proxy assignments, forcing users to rely on the web interface or other workarounds.

      Diagnosis and Solution

      After extensive testing, a working solution was found. The correct way to assign a proxy to a host in Zabbix 7.0 is to use the host.massupdate method with the parameter proxyid (not proxy_hostid), along with the mandatory monitored_by parameter.

      monitored_by: Must be set to "1" to enable monitoring via a proxy.

      proxyid: The ID of the proxy to assign.

      The following code snippet demonstrates the working solution:

      # Assuming you have a ZabbixAPI object 'zapi', a host_id, and a proxy_id.
      # Example:
      # host_id = "12132"
      # proxy_id = "7"
      # monitored_by_proxy = "1"
      
      try:
          result = zapi.do_request('host.massupdate', {
              "hosts": [{"hostid": host_id}],
              "proxyid": proxy_id,
              "monitored_by": "1"
          })
      
          if 'result' in result and result['result'].get('hostids') == [host_id]:
              print("Proxy assigned successfully via massupdate.")
          else:
              print(f"Unexpected response: {result}")
      except Exception as e:
          print(f"Error during massupdate: {e}")
      

      This solution has been verified to work on Zabbix 7.0.19. It correctly assigns the proxy, and the change is reflected in both the API and the web interface.

      Supporting Evidence and Context

      The root cause of this issue is the architectural change in Zabbix 7.0, where proxies were separated from hosts into a dedicated database table . This change, while necessary for new features like Proxy HA, has introduced inconsistencies in the API.

      A Zabbix Feature Request (ZBXNEXT-8500) confirms this major change: "Move proxies to a separate database table" .

      Community members have reported related issues, such as the Grafana-Zabbix plugin failing because it was querying the non-existent host field on the proxy object . The fix for that was to replace host with name.

      A developer's blog post about Zabbix 7.0.0rc1 mentions that the proxyid field was removed in the context of proxy groups . While our issue is with a regular proxy, it demonstrates the volatility of proxy-related API parameters in the 7.0 release.

      A search of the Zabbix forum and issue tracker did not reveal any existing report specifically about the host.update method failing to assign a proxy, making this a potentially undocumented issue.

      Recommended Actions
      Update the API documentation for Zabbix 7.0 and later:

      For host.update, clarify that the proxy_hostid parameter is deprecated or non-functional for assigning a proxy.

      For host.massupdate, explicitly document the parameters proxyid and monitored_by, and provide a clear example for assigning a proxy to a host.

      Consider fixing the host.update method to either work correctly or return a proper error message if the operation is not supported for proxy assignment. The current silent failure is a bug.

      Update the proxy.object documentation to reflect the changes made in Zabbix 7.0 (as noted in the ZBXNEXT-8500 comments ).

      Workaround for Users

      Until this is fixed in the API or clarified in the documentation, users should use the host.massupdate method with proxyid and monitored_by as shown in the code example above.

            Assignee:
            Zabbix Integration Team
            Reporter:
            Anton Osipov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: