mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] Removing ignore_throttled from anomaly detection job results searches (#203788)
`ignore_throttled` is automatically added to AD jobs when created. These are then reused in various searches where the whole `indices_options` object from the datafeed is passed in the search call. This PR adds a function to remove `ignore_throttled` in these situations to avoid triggering deprecation warnings.
This commit is contained in:
parent
46a1535f03
commit
a69a456e69
5 changed files with 17 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { omit } from 'lodash';
|
||||
import type { Aggregation, Datafeed } from '../types/anomaly_detection_jobs';
|
||||
|
||||
export function getAggregations<T>(obj: any): T | undefined {
|
||||
|
@ -18,3 +19,10 @@ export const getDatafeedAggregations = (
|
|||
): Aggregation | undefined => {
|
||||
return getAggregations<Aggregation>(datafeedConfig);
|
||||
};
|
||||
|
||||
export function getIndicesOptions(datafeedConfig?: Datafeed) {
|
||||
// remove ignore_throttled from indices_options to avoid deprecation warnings in the logs
|
||||
return datafeedConfig?.indices_options
|
||||
? omit(datafeedConfig.indices_options, 'ignore_throttled')
|
||||
: {};
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { getSeverityType } from '@kbn/ml-anomaly-utils';
|
||||
import { getIndicesOptions } from '../../../../../common/util/datafeed_utils';
|
||||
import type { MlResultsService } from '../../../services/results_service';
|
||||
import type { CombinedJobWithStats } from '../../../../../common/types/anomaly_detection_jobs';
|
||||
import type { Anomaly } from '../../../jobs/new_job/common/results_loader/results_loader';
|
||||
|
@ -32,7 +33,7 @@ export function chartLoaderProvider(mlResultsService: MlResultsService) {
|
|||
job.data_counts.latest_record_timestamp!,
|
||||
intervalMs,
|
||||
job.datafeed_config.runtime_mappings,
|
||||
job.datafeed_config.indices_options
|
||||
getIndicesOptions(job.datafeed_config)
|
||||
);
|
||||
if (resp.error !== undefined) {
|
||||
throw resp.error;
|
||||
|
|
|
@ -17,7 +17,7 @@ import { parseInterval } from '@kbn/ml-parse-interval';
|
|||
|
||||
import { initCardinalityFieldsCache } from './fields_aggs_cache';
|
||||
import { isValidAggregationField } from '../../../common/util/validation_utils';
|
||||
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';
|
||||
import { getDatafeedAggregations, getIndicesOptions } from '../../../common/util/datafeed_utils';
|
||||
import type { Datafeed, IndicesOptions } from '../../../common/types/anomaly_detection_jobs';
|
||||
|
||||
/**
|
||||
|
@ -190,7 +190,7 @@ export function fieldsServiceProvider({ asCurrentUser }: IScopedClusterClient) {
|
|||
{
|
||||
index,
|
||||
body,
|
||||
...(datafeedConfig?.indices_options ?? {}),
|
||||
...getIndicesOptions(datafeedConfig),
|
||||
},
|
||||
{ maxRetries: 0 }
|
||||
);
|
||||
|
@ -418,7 +418,7 @@ export function fieldsServiceProvider({ asCurrentUser }: IScopedClusterClient) {
|
|||
{
|
||||
index,
|
||||
body,
|
||||
...(datafeedConfig?.indices_options ?? {}),
|
||||
...getIndicesOptions(datafeedConfig),
|
||||
},
|
||||
{ maxRetries: 0 }
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ import { validateTimeRange, isValidTimeField } from './validate_time_range';
|
|||
import type { validateJobSchema } from '../../routes/schemas/job_validation_schema';
|
||||
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
|
||||
import type { MlClient } from '../../lib/ml_client';
|
||||
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';
|
||||
import { getDatafeedAggregations, getIndicesOptions } from '../../../common/util/datafeed_utils';
|
||||
import type { AuthorizationHeader } from '../../lib/request_authorization';
|
||||
|
||||
export type ValidateJobPayload = TypeOf<typeof validateJobSchema>;
|
||||
|
@ -74,7 +74,7 @@ export async function validateJob(
|
|||
timeField,
|
||||
job.datafeed_config.query,
|
||||
job.datafeed_config.runtime_mappings,
|
||||
job.datafeed_config.indices_options
|
||||
getIndicesOptions(job.datafeed_config)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
ML_JOB_ID,
|
||||
ML_PARTITION_FIELD_VALUE,
|
||||
} from '@kbn/ml-anomaly-utils';
|
||||
import { getIndicesOptions } from '../../../common/util/datafeed_utils';
|
||||
import { buildAnomalyTableItems } from './build_anomaly_table_items';
|
||||
import { ANOMALIES_TABLE_DEFAULT_QUERY_SIZE } from '../../../common/constants/search';
|
||||
import { getPartitionFieldsValuesFactory } from './get_partition_fields_values';
|
||||
|
@ -727,7 +728,7 @@ export function resultsServiceProvider(mlClient: MlClient, client?: IScopedClust
|
|||
},
|
||||
size: 0,
|
||||
},
|
||||
...(datafeedConfig?.indices_options ?? {}),
|
||||
...getIndicesOptions(datafeedConfig),
|
||||
};
|
||||
|
||||
if (client) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue