Skip to content

Commit

Permalink
validate fields only when group by enabled; update default window to …
Browse files Browse the repository at this point in the history
…5 min (opensearch-project#810)

Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan authored Nov 30, 2023
1 parent 059c291 commit fba42a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CorrelationRuleModel } from '../../../../types';

export const correlationRuleStateDefaultValue: CorrelationRuleModel = {
name: '',
time_window: 60000,
time_window: 300000,
queries: [
{
logType: '',
Expand Down
18 changes: 10 additions & 8 deletions public/pages/Correlations/containers/CreateCorrelationRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -709,15 +709,17 @@ export const CreateCorrelationRule: React.FC<CreateCorrelationRuleProps> = (
errors.time_window = 'Invalid time window.';
}

values.queries.forEach((query, idx) => {
if (!query.field) {
if (!errors.queries) {
errors.queries = Array(values.queries.length).fill(null);
}
if (groupByEnabled) {
values.queries.forEach((query, idx) => {
if (!query.field) {
if (!errors.queries) {
errors.queries = Array(values.queries.length).fill(null);
}

(errors.queries as Array<{ field: string }>)[idx] = { field: 'Field is required.' };
}
});
(errors.queries as Array<{ field: string }>)[idx] = { field: 'Field is required.' };
}
});
}

return errors;
}}
Expand Down

0 comments on commit fba42a5

Please sign in to comment.