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

[Monitoring] Enable out of the box alerts modal #101565

Merged
merged 21 commits into from
Jun 29, 2021

Conversation

estermv
Copy link
Contributor

@estermv estermv commented Jun 8, 2021

Summary

Closes #100133. This PR includes the following changes:

  • Remove auto-creation of default rules in stack monitoring
  • Adds a modal that allows the user to create the default rules:

Screenshot 2021-06-22 at 18 05 58

  • If there are already alerts created, the modal won't appear.
  • After the user answers "Yes" or "No" they shouldn't see the modal again. (we use localStorage to save if the user answered the modal)
  • Adds a "Rules and Alerts" in the navigation bar, with an option to create the default rules.

Screenshot 2021-06-22 at 18 06 08

Test cases

When monitoring is disabled

  • Everything should work as before - modal should not appear and alerts should not be created

When there is no monitoring data

  • Everything should work as before - modal should not appear and alerts should not be created

When the user has existing rules

  • They shouldn't see any modal

When the user doesn't have existing rules

  • They should see the modal the first time they visit a cluster overview page

When the user doesn't have existing rules and selects "Yes" on the rules modal

  • Rules should be created
  • The user shouldn't see the modal anymore

When the user doesn't have existing rules and selects "No" on the rules modal

  • Rules shouldn't be created
  • The user shouldn't see the modal anymore

When the user doesn't have existing rules and selects "Remind me later" or closes the modal with the X button:

  • Rules shouldn't be created
  • The user should see the modal in a new page session (this is controlled by storing a variable in the sessionStorage)

When the user selects "Create default rules" from the dropdown in the navigation bar

  • Rules should be created if they don't exist

Technical notes

Alerts are created by the api/monitoring/v1/alerts/enable endpoint. The backend didn't change, so the behavior of creating alerts should be the same as before.

There are a lot of test files modified. This is because the alerts modal appears on the cluster overview page that is the entry point of them and clicks happen on the modal overlay until it's closed. I tried to find a generic way to close it (or never open it), but I couldn't. I'll open a separate issue to look deeper into it.

Checklist

Delete any items that are not applicable to this PR.

@estermv
Copy link
Contributor Author

estermv commented Jun 22, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@ravikesarwani
Copy link
Contributor

@estermv One additional test case I would also suggest adding to the list it to make sure the flow is working correctly when monitoring is not enabled on the cluster and/or there is no monitoring data. The functionality differs on Cloud (ESS) and self-managed so we probably should try out on both.

@estermv
Copy link
Contributor Author

estermv commented Jun 23, 2021

@estermv One additional test case I would also suggest adding to the list it to make sure the flow is working correctly when monitoring is not enabled on the cluster and/or there is no monitoring data.

@ravikesarwani good point! Just added them and I'll also test them locally before opening the PR.

The functionality differs on Cloud (ESS) and self-managed so we probably should try out on both.

In which ways it differs? I'm not familiar with it.

@ravikesarwani
Copy link
Contributor

ravikesarwani commented Jun 23, 2021

In which ways it differs? I'm not familiar with it.

I haven't tried it out recently but recollect functionality around the following lines:
Cloud: In Cloud it knows that the cluster is in ESS and puts out a message asking customer to enable monitoring from the Cloud console.
Self-managed: If security is not enabled it asks user to enable security before stack monitoring can be used.
It gives out a message asking users to use metricbeat for setting up monitoring. It also has a "single click button" in this case to enable legacy Elasticsearch self monitoring (to get started quickly in a test environment).

@estermv
Copy link
Contributor Author

estermv commented Jun 23, 2021

@elasticmachine merge upstream

@estermv
Copy link
Contributor Author

estermv commented Jun 28, 2021

It gives out a message asking users to use metricbeat for setting up monitoring. It also has a "single click button" in this case to enable legacy Elasticsearch self monitoring (to get started quickly in a test environment).

Then this is for the messaging for when the user doesn't have monitoring enabled yet, it is not affected by the changes in this PR.

@estermv estermv marked this pull request as ready for review June 28, 2021 08:51
@estermv estermv requested a review from a team June 28, 2021 08:51
@estermv
Copy link
Contributor Author

estermv commented Jun 28, 2021

@elasticmachine merge upstream

@estermv estermv requested a review from a team June 28, 2021 08:51
@estermv estermv added release_note:enhancement Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.0.0 labels Jun 28, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)


