-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[ML] AIOps: Move Log Rate Analysis results callout to help popover. #192243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
walterra
merged 9 commits into
elastic:main
from
walterra:ml-aiops-log-rate-analysis-help-popover
Sep 23, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b886e06
move callout to help popover
walterra b827067
use badge instead of icon
walterra 62d336d
fix i18n
walterra f4b29bf
fix functional tests
walterra c301ea1
get rid of SCSS
walterra 97c37d8
add help icon to badge
walterra 5bd227d
Merge branch 'main' into ml-aiops-log-rate-analysis-help-popover
walterra aef2e0a
add click event to badge icon
walterra f32a85e
Merge branch 'main' into ml-aiops-log-rate-analysis-help-popover
walterra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_info_popover.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React, { useState, type FC } from 'react'; | ||
|
|
||
| import { EuiBadge, EuiPopover, EuiPopoverTitle, EuiText } from '@elastic/eui'; | ||
|
|
||
| import { LOG_RATE_ANALYSIS_TYPE } from '@kbn/aiops-log-rate-analysis'; | ||
| import { useAppSelector } from '@kbn/aiops-log-rate-analysis/state'; | ||
| import { i18n } from '@kbn/i18n'; | ||
|
|
||
| import { useEuiTheme } from '../../hooks/use_eui_theme'; | ||
|
|
||
| export const LogRateAnalysisInfoPopoverButton: FC<{ | ||
| onClick: React.MouseEventHandler<HTMLButtonElement>; | ||
| label: string; | ||
| }> = ({ onClick, label }) => { | ||
| return ( | ||
| <EuiBadge | ||
| iconType="help" | ||
|
rbrtj marked this conversation as resolved.
|
||
| iconSide="right" | ||
| color="success" | ||
| // Defining both iconOnClick and onClick so the mouse cursor changes for cases. | ||
| iconOnClick={onClick} | ||
| iconOnClickAriaLabel='Click to open "Log rate analysis info" popover' | ||
| onClick={onClick} | ||
| onClickAriaLabel='Click to open "Log rate analysis info" popover' | ||
| data-test-subj="aiopsLogRateAnalysisInfoPopoverButton" | ||
| > | ||
| {label} | ||
| </EuiBadge> | ||
| ); | ||
| }; | ||
|
|
||
| export const LogRateAnalysisInfoPopover: FC = () => { | ||
| const euiTheme = useEuiTheme(); | ||
|
|
||
| const showInfoPopover = useAppSelector( | ||
| (s) => s.logRateAnalysisResults.significantItems.length > 0 | ||
| ); | ||
| const zeroDocsFallback = useAppSelector((s) => s.logRateAnalysisResults.zeroDocsFallback); | ||
| const analysisType = useAppSelector((s) => s.logRateAnalysisResults.currentAnalysisType); | ||
| const fieldSelectionMessage = useAppSelector( | ||
| (s) => s.logRateAnalysisFieldCandidates.fieldSelectionMessage | ||
| ); | ||
|
|
||
| const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
|
|
||
| const infoTitlePrefix = i18n.translate('xpack.aiops.analysis.analysisTypeInfoTitlePrefix', { | ||
| defaultMessage: 'Analysis type: ', | ||
| }); | ||
| let infoTitle: string; | ||
| let infoContent: string; | ||
|
|
||
| if (!showInfoPopover) { | ||
| return null; | ||
| } | ||
|
|
||
| if (!zeroDocsFallback && analysisType === LOG_RATE_ANALYSIS_TYPE.SPIKE) { | ||
| infoTitle = i18n.translate('xpack.aiops.analysis.analysisTypeSpikeInfoTitle', { | ||
| defaultMessage: 'Log rate spike', | ||
| }); | ||
| infoContent = i18n.translate('xpack.aiops.analysis.analysisTypeSpikeInfoContent', { | ||
| defaultMessage: | ||
| 'The median log rate in the selected deviation time range is higher than the baseline. Therefore, the analysis results table shows statistically significant items within the deviation time range that are contributors to the spike. The "doc count" column refers to the amount of documents in the deviation time range.', | ||
| }); | ||
| } else if (!zeroDocsFallback && analysisType === LOG_RATE_ANALYSIS_TYPE.DIP) { | ||
| infoTitle = i18n.translate('xpack.aiops.analysis.analysisTypeDipInfoTitle', { | ||
| defaultMessage: 'Log rate dip', | ||
| }); | ||
| infoContent = i18n.translate('xpack.aiops.analysis.analysisTypeDipInfoContent', { | ||
| defaultMessage: | ||
| 'The median log rate in the selected deviation time range is lower than the baseline. Therefore, the analysis results table shows statistically significant items within the baseline time range that are less in number or missing within the deviation time range. The "doc count" column refers to the amount of documents in the baseline time range.', | ||
| }); | ||
| } else if (zeroDocsFallback && analysisType === LOG_RATE_ANALYSIS_TYPE.SPIKE) { | ||
| infoTitle = i18n.translate('xpack.aiops.analysis.analysisTypeSpikeFallbackInfoTitle', { | ||
| defaultMessage: 'Top items for deviation time range', | ||
| }); | ||
| infoContent = i18n.translate('xpack.aiops.analysis.analysisTypeSpikeInfoContentFallback', { | ||
| defaultMessage: | ||
| 'The baseline time range does not contain any documents. Therefore the results show top log message categories and field values for the deviation time range.', | ||
| }); | ||
| } else if (zeroDocsFallback && analysisType === LOG_RATE_ANALYSIS_TYPE.DIP) { | ||
| infoTitle = i18n.translate('xpack.aiops.analysis.analysisTypeDipFallbackInfoTitle', { | ||
| defaultMessage: 'Top items for baseline time range', | ||
| }); | ||
| infoContent = i18n.translate('xpack.aiops.analysis.analysisTypeDipInfoContentFallback', { | ||
| defaultMessage: | ||
| 'The deviation time range does not contain any documents. Therefore the results show top log message categories and field values for the baseline time range.', | ||
| }); | ||
| } else { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <EuiPopover | ||
| anchorPosition="upCenter" | ||
| button={ | ||
| <LogRateAnalysisInfoPopoverButton | ||
| onClick={setIsPopoverOpen.bind(null, !isPopoverOpen)} | ||
| label={infoTitle} | ||
| /> | ||
| } | ||
| closePopover={setIsPopoverOpen.bind(null, false)} | ||
| isOpen={isPopoverOpen} | ||
| ownFocus | ||
| panelPaddingSize="m" | ||
| > | ||
| {infoTitle && ( | ||
| <EuiPopoverTitle> | ||
| {infoTitlePrefix} | ||
| {infoTitle} | ||
| </EuiPopoverTitle> | ||
| )} | ||
|
|
||
| <EuiText size="s" css={{ maxWidth: `calc(${euiTheme.euiSizeXL} * 15);` }}> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit weird but it's a mix of what the EUI docs say to do with their sizes and what I copied over from the ml help popover while getting rid of the SCSS there. |
||
| <p> | ||
| {infoContent} | ||
| {fieldSelectionMessage && ` ${fieldSelectionMessage}`} | ||
| </p> | ||
| </EuiText> | ||
| </EuiPopover> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
x-pack/plugins/aiops/public/components/log_rate_analysis/log_rate_analysis_type_callout.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.