Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Jan 5, 2025
2 parents ca295e6 + 81d69fe commit ea343b0
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 106 deletions.
4 changes: 2 additions & 2 deletions keep-ui/app/(keep)/alerts/ViewAlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({
<Modal
onClose={handleClose}
isOpen={isOpen}
className="overflow-visible max-w-fit"
className="overflow-visible max-w-[800px]"
>
<div className="flex justify-between items-center mb-4 min-w-full">
<h2 className="text-lg font-semibold">Alert Details</h2>
Expand Down Expand Up @@ -130,7 +130,7 @@ export const ViewAlertModal: React.FC<ViewAlertModalProps> = ({
</div>
</div>
{alert && (
<pre className="p-2 bg-gray-100 rounded mt-2 overflow-auto">
<pre className="p-2 bg-gray-100 rounded mt-2 overflow-auto whitespace-pre-wrap break-all">
<p>&#123;</p>
{highlightKeys(alert, alert.enriched_fields)}
<p>&#125;</p>
Expand Down
91 changes: 41 additions & 50 deletions keep-ui/app/(keep)/alerts/alerts-rules-builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import QueryBuilder, {
} from "react-querybuilder";
import "react-querybuilder/dist/query-builder.scss";
import { Table } from "@tanstack/react-table";
import { FiSave } from "react-icons/fi";
import {
AlertDto,
severityMapping,
Expand All @@ -27,8 +28,6 @@ import { FiExternalLink } from "react-icons/fi";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { toast } from "react-toastify";
import { CornerDownLeft } from "lucide-react";
import { Link } from "@/components/ui";
import { DocumentTextIcon } from "@heroicons/react/24/outline";
import { STATIC_PRESETS_NAMES } from "@/entities/presets/model/constants";
import { Preset } from "@/entities/presets/model/types";
import { usePresetActions } from "@/entities/presets/model/usePresetActions";
Expand Down Expand Up @@ -89,7 +88,7 @@ const CustomMenuList = (props: MenuListProps<{}>) => {
<kbd style={kbdStyle}>Enter</kbd> to update query
</span>
<a
href="https://docs.keephq.dev/overview/presets"
href="https://docs.keephq.dev/overview/cel"
target="_blank"
rel="noopener noreferrer"
style={{
Expand Down Expand Up @@ -495,8 +494,8 @@ export const AlertsRulesBuilder = ({
operators: getOperators(id),
}))
: customFields
? customFields
: [];
? customFields
: [];

const onImportSQL = () => {
setImportSQLOpen(true);
Expand Down Expand Up @@ -564,25 +563,28 @@ export const AlertsRulesBuilder = ({
<div className="flex flex-wrap gap-2 items-center relative flex-grow">
{/* Textarea and error message container */}
<div className="flex-grow relative" ref={wrapperRef}>
<Textarea
ref={textAreaRef}
rows={1}
className="resize-none overflow-hidden w-full pr-9 min-h-[38px]" // Padding for clear button and height to match the button height
value={celRules}
onValueChange={onValueChange}
onKeyDown={handleKeyDown}
placeholder='Use CEL to filter your alerts e.g. source.contains("kibana").'
error={!isValidCEL}
onFocus={() => setShowSuggestions(true)}
/>
{celRules && (
<button
onClick={handleClearInput}
className="absolute top-0 right-0 w-9 h-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600" // Position to the left of the Enter to apply badge
>
<XMarkIcon className="h-4 w-4" />
</button>
)}
<div className="relative">
<IoSearchOutline className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4" />
<Textarea
ref={textAreaRef}
rows={1}
className="resize-none overflow-hidden w-full pr-9 pl-9 min-h-[38px]" // Added pl-9 for left padding to accommodate icon
value={celRules}
onValueChange={onValueChange}
onKeyDown={handleKeyDown}
placeholder='Use CEL to filter your alerts e.g. source.contains("kibana").'
error={!isValidCEL}
onFocus={() => setShowSuggestions(true)}
/>
{celRules && (
<button
onClick={handleClearInput}
className="absolute top-0 right-0 w-9 h-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600" // Position to the left of the Enter to apply badge
>
<XMarkIcon className="h-4 w-4" />
</button>
)}
</div>
{showSuggestions && (
<div className="absolute z-10 w-full">
<Select
Expand All @@ -599,16 +601,7 @@ export const AlertsRulesBuilder = ({
Invalid Common Expression Logic expression.
</div>
)}
<div className="flex items-center justify-between pt-1 px-2">
<Link
href="https://docs.keephq.dev/overview/presets"
target="_blank"
rel="noreferrer noopener"
className="text-xs text-tremor-muted"
icon={DocumentTextIcon}
>
CEL Documentation
</Link>
<div className="flex items-center justify-end pt-1 px-2">
<span className="text-xs text-gray-400">
<CornerDownLeft className="h-3 w-3 mr-1 inline-block" />
Enter to apply
Expand All @@ -618,22 +611,11 @@ export const AlertsRulesBuilder = ({
</div>

{/* Buttons next to the Textarea */}
{showSqlImport && (
<Button
color="orange"
variant="secondary"
type="button"
onClick={onImportSQL}
icon={TbDatabaseImport}
size="sm"
tooltip="Import from SQL"
>
Import from SQL
</Button>
)}
{showSave && (
<Button
icon={FiSave}
color="orange"
variant="secondary"
size="sm"
disabled={!celRules.length}
onClick={() => validateAndOpenSaveModal(celRules)}
Expand All @@ -642,9 +624,18 @@ export const AlertsRulesBuilder = ({
? "Edit preset"
: "Save current filter as a preset"
}
>
{action === "update" ? "Edit" : "Save"}
</Button>
></Button>
)}
{showSqlImport && (
<Button
color="orange"
variant="secondary"
type="button"
onClick={onImportSQL}
icon={TbDatabaseImport}
size="sm"
tooltip="Import from SQL"
></Button>
)}
{isDynamic && (
<Button
Expand Down
88 changes: 44 additions & 44 deletions keep-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion keep-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"lodash": "^4.17.21",
"lodash.debounce": "^4.0.8",
"lucide-react": "^0.460.0",
"next": "^14.2.13",
"next": "^14.2.22",
"next-auth": "^5.0.0-beta.25",
"openai": "^4.73.0",
"postcss": "^8.4.31",
Expand Down
26 changes: 20 additions & 6 deletions keep/api/tasks/process_event_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,26 @@ def process_event(
except Exception:
provider_class = ProvidersFactory.get_provider_class("keep")

event = provider_class.format_alert(
tenant_id=tenant_id,
event=event,
provider_id=provider_id,
provider_type=provider_type,
)
if isinstance(event, list):
event_list = []
for event_item in event:
if not isinstance(event_item, AlertDto):
event_list.append(provider_class.format_alert(
tenant_id=tenant_id,
event=event_item,
provider_id=provider_id,
provider_type=provider_type,
))
else:
event_list.append(event_item)
event = event_list
else:
event = provider_class.format_alert(
tenant_id=tenant_id,
event=event,
provider_id=provider_id,
provider_type=provider_type,
)
# SHAHAR: for aws cloudwatch, we get a subscription notification message that we should skip
# todo: move it to be generic
if event is None and provider_type == "cloudwatch":
Expand Down
Loading

0 comments on commit ea343b0

Please sign in to comment.