From 0f665346d4c94850012ed10ccac7c0c8674bd7a0 Mon Sep 17 00:00:00 2001 From: Tal Date: Tue, 3 Dec 2024 22:49:53 +0200 Subject: [PATCH] fix: small UI issue and victoriametrics best efforts (#2747) --- .../app/(keep)/alerts/alert-table-utils.tsx | 7 +++---- .../teams_provider/teams_provider.py | 6 +----- .../victoriametrics_provider.py | 21 +++++++++++-------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/keep-ui/app/(keep)/alerts/alert-table-utils.tsx b/keep-ui/app/(keep)/alerts/alert-table-utils.tsx index 24ef3e1bb..760d085bc 100644 --- a/keep-ui/app/(keep)/alerts/alert-table-utils.tsx +++ b/keep-ui/app/(keep)/alerts/alert-table-utils.tsx @@ -317,8 +317,8 @@ export const useAlertTableCols = ( columnHelper.accessor("status", { id: "status", header: "Status", - maxSize: 80, - size: 80, + maxSize: 100, + size: 100, cell: (context) => ( ( {getAlertLastReceieved(context.getValue())} diff --git a/keep/providers/teams_provider/teams_provider.py b/keep/providers/teams_provider/teams_provider.py index 2e1e458f6..32c9bfd88 100644 --- a/keep/providers/teams_provider/teams_provider.py +++ b/keep/providers/teams_provider/teams_provider.py @@ -125,11 +125,7 @@ def _notify( ) self.logger.debug("Alert message notified to Teams") - try: - return response.json() - except requests.exceptions.JSONDecodeError as e: - self.logger.error(f"Failed to decode response from Teams: {response.text}") - raise ProviderException("Response from Teams is invalid") from e + return {"response_text": response.text} if __name__ == "__main__": diff --git a/keep/providers/victoriametrics_provider/victoriametrics_provider.py b/keep/providers/victoriametrics_provider/victoriametrics_provider.py index 6a0594886..aca0e319e 100644 --- a/keep/providers/victoriametrics_provider/victoriametrics_provider.py +++ b/keep/providers/victoriametrics_provider/victoriametrics_provider.py @@ -51,7 +51,7 @@ class VictoriametricsProviderAuthConfig: default=8880, ) - VMAlertURL: AnyHttpUrl | None = dataclasses.field( + VMAlertURL: AnyHttpUrl | None = dataclasses.field( metadata={ "required": False, "description": "The full URL to the VMAlert instance. For example: http://vmalert.mydomain.com:8880", @@ -195,21 +195,24 @@ def _format_alert( ) -> AlertDto | list[AlertDto]: alerts = [] for alert in event["alerts"]: + annotations = alert.get("annotations", {}) + labels = alert.get("labels", {}) + fingerprint = alert.get("fingerprint") alerts.append( AlertDto( - name=alert["labels"]["alertname"], - fingerprint=alert["fingerprint"], - id=alert["fingerprint"], - description=alert["annotations"]["description"], - message=alert["annotations"]["summary"], + name=labels.get("alertname", ""), + fingerprint=fingerprint, + id=fingerprint, + description=annotations.get("description"), + message=annotations.get("summary"), status=VictoriametricsProvider.STATUS_MAP[alert["status"]], severity=VictoriametricsProvider.SEVERITIES_MAP[ alert.get("labels", {}).get("severity", "info") ], - startedAt=alert["startsAt"], - url=alert["generatorURL"], + startedAt=alert.get("startsAt"), + url=alert.get("generatorURL"), source=["victoriametrics"], - labels=alert["labels"], + labels=labels, lastReceived=datetime.datetime.now( tz=datetime.timezone.utc ).isoformat(),