[ZBX-25099] Using python Zabbix_Utils, the triggers.get API call always returns all triggers regardless of the host and hostids parameters. Created: 2024 Aug 22  Updated: 2024 Aug 22  Resolved: 2024 Aug 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 7.0.3
Fix Version/s: None

Type: Incident report Priority: Major
Reporter: Juan Carlos Angelucci Assignee: Zabbix Support Team
Resolution: Fixed Votes: 0
Labels: api, trigger.get
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: JPEG File Problem.jpg    

 Description   

When making the triggers.get API call and passing a host or hostids as parameters, it returns all triggers configured in Zabbix instead of filtering those that belong to the specified host. When testing the same method through Postman, it works correctly and only returns the triggers for the host provided as a parameter.

Attached are scripts to reproduce the error.
Python Using host
from zabbix_utils import ZabbixAPI

zabbix_url = "xxxxxxxxxxxxxx"
api_key = "xxxxxxxxxxxxxxxx"
zapi = ZabbixAPI(url=zabbix_url, token=api_key)
hostname= "xxxxxxxxxxx"
triggers = zapi.trigger.get(

{ "host": hostname, "output": "extend", }

)
for trigger in triggers:
print(f"- {trigger['description']}")

Python Using host
from zabbix_utils import ZabbixAPI

zabbix_url = "xxxxxxxxxxxxxx"
api_key = "xxxxxxxxxxxxxxxx"
zapi = ZabbixAPI(url=zabbix_url, token=api_key)
hostname= "xxxxxxxxxxx"

hosts = zapi.host.get({"filter": {"host": hostname}})
host_id = hosts[0]['hostid']
triggers = zapi.trigger.get(

{ "hostids": host_id, "output": "extend", }

)
for trigger in triggers:
print(f"- {trigger['description']}")

Postman:
Get: https://xxxxxxxxxxxxxx/api_jsonrpc.php
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params":

{ "host": "xxxxxxxxxxxx", "output": "extend" }

,
"auth": "xxxxxxxxxxxxxxx",
"id": 1
}

This was tested with Zabbix 7.



 Comments   
Comment by Alexey Pustovalov [ 2024 Aug 22 ]

You use API methods incorrectly:

triggers = zapi.trigger.get(
    host = 'Zabbix server',
    output = ["extend"]
    )

Please check official documentation: https://github.com/zabbix/python-zabbix-utils

Comment by Juan Carlos Angelucci [ 2024 Aug 22 ]

Same Result using 
["extend"]

 
from zabbix_utils import ZabbixAPI

  1. Conexión al Zabbix
    zabbix_url = "xxxxxxxxxxxxxxxx"
    api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
    zapi = ZabbixAPI(url=zabbix_url, token=api_key)
    hostname= "Zabbix Server"
    hosts = zapi.host.get({"filter": {"host": hostname}})
    host_id = hosts[0]['hostid']
    triggers = zapi.trigger.get( {         "host": hostname,         "output": ["extend"]     }

    )
    for trigger in triggers:
        print(f"- {trigger['description']}")

Comment by Juan Carlos Angelucci [ 2024 Aug 22 ]

Same Result using 
["extend"]

 
from zabbix_utils import ZabbixAPI

zabbix_url = "xxxxxxxxxxxxxxxx"
api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
zapi = ZabbixAPI(url=zabbix_url, token=api_key)
hostname= "Zabbix Server"
triggers = zapi.trigger.get(

{         "host": hostname,         "output": ["extend"]     }

)
for trigger in triggers:
    print(f"-

{trigger['description']}

")

Comment by Alexey Pustovalov [ 2024 Aug 22 ]

Please check official documentation: https://github.com/zabbix/python-zabbix-utils!

Comment by Juan Carlos Angelucci [ 2024 Aug 22 ]

"Thank you for responding. However, isn't this something that should be resolved by the Python library if the request is malformed? Due to the lack of [], it returns all the triggers."

Comment by Alexey Pustovalov [ 2024 Aug 22 ]

It is not malformed, you just do not specify any parameters. By default, it means all data.

Generated at Sun Jun 29 06:45:32 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.