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

[SIEM] Add toaster logic for Machine Learning #41401

Merged
merged 10 commits into from
Jul 17, 2019

Conversation

FrankHassanabad
Copy link
Contributor

@FrankHassanabad FrankHassanabad commented Jul 17, 2019

Summary

Fixes two blockers:

  1. Anomaly table would spin forever if you zero jobs configured on a fresh install.

  2. If you get Network or ML errors this will report the error to the user in the form of the global toaster.

Two examples of Error Toaster before the "See the full error(s)" is clicked:

toast

Screen Shot 2019-07-17 at 4 04 30 PM

Example Error Toasters from start job expanded and collapsed:

Screen Shot 2019-07-17 at 12 15 04 PM

Screen Shot 2019-07-17 at 12 14 58 PM

Example Network Error Toaster:
Screen Shot 2019-07-17 at 12 21 10 PM

Example API Error if you send in something bad such as a bad payload:
Screen Shot 2019-07-17 at 12 34 04 PM

Example Anomalies Table Error if you have a network issue:
Screen Shot 2019-07-17 at 12 39 57 PM

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

import { ToasterErrorsType, ToasterErrors } from './throw_if_not_ok';

export type ErrorToToasterArgs = Partial<AppToast> & {
error: unknown;
Copy link
Member

Choose a reason for hiding this comment

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

++ on the unknown here! And thanks for the reading material -- good stuff!

@FrankHassanabad FrankHassanabad changed the title Add toaster logic [SIEM] Add toaster logic for Machine Learning Jul 17, 2019
});

await throwIfNotOk(closeJobsResponse);
return [stopDatafeedsResponseJson, await closeJobsResponse.json()];
Copy link
Member

Choose a reason for hiding this comment

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

This file cleaned up real well with the way you've structured you're error reporting -- very nice! 👏

@FrankHassanabad FrankHassanabad marked this pull request as ready for review July 17, 2019 21:55
@FrankHassanabad FrankHassanabad added release_note:skip Skip the PR/issue when compiling release notes v8.0.0 v7.3.0 v7.4.0 labels Jul 17, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/secops

@spong
Copy link
Member

spong commented Jul 17, 2019

Looks like there's some title overflow in IE11, but this appears to be pre-existing, so no change necessary.

It's got the super skinny, but it works! 🎉

Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

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

Performed code review, checked out, tested locally against an Elastic Cloud 7.3.0 BC4 deployment in all browsers (Chrome, FF, Safari & IE11), and was getting errors everywhere expected. Did additional testing with multiple ml_nodes, disabling nodes while jobs were running, and so on and so forth and everything is looked good. LGTM 👍

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@FrankHassanabad FrankHassanabad merged commit 1f8c215 into elastic:master Jul 17, 2019
@FrankHassanabad FrankHassanabad deleted the add-toaster-logic branch July 17, 2019 23:45
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Jul 17, 2019
* Initial toaster logic

* Updated toaster error handling

* Cleanups of code not used

* Added i18n support

* Added missing i18n keys and fixed the name spaces of all of them

* Added unit test

* Added the rest of the unit tests

* Updated from feedback from the PR review

* Fix capitalization issue
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Jul 17, 2019
* Initial toaster logic

* Updated toaster error handling

* Cleanups of code not used

* Added i18n support

* Added missing i18n keys and fixed the name spaces of all of them

* Added unit test

* Added the rest of the unit tests

* Updated from feedback from the PR review

* Fix capitalization issue
FrankHassanabad added a commit that referenced this pull request Jul 18, 2019
## Summary

Fixes two blockers:

1) Anomaly table would spin forever if you zero jobs configured on a fresh install.

2) If you get Network or ML errors this will report the error to the user in the form of the global toaster.

Two examples of Error Toaster before the "See the full error(s)" is clicked:

