Conditionally sets ignore_throttled only when search:includeFrozen is true (#115451)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4cc94c5a45
commit
d91bc28846
|
@ -5,37 +5,41 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { estypes } from '@elastic/elasticsearch';
|
||||||
import {
|
import {
|
||||||
IndicesExistsAlias,
|
IndicesExistsAlias,
|
||||||
IndicesGet,
|
IndicesGet,
|
||||||
MlGetBuckets,
|
MlGetBuckets,
|
||||||
} from '@elastic/elasticsearch/api/requestParams';
|
} from '@elastic/elasticsearch/api/requestParams';
|
||||||
import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport';
|
import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport';
|
||||||
import { estypes } from '@elastic/elasticsearch';
|
import { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server';
|
||||||
import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server';
|
|
||||||
import {
|
|
||||||
InfraRouteConfig,
|
|
||||||
InfraServerPluginSetupDeps,
|
|
||||||
CallWithRequestParams,
|
|
||||||
InfraDatabaseSearchResponse,
|
|
||||||
InfraDatabaseMultiResponse,
|
|
||||||
InfraDatabaseFieldCapsResponse,
|
|
||||||
InfraDatabaseGetIndicesResponse,
|
|
||||||
InfraDatabaseGetIndicesAliasResponse,
|
|
||||||
} from './adapter_types';
|
|
||||||
import { TSVBMetricModel } from '../../../../common/inventory_models/types';
|
|
||||||
import {
|
import {
|
||||||
CoreSetup,
|
CoreSetup,
|
||||||
IRouter,
|
IRouter,
|
||||||
KibanaRequest,
|
KibanaRequest,
|
||||||
|
RequestHandler,
|
||||||
RouteMethod,
|
RouteMethod,
|
||||||
} from '../../../../../../../src/core/server';
|
} from '../../../../../../../src/core/server';
|
||||||
import { RequestHandler } from '../../../../../../../src/core/server';
|
|
||||||
import { InfraConfig } from '../../../plugin';
|
|
||||||
import type { InfraPluginRequestHandlerContext } from '../../../types';
|
|
||||||
import { UI_SETTINGS } from '../../../../../../../src/plugins/data/server';
|
import { UI_SETTINGS } from '../../../../../../../src/plugins/data/server';
|
||||||
import { TimeseriesVisData } from '../../../../../../../src/plugins/vis_types/timeseries/server';
|
import { TimeseriesVisData } from '../../../../../../../src/plugins/vis_types/timeseries/server';
|
||||||
import { InfraServerPluginStartDeps } from './adapter_types';
|
import { TSVBMetricModel } from '../../../../common/inventory_models/types';
|
||||||
|
import { InfraConfig } from '../../../plugin';
|
||||||
|
import type { InfraPluginRequestHandlerContext } from '../../../types';
|
||||||
|
import {
|
||||||
|
CallWithRequestParams,
|
||||||
|
InfraDatabaseFieldCapsResponse,
|
||||||
|
InfraDatabaseGetIndicesAliasResponse,
|
||||||
|
InfraDatabaseGetIndicesResponse,
|
||||||
|
InfraDatabaseMultiResponse,
|
||||||
|
InfraDatabaseSearchResponse,
|
||||||
|
InfraRouteConfig,
|
||||||
|
InfraServerPluginSetupDeps,
|
||||||
|
InfraServerPluginStartDeps,
|
||||||
|
} from './adapter_types';
|
||||||
|
|
||||||
|
interface FrozenIndexParams {
|
||||||
|
ignore_throttled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export class KibanaFramework {
|
export class KibanaFramework {
|
||||||
public router: IRouter<InfraPluginRequestHandlerContext>;
|
public router: IRouter<InfraPluginRequestHandlerContext>;
|
||||||
|
@ -133,7 +137,7 @@ export class KibanaFramework {
|
||||||
) {
|
) {
|
||||||
const { elasticsearch, uiSettings } = requestContext.core;
|
const { elasticsearch, uiSettings } = requestContext.core;
|
||||||
|
|
||||||
const includeFrozen = await uiSettings.client.get(UI_SETTINGS.SEARCH_INCLUDE_FROZEN);
|
const includeFrozen = await uiSettings.client.get<boolean>(UI_SETTINGS.SEARCH_INCLUDE_FROZEN);
|
||||||
if (endpoint === 'msearch') {
|
if (endpoint === 'msearch') {
|
||||||
const maxConcurrentShardRequests = await uiSettings.client.get(
|
const maxConcurrentShardRequests = await uiSettings.client.get(
|
||||||
UI_SETTINGS.COURIER_MAX_CONCURRENT_SHARD_REQUESTS
|
UI_SETTINGS.COURIER_MAX_CONCURRENT_SHARD_REQUESTS
|
||||||
|
@ -143,11 +147,17 @@ export class KibanaFramework {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const frozenIndicesParams = ['search', 'msearch'].includes(endpoint)
|
// Only set the "ignore_throttled" value (to false) if the Kibana setting
|
||||||
? {
|
// for "search:includeFrozen" is true (i.e. don't ignore throttled indices, a triple negative!)
|
||||||
ignore_throttled: !includeFrozen,
|
// More information:
|
||||||
}
|
// - https://github.com/elastic/kibana/issues/113197
|
||||||
: {};
|
// - https://github.com/elastic/elasticsearch/pull/77479
|
||||||
|
//
|
||||||
|
// NOTE: these params only need to be spread onto the search and msearch calls below
|
||||||
|
const frozenIndicesParams: FrozenIndexParams = {};
|
||||||
|
if (includeFrozen) {
|
||||||
|
frozenIndicesParams.ignore_throttled = false;
|
||||||
|
}
|
||||||
|
|
||||||
let apiResult;
|
let apiResult;
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
|
@ -166,37 +176,31 @@ export class KibanaFramework {
|
||||||
case 'fieldCaps':
|
case 'fieldCaps':
|
||||||
apiResult = elasticsearch.client.asCurrentUser.fieldCaps({
|
apiResult = elasticsearch.client.asCurrentUser.fieldCaps({
|
||||||
...params,
|
...params,
|
||||||
...frozenIndicesParams,
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'indices.existsAlias':
|
case 'indices.existsAlias':
|
||||||
apiResult = elasticsearch.client.asCurrentUser.indices.existsAlias({
|
apiResult = elasticsearch.client.asCurrentUser.indices.existsAlias({
|
||||||
...params,
|
...params,
|
||||||
...frozenIndicesParams,
|
|
||||||
} as IndicesExistsAlias);
|
} as IndicesExistsAlias);
|
||||||
break;
|
break;
|
||||||
case 'indices.getAlias':
|
case 'indices.getAlias':
|
||||||
apiResult = elasticsearch.client.asCurrentUser.indices.getAlias({
|
apiResult = elasticsearch.client.asCurrentUser.indices.getAlias({
|
||||||
...params,
|
...params,
|
||||||
...frozenIndicesParams,
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'indices.get':
|
case 'indices.get':
|
||||||
apiResult = elasticsearch.client.asCurrentUser.indices.get({
|
apiResult = elasticsearch.client.asCurrentUser.indices.get({
|
||||||
...params,
|
...params,
|
||||||
...frozenIndicesParams,
|
|
||||||
} as IndicesGet);
|
} as IndicesGet);
|
||||||
break;
|
break;
|
||||||
case 'transport.request':
|
case 'transport.request':
|
||||||
apiResult = elasticsearch.client.asCurrentUser.transport.request({
|
apiResult = elasticsearch.client.asCurrentUser.transport.request({
|
||||||
...params,
|
...params,
|
||||||
...frozenIndicesParams,
|
|
||||||
} as TransportRequestParams);
|
} as TransportRequestParams);
|
||||||
break;
|
break;
|
||||||
case 'ml.getBuckets':
|
case 'ml.getBuckets':
|
||||||
apiResult = elasticsearch.client.asCurrentUser.ml.getBuckets({
|
apiResult = elasticsearch.client.asCurrentUser.ml.getBuckets({
|
||||||
...params,
|
...params,
|
||||||
...frozenIndicesParams,
|
|
||||||
} as MlGetBuckets<any>);
|
} as MlGetBuckets<any>);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue