forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] AIOps: Move Log Rate Analysis results callout to help popover. (e…
…lastic#192243) ## Summary Moves the callout that describes some analysis details to a help popover. Before: <img width="1064" alt="image" src="https://github.com/user-attachments/assets/cb2820f9-8cdc-4d31-98ac-df199509767a"> After: <img width="1174" alt="image" src="https://github.com/user-attachments/assets/dc795816-6da6-4e58-bc86-d490034140ce"> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
8 changed files
with
142 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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 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" | ||
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);` }}> | ||
<p> | ||
{infoContent} | ||
{fieldSelectionMessage && ` ${fieldSelectionMessage}`} | ||
</p> | ||
</EuiText> | ||
</EuiPopover> | ||
); | ||
}; |
This file contains 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 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 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 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.