![toast](https://user-images.githubusercontent.com/1151048/61415060-f2089200-a8ac-11e9-8293-3dfcdbbe069e.png)

<img width="348" alt="Screen Shot 2019-07-17 at 4 04 30 PM" src="https://user-images.githubusercontent.com/1151048/61414971-ac4bc980-a8ac-11e9-9d15-28ab1229922f.png">

Example Error Toasters from start job expanded and collapsed:

<img width="800" alt="Screen Shot 2019-07-17 at 12 15 04 PM" src="https://user-images.githubusercontent.com/1151048/61414610-9e497900-a8ab-11e9-97cd-ec68e77a555c.png">

<img width="808" alt="Screen Shot 2019-07-17 at 12 14 58 PM" src="https://user-images.githubusercontent.com/1151048/61414628-aacdd180-a8ab-11e9-8ad8-edc67deb8874.png">

Example Network Error Toaster:
<img width="437" alt="Screen Shot 2019-07-17 at 12 21 10 PM" src="https://user-images.githubusercontent.com/1151048/61414635-b3260c80-a8ab-11e9-8e50-a35a05fc6d2b.png">

Example API Error if you send in something bad such as a bad payload:
<img width="442" alt="Screen Shot 2019-07-17 at 12 34 04 PM" src="https://user-images.githubusercontent.com/1151048/61414658-c0db9200-a8ab-11e9-88ed-e6634f17103a.png">

Example Anomalies Table Error if you have a network issue:
<img width="464" alt="Screen Shot 2019-07-17 at 12 39 57 PM" src="https://user-images.githubusercontent.com/1151048/61414691-cf29ae00-a8ab-11e9-882c-3cc770776f2f.png">



### Checklist

Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR.

- [x] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)
- [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/master/packages/kbn-i18n/README.md)
- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials
- [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)

### For maintainers

- [x] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
- [x] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
FrankHassanabad added a commit that referenced this pull request Jul 18, 2019
## Summary

Fixes two blockers:

1) Anomaly table would spin forever if you zero jobs configured on a fresh install.

2) If you get Network or ML errors this will report the error to the user in the form of the global toaster.

Two examples of Error Toaster before the "See the full error(s)" is clicked:

![toast](https://user-images.githubusercontent.com/1151048/61415060-f2089200-a8ac-11e9-8293-3dfcdbbe069e.png)

<img width="348" alt="Screen Shot 2019-07-17 at 4 04 30 PM" src="https://user-images.githubusercontent.com/1151048/61414971-ac4bc980-a8ac-11e9-9d15-28ab1229922f.png">

Example Error Toasters from start job expanded and collapsed:

<img width="800" alt="Screen Shot 2019-07-17 at 12 15 04 PM" src="https://user-images.githubusercontent.com/1151048/61414610-9e497900-a8ab-11e9-97cd-ec68e77a555c.png">

<img width="808" alt="Screen Shot 2019-07-17 at 12 14 58 PM" src="https://user-images.githubusercontent.com/1151048/61414628-aacdd180-a8ab-11e9-8ad8-edc67deb8874.png">

Example Network Error Toaster:
<img width="437" alt="Screen Shot 2019-07-17 at 12 21 10 PM" src="https://user-images.githubusercontent.com/1151048/61414635-b3260c80-a8ab-11e9-8e50-a35a05fc6d2b.png">

Example API Error if you send in something bad such as a bad payload:
<img width="442" alt="Screen Shot 2019-07-17 at 12 34 04 PM" src="https://user-images.githubusercontent.com/1151048/61414658-c0db9200-a8ab-11e9-88ed-e6634f17103a.png">

Example Anomalies Table Error if you have a network issue:
<img width="464" alt="Screen Shot 2019-07-17 at 12 39 57 PM" src="https://user-images.githubusercontent.com/1151048/61414691-cf29ae00-a8ab-11e9-882c-3cc770776f2f.png">



### Checklist

Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR.

- [x] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)
- [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/master/packages/kbn-i18n/README.md)
- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials
- [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)

### For maintainers

- [x] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
- [x] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
@@ -75,6 +79,7 @@ export const useAnomaliesTableData = ({
const config = useContext(KibanaConfigContext);
const capabilities = useContext(MlCapabilitiesContext);
const userPermissions = hasMlUserPermissions(capabilities);
const [, dispatchToaster] = useStateToaster();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit -I am used to see it the other way around like const dispatchToaster = useStateToaster()[1];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing wrong with that way since it is valid ts/js, but in the all the videos for React Hooks, including the introduction of them, they use array destructoring which is the reasoning for my choice.

Let me know if I'm not seeing something with the tutorials or others that have hooks which use array indexes over destructoring as I am curious.

iconType = 'alert',
dispatchToaster,
}: ErrorToToasterArgs) => {
if (isToasterError(error)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, I think that you can simplify it like that

const toast: AppToast = {
  id,
  title,
  color,
  iconType,
  errors: ['Network Error'],
};

if (isToasterError(error)) {
  toast.errors = error.messages;
} else if (isAnError(error)) {
  toast.errors = [error.message];
}

dispatchToaster({
  type: 'addToaster',
  toast,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appreciate it, I will try to work it into a follow up PR 🤞 here soon.

Thank you for looking at my PR Xavier and giving me feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.3.0 v7.4.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants