Skip to content

Commit

Permalink
feat: Merge branch 'main' into feature/apps
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl committed Jan 5, 2025
2 parents fe72a26 + dd60931 commit f3703ee
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 110 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
87 changes: 39 additions & 48 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 @@ -573,25 +572,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 @@ -608,16 +610,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 @@ -627,22 +620,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 @@ -651,9 +633,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 @@ -57,7 +57,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
4 changes: 2 additions & 2 deletions keep/api/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

load_dotenv(find_dotenv())
RUNNING_IN_CLOUD_RUN = os.environ.get("K_SERVICE") is not None
PROVIDER_PULL_INTERVAL_DAYS = int(
os.environ.get("KEEP_PULL_INTERVAL", 7)
PROVIDER_PULL_INTERVAL_MINUTE = int(
os.environ.get("KEEP_PULL_INTERVAL", 10080)
) # maximum once a week
STATIC_PRESETS = {
"feed": PresetDto(
Expand Down
8 changes: 4 additions & 4 deletions keep/api/routes/preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pydantic import BaseModel
from sqlmodel import Session, select

from keep.api.consts import PROVIDER_PULL_INTERVAL_DAYS, STATIC_PRESETS
from keep.api.consts import PROVIDER_PULL_INTERVAL_MINUTE, STATIC_PRESETS
from keep.api.core.db import get_db_preset_by_name
from keep.api.core.db import get_presets as get_presets_db
from keep.api.core.db import (
Expand Down Expand Up @@ -87,13 +87,13 @@ def pull_data_from_providers(

if provider.last_pull_time is not None:
now = datetime.now()
days_passed = (now - provider.last_pull_time).days
if days_passed <= PROVIDER_PULL_INTERVAL_DAYS:
minutes_passed = (now - provider.last_pull_time).total_seconds() / 60
if minutes_passed <= PROVIDER_PULL_INTERVAL_MINUTE:
logger.info(
"Skipping provider data pulling since not enough time has passed",
extra={
**extra,
"days_passed": days_passed,
"minutes_passed": minutes_passed,
"provider_last_pull_time": str(provider.last_pull_time),
},
)
Expand Down
Loading

0 comments on commit f3703ee

Please sign in to comment.