Skip to content

Commit

Permalink
[Discover] Inline shard failures warnings (#161271)
Browse files Browse the repository at this point in the history
- Closes #155216

## Summary

This PR replaces shard falures toasts with inline warnings in Discover.

- [x] Intercept shard failures in Discover main app
- [x] Show inline warnings above the grid instead
- [x] Handle NoResultsFound case too
- [x] Implement for Discover context app
- [x] Implement for saved search embeddable on Dashboard
- [x] Can we inline timeouts too?
- [x] Check SQL view
- [x] Add tests


Discover view with shard failures
<img width="400" alt="Screenshot 2023-07-06 at 14 23 48"
src="https://github.com/elastic/kibana/assets/1415710/a0799aa0-9d2e-42ee-b89b-e0e1180220a5">

Discover view with shard failures (and no results)
<img width="400" alt="Screenshot 2023-07-07 at 13 24 50"
src="https://github.com/elastic/kibana/assets/1415710/28dc2bad-9776-4aa9-8f51-219d1c87487a">

Dashboard view with shard failures
<img width="400" alt="Screenshot 2023-07-06 at 16 15 49"
src="https://github.com/elastic/kibana/assets/1415710/2a68c19a-1ca8-4f10-a9f5-4aa56f9160b0">

Surrounding documents view with shard failures
<img width="400" alt="Screenshot 2023-07-10 at 17 26 31"
src="https://github.com/elastic/kibana/assets/1415710/ade63cfe-a1c2-4c22-8823-58dcfef9357f">

Discover view with timeouts
<img width="400" alt="Screenshot 2023-07-07 at 16 47 27"
src="https://github.com/elastic/kibana/assets/1415710/0101be19-a555-4f96-b963-7fe418d51fb5">

Dashboard view with timeouts
<img width="400" alt="Screenshot 2023-07-07 at 16 48 18"
src="https://github.com/elastic/kibana/assets/1415710/82979365-4129-4385-8a13-9c139e1acbf1">

Surrounding documents view with timeouts
<img width="400" alt="Screenshot 2023-07-11 at 15 03 41"
src="https://github.com/elastic/kibana/assets/1415710/0ea41b79-ac6b-4456-9cfa-0d038b10da7d">

## Testing

For testing please uncomment
https://github.com/elastic/kibana/blob/3f102cf688dbfe87fd901cf7f8b59680ff62e5b8/src/plugins/data/common/search/search_source/search_source.ts#L922
or
https://github.com/elastic/kibana/blob/3f102cf688dbfe87fd901cf7f8b59680ff62e5b8/src/plugins/data/common/search/search_source/search_source.ts#L547
and switch to `kibana*` data view.


### Checklist

Delete any items that are not applicable to this PR.

- [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/main/packages/kbn-i18n/README.md)
- [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
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 10, 2023
1 parent 48b7acf commit c97d496
Show file tree
Hide file tree
Showing 56 changed files with 2,037 additions and 184 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -589,6 +589,7 @@ src/plugins/screenshot_mode @elastic/appex-sharedux
x-pack/examples/screenshotting_example @elastic/appex-sharedux
x-pack/plugins/screenshotting @elastic/kibana-reporting-services
examples/search_examples @elastic/kibana-data-discovery
packages/kbn-search-response-warnings @elastic/kibana-data-discovery
x-pack/plugins/searchprofiler @elastic/platform-deployment-management
x-pack/test/security_api_integration/packages/helpers @elastic/kibana-core
x-pack/plugins/security @elastic/kibana-security
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Expand Up @@ -92,6 +92,7 @@
"server": "src/legacy/server",
"share": "src/plugins/share",
"sharedUXPackages": "packages/shared-ux",
"searchResponseWarnings": "packages/kbn-search-response-warnings",
"securitySolutionPackages": "x-pack/packages/security-solution",
"serverlessPackages": "packages/serverless",
"coloring": "packages/kbn-coloring/src",
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -592,6 +592,7 @@
"@kbn/screenshotting-example-plugin": "link:x-pack/examples/screenshotting_example",
"@kbn/screenshotting-plugin": "link:x-pack/plugins/screenshotting",
"@kbn/search-examples-plugin": "link:examples/search_examples",
"@kbn/search-response-warnings": "link:packages/kbn-search-response-warnings",
"@kbn/searchprofiler-plugin": "link:x-pack/plugins/searchprofiler",
"@kbn/security-plugin": "link:x-pack/plugins/security",
"@kbn/security-solution-ess": "link:x-pack/plugins/security_solution_ess",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-search-response-warnings/README.md
@@ -0,0 +1,3 @@
# @kbn/search-response-warnings

Components and utils to render warnings which happen when executing search request. For example, shard failures and time outs.
19 changes: 19 additions & 0 deletions packages/kbn-search-response-warnings/index.ts
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export type { SearchResponseInterceptedWarning } from './src/types';

export {
SearchResponseWarnings,
type SearchResponseWarningsProps,
} from './src/components/search_response_warnings';

export {
getSearchResponseInterceptedWarnings,
removeInterceptedWarningDuplicates,
} from './src/utils/get_search_response_intercepted_warnings';
13 changes: 13 additions & 0 deletions packages/kbn-search-response-warnings/jest.config.js
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-search-response-warnings'],
};
5 changes: 5 additions & 0 deletions packages/kbn-search-response-warnings/kibana.jsonc
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/search-response-warnings",
"owner": "@elastic/kibana-data-discovery"
}
6 changes: 6 additions & 0 deletions packages/kbn-search-response-warnings/package.json
@@ -0,0 +1,6 @@
{
"name": "@kbn/search-response-warnings",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
@@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import type { SearchResponseWarning } from '@kbn/data-plugin/public';

export const searchResponseTimeoutWarningMock: SearchResponseWarning = {
type: 'timed_out',
message: 'Data might be incomplete because your request timed out',
reason: undefined,
};

export const searchResponseShardFailureWarningMock: SearchResponseWarning = {
type: 'shard_failure',
message: '3 of 4 shards failed',
text: 'The data might be incomplete or wrong.',
reason: {
type: 'illegal_argument_exception',
reason: 'Field [__anonymous_] of type [boolean] does not support custom formats',
},
};

export const searchResponseWarningsMock: SearchResponseWarning[] = [
searchResponseTimeoutWarningMock,
searchResponseShardFailureWarningMock,
{
type: 'shard_failure',
message: '3 of 4 shards failed',
text: 'The data might be incomplete or wrong.',
reason: {
type: 'query_shard_exception',
reason:
'failed to create query: [.ds-kibana_sample_data_logs-2023.07.11-000001][0] Testing shard failures!',
},
},
{
type: 'shard_failure',
message: '1 of 4 shards failed',
text: 'The data might be incomplete or wrong.',
reason: {
type: 'query_shard_exception',
reason:
'failed to create query: [.ds-kibana_sample_data_logs-2023.07.11-000001][0] Testing shard failures!',
},
},
];

0 comments on commit c97d496

Please sign in to comment.