diff --git a/docs/management/manage-data-views.asciidoc b/docs/management/manage-data-views.asciidoc
index 4c6a0d77b7a9e..c194444b72b59 100644
--- a/docs/management/manage-data-views.asciidoc
+++ b/docs/management/manage-data-views.asciidoc
@@ -170,7 +170,7 @@ Edit the settings for runtime fields, or remove runtime fields from data views.
[[scripted-fields]]
=== Add scripted fields to data views
-deprecated::[7.13,Use {ref}/runtime.html[runtime fields] instead of scripted fields. Runtime fields support Painless scripts and provide greater flexibility.]
+deprecated::[7.13,Use {ref}/runtime.html[runtime fields] instead of scripted fields. Runtime fields support Painless scripting and provide greater flexibility. You can also use the {ref}/esql.html[Elasticsearch Query Language (ES|QL)] to compute values directly at query time.]
Scripted fields compute data on the fly from the data in your {es} indices. The data is shown on
the Discover tab as part of the document data, and you can use scripted fields in your visualizations. You query scripted fields with the <>, and can filter them using the filter bar. The scripted field values are computed at query time, so they aren't indexed and cannot be searched using the {kib} default
@@ -193,33 +193,123 @@ For more information on scripted fields and additional examples, refer to
https://www.elastic.co/blog/using-painless-kibana-scripted-fields[Using Painless in {kib} scripted fields]
[float]
-[[create-scripted-field]]
-==== Create scripted fields
+[[migrate-off-scripted-fields]]
+==== Migrate to runtime fields or ES|QL queries
-Create and add scripted fields to your data views.
+The following code snippets demonstrate how an example scripted field called `computed_values` on the Kibana Sample Data Logs data view could be migrated to either a runtime field or an ES|QL query, highlighting the differences between each approach.
-. Go to the *Data Views* management page using the navigation menu or the <>.
+[float]
+[[scripted-field-example]]
+===== Scripted field
-. Select the data view you want to add a scripted field to.
+In the scripted field example, variables are created to track all values the script will need to access or return. Since scripted fields can only return a single value, the created variables must be returned together as an array at the end of the script.
-. Select the *Scripted fields* tab, then click *Add scripted field*.
+[source,text]
+----
+def hour_of_day = $('@timestamp', ZonedDateTime.parse('1970-01-01T00:00:00Z')).getHour();
+def time_of_day = '';
+
+if (hour_of_day >= 22 || hour_of_day < 5)
+ time_of_day = 'Night';
+else if (hour_of_day < 12)
+ time_of_day = 'Morning';
+else if (hour_of_day < 18)
+ time_of_day = 'Afternoon';
+else
+ time_of_day = 'Evening';
+
+def response_int = Integer.parseInt($('response.keyword', '200'));
+def response_category = '';
+
+if (response_int < 200)
+ response_category = 'Informational';
+else if (response_int < 300)
+ response_category = 'Successful';
+else if (response_int < 400)
+ response_category = 'Redirection';
+else if (response_int < 500)
+ response_category = 'Client Error';
+else
+ response_category = 'Server Error';
+
+return [time_of_day, response_category];
+----
-. Enter a *Name* for the scripted field, then enter the *Script* you want to use to compute a value on the fly from your index data.
+[float]
+[[runtime-field-example]]
+===== Runtime field
-. Click *Create field*.
+Unlike scripted fields, runtime fields do not need to return a single value and can emit values at any point in the script, which will be combined and returned as a multi-value field. This allows for more flexibility in the script logic and removes the need to manually manage an array of values.
-For more information about scripted fields in {es}, refer to {ref}/modules-scripting.html[Scripting].
+[source,text]
+----
+def hour_of_day = $('@timestamp', ZonedDateTime.parse('1970-01-01T00:00:00Z')).getHour();
+
+if (hour_of_day >= 22 || hour_of_day < 5)
+ emit('Night');
+else if (hour_of_day < 12)
+ emit('Morning');
+else if (hour_of_day < 18)
+ emit('Afternoon');
+else
+ emit('Evening');
+
+def response_int = Integer.parseInt($('response.keyword', '200'));
+
+if (response_int < 200)
+ emit('Informational');
+else if (response_int < 300)
+ emit('Successful');
+else if (response_int < 400)
+ emit('Redirection');
+else if (response_int < 500)
+ emit('Client Error');
+else
+ emit('Server Error');
+----
+
+[float]
+[[esql-example]]
+===== ES|QL query
+
+Alternatively, ES|QL can be used to skip the need for data view management entirely and simply compute the values you need at query time. ES|QL supports computing multiple field values in a single query, using computed values with its rich set of commands and functions, and even aggregations against computed values. This makes it an excellent solution for one-off queries and realtime data analysis.
+
+[source,esql]
+----
+FROM kibana_sample_data_logs
+ | EVAL hour_of_day = DATE_EXTRACT("HOUR_OF_DAY", @timestamp)
+ | EVAL time_of_day = CASE(
+ hour_of_day >= 22 OR hour_of_day < 5, "Night",
+ hour_of_day < 12, "Morning",
+ hour_of_day < 18, "Afternoon",
+ "Evening"
+ )
+ | EVAL response_int = TO_INTEGER(response)
+ | EVAL response_category = CASE(
+ response_int < 200, "Informational",
+ response_int < 300, "Successful",
+ response_int < 400, "Redirection",
+ response_int < 500, "Client Error",
+ "Server Error"
+ )
+ | EVAL computed_values = MV_APPEND(time_of_day, response_category)
+ | DROP hour_of_day, time_of_day, response_int, response_category
+----
[float]
[[update-scripted-field]]
==== Manage scripted fields
+WARNING: The ability to create new scripted fields has been removed from the *Data Views* management page in 9.0. Existing scripted fields can still be edited or deleted, and the creation UI can be accessed by navigating directly to `/app/management/kibana/dataViews/dataView/{dataViewId}/create-field`, but we recommend migrating to runtime fields or ES|QL queries instead to prepare for removal.
+
. Go to the *Data Views* management page using the navigation menu or the <>.
. Select the data view that contains the scripted field you want to manage.
. Select the *Scripted fields* tab, then open the scripted field edit options or delete the scripted field.
+For more information about scripted fields in {es}, refer to {ref}/modules-scripting.html[Scripting].
+
WARNING: Built-in validation is unsupported for scripted fields. When your scripts contain errors, you receive
exceptions when you view the dynamically generated data.
diff --git a/docs/upgrade-notes.asciidoc b/docs/upgrade-notes.asciidoc
index effe1308408cc..20ffef01b9b01 100644
--- a/docs/upgrade-notes.asciidoc
+++ b/docs/upgrade-notes.asciidoc
@@ -164,5 +164,19 @@ resolving issues if any deprecated features are enabled.
To access the assistant, go to **Stack Management** > **Upgrade Assistant**.
+[discrete]
+[[deprecation-202250]]
+.Scripted field creation has been disabled in the Data Views management page (9.0.0)
+[%collapsible]
+====
+*Details* +
+The ability to create new scripted fields has been removed from the *Data Views* management page in 9.0. Existing scripted fields can still be edited or deleted, and the creation UI can be accessed by navigating directly to `/app/management/kibana/dataViews/dataView/{dataViewId}/create-field`, but we recommend migrating to runtime fields or ES|QL queries instead to prepare for removal.
+For more information, refer to {kibana-pull}202250[#202250].
+*Impact* +
+It will no longer be possible to create new scripted fields directly from the *Data Views* management page.
+
+*Action* +
+Migrate to runtime fields or ES|QL instead of creating new scripted fields. Existing scripted fields can still be edited or deleted.
+====
\ No newline at end of file
diff --git a/packages/core/deprecations/core-deprecations-common/index.ts b/packages/core/deprecations/core-deprecations-common/index.ts
index de8122a18c551..828653289981b 100644
--- a/packages/core/deprecations/core-deprecations-common/index.ts
+++ b/packages/core/deprecations/core-deprecations-common/index.ts
@@ -8,6 +8,7 @@
*/
export type {
+ DeprecationDetailsMessage,
BaseDeprecationDetails,
ConfigDeprecationDetails,
FeatureDeprecationDetails,
diff --git a/packages/core/deprecations/core-deprecations-common/src/types.ts b/packages/core/deprecations/core-deprecations-common/src/types.ts
index 9a08be7808452..45f93aa5ba921 100644
--- a/packages/core/deprecations/core-deprecations-common/src/types.ts
+++ b/packages/core/deprecations/core-deprecations-common/src/types.ts
@@ -7,6 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
+export interface DeprecationDetailsMessage {
+ type: 'markdown' | 'text';
+ content: string;
+}
+
/**
* Base properties shared by all types of deprecations
*
@@ -22,7 +27,7 @@ export interface BaseDeprecationDetails {
* The description message to be displayed for the deprecation.
* Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
*/
- message: string | string[];
+ message: string | DeprecationDetailsMessage | Array;
/**
* levels:
* - warning: will not break deployment upon upgrade
diff --git a/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts b/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts
index 7fd12a815484a..d82caffce0343 100644
--- a/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts
+++ b/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts
@@ -345,6 +345,7 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
fieldFormattersNumber: `${KIBANA_DOCS}numeral.html`,
fieldFormattersString: `${KIBANA_DOCS}managing-data-views.html#string-field-formatters`,
runtimeFields: `${KIBANA_DOCS}managing-data-views.html#runtime-fields`,
+ migrateOffScriptedFields: `${KIBANA_DOCS}managing-data-views.html#migrate-off-scripted-fields`,
},
addData: `${KIBANA_DOCS}connect-to-elasticsearch.html`,
kibana: {
diff --git a/src/platform/packages/shared/kbn-doc-links/src/types.ts b/src/platform/packages/shared/kbn-doc-links/src/types.ts
index d55146420ec73..749e7a40708ca 100644
--- a/src/platform/packages/shared/kbn-doc-links/src/types.ts
+++ b/src/platform/packages/shared/kbn-doc-links/src/types.ts
@@ -304,6 +304,7 @@ export interface DocLinks {
readonly fieldFormattersNumber: string;
readonly fieldFormattersString: string;
readonly runtimeFields: string;
+ readonly migrateOffScriptedFields: string;
};
readonly addData: string;
readonly kibana: {
diff --git a/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/__snapshots__/scripted_field_table.test.tsx.snap b/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/__snapshots__/scripted_field_table.test.tsx.snap
index 95be4d4a7d632..19172b9866085 100644
--- a/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/__snapshots__/scripted_field_table.test.tsx.snap
+++ b/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/__snapshots__/scripted_field_table.test.tsx.snap
@@ -2,9 +2,7 @@
exports[`ScriptedFieldsTable should filter based on the lang filter 1`] = `
-
+
-
+
-
+
-
+
-
+
+
}
>
-
- Scripted fields can be used in visualizations and displayed in documents. However, they cannot be searched.
-
-
+
+ Scripted fields are deprecated
+
+
+
- Scripted fields are deprecated. Use
+ Use
- instead.
+ instead of scripted fields. Runtime fields support Painless scripting and provide greater flexibility. You can also use the
+
+ to compute values directly at query time.
+
+
+
+
+
+
+
+ Scripted fields can be used in visualizations and displayed in documents. However, they cannot be searched.
{
id="indexPatternManagement.editIndexPattern.scriptedLabel"
defaultMessage="Scripted fields can be used in visualizations and displayed in documents. However, they cannot be searched."
/>
-
-
-
-
-
- ),
- }}
- />
-
- {userEditPermission && (
-
-
-
-
-
- )}
);
-});
+};
diff --git a/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/scripted_fields_table.tsx b/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/scripted_fields_table.tsx
index 1a8483db6c6aa..915316135cd6c 100644
--- a/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/scripted_fields_table.tsx
+++ b/src/plugins/data_view_management/public/components/edit_index_pattern/scripted_fields_table/scripted_fields_table.tsx
@@ -59,7 +59,7 @@ export class ScriptedFieldsTable extends Component<
}
fetchFields = async () => {
- const fields = await (this.props.indexPattern.getScriptedFields() as ScriptedFieldItem[]);
+ const fields = this.props.indexPattern.getScriptedFields() as ScriptedFieldItem[];
const deprecatedLangsInUse = [];
const deprecatedLangs = getDeprecatedScriptingLanguages();
@@ -67,7 +67,7 @@ export class ScriptedFieldsTable extends Component<
for (const field of fields) {
const lang = field.lang;
- if (deprecatedLangs.includes(lang) || !supportedLangs.includes(lang)) {
+ if (lang && (deprecatedLangs.includes(lang) || !supportedLangs.includes(lang))) {
deprecatedLangsInUse.push(lang);
}
}
@@ -136,7 +136,7 @@ export class ScriptedFieldsTable extends Component<
return (
<>
-
+
diff --git a/src/plugins/data_view_management/public/components/edit_index_pattern/tabs/utils.ts b/src/plugins/data_view_management/public/components/edit_index_pattern/tabs/utils.ts
index 31f12e80366cc..4f249425774f7 100644
--- a/src/plugins/data_view_management/public/components/edit_index_pattern/tabs/utils.ts
+++ b/src/plugins/data_view_management/public/components/edit_index_pattern/tabs/utils.ts
@@ -96,7 +96,11 @@ export function getTabs(
'data-test-subj': 'tab-indexedFields',
});
- if (!isRollup(indexPattern.type) && scriptedFieldsEnabled) {
+ if (
+ !isRollup(indexPattern.type) &&
+ scriptedFieldsEnabled &&
+ indexPattern.getScriptedFields().length > 0
+ ) {
tabs.push({
name: getTitle('scripted', filteredCount, totalCount),
id: TAB_SCRIPTED_FIELDS,
diff --git a/src/plugins/data_view_management/public/mocks.ts b/src/plugins/data_view_management/public/mocks.ts
index 6abc53a64d3cf..dfc924ac5d49e 100644
--- a/src/plugins/data_view_management/public/mocks.ts
+++ b/src/plugins/data_view_management/public/mocks.ts
@@ -57,6 +57,7 @@ const docLinks = {
indexPatterns: {},
scriptedFields: {},
runtimeFields: {},
+ query: {},
} as any,
};
diff --git a/src/plugins/data_views/server/deprecations/scripted_fields.ts b/src/plugins/data_views/server/deprecations/scripted_fields.ts
index 5866216801ab6..a70bb29219dcd 100644
--- a/src/plugins/data_views/server/deprecations/scripted_fields.ts
+++ b/src/plugins/data_views/server/deprecations/scripted_fields.ts
@@ -7,85 +7,83 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
-import {
+import type {
CoreSetup,
DeprecationsDetails,
GetDeprecationsContext,
RegisterDeprecationsConfig,
+ SavedObjectsFindResult,
} from '@kbn/core/server';
import { i18n } from '@kbn/i18n';
-import { DataViewAttributes } from '../../common';
+import type { DocLinks } from '@kbn/doc-links';
+import type { DeprecationDetailsMessage } from '@kbn/core-deprecations-common';
+import type { DataViewAttributes } from '../../common';
-type IndexPatternAttributesWithFields = Pick;
+type DataViewAttributesWithFields = Pick;
export const createScriptedFieldsDeprecationsConfig: (
core: CoreSetup
) => RegisterDeprecationsConfig = (core: CoreSetup) => ({
getDeprecations: async (context: GetDeprecationsContext): Promise => {
- const finder =
- context.savedObjectsClient.createPointInTimeFinder({
+ const finder = context.savedObjectsClient.createPointInTimeFinder(
+ {
type: 'index-pattern',
perPage: 1000,
- fields: ['title', 'fields'],
+ fields: ['name', 'title', 'fields'],
namespaces: ['*'],
- });
+ }
+ );
+
+ const dataViewsWithScriptedFields: Array> =
+ [];
- const indexPatternsWithScriptedFields: IndexPatternAttributesWithFields[] = [];
for await (const response of finder.find()) {
- indexPatternsWithScriptedFields.push(
- ...response.saved_objects.map((so) => so.attributes).filter(hasScriptedField)
+ dataViewsWithScriptedFields.push(
+ ...response.saved_objects.filter((so) => hasScriptedField(so.attributes))
);
}
- if (indexPatternsWithScriptedFields.length > 0) {
- const PREVIEW_LIMIT = 3;
- const indexPatternTitles = indexPatternsWithScriptedFields.map((ip) => ip.title);
-
- return [
- {
- title: i18n.translate('dataViews.deprecations.scriptedFieldsTitle', {
- defaultMessage: 'Found data views using scripted fields',
- }),
- message: i18n.translate('dataViews.deprecations.scriptedFieldsMessage', {
- defaultMessage: `You have {numberOfIndexPatternsWithScriptedFields} data views ({titlesPreview}...) that use scripted fields. Scripted fields are deprecated and will be removed in future. Use runtime fields instead.`,
- values: {
- titlesPreview: indexPatternTitles.slice(0, PREVIEW_LIMIT).join('; '),
- numberOfIndexPatternsWithScriptedFields: indexPatternsWithScriptedFields.length,
- },
- }),
- documentationUrl:
- 'https://www.elastic.co/guide/en/elasticsearch/reference/7.x/runtime.html', // TODO: documentation service is not available serverside https://github.com/elastic/kibana/issues/95389
- level: 'warning', // warning because it is not set in stone WHEN we remove scripted fields, hence this deprecation is not a blocker for 8.0 upgrade
- correctiveActions: {
- manualSteps: [
- i18n.translate('dataViews.deprecations.scriptedFields.manualStepOneMessage', {
- defaultMessage: 'Navigate to Stack Management > Kibana > Data Views.',
- }),
- i18n.translate('dataViews.deprecations.scriptedFields.manualStepTwoMessage', {
- defaultMessage:
- 'Update {numberOfIndexPatternsWithScriptedFields} data views that have scripted fields to use runtime fields instead. In most cases, to migrate existing scripts, you will need to change "return ;" to "emit();". Data views with at least one scripted field: {allTitles}',
- values: {
- allTitles: indexPatternTitles.join('; '),
- numberOfIndexPatternsWithScriptedFields: indexPatternsWithScriptedFields.length,
- },
- ignoreTag: true,
- }),
- ],
- },
- },
- ];
- } else {
+ if (!dataViewsWithScriptedFields.length) {
return [];
}
+
+ return [
+ {
+ title: i18n.translate('dataViews.deprecations.scriptedFieldsTitle', {
+ defaultMessage: 'Found data views using scripted fields',
+ }),
+ message: buildMessage({
+ dataViewsWithScriptedFields,
+ docLinks: core.docLinks.links,
+ }),
+ documentationUrl: core.docLinks.links.indexPatterns.migrateOffScriptedFields,
+ deprecationType: 'feature',
+ level: 'warning', // warning because it is not set in stone WHEN we remove scripted fields, hence this deprecation is not a blocker for 9.0 upgrade
+ correctiveActions: {
+ manualSteps: [
+ i18n.translate('dataViews.deprecations.scriptedFields.manualStepOneMessage', {
+ defaultMessage: 'Navigate to Stack Management > Kibana > Data Views.',
+ }),
+ i18n.translate('dataViews.deprecations.scriptedFields.manualStepTwoMessage', {
+ defaultMessage:
+ 'Update data views that have scripted fields to use runtime fields instead. In most cases, you will only need to change "return ;" to "emit();".',
+ ignoreTag: true,
+ }),
+ i18n.translate('dataViews.deprecations.scriptedFields.manualStepThreeMessage', {
+ defaultMessage:
+ 'Alternatively, you can achieve similar functionality by computing values at query time using the Elasticsearch Query Language (ES|QL).',
+ }),
+ ],
+ },
+ },
+ ];
},
});
-export function hasScriptedField(indexPattern: IndexPatternAttributesWithFields) {
- if (indexPattern.fields) {
+export function hasScriptedField(dataView: DataViewAttributesWithFields) {
+ if (dataView.fields) {
try {
- return JSON.parse(indexPattern.fields).some(
- (field: { scripted?: boolean }) => field?.scripted
- );
+ return JSON.parse(dataView.fields).some((field: { scripted?: boolean }) => field?.scripted);
} catch (e) {
return false;
}
@@ -93,3 +91,55 @@ export function hasScriptedField(indexPattern: IndexPatternAttributesWithFields)
return false;
}
}
+
+const dataViewIdLabel = i18n.translate('dataViews.deprecations.scriptedFields.dataViewIdLabel', {
+ defaultMessage: 'ID',
+});
+
+const dataViewNameLabel = i18n.translate(
+ 'dataViews.deprecations.scriptedFields.dataViewNameLabel',
+ {
+ defaultMessage: 'Name',
+ }
+);
+
+const dataViewSpacesLabel = i18n.translate(
+ 'dataViews.deprecations.scriptedFields.dataViewSpacesLabel',
+ {
+ defaultMessage: 'Spaces',
+ }
+);
+
+const buildDataViewsListEntry = (
+ so: SavedObjectsFindResult
+) => `- **${dataViewIdLabel}:** ${so.id}
+ - **${dataViewNameLabel}:** ${
+ so.attributes.name
+ ? `!{tooltip[${so.attributes.name}](${so.attributes.title})}`
+ : so.attributes.title
+}
+ - **${dataViewSpacesLabel}:** ${so.namespaces?.join(', ')}`;
+
+const buildMessage = ({
+ dataViewsWithScriptedFields,
+ docLinks,
+}: {
+ dataViewsWithScriptedFields: Array>;
+ docLinks: DocLinks;
+}): DeprecationDetailsMessage => ({
+ type: 'markdown',
+ content: i18n.translate('dataViews.deprecations.scriptedFieldsMessage', {
+ defaultMessage: `You have {numberOfDataViewsWithScriptedFields} {numberOfDataViewsWithScriptedFields, plural, one {data view} other {data views}} containing scripted fields. Scripted fields are deprecated and will be removed in the future.
+
+The ability to create new scripted fields in the Data Views management page has been disabled in 9.0, and it is recommended to migrate to [runtime fields]({runtimeFieldsLink}) or the [Elasticsearch Query Language (ES|QL)]({esqlLink}) instead.
+
+The following is a list of all data views with scripted fields and their associated spaces:
+{dataViewsList}`,
+ values: {
+ numberOfDataViewsWithScriptedFields: dataViewsWithScriptedFields.length,
+ runtimeFieldsLink: docLinks.indexPatterns.runtimeFields,
+ esqlLink: docLinks.query.queryESQL,
+ dataViewsList: dataViewsWithScriptedFields.map(buildDataViewsListEntry).join('\n'),
+ },
+ }),
+});
diff --git a/src/plugins/data_views/tsconfig.json b/src/plugins/data_views/tsconfig.json
index 45992b3548f8e..a9d2a6ed7a6a0 100644
--- a/src/plugins/data_views/tsconfig.json
+++ b/src/plugins/data_views/tsconfig.json
@@ -37,6 +37,8 @@
"@kbn/core-http-browser",
"@kbn/core-http-browser-internal",
"@kbn/logging-mocks",
+ "@kbn/doc-links",
+ "@kbn/core-deprecations-common",
],
"exclude": [
"target/**/*",
diff --git a/test/api_integration/apis/data_views/deprecations/scripted_fields.ts b/test/api_integration/apis/data_views/deprecations/scripted_fields.ts
index 083fabada4ec7..6f54a02f97b3a 100644
--- a/test/api_integration/apis/data_views/deprecations/scripted_fields.ts
+++ b/test/api_integration/apis/data_views/deprecations/scripted_fields.ts
@@ -10,7 +10,8 @@
import expect from '@kbn/expect';
import type { DeprecationsGetResponse } from '@kbn/core/server';
import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common';
-import { FtrProviderContext } from '../../../ftr_provider_context';
+import type { DeprecationDetailsMessage } from '@kbn/core-deprecations-common';
+import type { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
@@ -75,7 +76,9 @@ export default function ({ getService }: FtrProviderContext) {
);
expect(dataPluginDeprecations.length).to.be(1);
- expect(dataPluginDeprecations[0].message).to.contain(title);
+ expect((dataPluginDeprecations[0].message as DeprecationDetailsMessage).content).to.contain(
+ title
+ );
});
});
}
diff --git a/test/functional/apps/management/data_views/_handle_version_conflict.ts b/test/functional/apps/management/data_views/_handle_version_conflict.ts
index 5b91aaa6a034c..b2f703350ac79 100644
--- a/test/functional/apps/management/data_views/_handle_version_conflict.ts
+++ b/test/functional/apps/management/data_views/_handle_version_conflict.ts
@@ -45,8 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
- await PageObjects.settings.clickScriptedFieldsTab();
- await PageObjects.settings.clickAddScriptedField();
+ await PageObjects.settings.goToAddScriptedField();
await PageObjects.settings.setScriptedFieldName(scriptedFiledName);
await PageObjects.settings.setScriptedFieldScript(`doc['bytes'].value`);
const response = await es.update(
diff --git a/test/functional/apps/management/data_views/_scripted_fields.ts b/test/functional/apps/management/data_views/_scripted_fields.ts
index df51514425a24..12eba2f5acaf5 100644
--- a/test/functional/apps/management/data_views/_scripted_fields.ts
+++ b/test/functional/apps/management/data_views/_scripted_fields.ts
@@ -59,8 +59,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
- await PageObjects.settings.clickScriptedFieldsTab();
- await PageObjects.settings.clickAddScriptedField();
+ await PageObjects.settings.goToAddScriptedField();
await PageObjects.settings.setScriptedFieldName('doomedScriptedField');
await PageObjects.settings.setScriptedFieldScript(`i n v a l i d s c r i p t`);
await PageObjects.settings.clickSaveScriptedField();
@@ -78,7 +77,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
- await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
const script = `1`;
await PageObjects.settings.addScriptedField(
@@ -112,7 +110,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
- await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
const script = `if (doc['machine.ram'].size() == 0) return -1;
else return doc['machine.ram'].value / (1024 * 1024 * 1024);
@@ -227,7 +224,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
- await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
scriptedPainlessFieldName2,
@@ -331,7 +327,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
- await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
scriptedPainlessFieldName2,
@@ -428,7 +423,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount(), 10);
- await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
scriptedPainlessFieldName2,
diff --git a/test/functional/apps/management/data_views/_scripted_fields_preview.ts b/test/functional/apps/management/data_views/_scripted_fields_preview.ts
index 705bdc5f6179b..51d025d99f8e1 100644
--- a/test/functional/apps/management/data_views/_scripted_fields_preview.ts
+++ b/test/functional/apps/management/data_views/_scripted_fields_preview.ts
@@ -33,8 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
- await PageObjects.settings.clickScriptedFieldsTab();
- await PageObjects.settings.clickAddScriptedField();
+ await PageObjects.settings.goToAddScriptedField();
await PageObjects.settings.setScriptedFieldName(SCRIPTED_FIELD_NAME);
});
diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts
index 2d2f50fc9f1f1..dcb38a8cf3e7c 100644
--- a/test/functional/page_objects/settings_page.ts
+++ b/test/functional/page_objects/settings_page.ts
@@ -263,10 +263,12 @@ export class SettingsPageObject extends FtrService {
}
async getScriptedFieldsTabCount() {
- return await this.retry.try(async () => {
+ try {
const text = await this.testSubjects.getVisibleText('tab-scriptedFields');
- return text.split(' ')[2].replace(/\((.*)\)/, '$1');
- });
+ return text.split(' ')[2].replace(/\((.*)\)/, '$1') || '0';
+ } catch (e) {
+ return '0';
+ }
}
async getRelationshipsTabCount() {
@@ -727,7 +729,7 @@ export class SettingsPageObject extends FtrService {
popularity: string,
script: string
) {
- await this.clickAddScriptedField();
+ await this.goToAddScriptedField();
await this.setScriptedFieldName(name);
if (language) await this.setScriptedFieldLanguage(language);
if (type) await this.setScriptedFieldType(type);
@@ -896,9 +898,12 @@ export class SettingsPageObject extends FtrService {
await this.monacoEditor.setCodeEditorValue(script);
}
- async clickAddScriptedField() {
- this.log.debug('click Add Scripted Field');
- await this.testSubjects.click('addScriptedFieldLink');
+ async goToAddScriptedField() {
+ this.log.debug('go to Add Scripted Field url');
+ const url = await this.browser.getCurrentUrl();
+ const newUrl = url.split('#')[0];
+ await this.browser.get(newUrl + '/create-field/');
+ await this.header.waitUntilLoadingHasFinished();
}
async clickSaveScriptedField() {
diff --git a/test/tsconfig.json b/test/tsconfig.json
index 1d8c301c44a2b..d7e0de39d5e5e 100644
--- a/test/tsconfig.json
+++ b/test/tsconfig.json
@@ -77,5 +77,6 @@
"@kbn/default-nav-devtools",
"@kbn/core-saved-objects-import-export-server-internal",
"@kbn/management-settings-ids",
+ "@kbn/core-deprecations-common",
]
}
diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json
index 519225179e043..c591204e88ae7 100644
--- a/x-pack/plugins/translations/translations/fr-FR.json
+++ b/x-pack/plugins/translations/translations/fr-FR.json
@@ -2476,9 +2476,6 @@
"dataViews.contentManagementType": "Vue de données",
"dataViews.dataStreamLabel": "Flux de données",
"dataViews.deprecations.scriptedFields.manualStepOneMessage": "Accédez à Gestion de la Suite > Kibana > Vues de données.",
- "dataViews.deprecations.scriptedFields.manualStepTwoMessage": "Mettez à jour les vues de données {numberOfIndexPatternsWithScriptedFields} qui ont des champs scriptés pour qu’elles utilisent des champs d'exécution. Dans la plupart des cas, pour migrer des scripts existants, vous devrez remplacer \"return ;\" par \"emit();\". Vues de données avec au moins un champ scripté : {allTitles}",
- "dataViews.deprecations.scriptedFieldsMessage": "Vous avez {numberOfIndexPatternsWithScriptedFields} vues de données ({titlesPreview}...) qui utilisent des champs scriptés. Les champs scriptés sont déclassés et seront supprimés à l'avenir. Utilisez plutôt des champs d'exécution.",
- "dataViews.deprecations.scriptedFieldsTitle": "Vues de données utilisant des champs scriptés trouvées",
"dataViews.fetchFieldErrorTitle": "Erreur lors de l'extraction des champs pour la vue de données {title} (ID : {id})",
"dataViews.frozenLabel": "Frozen",
"dataViews.functions.dataViewLoad.help": "Charge une vue de données",
@@ -5032,7 +5029,6 @@
"indexPatternManagement.editIndexPattern.couldNotLoadMessage": "La vue de données ayant l'ID {objectId} n'a pas pu être chargée. Essayez d'en créer une nouvelle.",
"indexPatternManagement.editIndexPattern.couldNotLoadTitle": "Impossible de charger la vue de données",
"indexPatternManagement.editIndexPattern.deleteButton": "Supprimer",
- "indexPatternManagement.editIndexPattern.deprecation": "Les champs scriptés sont déclassés. Utilisez {runtimeDocs} à la place.",
"indexPatternManagement.editIndexPattern.fields.addFieldButtonLabel": "Ajouter un champ",
"indexPatternManagement.editIndexPattern.fields.conflictModal.closeBtn": "Fermer",
"indexPatternManagement.editIndexPattern.fields.conflictModal.description": "Le type de champ {fieldName} change entre les index et peut ne pas être disponible pour la recherche, les visualisations et d'autres analyses.",
@@ -5080,12 +5076,9 @@
"indexPatternManagement.editIndexPattern.list.histogramSummary": "{aggName} (intervalle : {interval})",
"indexPatternManagement.editIndexPattern.mappingConflictHeader": "Conflit de mapping",
"indexPatternManagement.editIndexPattern.mappingConflictLabel": "{conflictFieldsLength, plural, one {Un champ est défini} other {# champs sont définis}} avec plusieurs types (chaîne, entier, etc.) dans les différents index qui correspondent à ce modèle. Vous pourrez peut-être utiliser ce ou ces champs en conflit dans certaines parties de Kibana, mais ils ne seront pas disponibles pour les fonctions qui nécessitent que Kibana connaisse leur type. Pour corriger ce problème, vous devrez réindexer vos données.",
- "indexPatternManagement.editIndexPattern.scripted.addFieldButton": "Ajouter un champ scripté",
"indexPatternManagement.editIndexPattern.scripted.deleteField.cancelButton": "Annuler",
"indexPatternManagement.editIndexPattern.scripted.deleteField.deleteButton": "Supprimer",
"indexPatternManagement.editIndexPattern.scripted.deleteFieldLabel": "Supprimer le champ scripté \"{fieldName}\" ?",
- "indexPatternManagement.editIndexPattern.scripted.deprecationLangHeader": "Langages déclassés en cours d'utilisation",
- "indexPatternManagement.editIndexPattern.scripted.deprecationLangLabel.deprecationLangDetail": "Les langages déclassés suivants sont en cours d'utilisation : {deprecatedLangsInUse}. La prise en charge de ces langages sera supprimée dans la prochaine version majeure de Kibana et d'Elasticsearch. Convertissez vos champs scriptés en {link} pour éviter tout problème.",
"indexPatternManagement.editIndexPattern.scripted.deprecationLangLabel.painlessDescription": "Painless",
"indexPatternManagement.editIndexPattern.scripted.newFieldPlaceholder": "Nouveau champ scripté",
"indexPatternManagement.editIndexPattern.scripted.table.deleteDescription": "Supprimer ce champ",
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index caf9062a48543..44a8ecae58872 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -2475,9 +2475,6 @@
"dataViews.contentManagementType": "データビュー",
"dataViews.dataStreamLabel": "データストリーム",
"dataViews.deprecations.scriptedFields.manualStepOneMessage": "[スタック管理]>[Kibana]>[データビュー]に移動します。",
- "dataViews.deprecations.scriptedFields.manualStepTwoMessage": "ランタイムフィールドを使用するには、スクリプト化されたフィールドがある{numberOfIndexPatternsWithScriptedFields}データビューを更新します。ほとんどの場合、既存のスクリプトを移行するには、「return ;」から「emit();」に変更する必要があります。1つ以上のスクリプト化されたフィールドがあるデータビュー:{allTitles}",
- "dataViews.deprecations.scriptedFieldsMessage": "スクリプト化されたフィールドを使用する{numberOfIndexPatternsWithScriptedFields}データビュー({titlesPreview}...)があります。スクリプト化されたフィールドは廃止予定であり、今後は削除されます。ランタイムフィールドを使用してください。",
- "dataViews.deprecations.scriptedFieldsTitle": "スクリプト化されたフィールドを使用しているデータビューが見つかりました。",
"dataViews.fetchFieldErrorTitle": "データビューのフィールド取得中にエラーが発生 {title}(ID:{id})",
"dataViews.frozenLabel": "凍結",
"dataViews.functions.dataViewLoad.help": "データビューを読み込みます",
@@ -5027,7 +5024,6 @@
"indexPatternManagement.editIndexPattern.couldNotLoadMessage": "ID {objectId}のデータビューを読み込めませんでした。新規作成してください。",
"indexPatternManagement.editIndexPattern.couldNotLoadTitle": "データビューを読み込めません",
"indexPatternManagement.editIndexPattern.deleteButton": "削除",
- "indexPatternManagement.editIndexPattern.deprecation": "スクリプトフィールドは廃止予定です。代わりに{runtimeDocs}を使用してください。",
"indexPatternManagement.editIndexPattern.fields.addFieldButtonLabel": "フィールドの追加",
"indexPatternManagement.editIndexPattern.fields.conflictModal.closeBtn": "閉じる",
"indexPatternManagement.editIndexPattern.fields.conflictModal.description": "{fieldName}フィールドの型がインデックス全体で変更され、検索、視覚化、他の分析で使用できない可能性があります。",
@@ -5075,12 +5071,9 @@
"indexPatternManagement.editIndexPattern.list.histogramSummary": "{aggName} (間隔:{interval})",
"indexPatternManagement.editIndexPattern.mappingConflictHeader": "マッピングの矛盾",
"indexPatternManagement.editIndexPattern.mappingConflictLabel": "{conflictFieldsLength, plural, other {# 個のフィールド}}が、このパターンと一致するインデックスの間で異なるタイプ(文字列、整数など)に定義されています。これらの矛盾したフィールドはKibanaの一部で使用できますが、Kibanaがタイプを把握しなければならない機能には使用できません。この問題を修正するにはデータのレンダリングが必要です。",
- "indexPatternManagement.editIndexPattern.scripted.addFieldButton": "スクリプトフィールドを追加",
"indexPatternManagement.editIndexPattern.scripted.deleteField.cancelButton": "キャンセル",
"indexPatternManagement.editIndexPattern.scripted.deleteField.deleteButton": "削除",
"indexPatternManagement.editIndexPattern.scripted.deleteFieldLabel": "スクリプトフィールド''{fieldName}''を削除しますか?",
- "indexPatternManagement.editIndexPattern.scripted.deprecationLangHeader": "廃止された言語が使用されています",
- "indexPatternManagement.editIndexPattern.scripted.deprecationLangLabel.deprecationLangDetail": "次の廃止された言語が使用されています。{deprecatedLangsInUse}これらの言語は、KibanaとElasticsearchの次のメジャーバージョンでサポートされなくなります。問題を避けるため、スクリプトフィールドを{link}に変換してください。",
"indexPatternManagement.editIndexPattern.scripted.deprecationLangLabel.painlessDescription": "Painless",
"indexPatternManagement.editIndexPattern.scripted.newFieldPlaceholder": "新規スクリプトフィールド",
"indexPatternManagement.editIndexPattern.scripted.table.deleteDescription": "このフィールドを削除します",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 74e0de50a811f..4b5e08db0eb4d 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -2466,9 +2466,6 @@
"dataViews.contentManagementType": "数据视图",
"dataViews.dataStreamLabel": "数据流",
"dataViews.deprecations.scriptedFields.manualStepOneMessage": "导航到'堆栈管理'>'Kibana'>'数据视图'。",
- "dataViews.deprecations.scriptedFields.manualStepTwoMessage": "更新 {numberOfIndexPatternsWithScriptedFields} 个具有脚本字段的数据视图以改为使用运行时字段。多数情况下,要迁移现有脚本,您需要将'return ;'更改为'emit();'。至少有一个脚本字段的数据视图:{allTitles}",
- "dataViews.deprecations.scriptedFieldsMessage": "您具有 {numberOfIndexPatternsWithScriptedFields} 个使用脚本字段的数据视图 ({titlesPreview}...)。脚本字段已过时,将在未来移除。请改为使用运行时脚本。",
- "dataViews.deprecations.scriptedFieldsTitle": "找到使用脚本字段的数据视图",
"dataViews.fetchFieldErrorTitle": "提取数据视图 {title}(ID:{id})的字段时出错",
"dataViews.frozenLabel": "已冻结",
"dataViews.functions.dataViewLoad.help": "加载数据视图",
@@ -4993,7 +4990,6 @@
"indexPatternManagement.editIndexPattern.couldNotLoadMessage": "无法加载 ID 为 {objectId} 的数据视图。尝试创建新视图。",
"indexPatternManagement.editIndexPattern.couldNotLoadTitle": "无法加载数据视图",
"indexPatternManagement.editIndexPattern.deleteButton": "删除",
- "indexPatternManagement.editIndexPattern.deprecation": "脚本字段已弃用。改用 {runtimeDocs}。",
"indexPatternManagement.editIndexPattern.fields.addFieldButtonLabel": "添加字段",
"indexPatternManagement.editIndexPattern.fields.conflictModal.closeBtn": "关闭",
"indexPatternManagement.editIndexPattern.fields.conflictModal.description": "{fieldName} 字段的类型在不同索引中会有所不同,并且可能无法用于搜索、可视化和其他分析。",
@@ -5041,11 +5037,8 @@
"indexPatternManagement.editIndexPattern.list.histogramSummary": "{aggName}(时间间隔:{interval})",
"indexPatternManagement.editIndexPattern.mappingConflictHeader": "映射冲突",
"indexPatternManagement.editIndexPattern.mappingConflictLabel": "{conflictFieldsLength, plural, one {一个字段} other {# 个字段}}已在匹配此模式的各个索引中定义为多个类型(字符串、整数等)。您也许仍能够在 Kibana 的各个部分中使用这些冲突字段,但它们将无法用于需要 Kibana 知道其类型的函数。要解决此问题,需要重新索引您的数据。",
- "indexPatternManagement.editIndexPattern.scripted.addFieldButton": "添加脚本字段",
"indexPatternManagement.editIndexPattern.scripted.deleteField.cancelButton": "取消",
"indexPatternManagement.editIndexPattern.scripted.deleteField.deleteButton": "删除",
- "indexPatternManagement.editIndexPattern.scripted.deprecationLangHeader": "在用的过时语言",
- "indexPatternManagement.editIndexPattern.scripted.deprecationLangLabel.deprecationLangDetail": "以下过时的语言仍在使用:{deprecatedLangsInUse}。Kibana 和 Elasticsearch 的下一主要版本将移除对这些语言的支持。将您的脚本字段转换成 {link} 以避免问题。",
"indexPatternManagement.editIndexPattern.scripted.deprecationLangLabel.painlessDescription": "Painless",
"indexPatternManagement.editIndexPattern.scripted.newFieldPlaceholder": "新建脚本字段",
"indexPatternManagement.editIndexPattern.scripted.table.deleteDescription": "删除此字段",
diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx
index beb4c7c0c678c..7c03e5e770ade 100644
--- a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx
+++ b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/deprecation_details_flyout.tsx
@@ -22,6 +22,9 @@ import {
EuiText,
EuiCallOut,
EuiSpacer,
+ EuiMarkdownFormat,
+ getDefaultEuiMarkdownPlugins,
+ useEuiFontSize,
} from '@elastic/eui';
import { uiMetricService, UIM_KIBANA_QUICK_RESOLVE_CLICK } from '../../lib/ui_metric';
@@ -103,6 +106,12 @@ const i18nTexts = {
),
};
+const { processingPlugins } = getDefaultEuiMarkdownPlugins({
+ processingConfig: {
+ linkProps: { target: '_blank' },
+ },
+});
+
interface AvailableCorrectiveActions {
api: boolean;
manual: boolean;
@@ -158,6 +167,8 @@ export const DeprecationDetailsFlyout = ({
resolveDeprecation(deprecation);
}, [deprecation, resolveDeprecation]);
+ const { lineHeight: lineHeightMedium } = useEuiFontSize('m');
+
return (
<>
@@ -185,11 +196,30 @@ export const DeprecationDetailsFlyout = ({
)}
- {messages.map((m, i) => (
-