Skip to content

Alerts in overview page#125337

Merged
mgiota merged 20 commits intoelastic:mainfrom
mgiota:draft_alerts_in_overview_page
Feb 23, 2022
Merged

Alerts in overview page#125337
mgiota merged 20 commits intoelastic:mainfrom
mgiota:draft_alerts_in_overview_page

Conversation

@mgiota
Copy link
Copy Markdown
Contributor

@mgiota mgiota commented Feb 11, 2022

Part of #124370. There will be some follow-up PR to polish the table for the overview page.

@estermv Here's a quick draft PR that brings the alerts table in Overview page. I did two changes to make this work:

Above two changes were enough to bring existing alerts table in the Overview page.

  • I did this change both to old and new Overview page.
  • AlertsTableTGrid is expecting a setRefetch prop. I didn't dive deeper into this, so for now I just passed an empty function.

As you will see in the screenshots below, there are UI issues, since there is a min-height applied to the alerts table. We would need to see how we could parameterize it in the timelines plugin or playaround with css.

Screenshot 2022-02-11 at 08 25 48

Screenshot 2022-02-10 at 23 26 28

This is an initial draft. I can clean it up a bit and open it for review. Or you can take it from here. Let me know what's best for you.

@mgiota
Copy link
Copy Markdown
Contributor Author

mgiota commented Feb 11, 2022

@XavierM There's a new requirement to display alerts in the Observability Overview page #124370 (comment). I drafted this PR to quickly bring existing Observability alerts table in overview page and pretty much works apart from an issue in the UI part.

From what I can tell there's a hardcoded min-height: 490 coming from timelines plugin. Do you think we could parameterize this? Also on latest main alerts table looks broken #125191 [Actionable Observability] Alerts table looks broken with unnecessary scrollbars. Since more pages want to display alerts table, I think we should also work on the responsiveness of the Alerts table.

import { AddToCaseAction } from '../../actions/timeline/cases/add_to_case_action';
import { TGridLoading, TGridEmpty, TimelineContext } from '../shared';

const FullWidthFlexGroup = styled(EuiFlexGroup)<{ $visible: boolean }>`
Copy link
Copy Markdown
Contributor Author

@mgiota mgiota Feb 11, 2022

Choose a reason for hiding this comment

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

@XavierM FullWidthFlexGroup has a hardcoded min-height, so I stopped using the one defined in the styles https://github.com/elastic/kibana/blob/main/x-pack/plugins/timelines/public/components/t_grid/styles.tsx#L466 and redefined a new style for FullWidthFlexGroup. Do we actually need this hardcoded min-height? Even integrated tGrid gets rid of the min-height https://github.com/elastic/kibana/blob/main/x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx#L83

With this change table looks much better (apart from the unnecessary scrollbar which is related to another issue)
Screenshot 2022-02-11 at 11 43 29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mgiota either way should be fine 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to make the min-height a prop of the pre-existing FullWidthFlexGroup instead of duplicating it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@afgomez It looks like min-height is not being used at all in the integrated version of t-grid and with this PR is it also removed from the standalone version of t-grid. Soon Alerts 2.0 is coming, where quite many things will be cleaned up. I suggest we keep it as it is for now if you don't mind.

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 14, 2022

@mgiota thanks a lot for this PR! I'm going to push some changes, if that's ok with you, mainly removing the old alerts table and probably reverting the changes to the new overview page.

I need to discuss this with the team, but I'm unsure of the need for the new page. It was a decision taken months ago about how to proceed with the overview page redesign and we thought that having a completely new page behind a feature toggle was the right approach, but now we are making changes to the "old" one and maybe that "new" page doesn't make sense anymore.

So, to keep future changes easier I think is better if we only make them to the "old" overview page. If in the future we want to have a "new" page we can add the alerts table there at that point.

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 14, 2022

@mgiota I pushed 3 commits to this PR:

  1. I removed the old alerts section from the overview page and adapt the style to match the other sections from the page. I'll clean up the code in a future PR.
  2. I removed the stateContainer. If we use it in the overview page it causes other problems (and without it, the table still seems to work):
    We already have a mechanism to keep the timepicker in sync with the kibana one. I'm not really familiar with how it works but I think is better to keep all sections at the same time range. We can introduce it back as part of a future PR, after better understanding both implementations.

Screenshot 2022-02-14 at 16 13 20

  1. Revert changes from the "new" overview page as mentioned in my previous comment.

If you see that everything is fine, I think this PR should be ready for review.

</EuiPanel>
</EuiFlexItem>
<AlertsTableTGrid
setRefetch={() => {}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm also not sure what's this, but looking at the code for the alerts page maybe we don't need this. Maybe one option is to mark it as optional?

Copy link
Copy Markdown
Contributor Author

@mgiota mgiota Feb 14, 2022

Choose a reason for hiding this comment

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

@estermv This was my initial thought as well, to make setRefetch optional, but then the whole page breaks, because apparently tGrid expects setRefetch to be there. I didn't have a closer look but you can have a look at how it is implemented in alerts_page https://github.com/elastic/kibana/blob/main/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/alerts_page.tsx#L222 and do something similar.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I added the setRefetch function. From what I understand setRefetch is used to set a function to update the tGrid from outside it. On the overview page, we need it when the user clicks on the "Refresh" button next to the datepicker.

@mgiota
Copy link
Copy Markdown
Contributor Author

mgiota commented Feb 14, 2022

@estermv I agree with the changes you pushed to the PR. Especially removing the state container. I was planning to revert this changes, since you already have the mechanism to get the information you need from routeParams.

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 15, 2022

@elasticmachine merge upstream

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 16, 2022

@elasticmachine merge upstream

@mgiota mgiota marked this pull request as ready for review February 17, 2022 09:43
@mgiota mgiota requested a review from a team as a code owner February 17, 2022 09:43
@mgiota mgiota requested a review from a team February 17, 2022 09:43
@mgiota mgiota requested a review from a team as a code owner February 17, 2022 09:43
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/unified-observability (Team:Unified observability)

@mgiota mgiota added Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.2.0 labels Feb 17, 2022
@mgiota mgiota changed the title Draft alerts in overview page Alerts in overview page Feb 17, 2022
import { AddToCaseAction } from '../../actions/timeline/cases/add_to_case_action';
import { TGridLoading, TGridEmpty, TimelineContext } from '../shared';

const FullWidthFlexGroup = styled(EuiFlexGroup)<{ $visible: boolean }>`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mgiota either way should be fine 👍

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 21, 2022