export function enableAlertsModalProvider($http, $window, $injector) {
function shouldShowAlertsModal(alerts) {
const modalHasBeenShown = $window.sessionStorage.getItem('ALERTS_MODAL_HAS_BEEN_SHOWN');
Copy link
Contributor

Choose a reason for hiding this comment

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

@estermv Is it on purpose that you use sessionStorage here instead of localStorage as you do later on for decisionMade?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's to easily manage the Remind me later option. The modal will appear again to the user in the next page session. This gives a nice "remind me later" feeling on when to show the modal again. (We can always add a specific timer later if we see this don't work)

When the user selects Yes or No we don't want the modal to appear again, so I use the localStorage as "permanent" storage. (Of course, there are some edge cases, like the user cleaning the localStorage or using a different browser, but we left this out from the scope of this PR)

@simianhacker simianhacker self-requested a review June 28, 2021 15:57
Copy link
Member

@simianhacker simianhacker left a comment

Choose a reason for hiding this comment

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

LGTM! Good Job! Thank you for including the checklist for the test scenarios, it was very helpful.

Copy link
Contributor

@katefarrar katefarrar left a comment

Choose a reason for hiding this comment

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

This looks good overall. I have a few UX observations / questions...

  • Once a user selects "Yes" from the modal and creates the rules they are then able to go to the "Alerts and rules" dropdown and "Create default rules". That makes it seem like the default rules were never created. Instead, could the language say "Re-create default rules"?

  • If a user click "Create default rules" from the "Alerts and rules" dropdown they don't receive any type of confirmation until there is a toast notification, which doesn't happen right away. Instead could the default rules modal pop up again and require them to select "Yes" so it's clear they have taken an action?

  • Can we add the "Manage rules" link that goes to app/management/insightsAndAlerting/triggersActions/rules to the "Alerts and rules" dropdown (same functionality the other Observability apps):

Screen Shot 2021-06-28 at 1 20 42 PM

  • Several toast notifications continue to pop up even if only one alert was created. Is that intended? For example, if I select "Yes" for the default rules to be created and then enter setup mode, only 1 alert shows even though I've received several toast notifications saying a new alert was created.

@estermv
Copy link
Contributor Author

estermv commented Jun 29, 2021

@katefarrar thanks a lot for your review!

* Once a user selects "Yes" from the modal and creates the rules they are then able to go to the "Alerts and rules" dropdown and "Create default rules". **That makes it seem like the default rules were never created. Instead, could the language say "Re-create default rules"?**

Should it say always "Re-create default rules"? If the user answers "No" in the modal, do we want to show "Create ..."? If we want both and change it base on the user answer, it's more complicated, since the dropdown appears on every page, I'm not sure if we can know from all pages if the user has alerts created, we could create a separate issue to investigate this.
If we can have always "Re-create default rules" then it's easy to change.

* If a user click "Create default rules" from the "Alerts and rules" dropdown they don't receive any type of confirmation until there is a toast notification, which doesn't happen right away. **Instead could the default rules modal pop up again and require them to select "Yes" so it's clear they have taken an action?**

The modal is not prepared to be opened from the dropdown, if we want this it should be implemented as a separate issue.

* Can we add the "Manage rules" link that goes to `app/management/insightsAndAlerting/triggersActions/rules` to the "Alerts and rules" dropdown (same functionality the other Observability apps):
Screen Shot 2021-06-28 at 1 20 42 PM

It was not clear what should be in this dropdown (there was a bit of discussion in the original issue regarding this). If I remember correctly, the major problem with your suggestion was that users can't edit the stack monitoring alerts from there, they can only delete them. We have a meeting later to discuss the changes of this PR, I'll bring this there and add it in case we have an agreement.

* Several toast notifications continue to pop up even if only one alert was created. Is that intended? **For example, if I select "Yes" for the default rules to be created and then enter setup mode, only 1 alert shows even though I've received several toast notifications saying a new alert was created.**

Not sure what you mean by this. Toast notifications appear each time you select to create alerts and this is intended since it's similar as it worked before. With the auto-creation of alerts, the toast notification appeared each time the user visits the stack monitoring page although nothing was happening if the user already had alerts created. So, for the first version, we thought that we could keep it the same.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
monitoring 562 565 +3

Async chunks

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

id before after diff
monitoring 731.2KB 737.8KB +6.6KB

Page load bundle

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

id before after diff
monitoring 45.5KB 45.5KB +26.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@estermv estermv merged commit 4640253 into elastic:master Jun 29, 2021
@estermv estermv deleted the 100133-stack-monitoring-alerts-opt-in branch June 29, 2021 15:35
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 29, 2021
* Remove api call to create alerts

* Add enable alerts modal

* Update modal title

* Add simple alerts dropdown

* change alerts modal design

* refactor alerts modal provider

* Add alerts dropdown

* Show toast after alert creation and add error handling

* Do not show alerts modal if alerts already exist

* Fix stack monitoring test

* Fix more stack monitoring tests and types

* Fix tests after merge

* Attempt to fix stack monitoring tests

* remove console.log

* Change text

* Remove commented comment

* Update docs for stack monitoring alerts

* Fix docs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 29, 2021
)

* [Monitoring] Enable out of the box alerts modal (#101565)

* Remove api call to create alerts

* Add enable alerts modal

* Update modal title

* Add simple alerts dropdown

* change alerts modal design

* refactor alerts modal provider

* Add alerts dropdown

* Show toast after alert creation and add error handling

* Do not show alerts modal if alerts already exist

* Fix stack monitoring test

* Fix more stack monitoring tests and types

* Fix tests after merge

* Attempt to fix stack monitoring tests

* remove console.log

* Change text

* Remove commented comment

* Update docs for stack monitoring alerts

* Fix docs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

* Removed strangely re-appearing test

This test was removed a long time ago in this commit: 5feb376 -- we are not sure why it reappeared.

Co-authored-by: Ester Martí Vilaseca <ester.martivilaseca@elastic.co>
Co-authored-by: Jason Rhodes <jason.rhodes@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:enhancement Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stack Monitoring] Change out of the box alerts to be opt-in, rather than auto-created
7 participants