Skip to content

Commit

Permalink
Add Rule.create_on to UI form
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirFilonov committed Dec 8, 2024
1 parent 53303f8 commit e68c23e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
30 changes: 25 additions & 5 deletions keep-ui/app/(keep)/rules/CorrelationSidebar/CorrelationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const CorrelationForm = ({
/>
</span>
</fieldset>
<fieldset className="grid grid-cols-2">
<fieldset className="grid grid-cols-3">
<div className="mr-10">
<label
className="flex items-center text-tremor-default font-medium text-tremor-content-strong"
Expand All @@ -109,7 +109,7 @@ export const CorrelationForm = ({
<Controller
control={control}
name="groupedAttributes"
render={({ field: { value, onChange } }) => (
render={({field: {value, onChange}}) => (
<MultiSelect
className="mt-2"
value={value}
Expand All @@ -126,7 +126,7 @@ export const CorrelationForm = ({
/>
</div>

<div>
<div className="mr-10">
<label
className="flex items-center text-tremor-default font-medium text-tremor-content-strong"
htmlFor="resolveOn"
Expand All @@ -137,7 +137,7 @@ export const CorrelationForm = ({
<Controller
control={control}
name="resolveOn"
render={({ field: { value, onChange } }) => (
render={({field: {value, onChange}}) => (
<Select value={value} onValueChange={onChange} className="mt-2">
<SelectItem value="never">No auto-resolution</SelectItem>
<SelectItem value="all">All alerts resolved</SelectItem>
Expand All @@ -147,13 +147,33 @@ export const CorrelationForm = ({
)}
/>
</div>

<div>
<label
className="flex items-center text-tremor-default font-medium text-tremor-content-strong"
htmlFor="resolveOn"
>
Start incident on{" "}
</label>

<Controller
control={control}
name="createOn"
render={({field: {value, onChange}}) => (
<Select value={value} onValueChange={onChange} className="mt-2">
<SelectItem value="any">Any condition met</SelectItem>
<SelectItem value="all">All conditions met</SelectItem>
</Select>
)}
/>
</div>
</fieldset>

<div className="flex items-center space-x-2">
<Controller
control={control}
name="requireApprove"
render={({ field: { value, onChange } }) => (
render={({field: {value, onChange}}) => (
<Switch
color="orange"
id="requireManualApprove"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const CorrelationSidebarBody = ({
groupedAttributes,
requireApprove,
resolveOn,
createOn,
} = correlationFormData;

const body = {
Expand All @@ -83,6 +84,7 @@ export const CorrelationSidebarBody = ({
groupingCriteria: alertsFound.length ? groupedAttributes : [],
requireApprove: requireApprove,
resolveOn: resolveOn,
createOn: createOn,
};

try {
Expand Down
2 changes: 2 additions & 0 deletions keep-ui/app/(keep)/rules/CorrelationSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const DEFAULT_CORRELATION_FORM_VALUES: CorrelationForm = {
groupedAttributes: [],
requireApprove: false,
resolveOn: "never",
createOn: "any",
query: {
combinator: "or",
rules: [
Expand All @@ -35,6 +36,7 @@ export type CorrelationForm = {
groupedAttributes: string[];
requireApprove: boolean;
resolveOn: "all" | "first" | "last" | "never";
createOn: "any" | "all";
query: RuleGroupType;
};

Expand Down
1 change: 1 addition & 0 deletions keep-ui/app/(keep)/rules/CorrelationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const CorrelationTable = ({ rules }: CorrelationTableProps) => {
groupedAttributes: selectedRule.grouping_criteria,
requireApprove: selectedRule.require_approve,
resolveOn: selectedRule.resolve_on,
createOn: selectedRule.create_on,
query: queryInGroup,
incidents: selectedRule.incidents,
};
Expand Down
1 change: 1 addition & 0 deletions keep-ui/utils/hooks/useRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Rule = {
update_time: string | null;
require_approve: boolean;
resolve_on: "all" | "first" | "last" | "never";
create_on: "any" | "all";
distribution: { [group: string]: { [timestamp: string]: number } };
incidents: number;
};
Expand Down
1 change: 0 additions & 1 deletion tests/test_rules_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pytest

from boom import fingerprint
from keep.api.core.db import create_rule as create_rule_db
from keep.api.core.db import get_incident_alerts_by_incident_id, get_last_incidents, set_last_alert
from keep.api.core.db import get_rules as get_rules_db
Expand Down

0 comments on commit e68c23e

Please sign in to comment.