Skip to content
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

[ML] AiOps: Action for adding Log Pattern embeddable to a dashboard and case #199478

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

rbrtj
Copy link
Contributor

@rbrtj rbrtj commented Nov 8, 2024

Summary

Part of #197247

  • Added the ability to add a Log Pattern Embeddable to a dashboard and case.

  • Fixed the Change Point Detection embeddable in cases and added a functional test to cover this scenario.

Screen.Recording.2024-11-06.at.13.58.01.mov

Checklist

Delete any items that are not applicable to this PR.

const isCasesEmbeddable = embeddingOrigin === AIOPS_EMBEDDABLE_ORIGIN.CASES;

// Disable filtering for cases embeddable, as it's not possible to delete filters
const actions = [...(isCasesEmbeddable ? [] : getActions(false)), ...getActions(true)];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It disables filtering for a pattern in cases. In dashboards, it is possible to delete a filter, but there is currently no such option in cases. I have disabled it for now, but it would be nice to have that option available inside the embeddable.


return (
<>
<FieldValidationCallout validationResults={fieldValidationResult} />
{(loading ?? true) === true ? <LoadingCategorization onCancel={cancelRequest} /> : null}
{(loading ?? true) === true ? (
<LoadingCategorization onCancel={cancelRequest} disableCancelLoading={isCasesEmbeddable} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled cancel loading in cases because it is not possible to refresh the embeddable. Therefore, after canceling, the embeddable would get stuck without results.

@@ -101,10 +101,6 @@ export const ChartGridEmbeddableWrapper: FC<ChangePointDetectionProps> = ({
10000
);

useEffect(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was causing an error because onLoading is not defined for the chart change point embeddable component.
image

@rbrtj rbrtj changed the title Aiops log analysis attachments [ML] AiOps: Action for adding Log Pattern embeddable to a dashboard and case Nov 8, 2024
@rbrtj rbrtj self-assigned this Nov 8, 2024
@rbrtj rbrtj added release_note:enhancement :ml v9.0.0 Team:ML Team label for ML (also use :ml) Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis backport:version Backport to applied version labels v8.17.0 labels Nov 8, 2024
@rbrtj rbrtj marked this pull request as ready for review November 8, 2024 13:43
@rbrtj rbrtj requested review from a team as code owners November 8, 2024 13:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great update! I tested adding pattern analysis to dashboards&cases from the page. Added some minor comments:

const SavedObjectSaveModalDashboard = withSuspense(LazySavedObjectSaveModalDashboard);

interface AttachmentsMenuProps {
dataView: DataView;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use useAiopsAppContext for some of the props here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #c696e4e


const onSave: SaveModalDashboardProps['onSave'] = useCallback(
({ dashboardId, newTitle, newDescription }) => {
const stateTransfer = embeddable!.getStateTransfer();
Copy link
Contributor

@walterra walterra Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is it possible to avoid the !? If you keep passing in embeddable via props you could make it non-optional, other maybe return early? (I saw it's the same for the change point one so probably fine to leave as is if too much trouble refactoring)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The embeddable is no longer passed as a prop since we're now calling useAiopsAppContext directly. In this scenario, I don't think there's much we can do about it. We could return early in the onSave callback, but that’s all.
I tried modifying the AiopsAppContext type to differentiate when embeddable should be defined, but achieving this isn’t that easy.

@@ -20,9 +20,10 @@ import { FormattedMessage } from '@kbn/i18n-react';

interface Props {
onCancel: () => void;
disableCancelLoading?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: An alternative to avoid another prop could be to make onCancel optional and set the button to disabled when it's not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #d162011

randomSamplerProbability: RandomSamplerProbability;
embeddable?: EmbeddableStart;
cases?: CasesPublicStart;
capabilities?: Capabilities;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capabilities shouldn't be optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #c696e4e
and #f5fdb03

]);

return (
<>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, this fragment isn't needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #d162011

@@ -20,9 +20,10 @@ import { FormattedMessage } from '@kbn/i18n-react';

interface Props {
onCancel: () => void;
disableCancelLoading?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than passing in an additional prop to disable this, onCancel could be made optional and the button only enabled if onCancel is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #d162011

const actions = [...getActions(false), ...getActions(true)];
const isCasesEmbeddable = embeddingOrigin === AIOPS_EMBEDDABLE_ORIGIN.CASES;

// Disable filtering for cases embeddable, as it's not possible to delete filters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Disable filtering for cases embeddable, as it's not possible to delete filters
// When in cases, we can only show the "Filter for pattern in Discover" actions as Cases does not have full filter management.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #d162011

const isCasesEmbeddable = embeddingOrigin === AIOPS_EMBEDDABLE_ORIGIN.CASES;

// Disable filtering for cases embeddable, as it's not possible to delete filters
const actions = [...(isCasesEmbeddable ? [] : getActions(false)), ...getActions(true)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, I think this is a bit more readable

Suggested change
const actions = [...(isCasesEmbeddable ? [] : getActions(false)), ...getActions(true)];
const actions = isCasesEmbeddable
? getActions(true)
: [...getActions(false), ...getActions(true)];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: #d162011

@walterra
Copy link
Contributor

To slightly increase the bundle size for the PR to pass you need to updated the threshold in this file for aiops: packages/kbn-optimizer/limits.yml.

@rbrtj rbrtj requested a review from a team as a code owner November 12, 2024 07:56
Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment about the cancel button, but otherwise LGTM


return (
<>
<FieldValidationCallout validationResults={fieldValidationResult} />
{(loading ?? true) === true ? <LoadingCategorization onCancel={cancelRequest} /> : null}
{(loading ?? true) === true ? <LoadingCategorization /> : null}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still want the ability to cancel the loading when the embeddable is in a dashboard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in: 1c4be00

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/kbn-optimizer/limits.yml

displayName: i18n.translate('xpack.aiops.logPatternAnalysis.cases.attachmentName', {
defaultMessage: 'Log pattern analysis',
}),
getAttachmentViewObject: () => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is optional, but you might also want to include a getAttachmentRemovalObject here to define a message for when this attachment is deleted from the case.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 625 627 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
aiops 581.1KB 587.1KB +6.0KB
ml 4.7MB 4.7MB +21.0B
total +6.0KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
aiops 15.5KB 16.1KB +641.0B
Unknown metric groups

async chunk count

id before after diff
aiops 37 38 +1

History

cc @rbrtj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis :ml release_note:enhancement Team:ML Team label for ML (also use :ml) v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants