From 59ed9f62b976654a02c0eb148ed66c68c049620d Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 6 Nov 2024 11:31:37 +0000 Subject: [PATCH 1/3] [ML] Removing use of ignore_throttled --- .../ml/aiops_log_pattern_analysis/schema.ts | 1 - .../queries/__mocks__/params_match_all.ts | 1 - .../queries/get_request_base.test.ts | 25 ------------------- .../queries/get_request_base.ts | 3 +-- ..._ml_anomaly_detectors__job_id__schema.json | 6 +---- ...t___ml_datafeeds__datafeed_id__schema.json | 6 +---- .../ml/server/models/job_service/jobs.ts | 4 +++ .../server/routes/schemas/datafeeds_schema.ts | 3 +++ .../aggregated_scripted_job.ts | 4 --- 9 files changed, 10 insertions(+), 43 deletions(-) delete mode 100644 x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.test.ts diff --git a/x-pack/packages/ml/aiops_log_pattern_analysis/schema.ts b/x-pack/packages/ml/aiops_log_pattern_analysis/schema.ts index 72b1dbca38032..05254e72a651c 100644 --- a/x-pack/packages/ml/aiops_log_pattern_analysis/schema.ts +++ b/x-pack/packages/ml/aiops_log_pattern_analysis/schema.ts @@ -38,7 +38,6 @@ export const indicesOptionsSchema = schema.object({ ), ignore_unavailable: schema.maybe(schema.boolean()), allow_no_indices: schema.maybe(schema.boolean()), - ignore_throttled: schema.maybe(schema.boolean()), }); /** diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/queries/__mocks__/params_match_all.ts b/x-pack/packages/ml/aiops_log_rate_analysis/queries/__mocks__/params_match_all.ts index a81ba523caa43..36d63c883ecd8 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/queries/__mocks__/params_match_all.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/queries/__mocks__/params_match_all.ts @@ -14,6 +14,5 @@ export const paramsMock = { baselineMax: 20, deviationMin: 30, deviationMax: 40, - includeFrozen: false, searchQuery: '{ "match_all": {} }', }; diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.test.ts b/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.test.ts deleted file mode 100644 index 33797e219fd37..0000000000000 --- a/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { paramsMock } from './__mocks__/params_match_all'; - -import { getRequestBase } from './get_request_base'; - -describe('getRequestBase', () => { - it('defaults to not setting `ignore_throttled`', () => { - const requestBase = getRequestBase(paramsMock); - expect(requestBase.ignore_throttled).toEqual(undefined); - }); - - it('adds `ignore_throttled=false` when `includeFrozen=true`', () => { - const requestBase = getRequestBase({ - ...paramsMock, - includeFrozen: true, - }); - expect(requestBase.ignore_throttled).toEqual(false); - }); -}); diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.ts b/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.ts index 8083cb25c12b5..8b16b5c050596 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/queries/get_request_base.ts @@ -7,8 +7,7 @@ import type { AiopsLogRateAnalysisSchema } from '../api/schema'; -export const getRequestBase = ({ index, includeFrozen }: AiopsLogRateAnalysisSchema) => ({ +export const getRequestBase = ({ index }: AiopsLogRateAnalysisSchema) => ({ index, - ...(includeFrozen ? { ignore_throttled: false } : {}), ignore_unavailable: true, }); diff --git a/x-pack/packages/ml/json_schemas/src/put___ml_anomaly_detectors__job_id__schema.json b/x-pack/packages/ml/json_schemas/src/put___ml_anomaly_detectors__job_id__schema.json index 79a871f1ef3fa..81e1d22bdad9b 100644 --- a/x-pack/packages/ml/json_schemas/src/put___ml_anomaly_detectors__job_id__schema.json +++ b/x-pack/packages/ml/json_schemas/src/put___ml_anomaly_detectors__job_id__schema.json @@ -10765,10 +10765,6 @@ "ignore_unavailable": { "description": "If true, missing or closed indices are not included in the response.", "type": "boolean" - }, - "ignore_throttled": { - "description": "If true, concrete, expanded or aliased indices are ignored when frozen.", - "type": "boolean" } } }, @@ -10884,4 +10880,4 @@ } } } -} \ No newline at end of file +} diff --git a/x-pack/packages/ml/json_schemas/src/put___ml_datafeeds__datafeed_id__schema.json b/x-pack/packages/ml/json_schemas/src/put___ml_datafeeds__datafeed_id__schema.json index 575411eb3a8c2..8bf2dbfc1f529 100644 --- a/x-pack/packages/ml/json_schemas/src/put___ml_datafeeds__datafeed_id__schema.json +++ b/x-pack/packages/ml/json_schemas/src/put___ml_datafeeds__datafeed_id__schema.json @@ -7932,10 +7932,6 @@ "ignore_unavailable": { "description": "If true, missing or closed indices are not included in the response.", "type": "boolean" - }, - "ignore_throttled": { - "description": "If true, concrete, expanded or aliased indices are ignored when frozen.", - "type": "boolean" } } }, @@ -8051,4 +8047,4 @@ } } } -} \ No newline at end of file +} diff --git a/x-pack/plugins/ml/server/models/job_service/jobs.ts b/x-pack/plugins/ml/server/models/job_service/jobs.ts index 9c4ea6b1d3307..fa779258e5f23 100644 --- a/x-pack/plugins/ml/server/models/job_service/jobs.ts +++ b/x-pack/plugins/ml/server/models/job_service/jobs.ts @@ -354,6 +354,10 @@ export function jobsProvider( const result: { datafeed?: Datafeed; job?: Job } = { job: undefined, datafeed: undefined }; if (datafeedResult && datafeedResult.job_id === jobId) { result.datafeed = datafeedResult; + if (result.datafeed.indices_options?.ignore_throttled !== undefined) { + // ignore_throttled is a deprecated setting, remove it from the response + delete result.datafeed.indices_options.ignore_throttled; + } } if (jobResults?.jobs?.length > 0) { diff --git a/x-pack/plugins/ml/server/routes/schemas/datafeeds_schema.ts b/x-pack/plugins/ml/server/routes/schemas/datafeeds_schema.ts index 27e1b6afe3364..2c61dca8859b2 100644 --- a/x-pack/plugins/ml/server/routes/schemas/datafeeds_schema.ts +++ b/x-pack/plugins/ml/server/routes/schemas/datafeeds_schema.ts @@ -27,7 +27,10 @@ export const indicesOptionsSchema = schema.object({ ), ignore_unavailable: schema.maybe(schema.boolean()), allow_no_indices: schema.maybe(schema.boolean()), + // retaining the deprecated ignore_throttled in case an older jobs are used + // we don't want to fail the schema validation if this is present ignore_throttled: schema.maybe(schema.boolean()), + failure_store: schema.maybe(schema.string()), }); export const datafeedConfigSchema = schema.object({ diff --git a/x-pack/test/functional/apps/ml/anomaly_detection_result_views/aggregated_scripted_job.ts b/x-pack/test/functional/apps/ml/anomaly_detection_result_views/aggregated_scripted_job.ts index d2171544aa993..0d27f9afe153b 100644 --- a/x-pack/test/functional/apps/ml/anomaly_detection_result_views/aggregated_scripted_job.ts +++ b/x-pack/test/functional/apps/ml/anomaly_detection_result_views/aggregated_scripted_job.ts @@ -59,7 +59,6 @@ export default function ({ getService }: FtrProviderContext) { expand_wildcards: ['open'], ignore_unavailable: false, allow_no_indices: true, - ignore_throttled: true, }, query: { match_all: {}, @@ -140,7 +139,6 @@ export default function ({ getService }: FtrProviderContext) { expand_wildcards: ['open'], ignore_unavailable: false, allow_no_indices: true, - ignore_throttled: true, }, query: { bool: { @@ -217,7 +215,6 @@ export default function ({ getService }: FtrProviderContext) { expand_wildcards: ['open'], ignore_unavailable: false, allow_no_indices: true, - ignore_throttled: true, }, query: { match_all: {}, @@ -317,7 +314,6 @@ export default function ({ getService }: FtrProviderContext) { expand_wildcards: ['open'], ignore_unavailable: false, allow_no_indices: true, - ignore_throttled: true, }, query: { bool: { From dab0b3524eb9cdfa8d5e5446ef7c920b2582f6e3 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:25:47 +0000 Subject: [PATCH 2/3] [CI] Auto-commit changed files from 'make api-docs' --- oas_docs/output/kibana.serverless.yaml | 12 +++--------- oas_docs/output/kibana.yaml | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 32d38c3569148..9f0c38baded7d 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -16693,14 +16693,10 @@ paths: type: object properties: active: - description: >- - When false, the enrollment API key is revoked and - cannot be used for enrolling Elastic Agents. + description: When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents. type: boolean api_key: - description: >- - The enrollment API key (token) used for enrolling - Elastic Agents. + description: The enrollment API key (token) used for enrolling Elastic Agents. type: string api_key_id: description: The ID of the API key in the Security API. @@ -16713,9 +16709,7 @@ paths: description: The name of the enrollment API key. type: string policy_id: - description: >- - The ID of the agent policy the Elastic Agent will be - enrolled in. + description: The ID of the agent policy the Elastic Agent will be enrolled in. type: string required: - id diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index 8a3d4d3634b8d..50fd92fdc8a9c 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -19477,14 +19477,10 @@ paths: type: object properties: active: - description: >- - When false, the enrollment API key is revoked and - cannot be used for enrolling Elastic Agents. + description: When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents. type: boolean api_key: - description: >- - The enrollment API key (token) used for enrolling - Elastic Agents. + description: The enrollment API key (token) used for enrolling Elastic Agents. type: string api_key_id: description: The ID of the API key in the Security API. @@ -19497,9 +19493,7 @@ paths: description: The name of the enrollment API key. type: string policy_id: - description: >- - The ID of the agent policy the Elastic Agent will be - enrolled in. + description: The ID of the agent policy the Elastic Agent will be enrolled in. type: string required: - id From 4a889a93d851503688e5e4bc519299b101362ff8 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 22 Nov 2024 09:45:48 +0000 Subject: [PATCH 3/3] adding comment --- x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v2.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v2.ts b/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v2.ts index 1e132f6f00e78..95c778a118454 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v2.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v2.ts @@ -45,6 +45,7 @@ export const aiopsLogRateAnalysisBase = schema.object({ end: schema.number(), searchQuery: schema.string(), timeFieldName: schema.string(), + // when v2 is removed, includeFrozen should not carry over to v3+ includeFrozen: schema.maybe(schema.boolean()), grouping: schema.maybe(schema.boolean()), /** Analysis selection time ranges */