Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): time represntation to locale time #3282

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions keep-ui/app/(keep)/alerts/alert-table-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,11 @@ export const useAlertTableCols = (
// data is a Date object (converted in usePresetAlerts)
cell: (context) => {
return (
<span title={context.getValue().toISOString()}>
<TimeAgo date={context.getValue().toISOString()} />
<span>
<TimeAgo
date={context.getValue().toISOString()}
title={context.getValue().toLocaleString()}
/>
</span>
);
},
Expand Down
4 changes: 3 additions & 1 deletion keep-ui/app/(keep)/alerts/alert-timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { getInitials } from "@/components/navbar/UserAvatar";
import { DynamicImageProviderIcon } from "@/components/ui";

const formatTimestamp = (timestamp: Date | string) => {
const date = new Date(timestamp);
const date = timestamp.toString().endsWith("Z")
? new Date(timestamp)
: new Date(timestamp.toString() + "Z");
return date.toLocaleString();
};

Expand Down
7 changes: 6 additions & 1 deletion keep/api/bl/enrichments_bl.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,12 @@ def _check_alert_matches_rule(self, alert: AlertDto, rule: MappingRule) -> bool:
):
self.logger.debug(
"Alert does not match any of the conditions for the rule",
extra={"fingerprint": alert.fingerprint, "rule_id": rule.id},
extra={
"fingerprint": alert.fingerprint,
"rule_id": rule.id,
"matchers": rule.matchers,
"alert": str(alert),
},
)
return False

Expand Down
7 changes: 3 additions & 4 deletions keep/api/tasks/process_event_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,11 @@ def __save_to_db(
)
session.add(audit)

alert_dto = AlertDto(**formatted_event.dict())
set_last_alert(tenant_id, alert, session=session)

# Mapping
try:
enrichments_bl.run_mapping_rules(alert_dto)
enrichments_bl.run_mapping_rules(formatted_event)
except Exception:
logger.exception("Failed to run mapping rules")

Expand All @@ -236,8 +235,8 @@ def __save_to_db(
for enrichment in alert_enrichment.enrichments:
# set the enrichment
value = alert_enrichment.enrichments[enrichment]
setattr(alert_dto, enrichment, value)
enriched_formatted_events.append(alert_dto)
setattr(formatted_event, enrichment, value)
enriched_formatted_events.append(formatted_event)
session.commit()

logger.info(
Expand Down
Loading