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
[Reporting] Add max concurrent shards setting to schema #170344
Changes from all commits
c2bc083
4b3857f
79a3515
704eeca
39f044f
eeafa51
40ca21a
4d6066f
6013b2d
9950af0
f4c5668
e74ce83
bd31abe
afdca86
06b0270
27fb67d
8b5b73f
2cd1f23
81460c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import type { Writable } from 'stream'; | |
import { errors as esErrors, estypes } from '@elastic/elasticsearch'; | ||
import type { IScopedClusterClient, IUiSettingsClient, Logger } from '@kbn/core/server'; | ||
import type { | ||
IEsSearchRequest, | ||
IKibanaSearchResponse, | ||
ISearchSource, | ||
ISearchStartSearchSource, | ||
|
@@ -66,7 +67,11 @@ export class CsvGenerator { | |
) {} | ||
|
||
private async openPointInTime(indexPatternTitle: string, settings: CsvExportSettings) { | ||
const { duration } = settings.scroll; | ||
const { | ||
includeFrozen, | ||
maxConcurrentShardRequests, | ||
scroll: { duration }, | ||
} = settings; | ||
let pitId: string | undefined; | ||
this.logger.debug(`Requesting PIT for: [${indexPatternTitle}]...`); | ||
try { | ||
|
@@ -77,11 +82,12 @@ export class CsvGenerator { | |
keep_alive: duration, | ||
ignore_unavailable: true, | ||
// @ts-expect-error ignore_throttled is not in the type definition, but it is accepted by es | ||
ignore_throttled: settings.includeFrozen ? false : undefined, // "true" will cause deprecation warnings logged in ES | ||
ignore_throttled: includeFrozen ? false : undefined, // "true" will cause deprecation warnings logged in ES | ||
}, | ||
{ | ||
requestTimeout: duration, | ||
maxRetries: 0, | ||
maxConcurrentShardRequests, | ||
} | ||
); | ||
pitId = response.id; | ||
|
@@ -135,7 +141,7 @@ export class CsvGenerator { | |
settings: CsvExportSettings, | ||
searchAfter?: estypes.SortResults | ||
) { | ||
const { scroll: scrollSettings } = settings; | ||
const { scroll: scrollSettings, maxConcurrentShardRequests } = settings; | ||
searchSource.setField('size', scrollSettings.size); | ||
|
||
if (searchAfter) { | ||
|
@@ -153,8 +159,14 @@ export class CsvGenerator { | |
throw new Error('Could not retrieve the search body!'); | ||
} | ||
|
||
const searchParams = { params: { body: searchBody } }; | ||
let results: estypes.SearchResponse<unknown>; | ||
const searchParams: IEsSearchRequest = { | ||
params: { | ||
body: searchBody, | ||
max_concurrent_shard_requests: maxConcurrentShardRequests, | ||
}, | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on other code I could find and the way the types are structured, it looks like const searchParams: IEsSearchRequest = {
params: {
body: searchBody,
max_concurrent_shard_requests: maxConcurrentShardRequests,
},
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome! changes in bd31abe |
||
|
||
let results: estypes.SearchResponse<unknown> | undefined; | ||
try { | ||
const { rawResponse, ...rawDetails } = await lastValueFrom( | ||
this.clients.data.search(searchParams, { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be added to thetransport
field of thedata.search()
call in thedoSearch()
method. Doing that will throw a type compilation error, since the field isn't known in the data service. You'll have to reach out to them and make sure the field is recognized and correctly sent in the requestsI think the recommended way to go in
doSearch
would be to add the maxConcurrentShardRequests onto the searchSource object with:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omg thank you good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some searching around to find how this is handled in other parts of the code, and I think
max_concurrent_shard_requests
must be in the body, not the options.