From da3398cc864cd731a20502d790bfa995875381e2 Mon Sep 17 00:00:00 2001 From: Tal Date: Tue, 24 Sep 2024 17:45:52 +0300 Subject: [PATCH] chore(logs): failing requests in Zabbix provider (#1993) --- .../zabbix_provider/zabbix_provider.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/keep/providers/zabbix_provider/zabbix_provider.py b/keep/providers/zabbix_provider/zabbix_provider.py index 5b00a3977..10caa2d4a 100644 --- a/keep/providers/zabbix_provider/zabbix_provider.py +++ b/keep/providers/zabbix_provider/zabbix_provider.py @@ -335,9 +335,26 @@ def __send_request(self, method: str, params: dict = None): response = requests.post(url, json=data, headers=headers) - response.raise_for_status() + try: + response.raise_for_status() + except requests.HTTPError: + self.logger.exception( + "Error while sending request to Zabbix API", + extra={ + "response": response.text, + "tenant_id": self.context_manager.tenant_id, + }, + ) + raise response_json = response.json() if "error" in response_json: + self.logger.error( + "Error while querying zabbix", + extra={ + "tenant_id": self.context_manager.tenant_id, + "response_json": response_json, + }, + ) raise ProviderMethodException(response_json.get("error", {}).get("data")) return response_json