Skip to content

fix(zabbix): populate hostname on pulled and pushed alerts#6612

Open
washosk wants to merge 1 commit into
keephq:mainfrom
washosk:fix/zabbix-missing-hostname
Open

fix(zabbix): populate hostname on pulled and pushed alerts#6612
washosk wants to merge 1 commit into
keephq:mainfrom
washosk:fix/zabbix-missing-hostname

Conversation

@washosk

@washosk washosk commented Jul 3, 2026

Copy link
Copy Markdown

Fixes #6613

Summary

Zabbix alerts were missing the host name in two separate ways:

  • Polling (_get_alerts): the problem.get call never asked Zabbix for host data (selectHosts was not set), so pulled alerts had no host information at all.
  • Webhook push (_format_alert): the installed Zabbix script sends the host as host_name / host_ip (matching the parameter names configured in setup_webhook), but the code read hostName / hostIp instead. The primary source, service ({HOST.HOST}), can be empty for problems tied to multiple hosts, and the fallback silently returned None due to this key mismatch.

Changes

  • Add selectHosts: ["host", "name"] to the problem.get request in _get_alerts, and map the host's visible name (falling back to its technical name) onto service/hostname on the AlertDto.
  • Fix _format_alert to read host_name/host_ip (matching the actual webhook payload keys) instead of the non-existent hostName/hostIp.

Test plan

  • Verify pulled alerts (via problem.get polling) now include a host name
  • Verify pushed webhook alerts for a multi-host trigger problem now include a host name
  • No existing tests cover this provider; consider adding unit tests for _get_alerts and _format_alert covering these cases

Zabbix problem.get() alerts never carried a host, since _get_alerts()
never requested host data from the API. Add selectHosts to the request
and map it onto AlertDto's service/hostname fields.

The webhook push path had a separate bug: the installed script sends
the host as host_name/host_ip (matching its own parameter names), but
_format_alert() looked for hostName/hostIp, so the fallback silently
returned None whenever {HOST.HOST} was empty (e.g. multi-host trigger
problems).
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. Bug Something isn't working Provider Providers related issues labels Jul 3, 2026
@CLAassistant

CLAassistant commented Jul 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@shahargl shahargl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just add the new fields and not remove the old one? For backward compatibility /older zabbix versions

@talboren talboren left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working lgtm This PR has been approved by a maintainer Provider Providers related issues size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zabbix alerts missing host name

4 participants