@elasticmachine merge upstream

@fkanout
Copy link
Copy Markdown
Contributor

fkanout commented Feb 21, 2022

The behavior in the Alerts page, when no alerts occurred, is to show an empty table. Is consistent behavior between the Alerts page and the overview page required from the Alert table perspective?

Overview page without alerts:
Screenshot 2022-02-21 at 15 46 29

Alerts page without alerts:
Screenshot 2022-02-21 at 15 53 02

Note: Not related to this PR, but The Alerts title at the top of the Overview page without any explanation. i.e., No alerts? Or there is an error while fetching the alerts.


export function useAlertIndexNames() {
const { data: indexNames = NO_INDEX_NAMES } = useFetcher(({ signal }) => {
return callObservabilityApi('GET /api/observability/rules/alerts/dynamic_index_pattern', {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it ok to hardcode this endpoint URL? Usually, this kind of code is shared centrally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you mean to pass it as a parameter of the hook? I think in this case the URL is directly tied to the hook because, as far as I understand, this is the endpoint that will return us the index names, so I don't think it will make sense to use the hook with a different URL.
What do you think @mgiota?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@estermv I think it is fine to keep it here

query: {
namespace: 'default',
registrationContexts: [
'observability.apm',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here for hardcoded registrationContexts. It seems that these values are technical filed-like?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand your point here, but I would prefer to keep this inside the hook because at this point we want always the same registrationContexts. We can always refactor it in the future if we need to.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fkanout I see your point and it would be nice to have constants for the registration contexts. As part of this PR I extracted existing functionality to a new hook https://github.com/elastic/kibana/blob/main/x-pack/plugins/observability/public/pages/alerts/containers/alerts_page/alerts_page.tsx#L148, so we could definitely refactor this in a follow up PR

Copy link
Copy Markdown
Contributor

@afgomez afgomez left a comment

Choose a reason for hiding this comment

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

Code looks alright!

The thing I'm missing is an empty state window. When there are no alerts the page looks strange.

Screenshot 2022-02-21 at 16 26 39

@@ -0,0 +1,32 @@
/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nicely extracted

import { AddToCaseAction } from '../../actions/timeline/cases/add_to_case_action';
import { TGridLoading, TGridEmpty, TimelineContext } from '../shared';

const FullWidthFlexGroup = styled(EuiFlexGroup)<{ $visible: boolean }>`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to make the min-height a prop of the pre-existing FullWidthFlexGroup instead of duplicating it?

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 21, 2022

@afgomez @fkanout I fixed the empty state when there are no alerts. There was an old check (not needed anymore) that was preventing the new table to render. Now the behavior is consistent with the Alerts page

@estermv
Copy link
Copy Markdown
Contributor

estermv commented Feb 22, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Test Failures

  • [job] [logs] Security Solution Tests / Detections > Need Admin Callouts indicating an admin is needed to migrate the alert data set The users index_mapping_outdated is "null" and their admin callouts should not show up On Rule Details page "before each" hook for "We show 1 primary callout"
  • [job] [logs] Security Solution Tests / Detections > Need Admin Callouts indicating an admin is needed to migrate the alert data set The users index_mapping_outdated is "true" and their admin callouts should show up On Detections home page We show the need admin primary callout
  • [job] [logs] Security Solution Tests / Detections > Need Admin Callouts indicating an admin is needed to migrate the alert data set The users index_mapping_outdated is "true" and their admin callouts should show up On Rule Details page "before each" hook for "We show 1 primary callout"

Metrics [docs]

Async chunks

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

id before after diff
observability 394.7KB 391.4KB -3.3KB
timelines 226.0KB 226.1KB +137.0B
total -3.2KB

History

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

cc @estermv @mgiota

@mgiota mgiota requested a review from afgomez February 22, 2022 14:22
@mgiota mgiota merged commit 3195a54 into elastic:main Feb 23, 2022
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 25, 2022
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 125337 or prevent reminders by adding the backport:skip label.

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 125337 or prevent reminders by adding the backport:skip label.

@estermv estermv added the backport:skip This PR does not require backporting label Feb 28, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 28, 2022
lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 2, 2022
* render alerts in overview page

* pass routeParams

* create useAlertIndexNames hook

* remove unused file

* use alertIndexNames hook in new overview page

* remove unused stuff

* fix failing tests

* remove min-height from FullWidthFlexGroup in standalone t-grid

* Remove old alerts section from overview and use same style as other sections

* remove alertsStateContainer from overview page

* revert changes in new overview page

* Add refetch function to alerts table

* Fix type

* rename file

* remove not needed check

* fix types

Co-authored-by: Ester Marti <ester.martivilaseca@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:enhancement Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" Team:Unified observability v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants