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

[Actionable Observability] Fix alerts' blank page in case of invalid query string #145067

Merged
merged 5 commits into from
Nov 14, 2022

Conversation

maryam-saeidi
Copy link
Member

@maryam-saeidi maryam-saeidi commented Nov 13, 2022

Implements #143641

📝 Summary

Fixes the alerts page crash when a wrong query is entered in the search bar query string.

image

Note
I am working on tests but I will create a separate PR for that.

🧪 How to test

  • Go to alerts / rule details page
  • Enter an invalid query such as {, page should not crash and you should see a toast with a related error message

@maryam-saeidi maryam-saeidi self-assigned this Nov 13, 2022
@maryam-saeidi maryam-saeidi added Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" bug Fixes for quality problems that affect the customer experience release_note:fix labels Nov 13, 2022
@maryam-saeidi maryam-saeidi changed the title [Actionable Observability] Validate alert query before saving it in state [Actionable Observability] Fix alerts' blank page in case of invalid query string Nov 13, 2022
appName: string;
setEsQuery: (query: { bool: BoolQuery }) => void;
queries?: Query[];
}

export interface AlertSearchBarWithUrlSyncProps extends CommonAlertSearchBarProps {
urlStorageKey: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

💬 Allowing consumers to set the storage key.

import { AlertStatus } from '../../../../common/typings';

const getAlertStatusQuery = (status: string): Query[] => {
return status ? [{ query: ALERT_STATUS_QUERY[status], language: 'kuery' }] : [];
};

export function AlertSearchBar({
Copy link
Member Author

Choose a reason for hiding this comment

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

💬 Renamed it to make it easier to find the usage of this component.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

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 487.5KB 487.8KB +317.0B
Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 59 65 +6
osquery 108 113 +5
securitySolution 441 447 +6
total +19

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 67 73 +6
osquery 109 115 +6
securitySolution 518 524 +6
total +20

History

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

cc @maryam-saeidi

@maryam-saeidi maryam-saeidi marked this pull request as ready for review November 14, 2022 10:29
@maryam-saeidi maryam-saeidi requested a review from a team as a code owner November 14, 2022 10:29
@elasticmachine
Copy link
Contributor

Pinging @elastic/actionable-observability (Team: Actionable Observability)

@benakansara
Copy link
Contributor

benakansara commented Nov 14, 2022

Can we display user-friendly message in place of stack trace? I don't know if this is the common practice across error messages in Kibana. If that is the case, then it's fine.

Screenshot 2022-11-14 at 12 11 01

@maryam-saeidi
Copy link
Member Author

Can we display user-friendly message in place of stack trace? I don't know if this is the common practice across error messages in Kibana. If that is the case, then it's fine.

I used a similar pattern as Kerry used here. The error message is coming from buildEsQuery in @kbn/es-query which is a shared function and when I tested a similar scenario in logs, I got the same error message:

image

In some other cases, the message is a bit more clear, like this one:
image

I am not aware of any other alternative. I tried to at least have a good title for this error :D

@@ -9,3 +9,4 @@ export const ALERTS_PAGE_ID = 'alerts-o11y';
export const ALERTS_SEARCH_BAR_ID = 'alerts-search-bar-o11y';
export const ALERTS_PER_PAGE = 50;
export const ALERTS_TABLE_ID = 'xpack.observability.alerts.alert.table';
export const URL_STORAGE_KEY = '_a';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to keep URL_STORAGE_KEY as _a here and searchBarParams in rule_details/constants.ts? The namings do not match.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to use a more meaningful name for this storage rather than _a, so I changed it on the rule details page.
But on the alerts page, I didn't change it since I wasn't sure if changing the URL structure will break anything. We can discuss this use-case within our team and I can update it in the next PR if that makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! 👍

Copy link
Contributor

@benakansara benakansara left a comment

Choose a reason for hiding this comment

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

LGTM. Tested locally, works well.
Left a question above.

Copy link
Contributor

@CoenWarmer CoenWarmer left a comment

Choose a reason for hiding this comment

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

Looks good!!

@maryam-saeidi maryam-saeidi merged commit 2d5709f into elastic:main Nov 14, 2022
@kibanamachine kibanamachine added v8.6.0 backport:skip This commit does not require backporting labels Nov 14, 2022
maryam-saeidi added a commit that referenced this pull request Nov 16, 2022
Closes #143641

## Summary

As a follow-up to this PR #145067,
in this PR I've added tests to make sure the same issue will not happen
in the future.

### Checklist

- [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
benakansara pushed a commit to benakansara/kibana that referenced this pull request Nov 17, 2022
…5259)

Closes elastic#143641

## Summary

As a follow-up to this PR elastic#145067,
in this PR I've added tests to make sure the same issue will not happen
in the future.

### Checklist

- [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
@maryam-saeidi maryam-saeidi deleted the 143641-fix-alert-search-bar branch December 19, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience release_note:fix Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants