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

[Search] Add a new advanced setting searchTimeout #75728

Merged
merged 36 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5e0959a
Add new x-pack advanced setting searchTimeout and use it in the Enhan…
Aug 23, 2020
a682fb7
docs
Aug 23, 2020
f2c4c16
Rely on server timeout in OSS (?)
Aug 26, 2020
2497e00
Rename function
Aug 26, 2020
a65596f
doc
Aug 27, 2020
1e9e9a0
Remove esShard from client
Aug 27, 2020
6d718c5
cleanup request parameters from FE
Aug 31, 2020
060ce08
doc
Aug 31, 2020
0310fb1
doc
Aug 31, 2020
1b4770a
Align request parameters on server,
Sep 1, 2020
70b5809
docs
Sep 1, 2020
f8aba5d
add management docs
Sep 1, 2020
f4d0064
docs
Sep 1, 2020
9c5c0ec
Remove import
Sep 1, 2020
befdf10
Break circular dep + fix msearch test
Sep 1, 2020
098a9ad
Remove deleted type
Sep 1, 2020
dac9d7a
Fix jest
Sep 1, 2020
f9273d6
Bring toSnakeCase back
Sep 2, 2020
3dc393e
docs
Sep 2, 2020
59f5cc1
fix jest
Sep 2, 2020
2841d57
Fix merge
Sep 3, 2020
313bbd7
Fix types
lukasolson Sep 5, 2020
2dea1e3
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 6, 2020
6111ac7
Allow timeout to be undefined
Sep 6, 2020
b1b466c
Fix jest test
Sep 6, 2020
5a7c9e0
Upldate docs
Sep 6, 2020
882c4fd
Fix msearch jest
Sep 6, 2020
b9306c0
Merge branch 'master' into search/search-timeout-setting
elasticmachine Sep 7, 2020
bec86a5
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 7, 2020
887b3ea
docs
Sep 7, 2020
b9c7dfc
Merge branch 'search/search-timeout-setting' of github.com:lizozom/ki…
Sep 8, 2020
4bdbcc6
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 8, 2020
f6d4b5b
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 8, 2020
4405680
Fix rollup search merge
Sep 8, 2020
61d1f76
Merge branch 'master' of github.com:elastic/kibana into search/search…
Sep 8, 2020
d5c6042
docs
Sep 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

