From 1046314c36730af1605a530815f6856f4d7be1e0 Mon Sep 17 00:00:00 2001 From: Tal Date: Fri, 13 Dec 2024 13:52:45 +0200 Subject: [PATCH] fix(kafka): lastReceived in ISO format (#2824) --- keep/providers/base/base_provider.py | 27 +++++++++++++++++---------- pyproject.toml | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/keep/providers/base/base_provider.py b/keep/providers/base/base_provider.py index f8e430c74..44e2ebe20 100644 --- a/keep/providers/base/base_provider.py +++ b/keep/providers/base/base_provider.py @@ -19,14 +19,16 @@ import requests from keep.api.bl.enrichments_bl import EnrichmentsBl -from keep.api.core.db import (get_custom_deduplication_rule, get_enrichments, - get_provider_by_name, is_linked_provider) -from keep.api.models.alert import (AlertDto, AlertSeverity, AlertStatus, - IncidentDto) +from keep.api.core.db import ( + get_custom_deduplication_rule, + get_enrichments, + get_provider_by_name, + is_linked_provider, +) +from keep.api.models.alert import AlertDto, AlertSeverity, AlertStatus, IncidentDto from keep.api.models.db.alert import AlertActionType from keep.api.models.db.topology import TopologyServiceInDto -from keep.api.utils.enrichment_helpers import \ - parse_and_enrich_deleted_and_assignees +from keep.api.utils.enrichment_helpers import parse_and_enrich_deleted_and_assignees from keep.contextmanager.contextmanager import ContextManager from keep.providers.models.provider_config import ProviderConfig, ProviderScope from keep.providers.models.provider_method import ProviderMethod @@ -352,8 +354,7 @@ def format_alert( provider_instance = None else: # To prevent circular imports - from keep.providers.providers_factory import \ - ProvidersFactory + from keep.providers.providers_factory import ProvidersFactory provider_instance: BaseProvider = ( ProvidersFactory.get_installed_provider( @@ -683,7 +684,10 @@ def _push_alert(self, alert: dict): id=alert_data.get("id", str(uuid.uuid4())), name=alert_data.get("name", "alert-from-event-queue"), status=alert_data.get("status", AlertStatus.FIRING), - lastReceived=alert_data.get("lastReceived", datetime.datetime.now()), + lastReceived=alert_data.get( + "lastReceived", + datetime.datetime.now(tz=datetime.timezone.utc).isoformat(), + ), environment=alert_data.get("environment", "alert-from-event-queue"), isDuplicate=alert_data.get("isDuplicate", False), duplicateReason=alert_data.get("duplicateReason", None), @@ -737,7 +741,9 @@ def is_installed(self) -> bool: """ Check if provider has been recorded in the database. """ - provider = get_provider_by_name(self.context_manager.tenant_id, self.config.name) + provider = get_provider_by_name( + self.context_manager.tenant_id, self.config.name + ) return provider is not None @property @@ -746,6 +752,7 @@ def is_provisioned(self) -> bool: Check if provider exist in env provisioning. """ from keep.parser.parser import Parser + parser = Parser() parser._parse_providers_from_env(self.context_manager) return self.config.name in self.context_manager.providers_context diff --git a/pyproject.toml b/pyproject.toml index 3b537a696..fc2b44046 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "keep" -version = "0.31.7" +version = "0.31.8" description = "Alerting. for developers, by developers." authors = ["Keep Alerting LTD"] packages = [{include = "keep"}]