Skip to content

Commit

Permalink
[8.x] [Security Solution][Detection Engine] fixes preview logs issue …
Browse files Browse the repository at this point in the history
…when switching between rules (#197098) (#198051)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution][Detection Engine] fixes preview logs issue when
switching between rules
(#197098)](#197098)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Vitalii
Dmyterko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-28T16:35:36Z","message":"[Security
Solution][Detection Engine] fixes preview logs issue when switching
between rules (#197098)\n\n## Summary\r\n\r\n - addresses
https://github.com/elastic/kibana/issues/196616","sha":"6a6d1f3b6e41f8e1740d3bba4f5537feddbbbb24","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:
SecuritySolution","backport:prev-minor","Team:Detection
Engine","v8.16.0","backport:version","v8.17.0"],"title":"[Security
Solution][Detection Engine] fixes preview logs issue when switching
between
rules","number":197098,"url":"https://github.com/elastic/kibana/pull/197098","mergeCommit":{"message":"[Security
Solution][Detection Engine] fixes preview logs issue when switching
between rules (#197098)\n\n## Summary\r\n\r\n - addresses
https://github.com/elastic/kibana/issues/196616","sha":"6a6d1f3b6e41f8e1740d3bba4f5537feddbbbb24"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197098","number":197098,"mergeCommit":{"message":"[Security
Solution][Detection Engine] fixes preview logs issue when switching
between rules (#197098)\n\n## Summary\r\n\r\n - addresses
https://github.com/elastic/kibana/issues/196616","sha":"6a6d1f3b6e41f8e1740d3bba4f5537feddbbbb24"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Vitalii Dmyterko <[email protected]>
  • Loading branch information
kibanamachine and vitaliidm authored Oct 28, 2024
1 parent 0db9aee commit 799297e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ const RulePreviewComponent: React.FC<RulePreviewProps> = ({

const [isDateRangeInvalid, setIsDateRangeInvalid] = useState(false);

const isLoggedRequestsSupported = RULE_TYPES_SUPPORTING_LOGGED_REQUESTS.includes(ruleType);

useEffect(() => {
const { start, end } = refreshedTimeframe(startDate, endDate);
setTimeframeStart(start);
Expand Down Expand Up @@ -194,7 +196,7 @@ const RulePreviewComponent: React.FC<RulePreviewProps> = ({
interval: scheduleRuleData.interval,
lookback: scheduleRuleData.from,
},
enableLoggedRequests: showElasticsearchRequests,
enableLoggedRequests: showElasticsearchRequests && isLoggedRequestsSupported,
});
setIsRefreshing(true);
}, [
Expand All @@ -205,6 +207,7 @@ const RulePreviewComponent: React.FC<RulePreviewProps> = ({
startDate,
startTransaction,
showElasticsearchRequests,
isLoggedRequestsSupported,
]);

const isDirty = useMemo(
Expand Down Expand Up @@ -279,7 +282,7 @@ const RulePreviewComponent: React.FC<RulePreviewProps> = ({
</EuiFlexItem>
</EuiFlexGroup>
</EuiFormRow>
{RULE_TYPES_SUPPORTING_LOGGED_REQUESTS.includes(ruleType) ? (
{isLoggedRequestsSupported ? (
<EuiFormRow>
<EuiFlexGroup alignItems="center" gutterSize="s" responsive>
<EuiFlexItem grow>
Expand Down Expand Up @@ -312,7 +315,7 @@ const RulePreviewComponent: React.FC<RulePreviewProps> = ({
logs={logs}
hasNoiseWarning={hasNoiseWarning}
isAborted={isAborted}
showElasticsearchRequests={showElasticsearchRequests}
showElasticsearchRequests={showElasticsearchRequests && isLoggedRequestsSupported}
/>
</div>
);
Expand Down

0 comments on commit 799297e

Please sign in to comment.