Skip to content

Commit

Permalink
fix(kafka): lastReceived in ISO format (#2824)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Dec 13, 2024
1 parent afc4a72 commit 1046314
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions keep/providers/base/base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"}]
Expand Down

0 comments on commit 1046314

Please sign in to comment.