```typescript
export declare function getSearchParamsFromRequest(searchRequest: SearchRequest, dependencies: {
esShardTimeout: number;
getConfig: GetConfigFn;
}): ISearchRequestParams;
```
Expand All @@ -19,7 +18,7 @@ export declare function getSearchParamsFromRequest(searchRequest: SearchRequest,
| Parameter | Type | Description |
| --- | --- | --- |
| searchRequest | <code>SearchRequest</code> | |
| dependencies | <code>{</code><br/><code> esShardTimeout: number;</code><br/><code> getConfig: GetConfigFn;</code><br/><code>}</code> | |
| dependencies | <code>{</code><br/><code> getConfig: GetConfigFn;</code><br/><code>}</code> | |

<b>Returns:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

## SearchInterceptor.(constructor)

This class should be instantiated with a `requestTimeout` corresponding with how many ms after requests are initiated that they should automatically cancel.
Constructs a new instance of the `SearchInterceptor` class

<b>Signature:</b>

```typescript
constructor(deps: SearchInterceptorDeps, requestTimeout?: number | undefined);
constructor(deps: SearchInterceptorDeps);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| deps | <code>SearchInterceptorDeps</code> | |
| requestTimeout | <code>number &#124; undefined</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ export declare class SearchInterceptor

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(deps, requestTimeout)](./kibana-plugin-plugins-data-public.searchinterceptor._constructor_.md) | | This class should be instantiated with a <code>requestTimeout</code> corresponding with how many ms after requests are initiated that they should automatically cancel. |
| [(constructor)(deps)](./kibana-plugin-plugins-data-public.searchinterceptor._constructor_.md) | | Constructs a new instance of the <code>SearchInterceptor</code> class |

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [deps](./kibana-plugin-plugins-data-public.searchinterceptor.deps.md) | | <code>SearchInterceptorDeps</code> | |
| [requestTimeout](./kibana-plugin-plugins-data-public.searchinterceptor.requesttimeout.md) | | <code>number &#124; undefined</code> | |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [getPendingCount$()](./kibana-plugin-plugins-data-public.searchinterceptor.getpendingcount_.md) | | Returns an <code>Observable</code> over the current number of pending searches. This could mean that one of the search requests is still in flight, or that it has only received partial responses. |
| [runSearch(request, signal, strategy)](./kibana-plugin-plugins-data-public.searchinterceptor.runsearch.md) | | |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when <code>cancelPending</code> is called, when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates <code>pendingCount$</code> when the request is started/finalized. |
| [setupTimers(options)](./kibana-plugin-plugins-data-public.searchinterceptor.setuptimers.md) | | |

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ UI_SETTINGS: {
readonly COURIER_MAX_CONCURRENT_SHARD_REQUESTS: "courier:maxConcurrentShardRequests";
readonly COURIER_BATCH_SEARCHES: "courier:batchSearches";
readonly SEARCH_INCLUDE_FROZEN: "search:includeFrozen";
readonly SEARCH_TIMEOUT: "search:timeout";
readonly HISTOGRAM_BAR_TARGET: "histogram:barTarget";
readonly HISTOGRAM_MAX_BARS: "histogram:maxBars";
readonly HISTORY_LIMIT: "history:limit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@
<b>Signature:</b>

```typescript
export declare function getDefaultSearchParams(config: SharedGlobalConfig): {
timeout: string;
export declare function getDefaultSearchParams(uiSettingsClient: IUiSettingsClient): Promise<{
maxConcurrentShardRequests: number | undefined;
ignoreThrottled: boolean;
ignoreUnavailable: boolean;
restTotalHitsAsInt: boolean;
};
trackTotalHits: boolean;
}>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| config | <code>SharedGlobalConfig</code> | |
| uiSettingsClient | <code>IUiSettingsClient</code> | |

<b>Returns:</b>

`{
timeout: string;
`Promise<{
maxConcurrentShardRequests: number | undefined;
ignoreThrottled: boolean;
ignoreUnavailable: boolean;
restTotalHitsAsInt: boolean;
}`
trackTotalHits: boolean;
}>`

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [getShardTimeout](./kibana-plugin-plugins-data-server.getshardtimeout.md)

## getShardTimeout() function

<b>Signature:</b>

```typescript
export declare function getShardTimeout(config: SharedGlobalConfig): {
timeout: string;
};
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| config | <code>SharedGlobalConfig</code> | |

<b>Returns:</b>

`{
timeout: string;
}`

Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

| Function | Description |
| --- | --- |
| [getDefaultSearchParams(config)](./kibana-plugin-plugins-data-server.getdefaultsearchparams.md) | |
| [getDefaultSearchParams(uiSettingsClient)](./kibana-plugin-plugins-data-server.getdefaultsearchparams.md) | |
| [getShardTimeout(config)](./kibana-plugin-plugins-data-server.getshardtimeout.md) | |
| [getTime(indexPattern, timeRange, options)](./kibana-plugin-plugins-data-server.gettime.md) | |
| [parseInterval(interval)](./kibana-plugin-plugins-data-server.parseinterval.md) | |
| [plugin(initializerContext)](./kibana-plugin-plugins-data-server.plugin.md) | Static code to be shared externally |
| [shouldReadFieldFromDocValues(aggregatable, esType)](./kibana-plugin-plugins-data-server.shouldreadfieldfromdocvalues.md) | |
| [toSnakeCase(obj)](./kibana-plugin-plugins-data-server.tosnakecase.md) | |
| [usageProvider(core)](./kibana-plugin-plugins-data-server.usageprovider.md) | |

## Interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

```typescript
start(core: CoreStart): {
search: ISearchStart<import(".").IEsSearchRequest, import(".").IEsSearchResponse<any>>;
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
fieldFormats: {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
Expand All @@ -27,7 +27,7 @@ start(core: CoreStart): {
<b>Returns:</b>

`{
search: ISearchStart<import(".").IEsSearchRequest, import(".").IEsSearchResponse<any>>;
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
fieldFormats: {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [toSnakeCase](./kibana-plugin-plugins-data-server.tosnakecase.md)

## toSnakeCase() function

<b>Signature:</b>

```typescript
export declare function toSnakeCase(obj: Record<string, any>): import("lodash").Dictionary<any>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| obj | <code>Record&lt;string, any&gt;</code> | |

<b>Returns:</b>

`import("lodash").Dictionary<any>`

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ UI_SETTINGS: {
readonly COURIER_MAX_CONCURRENT_SHARD_REQUESTS: "courier:maxConcurrentShardRequests";
readonly COURIER_BATCH_SEARCHES: "courier:batchSearches";
readonly SEARCH_INCLUDE_FROZEN: "search:includeFrozen";
readonly SEARCH_TIMEOUT: "search:timeout";
readonly HISTOGRAM_BAR_TARGET: "histogram:barTarget";
readonly HISTOGRAM_MAX_BARS: "histogram:maxBars";
readonly HISTORY_LIMIT: "history:limit";
Expand Down
1 change: 1 addition & 0 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ be inconsistent because different shards might be in different refresh states.
`search:includeFrozen`:: Includes {ref}/frozen-indices.html[frozen indices] in results.
Searching through frozen indices
might increase the search time. This setting is off by default. Users must opt-in to include frozen indices.
`search:timeout`:: Change the maximum timeout for a search session or set to 0 to disable the timeout and allow queries to run to completion.

[float]
[[kibana-siem-settings]]
Expand Down
15 changes: 0 additions & 15 deletions src/legacy/core_plugins/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
import { first } from 'rxjs/operators';
import { Cluster } from './server/lib/cluster';
import { createProxy } from './server/lib/create_proxy';

export default function (kibana) {
let defaultVars;

return new kibana.Plugin({
require: [],

uiExports: { injectDefaultVars: () => defaultVars },

async init(server) {
// All methods that ES plugin exposes are synchronous so we should get the first
// value from all observables here to be able to synchronously return and create
Expand All @@ -36,16 +31,6 @@ export default function (kibana) {
const adminCluster = new Cluster(client);
const dataCluster = new Cluster(client);

const esConfig = await server.newPlatform.__internals.elasticsearch.legacy.config$
.pipe(first())
.toPromise();

defaultVars = {
esRequestTimeout: esConfig.requestTimeout.asMilliseconds(),
esShardTimeout: esConfig.shardTimeout.asMilliseconds(),
esApiVersion: esConfig.apiVersion,
};

const clusters = new Map();
server.expose('getCluster', (name) => {
if (name === 'admin') {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const UI_SETTINGS = {
COURIER_MAX_CONCURRENT_SHARD_REQUESTS: 'courier:maxConcurrentShardRequests',
COURIER_BATCH_SEARCHES: 'courier:batchSearches',
SEARCH_INCLUDE_FROZEN: 'search:includeFrozen',
SEARCH_TIMEOUT: 'search:timeout',
HISTOGRAM_BAR_TARGET: 'histogram:barTarget',
HISTOGRAM_MAX_BARS: 'histogram:maxBars',
HISTORY_LIMIT: 'history:limit',
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/data/common/search/es_search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@
* under the License.
*/

export {
ISearchRequestParams,
IEsSearchRequest,
IEsSearchResponse,
ES_SEARCH_STRATEGY,
ISearchOptions,
} from './types';
export * from './types';
3 changes: 3 additions & 0 deletions src/plugins/data/common/search/es_search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ export interface IEsSearchResponse<Source = any> extends IKibanaSearchResponse {
isPartial?: boolean;
rawResponse: SearchResponse<Source>;
}

export const isEsResponse = (response: any): response is IEsSearchResponse =>
response && response.rawResponse;
9 changes: 1 addition & 8 deletions src/plugins/data/common/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,4 @@ export * from './es_search';
export * from './expressions';
export * from './tabify';
export * from './types';

export {
IEsSearchRequest,
IEsSearchResponse,
ES_SEARCH_STRATEGY,
ISearchRequestParams,
ISearchOptions,
} from './es_search';
export * from './es_search';
15 changes: 8 additions & 7 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ export const getKbnTypeNames: () => string[];
//
// @public (undocumented)
export function getSearchParamsFromRequest(searchRequest: SearchRequest, dependencies: {
esShardTimeout: number;
getConfig: GetConfigFn;
}): ISearchRequestParams;

Expand Down Expand Up @@ -1711,7 +1710,7 @@ export interface SearchError {
//
// @public (undocumented)
export class SearchInterceptor {
constructor(deps: SearchInterceptorDeps, requestTimeout?: number | undefined);
constructor(deps: SearchInterceptorDeps);
// @internal
protected abortController: AbortController;
// @internal (undocumented)
Expand All @@ -1725,13 +1724,14 @@ export class SearchInterceptor {
protected longRunningToast?: Toast;
// @internal
protected pendingCount$: BehaviorSubject<number>;
// (undocumented)
protected readonly requestTimeout?: number | undefined;
// (undocumented)
// @internal (undocumented)
protected runSearch(request: IEsSearchRequest, signal: AbortSignal, strategy?: string): Observable<IEsSearchResponse>;
search(request: IEsSearchRequest, options?: ISearchOptions): Observable<IEsSearchResponse>;
// (undocumented)
protected setupTimers(options?: ISearchOptions): {
// @internal (undocumented)
protected setupAbortSignal({ abortSignal, timeout, }: {
abortSignal?: AbortSignal;
timeout?: number;
}): {
combinedSignal: AbortSignal;
cleanup: () => void;
};
Expand Down Expand Up @@ -1902,6 +1902,7 @@ export const UI_SETTINGS: {
readonly COURIER_MAX_CONCURRENT_SHARD_REQUESTS: "courier:maxConcurrentShardRequests";
readonly COURIER_BATCH_SEARCHES: "courier:batchSearches";
readonly SEARCH_INCLUDE_FROZEN: "search:includeFrozen";
readonly SEARCH_TIMEOUT: "search:timeout";
readonly HISTOGRAM_BAR_TARGET: "histogram:barTarget";
readonly HISTOGRAM_MAX_BARS: "histogram:maxBars";
readonly HISTORY_LIMIT: "history:limit";
Expand Down
Loading