diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 501a3698d07d91..b426621fed2963 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -181,6 +181,12 @@ which also contains the timelion APIs and backend, look at the vis_type_timelion To integrate with the telemetry services for usage collection of your feature, there are 2 steps: +|{kib-repo}blob/{branch}/src/plugins/vis_default_editor/README.md[visDefaultEditor] +|The default editor is used in most primary visualizations, e.x. Area, Data table, Pie, etc. +It acts as a container for a particular visualization and options tabs. Contains the default "Data" tab in public/components/sidebar/data_tab.tsx. +The plugin exposes the static DefaultEditorController class to consume. + + |{kib-repo}blob/{branch}/src/plugins/vis_type_markdown/README.md[visTypeMarkdown] |The markdown visualization that can be used to place text panels on dashboards. diff --git a/src/plugins/charts/kibana.json b/src/plugins/charts/kibana.json index c4643d541c31c7..8967e931a0b102 100644 --- a/src/plugins/charts/kibana.json +++ b/src/plugins/charts/kibana.json @@ -3,5 +3,5 @@ "version": "kibana", "server": true, "ui": true, - "requiredBundles": ["kibanaUtils", "kibanaReact", "data"] + "requiredBundles": ["visDefaultEditor"] } diff --git a/src/plugins/console/server/lib/spec_definitions/js/mappings.ts b/src/plugins/console/server/lib/spec_definitions/js/mappings.ts index aa09278d075538..e6b3d4d5fcb6ef 100644 --- a/src/plugins/console/server/lib/spec_definitions/js/mappings.ts +++ b/src/plugins/console/server/lib/spec_definitions/js/mappings.ts @@ -157,58 +157,65 @@ export const mappings = (specService: SpecDefinitionsService) => { // dates format: { + // outer array required to for an array of string values __one_of: [ - ...[ - 'date', - 'date_time', - 'date_time_no_millis', - 'ordinal_date', - 'ordinal_date_time', - 'ordinal_date_time_no_millis', - 'time', - 'time_no_millis', - 't_time', - 't_time_no_millis', - 'week_date', - 'week_date_time', - 'week_date_time_no_millis', - ].map(function (s) { - return ['basic_' + s, 'strict_' + s]; - }), - ...[ - 'date', - 'date_hour', - 'date_hour_minute', - 'date_hour_minute_second', - 'date_hour_minute_second_fraction', - 'date_hour_minute_second_millis', - 'date_optional_time', - 'date_time', - 'date_time_no_millis', - 'hour', - 'hour_minute', - 'hour_minute_second', - 'hour_minute_second_fraction', - 'hour_minute_second_millis', - 'ordinal_date', - 'ordinal_date_time', - 'ordinal_date_time_no_millis', - 'time', - 'time_no_millis', - 't_time', - 't_time_no_millis', - 'week_date', - 'week_date_time', - 'weekDateTimeNoMillis', - 'week_year', - 'weekyearWeek', - 'weekyearWeekDay', - 'year', - 'year_month', - 'year_month_day', - 'epoch_millis', - 'epoch_second', - ], + [ + ...[ + 'date', + 'date_time', + 'date_time_no_millis', + 'ordinal_date', + 'ordinal_date_time', + 'ordinal_date_time_no_millis', + 'time', + 'time_no_millis', + 't_time', + 't_time_no_millis', + 'week_date', + 'week_date_time', + 'week_date_time_no_millis', + ].flatMap(function (s) { + return ['basic_' + s, 'strict_' + s]; + }), + ...[ + 'date', + 'date_hour', + 'date_hour_minute', + 'date_hour_minute_second', + 'date_hour_minute_second_fraction', + 'date_hour_minute_second_millis', + 'date_optional_time', + 'date_time', + 'date_time_no_millis', + 'hour', + 'hour_minute', + 'hour_minute_second', + 'hour_minute_second_fraction', + 'hour_minute_second_millis', + 'ordinal_date', + 'ordinal_date_time', + 'ordinal_date_time_no_millis', + 'time', + 'time_no_millis', + 't_time', + 't_time_no_millis', + 'week_date', + 'week_date_time', + 'weekDateTimeNoMillis', + 'weekyear', + 'strict_weekyear', + 'weekyear_week', + 'strict_weekyear_week', + 'strict_date_optional_time_nanos', + 'weekyear_week_day', + 'strict_weekyear_week_day', + 'year', + 'year_month', + 'year_month_day', + 'epoch_millis', + 'epoch_second', + ], + ].sort(), ], }, diff --git a/src/plugins/input_control_vis/kibana.json b/src/plugins/input_control_vis/kibana.json index 6928eb19d02e13..c6d1157f5ff258 100644 --- a/src/plugins/input_control_vis/kibana.json +++ b/src/plugins/input_control_vis/kibana.json @@ -4,6 +4,6 @@ "kibanaVersion": "kibana", "server": true, "ui": true, - "requiredPlugins": ["data", "expressions", "visualizations"], + "requiredPlugins": ["data", "expressions", "visualizations", "visDefaultEditor"], "requiredBundles": ["kibanaReact"] } diff --git a/src/plugins/region_map/kibana.json b/src/plugins/region_map/kibana.json index 6e1980c327dc05..bd5517d2a5bf7f 100644 --- a/src/plugins/region_map/kibana.json +++ b/src/plugins/region_map/kibana.json @@ -14,7 +14,7 @@ ], "requiredBundles": [ "kibanaUtils", - "kibanaReact", - "charts" + "charts", + "visDefaultEditor" ] } diff --git a/src/plugins/tile_map/kibana.json b/src/plugins/tile_map/kibana.json index 9881a2dd72308b..acf1424229c8e6 100644 --- a/src/plugins/tile_map/kibana.json +++ b/src/plugins/tile_map/kibana.json @@ -14,7 +14,7 @@ ], "requiredBundles": [ "kibanaUtils", - "kibanaReact", - "charts" + "charts", + "visDefaultEditor" ] } diff --git a/src/plugins/vis_default_editor/kibana.json b/src/plugins/vis_default_editor/kibana.json new file mode 100644 index 00000000000000..35ad0a3a8be9ac --- /dev/null +++ b/src/plugins/vis_default_editor/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "visDefaultEditor", + "version": "kibana", + "ui": true, + "requiredBundles": ["kibanaUtils", "kibanaReact", "data"] +} diff --git a/src/plugins/vis_default_editor/public/index.ts b/src/plugins/vis_default_editor/public/index.ts index 156d50f451b577..d7eb5eda7bdfe0 100644 --- a/src/plugins/vis_default_editor/public/index.ts +++ b/src/plugins/vis_default_editor/public/index.ts @@ -24,3 +24,11 @@ export * from './editor_size'; export * from './vis_options_props'; export * from './utils'; export { ISchemas, Schemas, Schema } from './schemas'; + +/** dummy plugin, we just want visDefaultEditor to have its own bundle */ +export function plugin() { + return new (class VisDefaultEditor { + setup() {} + start() {} + })(); +} diff --git a/src/plugins/vis_type_markdown/kibana.json b/src/plugins/vis_type_markdown/kibana.json index 4196bd7e857076..5723fdefe1e4cf 100644 --- a/src/plugins/vis_type_markdown/kibana.json +++ b/src/plugins/vis_type_markdown/kibana.json @@ -4,5 +4,5 @@ "ui": true, "server": true, "requiredPlugins": ["expressions", "visualizations"], - "requiredBundles": ["kibanaUtils", "kibanaReact", "data", "charts", "visualizations", "expressions"] + "requiredBundles": ["kibanaUtils", "kibanaReact", "charts", "visualizations", "expressions", "visDefaultEditor"] } diff --git a/src/plugins/vis_type_metric/kibana.json b/src/plugins/vis_type_metric/kibana.json index 26ca09e22f26e8..68ab0bf617e30d 100644 --- a/src/plugins/vis_type_metric/kibana.json +++ b/src/plugins/vis_type_metric/kibana.json @@ -5,5 +5,5 @@ "server": true, "ui": true, "requiredPlugins": ["data", "visualizations", "charts", "expressions"], - "requiredBundles": ["kibanaUtils", "kibanaReact"] + "requiredBundles": ["kibanaUtils", "visDefaultEditor"] } diff --git a/src/plugins/vis_type_table/kibana.json b/src/plugins/vis_type_table/kibana.json index b3c15564290770..b8a68909dc8571 100644 --- a/src/plugins/vis_type_table/kibana.json +++ b/src/plugins/vis_type_table/kibana.json @@ -11,8 +11,8 @@ ], "requiredBundles": [ "kibanaUtils", - "kibanaReact", "share", - "charts" + "charts", + "visDefaultEditor" ] } diff --git a/src/plugins/vis_type_tagcloud/kibana.json b/src/plugins/vis_type_tagcloud/kibana.json index 86f72ebfa936d7..441a899c3ab531 100644 --- a/src/plugins/vis_type_tagcloud/kibana.json +++ b/src/plugins/vis_type_tagcloud/kibana.json @@ -4,5 +4,5 @@ "ui": true, "server": true, "requiredPlugins": ["data", "expressions", "visualizations", "charts"], - "requiredBundles": ["kibanaUtils", "kibanaReact"] + "requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"] } diff --git a/src/plugins/vis_type_timelion/kibana.json b/src/plugins/vis_type_timelion/kibana.json index 6946568f5d809d..dda33c9fb6f2e2 100644 --- a/src/plugins/vis_type_timelion/kibana.json +++ b/src/plugins/vis_type_timelion/kibana.json @@ -5,5 +5,5 @@ "server": true, "ui": true, "requiredPlugins": ["visualizations", "data", "expressions"], - "requiredBundles": ["kibanaUtils", "kibanaReact"] + "requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"] } diff --git a/src/plugins/vis_type_vega/kibana.json b/src/plugins/vis_type_vega/kibana.json index 7ba5f23f10564b..231e252fe2c8a1 100644 --- a/src/plugins/vis_type_vega/kibana.json +++ b/src/plugins/vis_type_vega/kibana.json @@ -4,5 +4,5 @@ "server": true, "ui": true, "requiredPlugins": ["data", "visualizations", "mapsLegacy", "expressions", "inspector"], - "requiredBundles": ["kibanaUtils", "kibanaReact"] + "requiredBundles": ["kibanaUtils", "kibanaReact", "visDefaultEditor"] } diff --git a/src/plugins/vis_type_vislib/kibana.json b/src/plugins/vis_type_vislib/kibana.json index 7cba2e0d6a6b4b..720abff16b7c77 100644 --- a/src/plugins/vis_type_vislib/kibana.json +++ b/src/plugins/vis_type_vislib/kibana.json @@ -5,5 +5,5 @@ "ui": true, "requiredPlugins": ["charts", "data", "expressions", "visualizations", "kibanaLegacy"], "optionalPlugins": ["visTypeXy"], - "requiredBundles": ["kibanaUtils", "kibanaReact"] + "requiredBundles": ["kibanaUtils", "visDefaultEditor"] } diff --git a/src/plugins/visualize/kibana.json b/src/plugins/visualize/kibana.json index 318a1562efdfe9..2e40d291586005 100644 --- a/src/plugins/visualize/kibana.json +++ b/src/plugins/visualize/kibana.json @@ -18,6 +18,7 @@ "kibanaUtils", "kibanaReact", "home", - "discover" + "discover", + "visDefaultEditor" ] } diff --git a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx index 05ea585108c691..6e95df0dddd840 100644 --- a/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx +++ b/x-pack/plugins/apm/public/components/app/Settings/anomaly_detection/jobs_list.tsx @@ -97,7 +97,7 @@ export function JobsList({ data, status, onAddEnvironments }: Props) { defaultMessage="To add anomaly detection to a new environment, create a machine learning job. Existing machine learning jobs can be managed in {mlJobsLink}." values={{ mlJobsLink: ( - + {i18n.translate( 'xpack.apm.settings.anomalyDetection.jobList.mlDescriptionText.mlJobsLinkText', { diff --git a/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx index da345e35c10b13..4eb886509805d8 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx @@ -21,6 +21,6 @@ test('MLLink produces the correct URL', async () => { ); expect(href).toMatchInlineSnapshot( - `"/basepath/app/ml#/some/path?_g=(ml:(jobIds:!(something)),refreshInterval:(pause:!t,value:0),time:(from:now-5h,to:now-2h))"` + `"/basepath/app/ml#/some/path?_g=(ml:(jobIds:!(something)),refreshInterval:(pause:!t,value:0),time:(from:now-5h,to:now-2h))&mlManagement=(groupIds:!(apm))"` ); }); diff --git a/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx index d8ec212515c6f5..93ee9e0db48649 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx @@ -39,7 +39,9 @@ export function MLLink({ children, path = '', query = {}, external }: Props) { const href = url.format({ pathname: core.http.basePath.prepend('/app/ml'), - hash: `${path}?_g=${rison.encode(risonQuery as RisonValue)}`, + hash: `${path}?_g=${rison.encode( + risonQuery as RisonValue + )}&mlManagement=${rison.encode({ groupIds: ['apm'] })}`, }); return ( diff --git a/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts b/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts index ef85112918712d..c1cb903a0bb3ef 100644 --- a/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts +++ b/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts @@ -389,7 +389,7 @@ export async function aggregateLatencyMetrics() { return; } - const response = await destClient?.bulk({ + const response = await (destClient as any)?.bulk({ refresh: 'wait_for', body: flatten( docs.map((doc) => [ diff --git a/x-pack/plugins/apm/scripts/eslint.js b/x-pack/plugins/apm/scripts/eslint.js new file mode 100644 index 00000000000000..f221fc6dab23d7 --- /dev/null +++ b/x-pack/plugins/apm/scripts/eslint.js @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +//eslint-disable-next-line import/no-extraneous-dependencies +const { CLIEngine } = require('eslint'); +const { resolve } = require('path'); +//eslint-disable-next-line import/no-extraneous-dependencies +const { argv } = require('yargs'); + +async function run() { + const fix = !!argv.fix; + + const engine = new CLIEngine({ + fix, + cache: true, + extensions: ['.js', '.jsx', '.ts', '.tsx'], + }); + + const report = engine.executeOnFiles(resolve(__dirname, '..')); + + const formatter = engine.getFormatter(); + + return formatter(report.results); +} + +run() + .then((text) => { + //eslint-disable-next-line no-console + console.log(text); + process.exit(0); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); diff --git a/x-pack/plugins/apm/scripts/jest.js b/x-pack/plugins/apm/scripts/jest.js new file mode 100644 index 00000000000000..5c29dd91269378 --- /dev/null +++ b/x-pack/plugins/apm/scripts/jest.js @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +// eslint-disable-next-line import/no-extraneous-dependencies +require('@babel/register')({ + extensions: ['.js'], + plugins: [], + presets: [ + '@babel/typescript', + ['@babel/preset-env', { targets: { node: 'current' } }], + ], +}); + +// eslint-disable-next-line import/no-extraneous-dependencies +const { run } = require('jest'); + +process.env.NODE_ENV = process.env.NODE_ENV || 'test'; + +const config = require('../jest.config.js'); + +const argv = [...process.argv.slice(2), '--config', JSON.stringify(config)]; + +run(argv); diff --git a/x-pack/plugins/apm/scripts/precommit.js b/x-pack/plugins/apm/scripts/precommit.js new file mode 100644 index 00000000000000..87da3c1db8b28d --- /dev/null +++ b/x-pack/plugins/apm/scripts/precommit.js @@ -0,0 +1,69 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/* eslint-disable no-console*/ +/* eslint-disable import/no-extraneous-dependencies*/ + +const execa = require('execa'); +const Listr = require('listr'); +const { resolve } = require('path'); + +const cwd = resolve(__dirname, '../../../..'); + +const execaOpts = { cwd, stderr: 'pipe' }; + +const tasks = new Listr( + [ + { + title: 'Jest', + task: () => + execa( + 'node', + [ + resolve(__dirname, './jest.js'), + '--reporters', + resolve(__dirname, './node_modules/jest-silent-reporter'), + '--collect-coverage', + 'false', + ], + execaOpts + ), + }, + { + title: 'Typescript', + task: () => + execa('node', [resolve(__dirname, 'optimize-tsconfig.js')]).then(() => + execa( + require.resolve('typescript/bin/tsc'), + [ + '--project', + resolve(__dirname, '../../../tsconfig.json'), + '--pretty', + '--noEmit', + '--skipLibCheck', + ], + execaOpts + ) + ), + }, + { + title: 'Lint', + task: () => execa('node', [resolve(__dirname, 'eslint.js')], execaOpts), + }, + ], + { exitOnError: false, concurrent: true } +); + +tasks.run().catch((error) => { + // from src/dev/typescript/exec_in_projects.ts + process.exitCode = 1; + + const errors = error.errors || [error]; + + for (const e of errors) { + process.stderr.write(e.stdout); + } +}); diff --git a/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts b/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts index 01fa5b0509bcdc..83de83ace07b34 100644 --- a/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts +++ b/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts @@ -39,7 +39,7 @@ export async function createOrUpdateIndex({ await client.indices.exists({ index: indexName, }) - ).body as boolean; + ).body as unknown; if (!indexExists) { await client.indices.create({ diff --git a/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts index fd628f77eb519e..ca47540b04d826 100644 --- a/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts +++ b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts @@ -83,7 +83,7 @@ async function uploadData() { apmAgentConfigurationIndex: '.apm-agent-configuration', }, search: (body) => { - return client.search(body as any).then((res) => res.body); + return client.search(body as any).then((res) => res.body as any); }, indicesStats: (body) => { return client.indices.stats(body as any).then((res) => res.body); diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts b/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts index da087b4c1911a7..44c0c96142096a 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts @@ -60,11 +60,16 @@ export async function getServiceAnomalies({ query: { bool: { filter: [ - { term: { result_type: 'record' } }, + { terms: { result_type: ['model_plot', 'record'] } }, { terms: { job_id: mlJobIds } }, { range: { - timestamp: { gte: start, lte: end, format: 'epoch_millis' }, + timestamp: { + // fetch data for at least 30 minutes + gte: Math.min(end - 30 * 60 * 1000, start), + lte: end, + format: 'epoch_millis', + }, }, }, { @@ -83,7 +88,13 @@ export async function getServiceAnomalies({ top_score: { top_hits: { sort: { record_score: 'desc' }, - _source: { includes: ['actual', 'job_id', 'by_field_value'] }, + _source: [ + 'actual', + 'job_id', + 'by_field_value', + 'result_type', + 'record_score', + ], size: 1, }, }, @@ -113,10 +124,19 @@ interface ServiceAnomaliesAggResponse { hits: Array<{ sort: [number]; _source: { - actual: [number]; job_id: string; by_field_value: string; - }; + } & ( + | { + record_score: number | null; + result_type: 'record'; + actual: number[]; + } + | { + result_type: 'model_plot'; + actual?: number; + } + ); }>; }; }; @@ -127,12 +147,15 @@ interface ServiceAnomaliesAggResponse { function transformResponseToServiceAnomalies( response: ServiceAnomaliesAggResponse -): Record { +) { const serviceAnomaliesMap = ( response.aggregations?.services.buckets ?? [] - ).reduce( + ).reduce>( (statsByServiceName, { key: serviceName, top_score: topScoreAgg }) => { - const anomalyScore = topScoreAgg.hits.hits[0]?.sort?.[0]; + const mlResult = topScoreAgg.hits.hits[0]._source; + + const anomalyScore = + (mlResult.result_type === 'record' && mlResult.record_score) || 0; const severity = getSeverity(anomalyScore); const healthStatus = getServiceHealthStatus({ severity }); @@ -140,16 +163,20 @@ function transformResponseToServiceAnomalies( return { ...statsByServiceName, [serviceName]: { - transactionType: topScoreAgg.hits.hits[0]?._source?.by_field_value, + transactionType: mlResult.by_field_value, + jobId: mlResult.job_id, + actualValue: + mlResult.result_type === 'record' + ? mlResult.actual[0] + : mlResult.actual, anomalyScore, - actualValue: topScoreAgg.hits.hits[0]?._source?.actual?.[0], - jobId: topScoreAgg.hits.hits[0]?._source?.job_id, healthStatus, }, }; }, {} ); + return serviceAnomaliesMap; } diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx index b0df3723ca77ec..f1952287757726 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx @@ -611,116 +611,6 @@ describe('edit policy', () => { expect(findTestSubject(rendered, 'defaultAllocationWarning').exists()).toBeTruthy(); }); }); - describe('frozen phase', () => { - beforeEach(() => { - server.respondImmediately = true; - http.setupNodeListResponse(); - httpRequestsMockHelpers.setNodesDetailsResponse('attribute:true', [ - { nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } }, - ]); - }); - test('should allow 0 for phase timing', async () => { - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - setPhaseAfter(rendered, 'frozen', 0); - save(rendered); - expectedErrorMessages(rendered, []); - }); - test('should show positive number required error when trying to save cold phase with -1 for after', async () => { - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - setPhaseAfter(rendered, 'frozen', -1); - save(rendered); - expectedErrorMessages(rendered, [positiveNumberRequiredMessage]); - }); - test('should show spinner for node attributes input when loading', async () => { - server.respondImmediately = false; - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - expect(rendered.find('.euiLoadingSpinner').exists()).toBeTruthy(); - expect(rendered.find('.euiCallOut--warning').exists()).toBeFalsy(); - expect(getNodeAttributeSelect(rendered, 'frozen').exists()).toBeFalsy(); - }); - test('should show warning instead of node attributes input when none exist', async () => { - http.setupNodeListResponse({ - nodesByAttributes: {}, - nodesByRoles: { data: ['node1'] }, - }); - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy(); - openNodeAttributesSection(rendered, 'frozen'); - expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeTruthy(); - expect(getNodeAttributeSelect(rendered, 'frozen').exists()).toBeFalsy(); - }); - test('should show node attributes input when attributes exist', async () => { - http.setupNodeListResponse(); - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy(); - openNodeAttributesSection(rendered, 'frozen'); - expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeFalsy(); - const nodeAttributesSelect = getNodeAttributeSelect(rendered, 'frozen'); - expect(nodeAttributesSelect.exists()).toBeTruthy(); - expect(nodeAttributesSelect.find('option').length).toBe(2); - }); - test('should show view node attributes link when attribute selected and show flyout when clicked', async () => { - http.setupNodeListResponse(); - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy(); - openNodeAttributesSection(rendered, 'frozen'); - expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeFalsy(); - const nodeAttributesSelect = getNodeAttributeSelect(rendered, 'frozen'); - expect(nodeAttributesSelect.exists()).toBeTruthy(); - expect(findTestSubject(rendered, 'frozen-viewNodeDetailsFlyoutButton').exists()).toBeFalsy(); - expect(nodeAttributesSelect.find('option').length).toBe(2); - nodeAttributesSelect.simulate('change', { target: { value: 'attribute:true' } }); - rendered.update(); - const flyoutButton = findTestSubject(rendered, 'frozen-viewNodeDetailsFlyoutButton'); - expect(flyoutButton.exists()).toBeTruthy(); - await act(async () => { - await flyoutButton.simulate('click'); - }); - rendered.update(); - expect(rendered.find('.euiFlyout').exists()).toBeTruthy(); - }); - test('should show positive number required error when trying to save with -1 for index priority', async () => { - http.setupNodeListResponse(); - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - setPhaseAfter(rendered, 'frozen', 1); - setPhaseIndexPriority(rendered, 'frozen', -1); - save(rendered); - expectedErrorMessages(rendered, [positiveNumberRequiredMessage]); - }); - test('should show default allocation warning when no node roles are found', async () => { - http.setupNodeListResponse({ - nodesByAttributes: {}, - nodesByRoles: {}, - }); - const rendered = mountWithIntl(component); - noRollover(rendered); - setPolicyName(rendered, 'mypolicy'); - await activatePhase(rendered, 'frozen'); - expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy(); - expect(findTestSubject(rendered, 'defaultAllocationWarning').exists()).toBeTruthy(); - }); - }); describe('delete phase', () => { test('should allow 0 for phase timing', async () => { const rendered = mountWithIntl(component); diff --git a/x-pack/plugins/index_lifecycle_management/common/types/policies.ts b/x-pack/plugins/index_lifecycle_management/common/types/policies.ts index 8f913dd884dfee..a0ee82cbbe3852 100644 --- a/x-pack/plugins/index_lifecycle_management/common/types/policies.ts +++ b/x-pack/plugins/index_lifecycle_management/common/types/policies.ts @@ -6,7 +6,7 @@ import { Index as IndexInterface } from '../../../index_management/common/types'; -export type PhaseWithAllocation = 'warm' | 'cold' | 'frozen'; +export type PhaseWithAllocation = 'warm' | 'cold'; export interface SerializedPolicy { name: string; @@ -17,7 +17,6 @@ export interface Phases { hot?: SerializedHotPhase; warm?: SerializedWarmPhase; cold?: SerializedColdPhase; - frozen?: SerializedFrozenPhase; delete?: SerializedDeletePhase; } @@ -79,17 +78,6 @@ export interface SerializedColdPhase extends SerializedPhase { }; } -export interface SerializedFrozenPhase extends SerializedPhase { - actions: { - freeze?: {}; - allocate?: AllocateAction; - set_priority?: { - priority: number | null; - }; - migrate?: { enabled: boolean }; - }; -} - export interface SerializedDeletePhase extends SerializedPhase { actions: { wait_for_snapshot?: { @@ -123,7 +111,6 @@ export interface Policy { hot: HotPhase; warm: WarmPhase; cold: ColdPhase; - frozen: FrozenPhase; delete: DeletePhase; }; } @@ -196,14 +183,6 @@ export interface ColdPhase freezeEnabled: boolean; } -export interface FrozenPhase - extends CommonPhaseSettings, - PhaseWithMinAge, - PhaseWithAllocationAction, - PhaseWithIndexPriority { - freezeEnabled: boolean; -} - export interface DeletePhase extends CommonPhaseSettings, PhaseWithMinAge { waitForSnapshotPolicy: string; } diff --git a/x-pack/plugins/index_lifecycle_management/public/application/constants/policy.ts b/x-pack/plugins/index_lifecycle_management/public/application/constants/policy.ts index 6d4c57d23138d1..8a0a5d9fbdfad3 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/constants/policy.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/constants/policy.ts @@ -10,7 +10,6 @@ import { DeletePhase, HotPhase, WarmPhase, - FrozenPhase, } from '../../../common/types'; export const defaultNewHotPhase: HotPhase = { @@ -52,17 +51,6 @@ export const defaultNewColdPhase: ColdPhase = { dataTierAllocationType: 'default', }; -export const defaultNewFrozenPhase: FrozenPhase = { - phaseEnabled: false, - selectedMinimumAge: '0', - selectedMinimumAgeUnits: 'd', - selectedNodeAttrs: '', - selectedReplicaCount: '', - freezeEnabled: false, - phaseIndexPriority: '0', - dataTierAllocationType: 'default', -}; - export const defaultNewDeletePhase: DeletePhase = { phaseEnabled: false, selectedMinimumAge: '0', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/data_tier_allocation.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/data_tier_allocation.tsx index 3ae60a5a3d622a..4ec488f95c94d4 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/data_tier_allocation.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/data_tier_allocation.tsx @@ -86,38 +86,6 @@ const i18nTexts = { ), }, }, - frozen: { - default: { - input: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.defaultOption.input', - { defaultMessage: 'Use frozen nodes (recommended)' } - ), - helpText: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.defaultOption.helpText', - { defaultMessage: 'Move data to nodes in the frozen tier.' } - ), - }, - none: { - inputDisplay: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.noneOption.input', - { defaultMessage: 'Off' } - ), - helpText: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.noneOption.helpText', - { defaultMessage: 'Do not move data in the frozen phase.' } - ), - }, - custom: { - inputDisplay: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.customOption.input', - { defaultMessage: 'Custom' } - ), - helpText: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.customOption.helpText', - { defaultMessage: 'Move data based on node attributes.' } - ), - }, - }, }, }; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/default_allocation_warning.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/default_allocation_warning.tsx index a7ebc0d2e4a241..5aba411b6fe53e 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/default_allocation_warning.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/default_allocation_warning.tsx @@ -37,19 +37,6 @@ const i18nTexts = { } ), }, - frozen: { - title: i18n.translate( - 'xpack.indexLifecycleMgmt.frozenPhase.dataTier.defaultAllocationNotAvailableTitle', - { defaultMessage: 'No nodes assigned to the frozen tier' } - ), - body: i18n.translate( - 'xpack.indexLifecycleMgmt.frozenPhase.dataTier.defaultAllocationNotAvailableBody', - { - defaultMessage: - 'Assign at least one node to the frozen tier to use role-based allocation. The policy will fail to complete allocation if there are no frozen nodes.', - } - ), - }, }; interface Props { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/no_node_attributes_warning.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/no_node_attributes_warning.tsx index 1ba82623c2b947..ceccc51f95c1f3 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/no_node_attributes_warning.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/no_node_attributes_warning.tsx @@ -32,15 +32,6 @@ const i18nTexts = { } ), }, - frozen: { - body: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.frozen.nodeAttributesMissingDescription', - { - defaultMessage: - 'Define custom node attributes in elasticsearch.yml to use attribute-based allocation. Frozen nodes will be used instead.', - } - ), - }, }; export const NoNodeAttributesWarning: FunctionComponent<{ phase: PhaseWithAllocation }> = ({ diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/min_age_input.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/min_age_input.tsx index d7edbac3d1c54f..2e70ef255524d5 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/min_age_input.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/min_age_input.tsx @@ -27,11 +27,6 @@ function getTimingLabelForPhase(phase: keyof Phases) { defaultMessage: 'Timing for cold phase', }); - case 'frozen': - return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseFrozen.minimumAgeLabel', { - defaultMessage: 'Timing for frozen phase', - }); - case 'delete': return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseDelete.minimumAgeLabel', { defaultMessage: 'Timing for delete phase', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx index 85529ef0c9a5b3..67e8e42cf6fd15 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx @@ -43,7 +43,7 @@ import { } from '../../services/policies/policy_serialization'; import { ErrableFormRow, LearnMoreLink, PolicyJsonFlyout } from './components'; -import { ColdPhase, DeletePhase, FrozenPhase, HotPhase, WarmPhase } from './phases'; +import { ColdPhase, DeletePhase, HotPhase, WarmPhase } from './phases'; export interface Props { policies: PolicyFromES[]; @@ -144,10 +144,6 @@ export const EditPolicy: React.FunctionComponent = ({ (key: string, value: any) => setPhaseData('cold', key, value), [setPhaseData] ); - const setFrozenPhaseData = useCallback( - (key: string, value: any) => setPhaseData('frozen', key, value), - [setPhaseData] - ); const setDeletePhaseData = useCallback( (key: string, value: any) => setPhaseData('delete', key, value), [setPhaseData] @@ -328,16 +324,6 @@ export const EditPolicy: React.FunctionComponent = ({ - 0} - setPhaseData={setFrozenPhaseData} - phaseData={policy.phases.frozen} - hotPhaseRolloverEnabled={policy.phases.hot.rolloverEnabled} - /> - - - 0} diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/frozen_phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/frozen_phase.tsx deleted file mode 100644 index 6a849cc2c3f1f1..00000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/frozen_phase.tsx +++ /dev/null @@ -1,224 +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; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { FunctionComponent, Fragment } from 'react'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; - -import { EuiFieldNumber, EuiDescribedFormGroup, EuiSwitch, EuiTextColor } from '@elastic/eui'; - -import { FrozenPhase as FrozenPhaseInterface, Phases } from '../../../../../common/types'; -import { PhaseValidationErrors } from '../../../services/policies/policy_validation'; - -import { - LearnMoreLink, - ActiveBadge, - PhaseErrorMessage, - OptionalLabel, - ErrableFormRow, - MinAgeInput, - SetPriorityInput, - DescribedFormField, -} from '../components'; -import { DataTierAllocationField } from './shared'; - -const i18nTexts = { - freezeLabel: i18n.translate('xpack.indexLifecycleMgmt.frozenPhase.freezeIndexLabel', { - defaultMessage: 'Freeze index', - }), - dataTierAllocation: { - description: i18n.translate('xpack.indexLifecycleMgmt.frozenPhase.dataTier.description', { - defaultMessage: - 'Move data to data nodes optimized for infrequent, read-only access. Store frozen data on the least-expensive hardware.', - }), - }, -}; - -const frozenProperty: keyof Phases = 'frozen'; -const phaseProperty = (propertyName: keyof FrozenPhaseInterface) => propertyName; - -interface Props { - setPhaseData: (key: keyof FrozenPhaseInterface & string, value: string | boolean) => void; - phaseData: FrozenPhaseInterface; - isShowingErrors: boolean; - errors?: PhaseValidationErrors; - hotPhaseRolloverEnabled: boolean; -} -export const FrozenPhase: FunctionComponent = ({ - setPhaseData, - phaseData, - errors, - isShowingErrors, - hotPhaseRolloverEnabled, -}) => { - return ( -
- <> - {/* Section title group; containing min age */} - -

- -

{' '} - {phaseData.phaseEnabled && !isShowingErrors ? : null} - -
- } - titleSize="s" - description={ - -

- -

- - } - id={`${frozenProperty}-${phaseProperty('phaseEnabled')}`} - checked={phaseData.phaseEnabled} - onChange={(e) => { - setPhaseData(phaseProperty('phaseEnabled'), e.target.checked); - }} - aria-controls="frozenPhaseContent" - /> -
- } - fullWidth - > - {phaseData.phaseEnabled ? ( - - errors={errors} - phaseData={phaseData} - phase={frozenProperty} - isShowingErrors={isShowingErrors} - setPhaseData={setPhaseData} - rolloverEnabled={hotPhaseRolloverEnabled} - /> - ) : null} - - {phaseData.phaseEnabled ? ( - - {/* Data tier allocation section */} - - - {/* Replicas section */} - - {i18n.translate('xpack.indexLifecycleMgmt.frozenPhase.replicasTitle', { - defaultMessage: 'Replicas', - })} - - } - description={i18n.translate( - 'xpack.indexLifecycleMgmt.frozenPhase.numberOfReplicasDescription', - { - defaultMessage: - 'Set the number of replicas. Remains the same as the previous phase by default.', - } - )} - switchProps={{ - label: i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.frozenPhase.numberOfReplicas.switchLabel', - { defaultMessage: 'Set replicas' } - ), - initialValue: Boolean(phaseData.selectedReplicaCount), - onChange: (v) => { - if (!v) { - setPhaseData('selectedReplicaCount', ''); - } - }, - }} - fullWidth - > - - - - - } - isShowingErrors={isShowingErrors} - errors={errors?.selectedReplicaCount} - > - { - setPhaseData(phaseProperty('selectedReplicaCount'), e.target.value); - }} - min={0} - /> - - - - - - } - description={ - - {' '} - - - } - fullWidth - titleSize="xs" - > - { - setPhaseData(phaseProperty('freezeEnabled'), e.target.checked); - }} - label={i18nTexts.freezeLabel} - aria-label={i18nTexts.freezeLabel} - /> - - - errors={errors} - phaseData={phaseData} - phase={frozenProperty} - isShowingErrors={isShowingErrors} - setPhaseData={setPhaseData} - /> - - ) : null} - - - ); -}; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/index.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/index.ts index d59f2ff6413fd4..8d1ace5950497b 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/index.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/index.ts @@ -7,5 +7,4 @@ export { HotPhase } from './hot_phase'; export { WarmPhase } from './warm_phase'; export { ColdPhase } from './cold_phase'; -export { FrozenPhase } from './frozen_phase'; export { DeletePhase } from './delete_phase'; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/frozen_phase.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/frozen_phase.ts deleted file mode 100644 index 28d18b8f892635..00000000000000 --- a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/frozen_phase.ts +++ /dev/null @@ -1,156 +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; - * you may not use this file except in compliance with the Elastic License. - */ - -import { isEmpty } from 'lodash'; -import { serializedPhaseInitialization } from '../../constants'; -import { AllocateAction, FrozenPhase, SerializedFrozenPhase } from '../../../../common/types'; -import { isNumber, splitSizeAndUnits } from './policy_serialization'; -import { - numberRequiredMessage, - PhaseValidationErrors, - positiveNumberRequiredMessage, -} from './policy_validation'; -import { determineDataTierAllocationType } from '../../lib'; -import { serializePhaseWithAllocation } from './shared'; - -const frozenPhaseInitialization: FrozenPhase = { - phaseEnabled: false, - selectedMinimumAge: '0', - selectedMinimumAgeUnits: 'd', - selectedNodeAttrs: '', - selectedReplicaCount: '', - freezeEnabled: false, - phaseIndexPriority: '', - dataTierAllocationType: 'default', -}; - -export const frozenPhaseFromES = (phaseSerialized?: SerializedFrozenPhase): FrozenPhase => { - const phase = { ...frozenPhaseInitialization }; - if (phaseSerialized === undefined || phaseSerialized === null) { - return phase; - } - - phase.phaseEnabled = true; - - if (phaseSerialized.actions.allocate) { - phase.dataTierAllocationType = determineDataTierAllocationType( - phaseSerialized.actions.allocate - ); - } - - if (phaseSerialized.min_age) { - const { size: minAge, units: minAgeUnits } = splitSizeAndUnits(phaseSerialized.min_age); - phase.selectedMinimumAge = minAge; - phase.selectedMinimumAgeUnits = minAgeUnits; - } - - if (phaseSerialized.actions) { - const actions = phaseSerialized.actions; - if (actions.allocate) { - const allocate = actions.allocate; - if (allocate.require) { - Object.entries(allocate.require).forEach((entry) => { - phase.selectedNodeAttrs = entry.join(':'); - }); - if (allocate.number_of_replicas) { - phase.selectedReplicaCount = allocate.number_of_replicas.toString(); - } - } - } - - if (actions.freeze) { - phase.freezeEnabled = true; - } - - if (actions.set_priority) { - phase.phaseIndexPriority = actions.set_priority.priority - ? actions.set_priority.priority.toString() - : ''; - } - } - - return phase; -}; - -export const frozenPhaseToES = ( - phase: FrozenPhase, - originalPhase?: SerializedFrozenPhase -): SerializedFrozenPhase => { - if (!originalPhase) { - originalPhase = { ...serializedPhaseInitialization }; - } - - const esPhase = { ...originalPhase }; - - if (isNumber(phase.selectedMinimumAge)) { - esPhase.min_age = `${phase.selectedMinimumAge}${phase.selectedMinimumAgeUnits}`; - } - - esPhase.actions = serializePhaseWithAllocation(phase, esPhase.actions); - - if (isNumber(phase.selectedReplicaCount)) { - esPhase.actions.allocate = esPhase.actions.allocate || ({} as AllocateAction); - esPhase.actions.allocate.number_of_replicas = parseInt(phase.selectedReplicaCount, 10); - } else { - if (esPhase.actions.allocate) { - delete esPhase.actions.allocate.number_of_replicas; - } - } - - if ( - esPhase.actions.allocate && - !esPhase.actions.allocate.require && - !isNumber(esPhase.actions.allocate.number_of_replicas) && - isEmpty(esPhase.actions.allocate.include) && - isEmpty(esPhase.actions.allocate.exclude) - ) { - // remove allocate action if it does not define require or number of nodes - // and both include and exclude are empty objects (ES will fail to parse if we don't) - delete esPhase.actions.allocate; - } - - if (phase.freezeEnabled) { - esPhase.actions.freeze = {}; - } else { - delete esPhase.actions.freeze; - } - - if (isNumber(phase.phaseIndexPriority)) { - esPhase.actions.set_priority = { - priority: parseInt(phase.phaseIndexPriority, 10), - }; - } else { - delete esPhase.actions.set_priority; - } - - return esPhase; -}; - -export const validateFrozenPhase = (phase: FrozenPhase): PhaseValidationErrors => { - if (!phase.phaseEnabled) { - return {}; - } - - const phaseErrors = {} as PhaseValidationErrors; - - // index priority is optional, but if it's set, it needs to be a positive number - if (phase.phaseIndexPriority) { - if (!isNumber(phase.phaseIndexPriority)) { - phaseErrors.phaseIndexPriority = [numberRequiredMessage]; - } else if (parseInt(phase.phaseIndexPriority, 10) < 0) { - phaseErrors.phaseIndexPriority = [positiveNumberRequiredMessage]; - } - } - - // min age needs to be a positive number - if (!isNumber(phase.selectedMinimumAge)) { - phaseErrors.selectedMinimumAge = [numberRequiredMessage]; - } else if (parseInt(phase.selectedMinimumAge, 10) < 0) { - phaseErrors.selectedMinimumAge = [positiveNumberRequiredMessage]; - } - - return { ...phaseErrors }; -}; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.test.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.test.ts index 0e7257d437ee72..753ffb111cf130 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.test.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.test.ts @@ -8,7 +8,6 @@ import { serializePolicy } from './policy_serialization'; import { defaultNewColdPhase, defaultNewDeletePhase, - defaultNewFrozenPhase, defaultNewHotPhase, defaultNewWarmPhase, } from '../../constants'; @@ -35,12 +34,6 @@ describe('Policy serialization', () => { selectedNodeAttrs: 'another:thing', phaseEnabled: true, }, - frozen: { - ...defaultNewFrozenPhase, - dataTierAllocationType: 'default', - selectedNodeAttrs: 'another:thing', - phaseEnabled: true, - }, delete: { ...defaultNewDeletePhase }, }, }, @@ -54,9 +47,6 @@ describe('Policy serialization', () => { cold: { actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, }, - frozen: { - actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, - }, }, } ) @@ -89,14 +79,6 @@ describe('Policy serialization', () => { }, min_age: '0d', }, - frozen: { - actions: { - set_priority: { - priority: 0, - }, - }, - min_age: '0d', - }, }, }); }); @@ -120,12 +102,6 @@ describe('Policy serialization', () => { selectedNodeAttrs: 'another:thing', phaseEnabled: true, }, - frozen: { - ...defaultNewFrozenPhase, - dataTierAllocationType: 'custom', - selectedNodeAttrs: 'another:thing', - phaseEnabled: true, - }, delete: { ...defaultNewDeletePhase }, }, }, @@ -151,15 +127,6 @@ describe('Policy serialization', () => { }, }, }, - frozen: { - actions: { - allocate: { - include: { keep: 'this' }, - exclude: { keep: 'this' }, - require: { something: 'here' }, - }, - }, - }, }, } ) @@ -206,21 +173,6 @@ describe('Policy serialization', () => { }, min_age: '0d', }, - frozen: { - actions: { - allocate: { - include: { keep: 'this' }, - exclude: { keep: 'this' }, - require: { - another: 'thing', - }, - }, - set_priority: { - priority: 0, - }, - }, - min_age: '0d', - }, }, }); }); @@ -244,12 +196,6 @@ describe('Policy serialization', () => { selectedNodeAttrs: '', phaseEnabled: true, }, - frozen: { - ...defaultNewFrozenPhase, - dataTierAllocationType: 'custom', - selectedNodeAttrs: '', - phaseEnabled: true, - }, delete: { ...defaultNewDeletePhase }, }, }, @@ -263,9 +209,6 @@ describe('Policy serialization', () => { cold: { actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, }, - frozen: { - actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, - }, }, } ) @@ -301,15 +244,6 @@ describe('Policy serialization', () => { }, min_age: '0d', }, - frozen: { - actions: { - allocate: { include: {}, exclude: {}, require: { something: 'here' } }, - set_priority: { - priority: 0, - }, - }, - min_age: '0d', - }, }, }); }); @@ -333,12 +267,6 @@ describe('Policy serialization', () => { selectedNodeAttrs: 'ignore:this', phaseEnabled: true, }, - frozen: { - ...defaultNewFrozenPhase, - dataTierAllocationType: 'none', - selectedNodeAttrs: 'ignore:this', - phaseEnabled: true, - }, delete: { ...defaultNewDeletePhase }, }, }, @@ -352,9 +280,6 @@ describe('Policy serialization', () => { cold: { actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, }, - frozen: { - actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, - }, }, } ) @@ -394,17 +319,6 @@ describe('Policy serialization', () => { }, min_age: '0d', }, - frozen: { - actions: { - migrate: { - enabled: false, - }, - set_priority: { - priority: 0, - }, - }, - min_age: '0d', - }, }, }); }); @@ -420,9 +334,6 @@ describe('Policy serialization', () => { cold: { actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, }, - frozen: { - actions: { allocate: { include: {}, exclude: {}, require: { something: 'here' } } }, - }, }, }; @@ -444,12 +355,7 @@ describe('Policy serialization', () => { selectedNodeAttrs: 'ignore:this', phaseEnabled: true, }, - frozen: { - ...defaultNewFrozenPhase, - dataTierAllocationType: 'none' as DataTierAllocationType, - selectedNodeAttrs: 'ignore:this', - phaseEnabled: true, - }, + delete: { ...defaultNewDeletePhase }, }, }; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.ts index 31c063aba2c4aa..996b2e8c371b81 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_serialization.ts @@ -11,14 +11,12 @@ import { defaultNewDeletePhase, defaultNewHotPhase, defaultNewWarmPhase, - defaultNewFrozenPhase, serializedPhaseInitialization, } from '../../constants'; import { hotPhaseFromES, hotPhaseToES } from './hot_phase'; import { warmPhaseFromES, warmPhaseToES } from './warm_phase'; import { coldPhaseFromES, coldPhaseToES } from './cold_phase'; -import { frozenPhaseFromES, frozenPhaseToES } from './frozen_phase'; import { deletePhaseFromES, deletePhaseToES } from './delete_phase'; export const splitSizeAndUnits = (field: string): { size: string; units: string } => { @@ -55,7 +53,6 @@ export const initializeNewPolicy = (newPolicyName: string = ''): Policy => { hot: { ...defaultNewHotPhase }, warm: { ...defaultNewWarmPhase }, cold: { ...defaultNewColdPhase }, - frozen: { ...defaultNewFrozenPhase }, delete: { ...defaultNewDeletePhase }, }, }; @@ -73,7 +70,6 @@ export const deserializePolicy = (policy: PolicyFromES): Policy => { hot: hotPhaseFromES(phases.hot), warm: warmPhaseFromES(phases.warm), cold: coldPhaseFromES(phases.cold), - frozen: frozenPhaseFromES(phases.frozen), delete: deletePhaseFromES(phases.delete), }, }; @@ -98,13 +94,6 @@ export const serializePolicy = ( serializedPolicy.phases.cold = coldPhaseToES(policy.phases.cold, originalEsPolicy.phases.cold); } - if (policy.phases.frozen.phaseEnabled) { - serializedPolicy.phases.frozen = frozenPhaseToES( - policy.phases.frozen, - originalEsPolicy.phases.frozen - ); - } - if (policy.phases.delete.phaseEnabled) { serializedPolicy.phases.delete = deletePhaseToES( policy.phases.delete, diff --git a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_validation.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_validation.ts index f5197e6ffec998..ffd3c01ab001d2 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_validation.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/services/policies/policy_validation.ts @@ -8,7 +8,6 @@ import { i18n } from '@kbn/i18n'; import { ColdPhase, DeletePhase, - FrozenPhase, HotPhase, Policy, PolicyFromES, @@ -18,7 +17,6 @@ import { validateHotPhase } from './hot_phase'; import { validateWarmPhase } from './warm_phase'; import { validateColdPhase } from './cold_phase'; import { validateDeletePhase } from './delete_phase'; -import { validateFrozenPhase } from './frozen_phase'; export const propertyof = (propertyName: keyof T & string) => propertyName; @@ -117,7 +115,6 @@ export interface ValidationErrors { hot: PhaseValidationErrors; warm: PhaseValidationErrors; cold: PhaseValidationErrors; - frozen: PhaseValidationErrors; delete: PhaseValidationErrors; policyName: string[]; } @@ -158,14 +155,12 @@ export const validatePolicy = ( const hotPhaseErrors = validateHotPhase(policy.phases.hot); const warmPhaseErrors = validateWarmPhase(policy.phases.warm); const coldPhaseErrors = validateColdPhase(policy.phases.cold); - const frozenPhaseErrors = validateFrozenPhase(policy.phases.frozen); const deletePhaseErrors = validateDeletePhase(policy.phases.delete); const isValid = policyNameErrors.length === 0 && Object.keys(hotPhaseErrors).length === 0 && Object.keys(warmPhaseErrors).length === 0 && Object.keys(coldPhaseErrors).length === 0 && - Object.keys(frozenPhaseErrors).length === 0 && Object.keys(deletePhaseErrors).length === 0; return [ isValid, @@ -174,7 +169,6 @@ export const validatePolicy = ( hot: hotPhaseErrors, warm: warmPhaseErrors, cold: coldPhaseErrors, - frozen: frozenPhaseErrors, delete: deletePhaseErrors, }, ]; diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts index 5ef38a0e46dc39..8234686a542a9a 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts @@ -111,24 +111,6 @@ const coldPhaseSchema = schema.maybe( }) ); -const frozenPhaseSchema = schema.maybe( - schema.object({ - min_age: minAgeSchema, - actions: schema.object({ - migrate: migrateSchema, - set_priority: setPrioritySchema, - unfollow: unfollowSchema, - allocate: allocateSchema, - freeze: schema.maybe(schema.object({})), // Freeze has no options - searchable_snapshot: schema.maybe( - schema.object({ - snapshot_repository: schema.string(), - }) - ), - }), - }) -); - const deletePhaseSchema = schema.maybe( schema.object({ min_age: minAgeSchema, @@ -154,7 +136,6 @@ const bodySchema = schema.object({ hot: hotPhaseSchema, warm: warmPhaseSchema, cold: coldPhaseSchema, - frozen: frozenPhaseSchema, delete: deletePhaseSchema, }), }); diff --git a/x-pack/test/apm_api_integration/trial/tests/service_maps/__snapshots__/service_maps.snap b/x-pack/test/apm_api_integration/trial/tests/service_maps/__snapshots__/service_maps.snap index 199a49dce8f9e5..bf42c084381563 100644 --- a/x-pack/test/apm_api_integration/trial/tests/service_maps/__snapshots__/service_maps.snap +++ b/x-pack/test/apm_api_integration/trial/tests/service_maps/__snapshots__/service_maps.snap @@ -116,6 +116,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -143,6 +150,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -170,6 +184,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -182,6 +203,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">postgresql", "targetData": Object { @@ -203,6 +231,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-go", "targetData": Object { @@ -230,6 +265,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-python", "targetData": Object { @@ -237,6 +279,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -250,6 +299,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-ruby", "targetData": Object { @@ -276,6 +332,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">postgresql", "targetData": Object { @@ -297,6 +360,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-go", "targetData": Object { @@ -324,6 +394,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-python", "targetData": Object { @@ -331,6 +408,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -343,6 +427,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">elasticsearch", "targetData": Object { @@ -363,6 +454,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">postgresql", "targetData": Object { @@ -383,6 +481,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">redis", "targetData": Object { @@ -404,6 +509,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-go", "targetData": Object { @@ -431,6 +543,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-java", "targetData": Object { @@ -438,6 +557,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -451,6 +577,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-node", "targetData": Object { @@ -458,6 +591,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -545,6 +685,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -571,6 +718,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -597,6 +751,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -609,6 +770,12 @@ Array [ "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-go", "targetData": Object { @@ -635,6 +802,12 @@ Array [ "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-java", "targetData": Object { @@ -642,6 +815,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -654,6 +834,12 @@ Array [ "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-node", "targetData": Object { @@ -661,6 +847,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -673,6 +866,12 @@ Array [ "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-python", "targetData": Object { @@ -680,6 +879,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -692,6 +898,12 @@ Array [ "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-ruby", "targetData": Object { @@ -715,6 +927,12 @@ Array [ "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, }, Object { @@ -723,6 +941,13 @@ Array [ "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, Object { @@ -731,6 +956,13 @@ Array [ "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, Object { @@ -739,6 +971,13 @@ Array [ "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, Object { @@ -863,6 +1102,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -890,6 +1136,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -917,6 +1170,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -929,6 +1189,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">postgresql", "targetData": Object { @@ -950,6 +1217,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-go", "targetData": Object { @@ -977,6 +1251,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-python", "targetData": Object { @@ -984,6 +1265,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -997,6 +1285,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-ruby", "targetData": Object { @@ -1023,6 +1318,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">postgresql", "targetData": Object { @@ -1044,6 +1346,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-go", "targetData": Object { @@ -1071,6 +1380,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-python", "targetData": Object { @@ -1078,6 +1394,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1090,6 +1413,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">elasticsearch", "targetData": Object { @@ -1110,6 +1440,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">postgresql", "targetData": Object { @@ -1130,6 +1467,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": ">redis", "targetData": Object { @@ -1151,6 +1495,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-go", "targetData": Object { @@ -1178,6 +1529,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-java", "targetData": Object { @@ -1185,6 +1543,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1198,6 +1563,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, "target": "opbeans-node", "targetData": Object { @@ -1205,6 +1577,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1292,6 +1671,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1318,6 +1704,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1344,6 +1737,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1356,6 +1756,12 @@ Object { "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-go", "targetData": Object { @@ -1382,6 +1788,12 @@ Object { "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-java", "targetData": Object { @@ -1389,6 +1801,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1401,6 +1820,12 @@ Object { "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-node", "targetData": Object { @@ -1408,6 +1833,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1420,6 +1852,12 @@ Object { "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-python", "targetData": Object { @@ -1427,6 +1865,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, }, @@ -1439,6 +1884,12 @@ Object { "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, "target": "opbeans-ruby", "targetData": Object { @@ -1462,6 +1913,12 @@ Object { "id": "opbeans-rum", "service.environment": "testing", "service.name": "opbeans-rum", + "serviceAnomalyStats": Object { + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, }, }, Object { @@ -1470,6 +1927,13 @@ Object { "id": "opbeans-python", "service.environment": "production", "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, Object { @@ -1478,6 +1942,13 @@ Object { "id": "opbeans-java", "service.environment": "production", "service.name": "opbeans-java", + "serviceAnomalyStats": Object { + "actualValue": 14901.319999999996, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, Object { @@ -1486,6 +1957,13 @@ Object { "id": "opbeans-node", "service.environment": "testing", "service.name": "opbeans-node", + "serviceAnomalyStats": Object { + "actualValue": 32226.649122807008, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-testing-d457-high_mean_transaction_duration", + "transactionType": "request", + }, }, }, Object { diff --git a/x-pack/test/apm_api_integration/trial/tests/service_maps/service_maps.ts b/x-pack/test/apm_api_integration/trial/tests/service_maps/service_maps.ts index 11b5ca71e64e7e..2e4a859f08cca0 100644 --- a/x-pack/test/apm_api_integration/trial/tests/service_maps/service_maps.ts +++ b/x-pack/test/apm_api_integration/trial/tests/service_maps/service_maps.ts @@ -153,33 +153,47 @@ export default function serviceMapsApiTests({ getService }: FtrProviderContext) (el: { data: { serviceAnomalyStats?: {} } }) => !isEmpty(el.data.serviceAnomalyStats) ); - expectSnapshot(dataWithAnomalies.length).toMatchInline(`2`); + expectSnapshot(dataWithAnomalies.length).toMatchInline(`6`); expectSnapshot(dataWithAnomalies.slice(0, 3)).toMatchInline(` Array [ Object { "data": Object { - "agent.name": "go", - "id": "opbeans-go", + "agent.name": "rum-js", + "id": "opbeans-rum", "service.environment": "testing", - "service.name": "opbeans-go", + "service.name": "opbeans-rum", "serviceAnomalyStats": Object { - "actualValue": 3933482.1764705875, - "anomalyScore": 2.6101702751482714, + "anomalyScore": 0, "healthStatus": "healthy", - "jobId": "apm-testing-d457-high_mean_transaction_duration", + "jobId": "apm-environment_not_defined-7ed6-high_mean_transaction_duration", + "transactionType": "page-load", + }, + }, + }, + Object { + "data": Object { + "agent.name": "python", + "id": "opbeans-python", + "service.environment": "production", + "service.name": "opbeans-python", + "serviceAnomalyStats": Object { + "actualValue": 66218.08333333333, + "anomalyScore": 0, + "healthStatus": "healthy", + "jobId": "apm-production-229a-high_mean_transaction_duration", "transactionType": "request", }, }, }, Object { "data": Object { - "agent.name": "ruby", - "id": "opbeans-ruby", + "agent.name": "java", + "id": "opbeans-java", "service.environment": "production", - "service.name": "opbeans-ruby", + "service.name": "opbeans-java", "serviceAnomalyStats": Object { - "actualValue": 684716.5813953485, - "anomalyScore": 0.20498907719907372, + "actualValue": 14901.319999999996, + "anomalyScore": 0, "healthStatus": "healthy", "jobId": "apm-production-229a-high_mean_transaction_duration", "transactionType": "request", diff --git a/x-pack/test/apm_api_integration/trial/tests/services/top_services.ts b/x-pack/test/apm_api_integration/trial/tests/services/top_services.ts index c93816dfb48b90..ab127aaac8490e 100644 --- a/x-pack/test/apm_api_integration/trial/tests/services/top_services.ts +++ b/x-pack/test/apm_api_integration/trial/tests/services/top_services.ts @@ -59,13 +59,13 @@ export default function ApiTest({ getService }: FtrProviderContext) { expectSnapshot(healthStatuses).toMatchInline(` Array [ - undefined, - undefined, "healthy", "healthy", - undefined, - undefined, - undefined, + "healthy", + "healthy", + "healthy", + "healthy", + "healthy", ] `); }); diff --git a/x-pack/test/stack_functional_integration/configs/tests_list.js b/x-pack/test/stack_functional_integration/configs/tests_list.js index ff68cb6285965d..0d91a078b73fdf 100644 --- a/x-pack/test/stack_functional_integration/configs/tests_list.js +++ b/x-pack/test/stack_functional_integration/configs/tests_list.js @@ -46,10 +46,14 @@ export default (envObj) => { if (envObj.XPACK === 'YES' && ['TRIAL', 'GOLD', 'PLATINUM'].includes(envObj.LICENSE)) { // we can't test enabling monitoring on this config because we already enable it through cluster settings for both clusters. - if (envObj.VM !== 'ubuntu16_tar_ccs') { + if (envObj.VM !== 'ubuntu16_tar_ccs' && envObj.VM !== 'centos7_rpm') { // monitoring is last because we switch to the elastic superuser here xs.push('monitoring'); } + if (envObj.VM === 'centos7_rpm') { + // monitoring is last because we switch to the elastic superuser here + xs.push('monitoring/_monitoring_metricbeat'); + } } return xs; diff --git a/x-pack/test/stack_functional_integration/test/functional/apps/monitoring/_monitoring_metricbeat.js b/x-pack/test/stack_functional_integration/test/functional/apps/monitoring/_monitoring_metricbeat.js new file mode 100644 index 00000000000000..c11a1baed717c3 --- /dev/null +++ b/x-pack/test/stack_functional_integration/test/functional/apps/monitoring/_monitoring_metricbeat.js @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export default ({ getService, getPageObjects }) => { + describe('monitoring app - stack functional integration - suite', () => { + const browser = getService('browser'); + const PageObjects = getPageObjects(['security', 'monitoring', 'common']); + const log = getService('log'); + const testSubjects = getService('testSubjects'); + const isSaml = !!process.env.VM.includes('saml') || !!process.env.VM.includes('oidc'); + + before(async () => { + await browser.setWindowSize(1200, 800); + if (process.env.SECURITY === 'YES' && !isSaml) { + await PageObjects.security.logout(); + log.debug('### log in as elastic superuser to enable monitoring'); + // Tests may be running as a non-superuser like `power` but that user + // doesn't have the cluster privs to enable monitoring. + // On the SAML config, this will fail, but the test recovers on the next + // navigate and logs in as the saml user. + } + // navigateToApp without a username and password will default to the superuser + await PageObjects.common.navigateToApp('monitoring', { insertTimestamp: false }); + }); + + it('should have Monitoring already enabled', async () => { + await testSubjects.click('esOverview'); + }); + + after(async () => { + if (process.env.SECURITY === 'YES' && !isSaml) { + await PageObjects.security.forceLogout(isSaml); + } + }); + }); +};