diff --git a/api_docs/actions.mdx b/api_docs/actions.mdx index a5b27c67eaca15..0131bca3e6c507 100644 --- a/api_docs/actions.mdx +++ b/api_docs/actions.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import actionsObj from './actions.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 116 | 0 | 116 | 7 | + ## Server ### Setup diff --git a/api_docs/advanced_settings.mdx b/api_docs/advanced_settings.mdx index 5b0e69c14f58b0..241b6b82598c3f 100644 --- a/api_docs/advanced_settings.mdx +++ b/api_docs/advanced_settings.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import advancedSettingsObj from './advanced_settings.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 23 | 0 | 22 | 1 | + ## Client ### Setup diff --git a/api_docs/alerting.json b/api_docs/alerting.json index 13a150d0af00da..979f444659c208 100644 --- a/api_docs/alerting.json +++ b/api_docs/alerting.json @@ -5,7 +5,42 @@ "functions": [], "interfaces": [], "enums": [], - "misc": [], + "misc": [ + { + "parentPluginId": "alerting", + "id": "def-public.AlertNavigationHandler", + "type": "Type", + "tags": [], + "label": "AlertNavigationHandler", + "description": [ + "\nReturns information that can be used to navigate to a specific page to view the given rule.\n" + ], + "signature": [ + "(alert: Pick<", + { + "pluginId": "alerting", + "scope": "common", + "docId": "kibAlertingPluginApi", + "section": "def-common.Alert", + "text": "Alert" + }, + ", \"enabled\" | \"id\" | \"name\" | \"params\" | \"actions\" | \"tags\" | \"alertTypeId\" | \"consumer\" | \"schedule\" | \"scheduledTaskId\" | \"createdBy\" | \"updatedBy\" | \"createdAt\" | \"updatedAt\" | \"apiKeyOwner\" | \"throttle\" | \"notifyWhen\" | \"muteAll\" | \"mutedInstanceIds\" | \"executionStatus\">) => string | ", + { + "pluginId": "kibanaUtils", + "scope": "common", + "docId": "kibKibanaUtilsPluginApi", + "section": "def-common.JsonObject", + "text": "JsonObject" + } + ], + "source": { + "path": "x-pack/plugins/alerting/public/alert_navigation_registry/types.ts", + "lineNumber": 20 + }, + "deprecated": false, + "initialIsOpen": false + } + ], "objects": [], "setup": { "parentPluginId": "alerting", @@ -24,44 +59,58 @@ "parentPluginId": "alerting", "id": "def-public.PluginSetupContract.registerNavigation", "type": "Function", - "tags": [], + "tags": [ + "throws" + ], "label": "registerNavigation", - "description": [], + "description": [ + "\nRegister a customized view of the particular rule type. Stack Management provides a generic overview, but a developer can register a\ncustom navigation to provide the user an extra link to a more curated view. The alerting plugin doesn't actually do\nanything with this information, but it can be used by other plugins via the `getNavigation` functionality. Currently\nthe trigger_actions_ui plugin uses it to expose the link from the generic rule view in Stack Management.\n" + ], "signature": [ - "(consumer: string, alertType: string, handler: ", - "AlertNavigationHandler", + "(applicationId: string, ruleType: string, handler: ", + { + "pluginId": "alerting", + "scope": "public", + "docId": "kibAlertingPluginApi", + "section": "def-public.AlertNavigationHandler", + "text": "AlertNavigationHandler" + }, ") => void" ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 15 + "lineNumber": 30 }, "deprecated": false, "returnComment": [], "children": [ { "parentPluginId": "alerting", - "id": "def-public.consumer", + "id": "def-public.applicationId", "type": "string", "tags": [], - "label": "consumer", - "description": [], + "label": "applicationId", + "description": [ + "The application id that the user should be navigated to, to view a particular alert in a custom way." + ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 16 + "lineNumber": 31 }, "deprecated": false }, { "parentPluginId": "alerting", - "id": "def-public.alertType", + "id": "def-public.ruleType", "type": "string", "tags": [], - "label": "alertType", - "description": [], + "label": "ruleType", + "description": [ + "The rule type that has been registered with Alerting.Server.PluginSetupContract.registerType. If\nno such rule with that id exists, a warning is output to the console log. It used to throw an error, but that was temporarily moved\nbecause it was causing flaky test failures with https://github.com/elastic/kibana/issues/59229 and needs to be\ninvestigated more." + ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 17 + "lineNumber": 32 }, "deprecated": false }, @@ -71,7 +120,9 @@ "type": "Function", "tags": [], "label": "handler", - "description": [], + "description": [ + "The navigation handler should return either a relative URL, or a state object. This information can be used,\nin conjunction with the consumer id, to navigate the user to a custom URL to view a rule's details." + ], "signature": [ "(alert: Pick<", { @@ -81,15 +132,7 @@ "section": "def-common.Alert", "text": "Alert" }, - ", \"enabled\" | \"id\" | \"name\" | \"params\" | \"actions\" | \"tags\" | \"alertTypeId\" | \"consumer\" | \"schedule\" | \"scheduledTaskId\" | \"createdBy\" | \"updatedBy\" | \"createdAt\" | \"updatedAt\" | \"apiKeyOwner\" | \"throttle\" | \"notifyWhen\" | \"muteAll\" | \"mutedInstanceIds\" | \"executionStatus\">, alertType: ", - { - "pluginId": "alerting", - "scope": "common", - "docId": "kibAlertingPluginApi", - "section": "def-common.AlertType", - "text": "AlertType" - }, - "<\"default\", \"recovered\">) => string | ", + ", \"enabled\" | \"id\" | \"name\" | \"params\" | \"actions\" | \"tags\" | \"alertTypeId\" | \"consumer\" | \"schedule\" | \"scheduledTaskId\" | \"createdBy\" | \"updatedBy\" | \"createdAt\" | \"updatedAt\" | \"apiKeyOwner\" | \"throttle\" | \"notifyWhen\" | \"muteAll\" | \"mutedInstanceIds\" | \"executionStatus\">) => string | ", { "pluginId": "kibanaUtils", "scope": "common", @@ -100,7 +143,7 @@ ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 18 + "lineNumber": 33 }, "deprecated": false } @@ -112,29 +155,39 @@ "type": "Function", "tags": [], "label": "registerDefaultNavigation", - "description": [], + "description": [ + "\nRegister a customized view for all rule types. Stack Management provides a generic overview, but a developer can register a\ncustom navigation to provide the user an extra link to a more curated view. The alerting plugin doesn't actually do\nanything with this information, but it can be used by other plugins via the `getNavigation` functionality. Currently\nthe trigger_actions_ui plugin uses it to expose the link from the generic rule view in Stack Management.\n" + ], "signature": [ - "(consumer: string, handler: ", - "AlertNavigationHandler", + "(applicationId: string, handler: ", + { + "pluginId": "alerting", + "scope": "public", + "docId": "kibAlertingPluginApi", + "section": "def-public.AlertNavigationHandler", + "text": "AlertNavigationHandler" + }, ") => void" ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 20 + "lineNumber": 46 }, "deprecated": false, "returnComment": [], "children": [ { "parentPluginId": "alerting", - "id": "def-public.consumer", + "id": "def-public.applicationId", "type": "string", "tags": [], - "label": "consumer", - "description": [], + "label": "applicationId", + "description": [ + "The application id that the user should be navigated to, to view a particular alert in a custom way." + ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 20 + "lineNumber": 46 }, "deprecated": false }, @@ -144,7 +197,9 @@ "type": "Function", "tags": [], "label": "handler", - "description": [], + "description": [ + "The navigation handler should return either a relative URL, or a state object. This information can be used,\nin conjunction with the consumer id, to navigate the user to a custom URL to view a rule's details." + ], "signature": [ "(alert: Pick<", { @@ -154,15 +209,7 @@ "section": "def-common.Alert", "text": "Alert" }, - ", \"enabled\" | \"id\" | \"name\" | \"params\" | \"actions\" | \"tags\" | \"alertTypeId\" | \"consumer\" | \"schedule\" | \"scheduledTaskId\" | \"createdBy\" | \"updatedBy\" | \"createdAt\" | \"updatedAt\" | \"apiKeyOwner\" | \"throttle\" | \"notifyWhen\" | \"muteAll\" | \"mutedInstanceIds\" | \"executionStatus\">, alertType: ", - { - "pluginId": "alerting", - "scope": "common", - "docId": "kibAlertingPluginApi", - "section": "def-common.AlertType", - "text": "AlertType" - }, - "<\"default\", \"recovered\">) => string | ", + ", \"enabled\" | \"id\" | \"name\" | \"params\" | \"actions\" | \"tags\" | \"alertTypeId\" | \"consumer\" | \"schedule\" | \"scheduledTaskId\" | \"createdBy\" | \"updatedBy\" | \"createdAt\" | \"updatedAt\" | \"apiKeyOwner\" | \"throttle\" | \"notifyWhen\" | \"muteAll\" | \"mutedInstanceIds\" | \"executionStatus\">) => string | ", { "pluginId": "kibanaUtils", "scope": "common", @@ -173,7 +220,7 @@ ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 20 + "lineNumber": 46 }, "deprecated": false } @@ -192,7 +239,7 @@ "description": [], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 22 + "lineNumber": 48 }, "deprecated": false, "children": [ @@ -224,7 +271,7 @@ ], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 23 + "lineNumber": 49 }, "deprecated": false, "returnComment": [], @@ -238,7 +285,7 @@ "description": [], "source": { "path": "x-pack/plugins/alerting/public/plugin.ts", - "lineNumber": 23 + "lineNumber": 49 }, "deprecated": false } @@ -3857,7 +3904,7 @@ "label": "ReservedActionGroups", "description": [], "signature": [ - "\"recovered\" | RecoveryActionGroupId" + "RecoveryActionGroupId | \"recovered\"" ], "source": { "path": "x-pack/plugins/alerting/common/builtin_action_groups.ts", diff --git a/api_docs/alerting.mdx b/api_docs/alerting.mdx index a0294a02d9f109..c3c844148106f0 100644 --- a/api_docs/alerting.mdx +++ b/api_docs/alerting.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import alertingObj from './alerting.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 213 | 0 | 213 | 15 | + ## Client ### Setup @@ -19,6 +29,9 @@ import alertingObj from './alerting.json'; ### Start +### Consts, variables and types + + ## Server ### Functions diff --git a/api_docs/apm.mdx b/api_docs/apm.mdx index d037dc99e1a542..e2a4ee9e7ea7ab 100644 --- a/api_docs/apm.mdx +++ b/api_docs/apm.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import apmObj from './apm.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 37 | 0 | 37 | 30 | + ## Client ### Setup diff --git a/api_docs/apm_oss.mdx b/api_docs/apm_oss.mdx index 73707040013788..2a03249734f9c9 100644 --- a/api_docs/apm_oss.mdx +++ b/api_docs/apm_oss.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import apmOssObj from './apm_oss.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 4 | 0 | 4 | 0 | + ## Server ### Setup diff --git a/api_docs/banners.mdx b/api_docs/banners.mdx index e6b648e38cdc34..d9727cb817e26a 100644 --- a/api_docs/banners.mdx +++ b/api_docs/banners.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import bannersObj from './banners.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 9 | 0 | 9 | 0 | + ## Common ### Interfaces diff --git a/api_docs/bfetch.mdx b/api_docs/bfetch.mdx index faf3d7eefc7f9f..217e190831313b 100644 --- a/api_docs/bfetch.mdx +++ b/api_docs/bfetch.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import bfetchObj from './bfetch.json'; +Considering using bfetch capabilities when fetching large amounts of data. This services supports batching HTTP requests and streaming responses back. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 73 | 1 | 62 | 2 | + ## Client ### Start diff --git a/api_docs/canvas.mdx b/api_docs/canvas.mdx index 75ac78d571bc99..9d8707ab778e6b 100644 --- a/api_docs/canvas.mdx +++ b/api_docs/canvas.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import canvasObj from './canvas.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 6 | 0 | 5 | 3 | + ## Client ### Setup diff --git a/api_docs/cases.json b/api_docs/cases.json index bc92995dff6e91..cccf5de2710e28 100644 --- a/api_docs/cases.json +++ b/api_docs/cases.json @@ -34,21 +34,9 @@ "text": "CasesUiStart" }, ", ", - { - "pluginId": "cases", - "scope": "public", - "docId": "kibCasesPluginApi", - "section": "def-public.SetupPlugins", - "text": "SetupPlugins" - }, + "SetupPlugins", ", ", - { - "pluginId": "cases", - "scope": "public", - "docId": "kibCasesPluginApi", - "section": "def-public.StartPlugins", - "text": "StartPlugins" - }, + "StartPlugins", ">" ], "source": { @@ -117,13 +105,7 @@ "text": "CoreSetup" }, ", plugins: ", - { - "pluginId": "cases", - "scope": "public", - "docId": "kibCasesPluginApi", - "section": "def-public.SetupPlugins", - "text": "SetupPlugins" - }, + "SetupPlugins", ") => void" ], "source": { @@ -164,13 +146,7 @@ "label": "plugins", "description": [], "signature": [ - { - "pluginId": "cases", - "scope": "public", - "docId": "kibCasesPluginApi", - "section": "def-public.SetupPlugins", - "text": "SetupPlugins" - } + "SetupPlugins" ], "source": { "path": "x-pack/plugins/cases/public/plugin.ts", @@ -199,127 +175,676 @@ "text": "CoreStart" }, ", plugins: ", + "StartPlugins", + ") => ", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CasesUiStart", + "text": "CasesUiStart" + } + ], + "source": { + "path": "x-pack/plugins/cases/public/plugin.ts", + "lineNumber": 38 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.CasesUiPlugin.start.$1", + "type": "Object", + "tags": [], + "label": "core", + "description": [], + "signature": [ + { + "pluginId": "core", + "scope": "public", + "docId": "kibCorePluginApi", + "section": "def-public.CoreStart", + "text": "CoreStart" + } + ], + "source": { + "path": "x-pack/plugins/cases/public/plugin.ts", + "lineNumber": 38 + }, + "deprecated": false, + "isRequired": true + }, + { + "parentPluginId": "cases", + "id": "def-public.CasesUiPlugin.start.$2", + "type": "Object", + "tags": [], + "label": "plugins", + "description": [], + "signature": [ + "StartPlugins" + ], + "source": { + "path": "x-pack/plugins/cases/public/plugin.ts", + "lineNumber": 38 + }, + "deprecated": false, + "isRequired": true + } + ], + "returnComment": [] + }, + { + "parentPluginId": "cases", + "id": "def-public.CasesUiPlugin.stop", + "type": "Function", + "tags": [], + "label": "stop", + "description": [], + "signature": [ + "() => void" + ], + "source": { + "path": "x-pack/plugins/cases/public/plugin.ts", + "lineNumber": 92 + }, + "deprecated": false, + "children": [], + "returnComment": [] + } + ], + "initialIsOpen": false + } + ], + "functions": [], + "interfaces": [ + { + "parentPluginId": "cases", + "id": "def-public.AllCasesProps", + "type": "Interface", + "tags": [], + "label": "AllCasesProps", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesProps", + "text": "AllCasesProps" + }, + " extends ", + "Owner" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/index.tsx", + "lineNumber": 13 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.AllCasesProps.caseDetailsNavigation", + "type": "Object", + "tags": [], + "label": "caseDetailsNavigation", + "description": [], + "signature": [ + "CasesNavigation", + "<", + "CaseDetailsHrefSchema", + ", \"configurable\">" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/index.tsx", + "lineNumber": 14 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesProps.configureCasesNavigation", + "type": "Object", + "tags": [], + "label": "configureCasesNavigation", + "description": [], + "signature": [ + "CasesNavigation", + ", null>" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/index.tsx", + "lineNumber": 15 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesProps.createCaseNavigation", + "type": "Object", + "tags": [], + "label": "createCaseNavigation", + "description": [], + "signature": [ + "CasesNavigation", + ", null>" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/index.tsx", + "lineNumber": 16 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesProps.userCanCrud", + "type": "boolean", + "tags": [], + "label": "userCanCrud", + "description": [], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/index.tsx", + "lineNumber": 17 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps", + "type": "Interface", + "tags": [], + "label": "AllCasesSelectorModalProps", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesSelectorModalProps", + "text": "AllCasesSelectorModalProps" + }, + " extends ", + "Owner" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 23 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps.alertData", + "type": "Object", + "tags": [], + "label": "alertData", + "description": [], + "signature": [ + "Pick<{ type: ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.CommentType", + "text": "CommentType" + }, + ".alert | ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.CommentType", + "text": "CommentType" + }, + ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; }, \"index\" | \"rule\" | \"alertId\" | \"owner\"> | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 24 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps.createCaseNavigation", + "type": "Object", + "tags": [], + "label": "createCaseNavigation", + "description": [], + "signature": [ + "CasesNavigation", + ", null>" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 25 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps.hiddenStatuses", + "type": "Array", + "tags": [], + "label": "hiddenStatuses", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.CaseStatusWithAllStatus", + "text": "CaseStatusWithAllStatus" + }, + "[] | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 26 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps.onRowClick", + "type": "Function", + "tags": [], + "label": "onRowClick", + "description": [], + "signature": [ + "(theCase?: ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.Case", + "text": "Case" + }, + " | ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.SubCase", + "text": "SubCase" + }, + " | undefined) => void" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 27 + }, + "deprecated": false, + "returnComment": [], + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.theCase", + "type": "CompoundType", + "tags": [], + "label": "theCase", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.Case", + "text": "Case" + }, + " | ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.SubCase", + "text": "SubCase" + }, + " | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 27 + }, + "deprecated": false + } + ] + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps.updateCase", + "type": "Function", + "tags": [], + "label": "updateCase", + "description": [], + "signature": [ + "((newCase: ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.Case", + "text": "Case" + }, + ") => void) | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 28 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.AllCasesSelectorModalProps.userCanCrud", + "type": "boolean", + "tags": [], + "label": "userCanCrud", + "description": [], + "source": { + "path": "x-pack/plugins/cases/public/components/all_cases/selector_modal/index.tsx", + "lineNumber": 29 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "cases", + "id": "def-public.CaseViewProps", + "type": "Interface", + "tags": [], + "label": "CaseViewProps", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CaseViewProps", + "text": "CaseViewProps" + }, + " extends ", + "CaseViewComponentProps" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/case_view/index.tsx", + "lineNumber": 63 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.CaseViewProps.onCaseDataSuccess", + "type": "Function", + "tags": [], + "label": "onCaseDataSuccess", + "description": [], + "signature": [ + "((data: ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.Case", + "text": "Case" + }, + ") => void) | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/case_view/index.tsx", + "lineNumber": 64 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.CaseViewProps.timelineIntegration", + "type": "Object", + "tags": [], + "label": "timelineIntegration", + "description": [], + "signature": [ + "CasesTimelineIntegration", + " | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/case_view/index.tsx", + "lineNumber": 65 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "cases", + "id": "def-public.ConfigureCasesProps", + "type": "Interface", + "tags": [], + "label": "ConfigureCasesProps", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.ConfigureCasesProps", + "text": "ConfigureCasesProps" + }, + " extends ", + "Owner" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/configure_cases/index.tsx", + "lineNumber": 55 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.ConfigureCasesProps.userCanCrud", + "type": "boolean", + "tags": [], + "label": "userCanCrud", + "description": [], + "source": { + "path": "x-pack/plugins/cases/public/components/configure_cases/index.tsx", + "lineNumber": 56 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "cases", + "id": "def-public.CreateCaseProps", + "type": "Interface", + "tags": [], + "label": "CreateCaseProps", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CreateCaseProps", + "text": "CreateCaseProps" + }, + " extends ", + "Owner" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 34 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "cases", + "id": "def-public.CreateCaseProps.afterCaseCreated", + "type": "Function", + "tags": [], + "label": "afterCaseCreated", + "description": [], + "signature": [ + "((theCase: ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.Case", + "text": "Case" + }, + ", postComment: (args: PostComment) => Promise) => Promise) | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 35 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.CreateCaseProps.caseType", + "type": "CompoundType", + "tags": [], + "label": "caseType", + "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.CaseType", + "text": "CaseType" + }, + " | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 36 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.CreateCaseProps.hideConnectorServiceNowSir", + "type": "CompoundType", + "tags": [], + "label": "hideConnectorServiceNowSir", + "description": [], + "signature": [ + "boolean | undefined" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 37 + }, + "deprecated": false + }, + { + "parentPluginId": "cases", + "id": "def-public.CreateCaseProps.onCancel", + "type": "Function", + "tags": [], + "label": "onCancel", + "description": [], + "signature": [ + "() => void" + ], + "source": { + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 38 + }, + "deprecated": false, + "returnComment": [], + "children": [] + }, + { + "parentPluginId": "cases", + "id": "def-public.CreateCaseProps.onSuccess", + "type": "Function", + "tags": [], + "label": "onSuccess", + "description": [], + "signature": [ + "(theCase: ", { "pluginId": "cases", - "scope": "public", + "scope": "common", "docId": "kibCasesPluginApi", - "section": "def-public.StartPlugins", - "text": "StartPlugins" + "section": "def-common.Case", + "text": "Case" }, - ") => ", - { - "pluginId": "cases", - "scope": "public", - "docId": "kibCasesPluginApi", - "section": "def-public.CasesUiStart", - "text": "CasesUiStart" - } + ") => Promise" ], "source": { - "path": "x-pack/plugins/cases/public/plugin.ts", - "lineNumber": 38 + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 39 }, "deprecated": false, + "returnComment": [], "children": [ { "parentPluginId": "cases", - "id": "def-public.CasesUiPlugin.start.$1", - "type": "Object", - "tags": [], - "label": "core", - "description": [], - "signature": [ - { - "pluginId": "core", - "scope": "public", - "docId": "kibCorePluginApi", - "section": "def-public.CoreStart", - "text": "CoreStart" - } - ], - "source": { - "path": "x-pack/plugins/cases/public/plugin.ts", - "lineNumber": 38 - }, - "deprecated": false, - "isRequired": true - }, - { - "parentPluginId": "cases", - "id": "def-public.CasesUiPlugin.start.$2", + "id": "def-public.theCase", "type": "Object", "tags": [], - "label": "plugins", + "label": "theCase", "description": [], "signature": [ { "pluginId": "cases", - "scope": "public", + "scope": "common", "docId": "kibCasesPluginApi", - "section": "def-public.StartPlugins", - "text": "StartPlugins" + "section": "def-common.Case", + "text": "Case" } ], "source": { - "path": "x-pack/plugins/cases/public/plugin.ts", - "lineNumber": 38 + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 39 }, - "deprecated": false, - "isRequired": true + "deprecated": false } - ], - "returnComment": [] + ] }, { "parentPluginId": "cases", - "id": "def-public.CasesUiPlugin.stop", - "type": "Function", + "id": "def-public.CreateCaseProps.timelineIntegration", + "type": "Object", "tags": [], - "label": "stop", + "label": "timelineIntegration", "description": [], "signature": [ - "() => void" + "CasesTimelineIntegration", + " | undefined" ], "source": { - "path": "x-pack/plugins/cases/public/plugin.ts", - "lineNumber": 92 + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 40 }, - "deprecated": false, - "children": [], - "returnComment": [] - } - ], - "initialIsOpen": false - } - ], - "functions": [], - "interfaces": [ - { - "parentPluginId": "cases", - "id": "def-public.Owner", - "type": "Interface", - "tags": [], - "label": "Owner", - "description": [], - "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 42 - }, - "deprecated": false, - "children": [ + "deprecated": false + }, { "parentPluginId": "cases", - "id": "def-public.Owner.owner", - "type": "Array", + "id": "def-public.CreateCaseProps.withSteps", + "type": "CompoundType", "tags": [], - "label": "owner", + "label": "withSteps", "description": [], "signature": [ - "string[]" + "boolean | undefined" ], "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 43 + "path": "x-pack/plugins/cases/public/components/create/index.tsx", + "lineNumber": 41 }, "deprecated": false } @@ -328,148 +853,100 @@ }, { "parentPluginId": "cases", - "id": "def-public.SetupPlugins", + "id": "def-public.RecentCasesProps", "type": "Interface", "tags": [], - "label": "SetupPlugins", + "label": "RecentCasesProps", "description": [], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.RecentCasesProps", + "text": "RecentCasesProps" + }, + " extends ", + "Owner" + ], "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 22 + "path": "x-pack/plugins/cases/public/components/recent_cases/index.tsx", + "lineNumber": 20 }, "deprecated": false, "children": [ { "parentPluginId": "cases", - "id": "def-public.SetupPlugins.security", + "id": "def-public.RecentCasesProps.allCasesNavigation", "type": "Object", "tags": [], - "label": "security", + "label": "allCasesNavigation", "description": [], "signature": [ - { - "pluginId": "security", - "scope": "public", - "docId": "kibSecurityPluginApi", - "section": "def-public.SecurityPluginSetup", - "text": "SecurityPluginSetup" - } + "CasesNavigation", + ", null>" ], "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 23 + "path": "x-pack/plugins/cases/public/components/recent_cases/index.tsx", + "lineNumber": 21 }, "deprecated": false }, { "parentPluginId": "cases", - "id": "def-public.SetupPlugins.triggersActionsUi", + "id": "def-public.RecentCasesProps.caseDetailsNavigation", "type": "Object", "tags": [], - "label": "triggersActionsUi", + "label": "caseDetailsNavigation", "description": [], "signature": [ - { - "pluginId": "triggersActionsUi", - "scope": "public", - "docId": "kibTriggersActionsUiPluginApi", - "section": "def-public.TriggersAndActionsUIPublicPluginSetup", - "text": "TriggersAndActionsUIPublicPluginSetup" - } + "CasesNavigation", + "<", + "CaseDetailsHrefSchema", + ", \"configurable\">" ], "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 24 + "path": "x-pack/plugins/cases/public/components/recent_cases/index.tsx", + "lineNumber": 22 }, "deprecated": false - } - ], - "initialIsOpen": false - }, - { - "parentPluginId": "cases", - "id": "def-public.StartPlugins", - "type": "Interface", - "tags": [], - "label": "StartPlugins", - "description": [], - "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 27 - }, - "deprecated": false, - "children": [ + }, { "parentPluginId": "cases", - "id": "def-public.StartPlugins.triggersActionsUi", + "id": "def-public.RecentCasesProps.createCaseNavigation", "type": "Object", "tags": [], - "label": "triggersActionsUi", + "label": "createCaseNavigation", "description": [], "signature": [ - { - "pluginId": "triggersActionsUi", - "scope": "public", - "docId": "kibTriggersActionsUiPluginApi", - "section": "def-public.TriggersAndActionsUIPublicPluginStart", - "text": "TriggersAndActionsUIPublicPluginStart" - } + "CasesNavigation", + ", null>" ], "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 28 + "path": "x-pack/plugins/cases/public/components/recent_cases/index.tsx", + "lineNumber": 23 }, "deprecated": false - } - ], - "initialIsOpen": false - } - ], - "enums": [], - "misc": [ - { - "parentPluginId": "cases", - "id": "def-public.StartServices", - "type": "Type", - "tags": [], - "label": "StartServices", - "description": [ - "\nTODO: The extra security service is one that should be implemented in the kibana context of the consuming application.\nSecurity is needed for access to authc for the `useCurrentUser` hook. Security_Solution currently passes it via renderApp in public/plugin.tsx\nLeaving it out currently in lieu of RBAC changes" - ], - "signature": [ - { - "pluginId": "core", - "scope": "public", - "docId": "kibCorePluginApi", - "section": "def-public.CoreStart", - "text": "CoreStart" - }, - " & ", - { - "pluginId": "cases", - "scope": "public", - "docId": "kibCasesPluginApi", - "section": "def-public.StartPlugins", - "text": "StartPlugins" }, - " & { security: ", { - "pluginId": "security", - "scope": "public", - "docId": "kibSecurityPluginApi", - "section": "def-public.SecurityPluginSetup", - "text": "SecurityPluginSetup" - }, - "; }" + "parentPluginId": "cases", + "id": "def-public.RecentCasesProps.maxCasesToShow", + "type": "number", + "tags": [], + "label": "maxCasesToShow", + "description": [], + "source": { + "path": "x-pack/plugins/cases/public/components/recent_cases/index.tsx", + "lineNumber": 24 + }, + "deprecated": false + } ], - "source": { - "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 37 - }, - "deprecated": false, "initialIsOpen": false } ], + "enums": [], + "misc": [], "objects": [], "start": { "parentPluginId": "cases", @@ -490,20 +967,36 @@ "type": "Function", "tags": [], "label": "getAllCases", - "description": [], + "description": [ + "\nGet the all cases table" + ], "signature": [ "(props: ", - "AllCasesProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesProps", + "text": "AllCasesProps" + }, ") => React.ReactElement<", - "AllCasesProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesProps", + "text": "AllCasesProps" + }, ">" ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 47 + "lineNumber": 52 }, "deprecated": false, - "returnComment": [], + "returnComment": [ + "A react component that displays all cases" + ], "children": [ { "parentPluginId": "cases", @@ -511,13 +1004,21 @@ "type": "Object", "tags": [], "label": "props", - "description": [], - "signature": [ + "description": [ "AllCasesProps" ], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesProps", + "text": "AllCasesProps" + } + ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 47 + "lineNumber": 52 }, "deprecated": false } @@ -529,20 +1030,36 @@ "type": "Function", "tags": [], "label": "getAllCasesSelectorModal", - "description": [], + "description": [ + "\nuse Modal hook for all cases selector" + ], "signature": [ "(props: ", - "AllCasesSelectorModalProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesSelectorModalProps", + "text": "AllCasesSelectorModalProps" + }, ") => React.ReactElement<", - "AllCasesSelectorModalProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesSelectorModalProps", + "text": "AllCasesSelectorModalProps" + }, ">" ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 48 + "lineNumber": 58 }, "deprecated": false, - "returnComment": [], + "returnComment": [ + "A react component that is a modal for selecting a case" + ], "children": [ { "parentPluginId": "cases", @@ -550,13 +1067,21 @@ "type": "Object", "tags": [], "label": "props", - "description": [], + "description": [ + "UseAllCasesSelectorModalProps" + ], "signature": [ - "AllCasesSelectorModalProps" + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.AllCasesSelectorModalProps", + "text": "AllCasesSelectorModalProps" + } ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 49 + "lineNumber": 59 }, "deprecated": false } @@ -568,20 +1093,36 @@ "type": "Function", "tags": [], "label": "getCaseView", - "description": [], + "description": [ + "\nGet the case view component" + ], "signature": [ "(props: ", - "CaseViewProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CaseViewProps", + "text": "CaseViewProps" + }, ") => React.ReactElement<", - "CaseViewProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CaseViewProps", + "text": "CaseViewProps" + }, ">" ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 51 + "lineNumber": 66 }, "deprecated": false, - "returnComment": [], + "returnComment": [ + "A react component for viewing a specific case" + ], "children": [ { "parentPluginId": "cases", @@ -589,13 +1130,21 @@ "type": "Object", "tags": [], "label": "props", - "description": [], - "signature": [ + "description": [ "CaseViewProps" ], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CaseViewProps", + "text": "CaseViewProps" + } + ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 51 + "lineNumber": 66 }, "deprecated": false } @@ -607,20 +1156,36 @@ "type": "Function", "tags": [], "label": "getConfigureCases", - "description": [], + "description": [ + "\nGet the configure case component" + ], "signature": [ "(props: ", - "ConfigureCasesProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.ConfigureCasesProps", + "text": "ConfigureCasesProps" + }, ") => React.ReactElement<", - "ConfigureCasesProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.ConfigureCasesProps", + "text": "ConfigureCasesProps" + }, ">" ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 52 + "lineNumber": 72 }, "deprecated": false, - "returnComment": [], + "returnComment": [ + "A react component for configuring a specific case" + ], "children": [ { "parentPluginId": "cases", @@ -628,13 +1193,21 @@ "type": "Object", "tags": [], "label": "props", - "description": [], - "signature": [ + "description": [ "ConfigureCasesProps" ], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.ConfigureCasesProps", + "text": "ConfigureCasesProps" + } + ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 52 + "lineNumber": 72 }, "deprecated": false } @@ -646,20 +1219,36 @@ "type": "Function", "tags": [], "label": "getCreateCase", - "description": [], + "description": [ + "\nGet the create case form" + ], "signature": [ "(props: ", - "CreateCaseProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CreateCaseProps", + "text": "CreateCaseProps" + }, ") => React.ReactElement<", - "CreateCaseProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CreateCaseProps", + "text": "CreateCaseProps" + }, ">" ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 53 + "lineNumber": 78 }, "deprecated": false, - "returnComment": [], + "returnComment": [ + "A react component for creating a new case" + ], "children": [ { "parentPluginId": "cases", @@ -667,13 +1256,21 @@ "type": "Object", "tags": [], "label": "props", - "description": [], - "signature": [ + "description": [ "CreateCaseProps" ], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.CreateCaseProps", + "text": "CreateCaseProps" + } + ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 53 + "lineNumber": 78 }, "deprecated": false } @@ -685,20 +1282,36 @@ "type": "Function", "tags": [], "label": "getRecentCases", - "description": [], + "description": [ + "\nGet the recent cases component" + ], "signature": [ "(props: ", - "RecentCasesProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.RecentCasesProps", + "text": "RecentCasesProps" + }, ") => React.ReactElement<", - "RecentCasesProps", + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.RecentCasesProps", + "text": "RecentCasesProps" + }, ">" ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 54 + "lineNumber": 84 }, "deprecated": false, - "returnComment": [], + "returnComment": [ + "A react component for showing recent cases" + ], "children": [ { "parentPluginId": "cases", @@ -706,13 +1319,21 @@ "type": "Object", "tags": [], "label": "props", - "description": [], - "signature": [ + "description": [ "RecentCasesProps" ], + "signature": [ + { + "pluginId": "cases", + "scope": "public", + "docId": "kibCasesPluginApi", + "section": "def-public.RecentCasesProps", + "text": "RecentCasesProps" + } + ], "source": { "path": "x-pack/plugins/cases/public/types.ts", - "lineNumber": 54 + "lineNumber": 84 }, "deprecated": false } @@ -6138,7 +6759,7 @@ "label": "Comment", "description": [], "signature": [ - "({ comment: string; type: ", + "({ type: ", { "pluginId": "cases", "scope": "common", @@ -6146,7 +6767,15 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".user; owner: string; } & { associationType: ", + ".alert | ", + { + "pluginId": "cases", + "scope": "common", + "docId": "kibCasesPluginApi", + "section": "def-common.CommentType", + "text": "CommentType" + }, + ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; } & { associationType: ", { "pluginId": "cases", "scope": "common", @@ -6170,15 +6799,7 @@ "section": "def-common.ElasticUser", "text": "ElasticUser" }, - " | null; version: string; }) | ({ type: ", - { - "pluginId": "cases", - "scope": "common", - "docId": "kibCasesPluginApi", - "section": "def-common.CommentType", - "text": "CommentType" - }, - ".alert | ", + " | null; version: string; }) | ({ comment: string; type: ", { "pluginId": "cases", "scope": "common", @@ -6186,7 +6807,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; } & { associationType: ", + ".user; owner: string; } & { associationType: ", { "pluginId": "cases", "scope": "common", @@ -6333,7 +6954,7 @@ "label": "CommentPatchRequest", "description": [], "signature": [ - "({ comment: string; type: ", + "({ type: ", { "pluginId": "cases", "scope": "common", @@ -6341,7 +6962,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".user; owner: string; } & { id: string; version: string; }) | ({ type: ", + ".alert | ", { "pluginId": "cases", "scope": "common", @@ -6349,7 +6970,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".alert | ", + ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; } & { id: string; version: string; }) | ({ comment: string; type: ", { "pluginId": "cases", "scope": "common", @@ -6357,7 +6978,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; } & { id: string; version: string; })" + ".user; owner: string; } & { id: string; version: string; })" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/comment.ts", @@ -6374,7 +6995,7 @@ "label": "CommentRequest", "description": [], "signature": [ - "{ comment: string; type: ", + "{ type: ", { "pluginId": "cases", "scope": "common", @@ -6382,7 +7003,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".user; owner: string; } | { type: ", + ".alert | ", { "pluginId": "cases", "scope": "common", @@ -6390,7 +7011,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".alert | ", + ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; } | { comment: string; type: ", { "pluginId": "cases", "scope": "common", @@ -6398,7 +7019,7 @@ "section": "def-common.CommentType", "text": "CommentType" }, - ".generatedAlert; alertId: string | string[]; index: string | string[]; rule: { id: string | null; name: string | null; }; owner: string; }" + ".user; owner: string; }" ], "source": { "path": "x-pack/plugins/cases/common/api/cases/comment.ts", diff --git a/api_docs/cases.mdx b/api_docs/cases.mdx index 20d371cbcdc6e0..00714b3217fca8 100644 --- a/api_docs/cases.mdx +++ b/api_docs/cases.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import casesObj from './cases.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 406 | 0 | 381 | 13 | + ## Client ### Start @@ -22,9 +32,6 @@ import casesObj from './cases.json'; ### Interfaces -### Consts, variables and types - - ## Server ### Classes diff --git a/api_docs/charts.mdx b/api_docs/charts.mdx index 1cbdb2f19a6fbb..95d0bd527e631b 100644 --- a/api_docs/charts.mdx +++ b/api_docs/charts.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import chartsObj from './charts.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 190 | 2 | 159 | 1 | + ## Client ### Start diff --git a/api_docs/cloud.mdx b/api_docs/cloud.mdx index 4a61ce885f1548..f9d44f9c8d08ba 100644 --- a/api_docs/cloud.mdx +++ b/api_docs/cloud.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import cloudObj from './cloud.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 20 | 0 | 20 | 0 | + ## Client ### Setup diff --git a/api_docs/console.mdx b/api_docs/console.mdx index 3514fa2697aaa0..74a7fadf7a5c37 100644 --- a/api_docs/console.mdx +++ b/api_docs/console.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import consoleObj from './console.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2 | 0 | 2 | 0 | + ## Server ### Setup diff --git a/api_docs/core.mdx b/api_docs/core.mdx index 77050dd72894a8..31889ec1042b84 100644 --- a/api_docs/core.mdx +++ b/api_docs/core.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import coreObj from './core.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2273 | 148 | 1052 | 26 | + ## Client ### Classes diff --git a/api_docs/core_application.mdx b/api_docs/core_application.mdx index 76d2d95f21e05f..ce165343346322 100644 --- a/api_docs/core_application.mdx +++ b/api_docs/core_application.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import coreApplicationObj from './core_application.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2273 | 148 | 1052 | 26 | + ## Client ### Classes diff --git a/api_docs/core_chrome.mdx b/api_docs/core_chrome.mdx index a9e100b79a91ec..3fbc87ad30fffc 100644 --- a/api_docs/core_chrome.mdx +++ b/api_docs/core_chrome.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import coreChromeObj from './core_chrome.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2273 | 148 | 1052 | 26 | + ## Client ### Interfaces diff --git a/api_docs/core_http.mdx b/api_docs/core_http.mdx index ea545eb6d70def..4f15e1a1ce90c5 100644 --- a/api_docs/core_http.mdx +++ b/api_docs/core_http.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import coreHttpObj from './core_http.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2273 | 148 | 1052 | 26 | + ## Client ### Interfaces diff --git a/api_docs/core_saved_objects.mdx b/api_docs/core_saved_objects.mdx index d534853f7f29db..fd3f96e081c9e3 100644 --- a/api_docs/core_saved_objects.mdx +++ b/api_docs/core_saved_objects.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import coreSavedObjectsObj from './core_saved_objects.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2273 | 148 | 1052 | 26 | + ## Client ### Classes diff --git a/api_docs/dashboard.mdx b/api_docs/dashboard.mdx index bddd6f91796fc7..de34ce88a77be5 100644 --- a/api_docs/dashboard.mdx +++ b/api_docs/dashboard.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dashboardObj from './dashboard.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 145 | 1 | 133 | 9 | + ## Client ### Setup diff --git a/api_docs/dashboard_enhanced.mdx b/api_docs/dashboard_enhanced.mdx index 1ef8820befc41c..4af7f6f96cf23c 100644 --- a/api_docs/dashboard_enhanced.mdx +++ b/api_docs/dashboard_enhanced.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dashboardEnhancedObj from './dashboard_enhanced.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 51 | 0 | 50 | 0 | + ## Client ### Setup diff --git a/api_docs/dashboard_mode.mdx b/api_docs/dashboard_mode.mdx index 2108754adbd5db..28b68e29bd5f26 100644 --- a/api_docs/dashboard_mode.mdx +++ b/api_docs/dashboard_mode.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dashboardModeObj from './dashboard_mode.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 11 | 0 | 11 | 0 | + ## Server ### Classes diff --git a/api_docs/data.json b/api_docs/data.json index 2f9e74584603fc..993dcec522d5e8 100644 --- a/api_docs/data.json +++ b/api_docs/data.json @@ -12344,34 +12344,6 @@ "lineNumber": 222 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", - "lineNumber": 11 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", - "lineNumber": 16 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx", - "lineNumber": 25 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx", - "lineNumber": 162 - } - }, { "plugin": "infra", "link": { @@ -12848,6 +12820,20 @@ "lineNumber": 11 } }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", + "lineNumber": 11 + } + }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", + "lineNumber": 16 + } + }, { "plugin": "ml", "link": { @@ -15759,20 +15745,6 @@ "lineNumber": 11 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx", - "lineNumber": 25 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx", - "lineNumber": 28 - } - }, { "plugin": "infra", "link": { @@ -16382,48 +16354,6 @@ "lineNumber": 57 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 14 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 27 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 213 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 234 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts", - "lineNumber": 12 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts", - "lineNumber": 17 - } - }, { "plugin": "observability", "link": { @@ -34346,34 +34276,6 @@ "lineNumber": 222 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", - "lineNumber": 11 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", - "lineNumber": 16 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx", - "lineNumber": 25 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx", - "lineNumber": 162 - } - }, { "plugin": "infra", "link": { @@ -34850,6 +34752,20 @@ "lineNumber": 11 } }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", + "lineNumber": 11 + } + }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", + "lineNumber": 16 + } + }, { "plugin": "ml", "link": { diff --git a/api_docs/data.mdx b/api_docs/data.mdx index f585b23a16a0c6..bd48fb09df8b30 100644 --- a/api_docs/data.mdx +++ b/api_docs/data.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataObj from './data.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Client ### Setup diff --git a/api_docs/data_autocomplete.mdx b/api_docs/data_autocomplete.mdx index c2231648ac905d..7d18feb2140dd4 100644 --- a/api_docs/data_autocomplete.mdx +++ b/api_docs/data_autocomplete.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataAutocompleteObj from './data_autocomplete.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Client ### Interfaces diff --git a/api_docs/data_enhanced.mdx b/api_docs/data_enhanced.mdx index 07a00b908e7b26..1e6709794d3c49 100644 --- a/api_docs/data_enhanced.mdx +++ b/api_docs/data_enhanced.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataEnhancedObj from './data_enhanced.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 16 | 0 | 16 | 2 | + ## Client ### Start diff --git a/api_docs/data_field_formats.mdx b/api_docs/data_field_formats.mdx index faeba4ac56454d..c13562eba142df 100644 --- a/api_docs/data_field_formats.mdx +++ b/api_docs/data_field_formats.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataFieldFormatsObj from './data_field_formats.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Client ### Consts, variables and types diff --git a/api_docs/data_index_patterns.json b/api_docs/data_index_patterns.json index af5ddec4809768..056442ee29d668 100644 --- a/api_docs/data_index_patterns.json +++ b/api_docs/data_index_patterns.json @@ -6117,34 +6117,6 @@ "lineNumber": 222 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", - "lineNumber": 11 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", - "lineNumber": 16 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx", - "lineNumber": 25 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx", - "lineNumber": 162 - } - }, { "plugin": "infra", "link": { @@ -6621,6 +6593,20 @@ "lineNumber": 11 } }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", + "lineNumber": 11 + } + }, + { + "plugin": "ml", + "link": { + "path": "x-pack/plugins/ml/public/application/util/field_types_utils.ts", + "lineNumber": 16 + } + }, { "plugin": "ml", "link": { @@ -9532,20 +9518,6 @@ "lineNumber": 11 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx", - "lineNumber": 25 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx", - "lineNumber": 28 - } - }, { "plugin": "infra", "link": { @@ -10155,48 +10127,6 @@ "lineNumber": 57 } }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 14 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 27 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 213 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts", - "lineNumber": 234 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts", - "lineNumber": 12 - } - }, - { - "plugin": "ml", - "link": { - "path": "x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts", - "lineNumber": 17 - } - }, { "plugin": "observability", "link": { diff --git a/api_docs/data_index_patterns.mdx b/api_docs/data_index_patterns.mdx index df226467aefdce..8313619594a753 100644 --- a/api_docs/data_index_patterns.mdx +++ b/api_docs/data_index_patterns.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataIndexPatternsObj from './data_index_patterns.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Server ### Functions diff --git a/api_docs/data_query.mdx b/api_docs/data_query.mdx index ae804971a43194..751cd14dc7c5be 100644 --- a/api_docs/data_query.mdx +++ b/api_docs/data_query.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataQueryObj from './data_query.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Client ### Functions diff --git a/api_docs/data_search.mdx b/api_docs/data_search.mdx index 370bd2ffd101e8..d07be7dfc62aa2 100644 --- a/api_docs/data_search.mdx +++ b/api_docs/data_search.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataSearchObj from './data_search.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Client ### Functions diff --git a/api_docs/data_ui.mdx b/api_docs/data_ui.mdx index 9eedffdce76f61..c31b561bd4c803 100644 --- a/api_docs/data_ui.mdx +++ b/api_docs/data_ui.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import dataUiObj from './data_ui.json'; +Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters. + +Contact [App Services](https://github.com/orgs/elastic/teams/kibana-app-services) for questions regarding this plugin. + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3809 | 107 | 3257 | 75 | + ## Client ### Functions diff --git a/api_docs/data_visualizer.json b/api_docs/data_visualizer.json index b4544a03817909..c965a0a5923ac4 100644 --- a/api_docs/data_visualizer.json +++ b/api_docs/data_visualizer.json @@ -3,7 +3,69 @@ "client": { "classes": [], "functions": [], - "interfaces": [], + "interfaces": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-public.IndexDataVisualizerViewProps", + "type": "Interface", + "tags": [], + "label": "IndexDataVisualizerViewProps", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx", + "lineNumber": 119 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-public.IndexDataVisualizerViewProps.currentIndexPattern", + "type": "Object", + "tags": [], + "label": "currentIndexPattern", + "description": [], + "signature": [ + { + "pluginId": "data", + "scope": "common", + "docId": "kibDataIndexPatternsPluginApi", + "section": "def-common.IndexPattern", + "text": "IndexPattern" + } + ], + "source": { + "path": "x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx", + "lineNumber": 120 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-public.IndexDataVisualizerViewProps.currentSavedSearch", + "type": "CompoundType", + "tags": [], + "label": "currentSavedSearch", + "description": [], + "signature": [ + { + "pluginId": "dataVisualizer", + "scope": "common", + "docId": "kibDataVisualizerPluginApi", + "section": "def-common.SavedSearchSavedObject", + "text": "SavedSearchSavedObject" + }, + " | null" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx", + "lineNumber": 121 + }, + "deprecated": false + } + ], + "initialIsOpen": false + } + ], "enums": [], "misc": [], "objects": [], @@ -15,11 +77,11 @@ "label": "DataVisualizerPluginStart", "description": [], "signature": [ - "{ getFileDataVisualizerComponent: () => Promise>; getMaxBytesFormatted: () => string; }" + "{ getFileDataVisualizerComponent: () => Promise>; getIndexDataVisualizerComponent: () => Promise>; getMaxBytesFormatted: () => string; }" ], "source": { "path": "x-pack/plugins/data_visualizer/public/plugin.ts", - "lineNumber": 33 + "lineNumber": 38 }, "deprecated": false, "lifecycle": "start", @@ -46,8 +108,8 @@ "label": "DataVisualizerTableState", "description": [], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 14 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 19 }, "deprecated": false, "children": [ @@ -59,8 +121,8 @@ "label": "pageSize", "description": [], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 15 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 20 }, "deprecated": false }, @@ -72,8 +134,8 @@ "label": "pageIndex", "description": [], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 16 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 21 }, "deprecated": false }, @@ -85,8 +147,8 @@ "label": "sortField", "description": [], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 17 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 22 }, "deprecated": false }, @@ -98,8 +160,8 @@ "label": "sortDirection", "description": [], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 18 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 23 }, "deprecated": false }, @@ -114,8 +176,8 @@ "string[]" ], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 19 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 24 }, "deprecated": false }, @@ -130,8 +192,8 @@ "string[]" ], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 20 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 25 }, "deprecated": false }, @@ -143,8 +205,579 @@ "label": "showDistributions", "description": [], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 21 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 26 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.DocumentCountBuckets", + "type": "Interface", + "tags": [], + "label": "DocumentCountBuckets", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 22 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-common.DocumentCountBuckets.Unnamed", + "type": "Any", + "tags": [], + "label": "Unnamed", + "description": [], + "signature": [ + "any" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 23 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.DocumentCounts", + "type": "Interface", + "tags": [], + "label": "DocumentCounts", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 26 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-common.DocumentCounts.buckets", + "type": "Object", + "tags": [], + "label": "buckets", + "description": [], + "signature": [ + { + "pluginId": "dataVisualizer", + "scope": "common", + "docId": "kibDataVisualizerPluginApi", + "section": "def-common.DocumentCountBuckets", + "text": "DocumentCountBuckets" + }, + " | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 27 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.DocumentCounts.interval", + "type": "number", + "tags": [], + "label": "interval", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 28 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldRequestConfig", + "type": "Interface", + "tags": [], + "label": "FieldRequestConfig", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 16 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldRequestConfig.fieldName", + "type": "string", + "tags": [], + "label": "fieldName", + "description": [], + "signature": [ + "string | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 17 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldRequestConfig.type", + "type": "CompoundType", + "tags": [], + "label": "type", + "description": [], + "signature": [ + "\"number\" | \"boolean\" | \"date\" | \"keyword\" | \"text\" | \"ip\" | \"geo_point\" | \"geo_shape\" | \"unknown\"" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 18 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldRequestConfig.cardinality", + "type": "number", + "tags": [], + "label": "cardinality", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 19 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats", + "type": "Interface", + "tags": [], + "label": "FieldVisStats", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 31 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.cardinality", + "type": "number", + "tags": [], + "label": "cardinality", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 32 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.count", + "type": "number", + "tags": [], + "label": "count", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 33 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.sampleCount", + "type": "number", + "tags": [], + "label": "sampleCount", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 34 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.trueCount", + "type": "number", + "tags": [], + "label": "trueCount", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 35 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.falseCount", + "type": "number", + "tags": [], + "label": "falseCount", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 36 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.earliest", + "type": "number", + "tags": [], + "label": "earliest", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 37 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.latest", + "type": "number", + "tags": [], + "label": "latest", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 38 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.documentCounts", + "type": "Object", + "tags": [], + "label": "documentCounts", + "description": [], + "signature": [ + "{ buckets?: ", + { + "pluginId": "dataVisualizer", + "scope": "common", + "docId": "kibDataVisualizerPluginApi", + "section": "def-common.DocumentCountBuckets", + "text": "DocumentCountBuckets" + }, + " | undefined; interval?: number | undefined; } | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 39 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.avg", + "type": "number", + "tags": [], + "label": "avg", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 43 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.distribution", + "type": "Object", + "tags": [], + "label": "distribution", + "description": [], + "signature": [ + "{ percentiles: ", + { + "pluginId": "dataVisualizer", + "scope": "common", + "docId": "kibDataVisualizerPluginApi", + "section": "def-common.Percentile", + "text": "Percentile" + }, + "[]; maxPercentile: number; minPercentile: 0; } | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 44 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.fieldName", + "type": "string", + "tags": [], + "label": "fieldName", + "description": [], + "signature": [ + "string | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 49 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.isTopValuesSampled", + "type": "CompoundType", + "tags": [], + "label": "isTopValuesSampled", + "description": [], + "signature": [ + "boolean | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 50 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.max", + "type": "number", + "tags": [], + "label": "max", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 51 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.median", + "type": "number", + "tags": [], + "label": "median", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 52 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.min", + "type": "number", + "tags": [], + "label": "min", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 53 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.topValues", + "type": "Array", + "tags": [], + "label": "topValues", + "description": [], + "signature": [ + "{ key: React.ReactText; doc_count: number; }[] | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 54 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.topValuesSampleSize", + "type": "number", + "tags": [], + "label": "topValuesSampleSize", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 55 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.topValuesSamplerShardSize", + "type": "number", + "tags": [], + "label": "topValuesSamplerShardSize", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 56 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.examples", + "type": "Array", + "tags": [], + "label": "examples", + "description": [], + "signature": [ + "(string | object)[] | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 57 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.timeRangeEarliest", + "type": "number", + "tags": [], + "label": "timeRangeEarliest", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 58 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.FieldVisStats.timeRangeLatest", + "type": "number", + "tags": [], + "label": "timeRangeLatest", + "description": [], + "signature": [ + "number | undefined" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 59 + }, + "deprecated": false + } + ], + "initialIsOpen": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.Percentile", + "type": "Interface", + "tags": [], + "label": "Percentile", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 10 + }, + "deprecated": false, + "children": [ + { + "parentPluginId": "dataVisualizer", + "id": "def-common.Percentile.percent", + "type": "number", + "tags": [], + "label": "percent", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 11 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.Percentile.minValue", + "type": "number", + "tags": [], + "label": "minValue", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 12 + }, + "deprecated": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.Percentile.maxValue", + "type": "number", + "tags": [], + "label": "maxValue", + "description": [], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/field_request_config.ts", + "lineNumber": 13 }, "deprecated": false } @@ -216,8 +849,8 @@ "any[]" ], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 10 + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 17 }, "deprecated": false, "initialIsOpen": false @@ -230,11 +863,11 @@ "label": "JobFieldType", "description": [], "signature": [ - "\"number\" | \"boolean\" | \"date\" | \"text\" | \"keyword\" | \"ip\" | \"geo_point\" | \"geo_shape\" | \"unknown\"" + "\"number\" | \"boolean\" | \"date\" | \"keyword\" | \"text\" | \"ip\" | \"geo_point\" | \"geo_shape\" | \"unknown\"" ], "source": { - "path": "x-pack/plugins/data_visualizer/common/types.ts", - "lineNumber": 12 + "path": "x-pack/plugins/data_visualizer/common/types/job_field_type.ts", + "lineNumber": 9 }, "deprecated": false, "initialIsOpen": false @@ -287,6 +920,47 @@ "deprecated": false, "initialIsOpen": false }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.OMIT_FIELDS", + "type": "Array", + "tags": [], + "label": "OMIT_FIELDS", + "description": [], + "signature": [ + "string[]" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/constants.ts", + "lineNumber": 33 + }, + "deprecated": false, + "initialIsOpen": false + }, + { + "parentPluginId": "dataVisualizer", + "id": "def-common.SavedSearchSavedObject", + "type": "Type", + "tags": [], + "label": "SavedSearchSavedObject", + "description": [], + "signature": [ + { + "pluginId": "core", + "scope": "public", + "docId": "kibCoreSavedObjectsPluginApi", + "section": "def-public.SimpleSavedObject", + "text": "SimpleSavedObject" + }, + "" + ], + "source": { + "path": "x-pack/plugins/data_visualizer/common/types/index.ts", + "lineNumber": 29 + }, + "deprecated": false, + "initialIsOpen": false + }, { "parentPluginId": "dataVisualizer", "id": "def-common.UI_SETTING_MAX_FILE_SIZE", @@ -325,4 +999,4 @@ } ] } -} +} \ No newline at end of file diff --git a/api_docs/data_visualizer.mdx b/api_docs/data_visualizer.mdx index 07d4fc76d448a2..384fd07bd11762 100644 --- a/api_docs/data_visualizer.mdx +++ b/api_docs/data_visualizer.mdx @@ -1,29 +1,42 @@ --- -id: kibFileDataVisualizerPluginApi -slug: /kibana-dev-docs/fileDataVisualizerPluginApi -title: fileDataVisualizer +id: kibDataVisualizerPluginApi +slug: /kibana-dev-docs/dataVisualizerPluginApi +title: dataVisualizer image: https://source.unsplash.com/400x175/?github -summary: API docs for the fileDataVisualizer plugin +summary: API docs for the dataVisualizer plugin date: 2020-11-16 -tags: ['contributor', 'dev', 'apidocs', 'kibana', 'fileDataVisualizer'] +tags: ['contributor', 'dev', 'apidocs', 'kibana', 'dataVisualizer'] warning: This document is auto-generated and is meant to be viewed inside our experimental, new docs system. Reach out in #docs-engineering for more info. --- -import fileDataVisualizerObj from './file_data_visualizer.json'; +import dataVisualizerObj from './data_visualizer.json'; + + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 59 | 1 | 59 | 0 | ## Client ### Start - + + +### Interfaces + ## Common ### Objects - + ### Interfaces - + ### Consts, variables and types - + diff --git a/api_docs/deprecations.mdx b/api_docs/deprecations.mdx index b5fe8d1e31da0a..74dae7faf838a4 100644 --- a/api_docs/deprecations.mdx +++ b/api_docs/deprecations.mdx @@ -111,6 +111,8 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [clone_panel_action.tsx#L14](https://github.com/elastic/kibana/tree/master/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx#L14) | - | | | [clone_panel_action.tsx#L98](https://github.com/elastic/kibana/tree/master/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx#L98) | - | | | [clone_panel_action.tsx#L126](https://github.com/elastic/kibana/tree/master/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx#L126) | - | +| | [use_dashboard_state_manager.ts#L23](https://github.com/elastic/kibana/tree/master/src/plugins/dashboard/public/application/hooks/use_dashboard_state_manager.ts#L23) | - | +| | [use_dashboard_state_manager.ts#L35](https://github.com/elastic/kibana/tree/master/src/plugins/dashboard/public/application/hooks/use_dashboard_state_manager.ts#L35) | - | @@ -127,8 +129,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [search_embeddable.ts#L23](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/application/embeddable/search_embeddable.ts#L23) | - | | | [search_embeddable.ts#L59](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/application/embeddable/search_embeddable.ts#L59) | - | | | [kibana_services.ts#L104](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/kibana_services.ts#L104) | - | -| | [search_embeddable.ts#L23](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/application/embeddable/search_embeddable.ts#L23) | - | -| | [search_embeddable.ts#L59](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/application/embeddable/search_embeddable.ts#L59) | - | | | [kibana_services.ts#L101](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/kibana_services.ts#L101) | - | | | [create_doc_table_react.tsx#L15](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/application/angular/doc_table/create_doc_table_react.tsx#L15) | - | | | [create_doc_table_react.tsx#L25](https://github.com/elastic/kibana/tree/master/src/plugins/discover/public/application/angular/doc_table/create_doc_table_react.tsx#L25) | - | @@ -153,7 +153,7 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | Deprecated API | Reference location | Remove By | | ---------------|-----------|-----------| | | [attribute_service.tsx#L13](https://github.com/elastic/kibana/tree/master/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx#L13) | - | -| | [attribute_service.tsx#L165](https://github.com/elastic/kibana/tree/master/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx#L165) | - | +| | [attribute_service.tsx#L167](https://github.com/elastic/kibana/tree/master/src/plugins/embeddable/public/lib/attribute_service/attribute_service.tsx#L167) | - | @@ -189,7 +189,7 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [query_bar.tsx#L30](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/query_bar.tsx#L30) | - | | | [query_bar.tsx#L38](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/query_bar.tsx#L38) | - | | | [plugin.ts#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/server/plugin.ts#L14) | - | -| | [plugin.ts#L190](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/server/plugin.ts#L190) | - | +| | [plugin.ts#L189](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/server/plugin.ts#L189) | - | | | [plugin.d.ts#L2](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/target/types/server/plugin.d.ts#L2) | - | | | [plugin.d.ts#L84](https://github.com/elastic/kibana/tree/master/x-pack/plugins/fleet/target/types/server/plugin.d.ts#L84) | - | @@ -228,18 +228,18 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | Deprecated API | Reference location | Remove By | | ---------------|-----------|-----------| -| | [plugin.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/plugin.ts#L12) | 7.16 | -| | [plugin.ts#L38](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/plugin.ts#L38) | 7.16 | +| | [plugin.ts#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/plugin.ts#L14) | 7.16 | +| | [plugin.ts#L42](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/plugin.ts#L42) | 7.16 | | | [types.ts#L9](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L9) | 7.16 | -| | [types.ts#L39](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L39) | 7.16 | +| | [types.ts#L40](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L40) | 7.16 | | | [types.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L1) | 7.16 | -| | [types.d.ts#L24](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L24) | 7.16 | +| | [types.d.ts#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L25) | 7.16 | | | [types.ts#L10](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L10) | 7.16 | -| | [types.ts#L42](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L42) | 7.16 | -| | [types.ts#L49](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L49) | 7.16 | +| | [types.ts#L43](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L43) | 7.16 | +| | [types.ts#L50](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/server/types.ts#L50) | 7.16 | | | [types.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L1) | 7.16 | -| | [types.d.ts#L26](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L26) | 7.16 | -| | [types.d.ts#L32](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L32) | 7.16 | +| | [types.d.ts#L27](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L27) | 7.16 | +| | [types.d.ts#L33](https://github.com/elastic/kibana/tree/master/x-pack/plugins/index_management/target/types/server/types.d.ts#L33) | 7.16 | @@ -578,6 +578,11 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [custom_metric_form.d.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/target/types/public/pages/metrics/inventory_view/components/waffle/metric_control/custom_metric_form.d.ts#L8) | - | | | [index.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/target/types/public/pages/metrics/inventory_view/components/waffle/metric_control/index.d.ts#L1) | - | | | [index.d.ts#L9](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/target/types/public/pages/metrics/inventory_view/components/waffle/metric_control/index.d.ts#L9) | - | +| | [log_entry_categories_analysis.ts#L9](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts#L9) | 7.16 | +| | [log_entry_categories_analysis.ts#L139](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts#L139) | 7.16 | +| | [log_entry_categories_analysis.ts#L405](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts#L405) | 7.16 | +| | [log_entry_categories_analysis.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/target/types/server/lib/log_analysis/log_entry_categories_analysis.d.ts#L1) | 7.16 | +| | [log_entry_categories_analysis.d.ts#L58](https://github.com/elastic/kibana/tree/master/x-pack/plugins/infra/target/types/server/lib/log_analysis/log_entry_categories_analysis.d.ts#L58) | 7.16 | @@ -587,8 +592,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | ---------------|-----------|-----------| | | [embeddable.tsx#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.tsx#L14) | - | | | [embeddable.tsx#L85](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.tsx#L85) | - | -| | [index.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx#L25) | - | -| | [index.tsx#L102](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx#L102) | - | | | [field_item.tsx#L47](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx#L47) | - | | | [field_item.tsx#L172](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx#L172) | - | | | [datapanel.tsx#L42](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx#L42) | - | @@ -603,10 +606,10 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [types.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/types.ts#L8) | - | | | [types.ts#L57](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/types.ts#L57) | - | | | [field_stats.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L11) | - | -| | [field_stats.ts#L141](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L141) | - | -| | [field_stats.ts#L250](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L250) | - | -| | [field_stats.ts#L290](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L290) | - | -| | [field_stats.ts#L332](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L332) | - | +| | [field_stats.ts#L139](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L139) | - | +| | [field_stats.ts#L248](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L248) | - | +| | [field_stats.ts#L287](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L287) | - | +| | [field_stats.ts#L329](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L329) | - | | | [types.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/public/indexpattern_datasource/types.d.ts#L1) | - | | | [types.d.ts#L22](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/public/indexpattern_datasource/types.d.ts#L22) | - | | | [field_stats.d.ts#L3](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/server/routes/field_stats.d.ts#L3) | - | @@ -618,10 +621,10 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [types.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/types.ts#L8) | - | | | [types.ts#L57](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/types.ts#L57) | - | | | [field_stats.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L11) | - | -| | [field_stats.ts#L141](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L141) | - | -| | [field_stats.ts#L250](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L250) | - | -| | [field_stats.ts#L290](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L290) | - | -| | [field_stats.ts#L332](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L332) | - | +| | [field_stats.ts#L139](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L139) | - | +| | [field_stats.ts#L248](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L248) | - | +| | [field_stats.ts#L287](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L287) | - | +| | [field_stats.ts#L329](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L329) | - | | | [types.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/public/indexpattern_datasource/types.d.ts#L1) | - | | | [types.d.ts#L22](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/public/indexpattern_datasource/types.d.ts#L22) | - | | | [field_stats.d.ts#L3](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/server/routes/field_stats.d.ts#L3) | - | @@ -630,8 +633,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [field_stats.d.ts#L9](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/server/routes/field_stats.d.ts#L9) | - | | | [embeddable.tsx#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.tsx#L14) | - | | | [embeddable.tsx#L85](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.tsx#L85) | - | -| | [index.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx#L25) | - | -| | [index.tsx#L102](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx#L102) | - | | | [field_item.tsx#L47](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx#L47) | - | | | [field_item.tsx#L172](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/field_item.tsx#L172) | - | | | [datapanel.tsx#L42](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.tsx#L42) | - | @@ -646,10 +647,10 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [types.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/types.ts#L8) | - | | | [types.ts#L57](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/public/indexpattern_datasource/types.ts#L57) | - | | | [field_stats.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L11) | - | -| | [field_stats.ts#L141](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L141) | - | -| | [field_stats.ts#L250](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L250) | - | -| | [field_stats.ts#L290](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L290) | - | -| | [field_stats.ts#L332](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L332) | - | +| | [field_stats.ts#L139](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L139) | - | +| | [field_stats.ts#L248](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L248) | - | +| | [field_stats.ts#L287](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L287) | - | +| | [field_stats.ts#L329](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/server/routes/field_stats.ts#L329) | - | | | [types.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/public/indexpattern_datasource/types.d.ts#L1) | - | | | [types.d.ts#L22](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/public/indexpattern_datasource/types.d.ts#L22) | - | | | [field_stats.d.ts#L3](https://github.com/elastic/kibana/tree/master/x-pack/plugins/lens/target/types/server/routes/field_stats.d.ts#L3) | - | @@ -935,7 +936,7 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | Deprecated API | Reference location | Remove By | | ---------------|-----------|-----------| | | [types.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/embeddable/types.ts#L8) | - | -| | [types.ts#L44](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/embeddable/types.ts#L44) | - | +| | [types.ts#L45](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/embeddable/types.ts#L45) | - | | | [es_doc_field.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts#L12) | - | | | [es_doc_field.ts#L45](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts#L45) | - | | | [es_source.ts#L10](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts#L10) | - | @@ -1125,7 +1126,7 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [get_docvalue_source_fields.test.ts#L10](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/sources/es_search_source/get_docvalue_source_fields.test.ts#L10) | - | | | [get_docvalue_source_fields.test.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/sources/es_search_source/get_docvalue_source_fields.test.ts#L12) | - | | | [types.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/embeddable/types.ts#L8) | - | -| | [types.ts#L44](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/embeddable/types.ts#L44) | - | +| | [types.ts#L45](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/embeddable/types.ts#L45) | - | | | [es_doc_field.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts#L12) | - | | | [es_doc_field.ts#L45](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/fields/es_doc_field.ts#L45) | - | | | [es_source.ts#L10](https://github.com/elastic/kibana/tree/master/x-pack/plugins/maps/public/classes/sources/es_source/es_source.ts#L10) | - | @@ -1250,8 +1251,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [utils.d.ts#L37](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.d.ts#L37) | - | | | [edit_utils.d.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.d.ts#L8) | - | | | [edit_utils.d.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.d.ts#L11) | - | -| | [actions_panel.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx#L25) | - | -| | [actions_panel.tsx#L28](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx#L28) | - | | | [new_job_utils.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts#L11) | - | | | [new_job_utils.ts#L34](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts#L34) | - | | | [exploration_query_bar.tsx#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx#L14) | - | @@ -1260,12 +1259,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [editor.tsx#L62](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/editor.tsx#L62) | - | | | [custom_urls.tsx#L40](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/tabs/custom_urls.tsx#L40) | - | | | [custom_urls.tsx#L57](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/tabs/custom_urls.tsx#L57) | - | -| | [lens_utils.ts#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L14) | - | -| | [lens_utils.ts#L27](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L27) | - | -| | [lens_utils.ts#L213](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L213) | - | -| | [lens_utils.ts#L234](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L234) | - | -| | [actions.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts#L12) | - | -| | [actions.ts#L17](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts#L17) | - | | | [explorer_query_bar.tsx#L17](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/explorer/components/explorer_query_bar/explorer_query_bar.tsx#L17) | - | | | [explorer_query_bar.tsx#L31](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/explorer/components/explorer_query_bar/explorer_query_bar.tsx#L31) | - | | | [explorer_query_bar.tsx#L100](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/explorer/components/explorer_query_bar/explorer_query_bar.tsx#L100) | - | @@ -1275,8 +1268,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [common.ts#L222](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/components/data_grid/common.ts#L222) | - | | | [field_types_utils.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.ts#L11) | - | | | [field_types_utils.ts#L16](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.ts#L16) | - | -| | [page.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx#L25) | - | -| | [page.tsx#L162](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx#L162) | - | | | [field_types_utils.test.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L8) | - | | | [field_types_utils.test.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L19) | - | | | [field_types_utils.test.ts#L40](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L40) | - | @@ -1286,8 +1277,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [common.ts#L222](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/components/data_grid/common.ts#L222) | - | | | [field_types_utils.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.ts#L11) | - | | | [field_types_utils.ts#L16](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.ts#L16) | - | -| | [page.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx#L25) | - | -| | [page.tsx#L162](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx#L162) | - | | | [field_types_utils.test.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L8) | - | | | [field_types_utils.test.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L19) | - | | | [field_types_utils.test.ts#L40](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L40) | - | @@ -1316,8 +1305,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [utils.d.ts#L37](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.d.ts#L37) | - | | | [edit_utils.d.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.d.ts#L8) | - | | | [edit_utils.d.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.d.ts#L11) | - | -| | [actions_panel.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx#L25) | - | -| | [actions_panel.tsx#L28](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/actions_panel/actions_panel.tsx#L28) | - | | | [new_job_utils.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts#L11) | - | | | [new_job_utils.ts#L34](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/new_job/utils/new_job_utils.ts#L34) | - | | | [exploration_query_bar.tsx#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx#L14) | - | @@ -1326,12 +1313,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [editor.tsx#L62](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/editor.tsx#L62) | - | | | [custom_urls.tsx#L40](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/tabs/custom_urls.tsx#L40) | - | | | [custom_urls.tsx#L57](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/tabs/custom_urls.tsx#L57) | - | -| | [lens_utils.ts#L14](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L14) | - | -| | [lens_utils.ts#L27](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L27) | - | -| | [lens_utils.ts#L213](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L213) | - | -| | [lens_utils.ts#L234](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/lens_utils.ts#L234) | - | -| | [actions.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts#L12) | - | -| | [actions.ts#L17](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_row/action_menu/actions.ts#L17) | - | | | [explorer_query_bar.tsx#L17](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/explorer/components/explorer_query_bar/explorer_query_bar.tsx#L17) | - | | | [explorer_query_bar.tsx#L31](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/explorer/components/explorer_query_bar/explorer_query_bar.tsx#L31) | - | | | [explorer_query_bar.tsx#L100](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/explorer/components/explorer_query_bar/explorer_query_bar.tsx#L100) | - | @@ -1341,8 +1322,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [common.ts#L222](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/components/data_grid/common.ts#L222) | - | | | [field_types_utils.ts#L11](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.ts#L11) | - | | | [field_types_utils.ts#L16](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.ts#L16) | - | -| | [page.tsx#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx#L25) | - | -| | [page.tsx#L162](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/datavisualizer/index_based/page.tsx#L162) | - | | | [field_types_utils.test.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L8) | - | | | [field_types_utils.test.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L19) | - | | | [field_types_utils.test.ts#L40](https://github.com/elastic/kibana/tree/master/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts#L40) | - | @@ -1382,7 +1361,7 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [static_globals.ts#L43](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/server/static_globals.ts#L43) | 7.16 | | | [plugin.ts#L18](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/server/plugin.ts#L18) | 7.16 | | | [plugin.ts#L74](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/server/plugin.ts#L74) | 7.16 | -| | [plugin.ts#L284](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/server/plugin.ts#L284) | 7.16 | +| | [plugin.ts#L279](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/server/plugin.ts#L279) | 7.16 | | | [types.d.ts#L2](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/target/types/server/types.d.ts#L2) | 7.16 | | | [types.d.ts#L47](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/target/types/server/types.d.ts#L47) | 7.16 | | | [plugin.d.ts#L1](https://github.com/elastic/kibana/tree/master/x-pack/plugins/monitoring/target/types/server/plugin.d.ts#L1) | 7.16 | @@ -1471,22 +1450,22 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | Deprecated API | Reference location | Remove By | | ---------------|-----------|-----------| -| | [types.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L19) | - | -| | [types.ts#L104](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L104) | - | +| | [types.ts#L18](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L18) | - | +| | [types.ts#L95](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L95) | - | | | [utils.ts#L10](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L10) | - | | | [utils.ts#L53](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L53) | - | | | [utils.ts#L61](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L61) | - | | | [utils.ts#L69](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L69) | - | | | [default_configs.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts#L19) | - | -| | [default_configs.ts#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts#L25) | - | -| | [types.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L19) | - | -| | [types.ts#L104](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L104) | - | +| | [default_configs.ts#L24](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts#L24) | - | +| | [types.ts#L18](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L18) | - | +| | [types.ts#L95](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts#L95) | - | | | [utils.ts#L10](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L10) | - | | | [utils.ts#L53](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L53) | - | | | [utils.ts#L61](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L61) | - | | | [utils.ts#L69](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/utils.ts#L69) | - | | | [default_configs.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts#L19) | - | -| | [default_configs.ts#L25](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts#L25) | - | +| | [default_configs.ts#L24](https://github.com/elastic/kibana/tree/master/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts#L24) | - | @@ -1562,9 +1541,9 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | Deprecated API | Reference location | Remove By | | ---------------|-----------|-----------| -| | [types.ts#L22](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L22) | - | -| | [types.ts#L72](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L72) | - | -| | [action.ts#L20](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts#L20) | - | +| | [types.ts#L21](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L21) | - | +| | [types.ts#L66](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L66) | - | +| | [action.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts#L19) | - | | | [action.ts#L100](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts#L100) | - | | | [index.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/common/search_strategy/index_fields/index.ts#L8) | - | | | [index.ts#L86](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/common/search_strategy/index_fields/index.ts#L86) | - | @@ -1601,9 +1580,9 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [types.ts#L41](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/network/pages/details/types.ts#L41) | - | | | [index.tsx#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx#L12) | - | | | [index.tsx#L34](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx#L34) | - | -| | [middleware.ts#L48](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L48) | - | -| | [middleware.ts#L64](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L64) | - | -| | [middleware.ts#L69](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L69) | - | +| | [middleware.ts#L44](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L44) | - | +| | [middleware.ts#L60](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L60) | - | +| | [middleware.ts#L65](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L65) | - | | | [types.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts#L12) | - | | | [types.ts#L28](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts#L28) | - | | | [index.tsx#L15](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx#L15) | - | @@ -1658,8 +1637,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [use_field_value_autocomplete.ts#L31](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/components/autocomplete/hooks/use_field_value_autocomplete.ts#L31) | - | | | [field_value_match.tsx#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_match.tsx#L19) | - | | | [field_value_match.tsx#L30](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_match.tsx#L30) | - | -| | [query.ts#L13](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/server/lib/detection_engine/reference_rules/query.ts#L13) | - | -| | [query.ts#L52](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/server/lib/detection_engine/reference_rules/query.ts#L52) | - | | | [model.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/store/sourcerer/model.ts#L8) | - | | | [model.ts#L30](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/store/sourcerer/model.ts#L30) | - | | | [index.tsx#L33](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/severity_mapping/index.tsx#L33) | - | @@ -1776,9 +1753,9 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [index.tsx#L242](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/risk_score_mapping/index.tsx#L242) | - | | | [index.tsx#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/autocomplete_field/index.tsx#L12) | - | | | [index.tsx#L35](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/autocomplete_field/index.tsx#L35) | - | -| | [types.ts#L22](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L22) | - | -| | [types.ts#L72](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L72) | - | -| | [action.ts#L20](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts#L20) | - | +| | [types.ts#L21](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L21) | - | +| | [types.ts#L66](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/types.ts#L66) | - | +| | [action.ts#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts#L19) | - | | | [action.ts#L100](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/action.ts#L100) | - | | | [index.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/common/search_strategy/index_fields/index.ts#L8) | - | | | [index.ts#L86](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/common/search_strategy/index_fields/index.ts#L86) | - | @@ -1815,9 +1792,9 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [types.ts#L41](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/network/pages/details/types.ts#L41) | - | | | [index.tsx#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx#L12) | - | | | [index.tsx#L34](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/network/components/network_top_countries_table/index.tsx#L34) | - | -| | [middleware.ts#L48](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L48) | - | -| | [middleware.ts#L64](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L64) | - | -| | [middleware.ts#L69](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L69) | - | +| | [middleware.ts#L44](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L44) | - | +| | [middleware.ts#L60](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L60) | - | +| | [middleware.ts#L65](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts#L65) | - | | | [types.ts#L12](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts#L12) | - | | | [types.ts#L28](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/description_step/types.ts#L28) | - | | | [index.tsx#L15](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx#L15) | - | @@ -1872,8 +1849,6 @@ warning: This document is auto-generated and is meant to be viewed inside our ex | | [use_field_value_autocomplete.ts#L31](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/components/autocomplete/hooks/use_field_value_autocomplete.ts#L31) | - | | | [field_value_match.tsx#L19](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_match.tsx#L19) | - | | | [field_value_match.tsx#L30](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_match.tsx#L30) | - | -| | [query.ts#L13](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/server/lib/detection_engine/reference_rules/query.ts#L13) | - | -| | [query.ts#L52](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/server/lib/detection_engine/reference_rules/query.ts#L52) | - | | | [model.ts#L8](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/store/sourcerer/model.ts#L8) | - | | | [model.ts#L30](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/common/store/sourcerer/model.ts#L30) | - | | | [index.tsx#L33](https://github.com/elastic/kibana/tree/master/x-pack/plugins/security_solution/public/detections/components/rules/severity_mapping/index.tsx#L33) | - | diff --git a/api_docs/dev_tools.mdx b/api_docs/dev_tools.mdx index 63abb581b1d3ec..89d67f54866f23 100644 --- a/api_docs/dev_tools.mdx +++ b/api_docs/dev_tools.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import devToolsObj from './dev_tools.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 10 | 0 | 8 | 2 | + ## Client ### Setup diff --git a/api_docs/discover.mdx b/api_docs/discover.mdx index b5f6cefde7cc42..d4720530b58487 100644 --- a/api_docs/discover.mdx +++ b/api_docs/discover.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import discoverObj from './discover.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 64 | 0 | 51 | 6 | + ## Client ### Setup diff --git a/api_docs/discover_enhanced.mdx b/api_docs/discover_enhanced.mdx index 06037e1190c0d8..fb8842cd56bfed 100644 --- a/api_docs/discover_enhanced.mdx +++ b/api_docs/discover_enhanced.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import discoverEnhancedObj from './discover_enhanced.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 39 | 0 | 37 | 2 | + ## Client ### Classes diff --git a/api_docs/embeddable.mdx b/api_docs/embeddable.mdx index eafc8543b7ce13..46a877be6ac243 100644 --- a/api_docs/embeddable.mdx +++ b/api_docs/embeddable.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import embeddableObj from './embeddable.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 449 | 4 | 379 | 3 | + ## Client ### Setup diff --git a/api_docs/embeddable_enhanced.mdx b/api_docs/embeddable_enhanced.mdx index 58800f0e7d3435..8680c6807bbcaa 100644 --- a/api_docs/embeddable_enhanced.mdx +++ b/api_docs/embeddable_enhanced.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import embeddableEnhancedObj from './embeddable_enhanced.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 14 | 0 | 14 | 0 | + ## Client ### Setup diff --git a/api_docs/encrypted_saved_objects.mdx b/api_docs/encrypted_saved_objects.mdx index 654427d83c3598..e152ec4aec9a85 100644 --- a/api_docs/encrypted_saved_objects.mdx +++ b/api_docs/encrypted_saved_objects.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import encryptedSavedObjectsObj from './encrypted_saved_objects.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 30 | 0 | 28 | 3 | + ## Server ### Setup diff --git a/api_docs/enterprise_search.mdx b/api_docs/enterprise_search.mdx index 1f9dfaae078f40..8156918dcefe49 100644 --- a/api_docs/enterprise_search.mdx +++ b/api_docs/enterprise_search.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import enterpriseSearchObj from './enterprise_search.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 2 | 0 | 2 | 0 | + ## Server ### Objects diff --git a/api_docs/es_ui_shared.mdx b/api_docs/es_ui_shared.mdx index 2fd04e135e3fd3..e317299f0b48aa 100644 --- a/api_docs/es_ui_shared.mdx +++ b/api_docs/es_ui_shared.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import esUiSharedObj from './es_ui_shared.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 88 | 4 | 86 | 1 | + ## Client ### Objects diff --git a/api_docs/event_log.mdx b/api_docs/event_log.mdx index 6948a63cf85c93..409d6ad6d21c29 100644 --- a/api_docs/event_log.mdx +++ b/api_docs/event_log.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import eventLogObj from './event_log.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 70 | 0 | 70 | 4 | + ## Server ### Setup diff --git a/api_docs/expressions.mdx b/api_docs/expressions.mdx index a57e91bf2a333b..e0544d866766ed 100644 --- a/api_docs/expressions.mdx +++ b/api_docs/expressions.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import expressionsObj from './expressions.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 1871 | 57 | 1444 | 5 | + ## Client ### Setup diff --git a/api_docs/features.mdx b/api_docs/features.mdx index 99776f69301592..377945d852ddd6 100644 --- a/api_docs/features.mdx +++ b/api_docs/features.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import featuresObj from './features.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 215 | 0 | 97 | 2 | + ## Client ### Setup diff --git a/api_docs/file_upload.mdx b/api_docs/file_upload.mdx index aa4af1121e1183..acd0ed52e41826 100644 --- a/api_docs/file_upload.mdx +++ b/api_docs/file_upload.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import fileUploadObj from './file_upload.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 128 | 4 | 128 | 1 | + ## Client ### Start diff --git a/api_docs/fleet.mdx b/api_docs/fleet.mdx index 1388184f7a9480..2113069fe47e07 100644 --- a/api_docs/fleet.mdx +++ b/api_docs/fleet.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import fleetObj from './fleet.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 1071 | 15 | 981 | 8 | + ## Client ### Setup diff --git a/api_docs/global_search.mdx b/api_docs/global_search.mdx index 2e88a252eb35dd..041b9aba8ec7c8 100644 --- a/api_docs/global_search.mdx +++ b/api_docs/global_search.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import globalSearchObj from './global_search.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 68 | 0 | 14 | 5 | + ## Client ### Setup diff --git a/api_docs/home.mdx b/api_docs/home.mdx index 0a8bac237b045b..23c58467b6a986 100644 --- a/api_docs/home.mdx +++ b/api_docs/home.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import homeObj from './home.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 89 | 0 | 65 | 5 | + ## Client ### Setup diff --git a/api_docs/index_lifecycle_management.mdx b/api_docs/index_lifecycle_management.mdx index f6aff00be5c616..a16206ad3d3610 100644 --- a/api_docs/index_lifecycle_management.mdx +++ b/api_docs/index_lifecycle_management.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import indexLifecycleManagementObj from './index_lifecycle_management.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 5 | 0 | 5 | 0 | + ## Client ### Interfaces diff --git a/api_docs/index_management.mdx b/api_docs/index_management.mdx index 0f22d279f7ecf9..9190012ac0b293 100644 --- a/api_docs/index_management.mdx +++ b/api_docs/index_management.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import indexManagementObj from './index_management.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 162 | 12 | 157 | 3 | + ## Client ### Functions diff --git a/api_docs/index_pattern_field_editor.mdx b/api_docs/index_pattern_field_editor.mdx index 7c057e8706f7de..1627a18e66724a 100644 --- a/api_docs/index_pattern_field_editor.mdx +++ b/api_docs/index_pattern_field_editor.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import indexPatternFieldEditorObj from './index_pattern_field_editor.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 31 | 1 | 29 | 4 | + ## Client ### Start diff --git a/api_docs/index_pattern_management.mdx b/api_docs/index_pattern_management.mdx index b74d3a7262870a..7d82efb213ff1c 100644 --- a/api_docs/index_pattern_management.mdx +++ b/api_docs/index_pattern_management.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import indexPatternManagementObj from './index_pattern_management.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 46 | 0 | 46 | 4 | + ## Client ### Setup diff --git a/api_docs/infra.mdx b/api_docs/infra.mdx index 83eb9982628644..0a13dcdfb5bcca 100644 --- a/api_docs/infra.mdx +++ b/api_docs/infra.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import infraObj from './infra.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 23 | 0 | 20 | 4 | + ## Client ### Objects diff --git a/api_docs/ingest_pipelines.mdx b/api_docs/ingest_pipelines.mdx index eb56280c5b4ae5..25bdbceda4eadd 100644 --- a/api_docs/ingest_pipelines.mdx +++ b/api_docs/ingest_pipelines.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import ingestPipelinesObj from './ingest_pipelines.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 9 | 0 | 9 | 4 | + ## Client ### Classes diff --git a/api_docs/inspector.mdx b/api_docs/inspector.mdx index 1fe62ba63e26e3..d69ef22ce788ad 100644 --- a/api_docs/inspector.mdx +++ b/api_docs/inspector.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import inspectorObj from './inspector.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 101 | 6 | 78 | 4 | + ## Client ### Setup diff --git a/api_docs/kibana_legacy.mdx b/api_docs/kibana_legacy.mdx index 208cb8013d063b..5cd9244f0ea57f 100644 --- a/api_docs/kibana_legacy.mdx +++ b/api_docs/kibana_legacy.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import kibanaLegacyObj from './kibana_legacy.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 93 | 3 | 85 | 1 | + ## Client ### Functions diff --git a/api_docs/kibana_react.mdx b/api_docs/kibana_react.mdx index f4a5cf71d6a3d8..da356108593a14 100644 --- a/api_docs/kibana_react.mdx +++ b/api_docs/kibana_react.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import kibanaReactObj from './kibana_react.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 245 | 1 | 216 | 4 | + ## Client ### Objects diff --git a/api_docs/kibana_utils.mdx b/api_docs/kibana_utils.mdx index 9a9001af4b1f0c..a76992e0bc2b89 100644 --- a/api_docs/kibana_utils.mdx +++ b/api_docs/kibana_utils.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import kibanaUtilsObj from './kibana_utils.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 551 | 5 | 373 | 8 | + ## Client ### Objects diff --git a/api_docs/lens.mdx b/api_docs/lens.mdx index 8e9369253c2e34..8c47be1b5897ca 100644 --- a/api_docs/lens.mdx +++ b/api_docs/lens.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import lensObj from './lens.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 172 | 0 | 161 | 16 | + ## Client ### Interfaces diff --git a/api_docs/license_api_guard.mdx b/api_docs/license_api_guard.mdx index d11b92e9bbc145..a2859cc03f8775 100644 --- a/api_docs/license_api_guard.mdx +++ b/api_docs/license_api_guard.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import licenseApiGuardObj from './license_api_guard.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 8 | 0 | 8 | 0 | + ## Server ### Classes diff --git a/api_docs/license_management.mdx b/api_docs/license_management.mdx index 8fde04390ebf08..b198e83acebf35 100644 --- a/api_docs/license_management.mdx +++ b/api_docs/license_management.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import licenseManagementObj from './license_management.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 3 | 0 | 3 | 0 | + ## Client ### Setup diff --git a/api_docs/licensing.mdx b/api_docs/licensing.mdx index 695734b79f4934..af26b10762d273 100644 --- a/api_docs/licensing.mdx +++ b/api_docs/licensing.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import licensingObj from './licensing.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 120 | 0 | 44 | 8 | + ## Client ### Setup diff --git a/api_docs/lists.mdx b/api_docs/lists.mdx index 8ef77a85fb548e..47b1bde5c07822 100644 --- a/api_docs/lists.mdx +++ b/api_docs/lists.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import listsObj from './lists.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 151 | 0 | 143 | 38 | + ## Client ### Setup diff --git a/api_docs/management.mdx b/api_docs/management.mdx index 16e097a6158e6a..22586c7b58b494 100644 --- a/api_docs/management.mdx +++ b/api_docs/management.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import managementObj from './management.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 38 | 0 | 38 | 4 | + ## Client ### Setup diff --git a/api_docs/maps.mdx b/api_docs/maps.mdx index f4f5594b193471..efa7ddb5fddf58 100644 --- a/api_docs/maps.mdx +++ b/api_docs/maps.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import mapsObj from './maps.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 196 | 2 | 195 | 11 | + ## Client ### Start diff --git a/api_docs/maps_ems.mdx b/api_docs/maps_ems.mdx index 5907add0c54659..0abd9d511cf90c 100644 --- a/api_docs/maps_ems.mdx +++ b/api_docs/maps_ems.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import mapsEmsObj from './maps_ems.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 75 | 1 | 75 | 0 | + ## Client ### Setup diff --git a/api_docs/metrics_entities.mdx b/api_docs/metrics_entities.mdx index 19a27636511c3c..182a78cd0ddc1b 100644 --- a/api_docs/metrics_entities.mdx +++ b/api_docs/metrics_entities.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import metricsEntitiesObj from './metrics_entities.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 9 | 0 | 6 | 1 | + ## Server ### Setup diff --git a/api_docs/ml.mdx b/api_docs/ml.mdx index abb03511bbcaa7..4a9b98a3268373 100644 --- a/api_docs/ml.mdx +++ b/api_docs/ml.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import mlObj from './ml.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 274 | 10 | 270 | 32 | + ## Client ### Start diff --git a/api_docs/monitoring.mdx b/api_docs/monitoring.mdx index 4c32b1c933c930..e3dd2a0bbb6a5d 100644 --- a/api_docs/monitoring.mdx +++ b/api_docs/monitoring.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import monitoringObj from './monitoring.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 10 | 0 | 10 | 2 | + ## Server ### Setup diff --git a/api_docs/navigation.mdx b/api_docs/navigation.mdx index d9dc1703ed4d86..b8b6f82162916a 100644 --- a/api_docs/navigation.mdx +++ b/api_docs/navigation.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import navigationObj from './navigation.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 31 | 0 | 31 | 2 | + ## Client ### Setup diff --git a/api_docs/newsfeed.mdx b/api_docs/newsfeed.mdx index cb5c264e1940c7..0c3fe2bbc6640a 100644 --- a/api_docs/newsfeed.mdx +++ b/api_docs/newsfeed.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import newsfeedObj from './newsfeed.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 17 | 0 | 17 | 0 | + ## Client ### Setup diff --git a/api_docs/observability.mdx b/api_docs/observability.mdx index 353e65b0fa0808..6787e3f0238c87 100644 --- a/api_docs/observability.mdx +++ b/api_docs/observability.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import observabilityObj from './observability.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 194 | 0 | 194 | 10 | + ## Client ### Setup diff --git a/api_docs/osquery.mdx b/api_docs/osquery.mdx index 8638e916107a4a..a981f8f4b8c658 100644 --- a/api_docs/osquery.mdx +++ b/api_docs/osquery.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import osqueryObj from './osquery.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 10 | 0 | 10 | 0 | + ## Client ### Setup diff --git a/api_docs/presentation_util.mdx b/api_docs/presentation_util.mdx index 9416a74b8f42c1..3df30c54e4390b 100644 --- a/api_docs/presentation_util.mdx +++ b/api_docs/presentation_util.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import presentationUtilObj from './presentation_util.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 125 | 1 | 121 | 3 | + ## Client ### Setup diff --git a/api_docs/remote_clusters.mdx b/api_docs/remote_clusters.mdx index a669a858ba6be1..166aeee82153e1 100644 --- a/api_docs/remote_clusters.mdx +++ b/api_docs/remote_clusters.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import remoteClustersObj from './remote_clusters.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 4 | 0 | 4 | 0 | + ## Client ### Setup diff --git a/api_docs/reporting.mdx b/api_docs/reporting.mdx index 445d38e4ec71b8..f349b223ddf97c 100644 --- a/api_docs/reporting.mdx +++ b/api_docs/reporting.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import reportingObj from './reporting.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 133 | 1 | 132 | 19 | + ## Client ### Start diff --git a/api_docs/rollup.mdx b/api_docs/rollup.mdx index 3216c8cd968952..7a7765dfe1584a 100644 --- a/api_docs/rollup.mdx +++ b/api_docs/rollup.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import rollupObj from './rollup.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 20 | 0 | 20 | 0 | + ## Common ### Objects diff --git a/api_docs/rule_registry.mdx b/api_docs/rule_registry.mdx index 964d29594d3c66..a0171607e8eebd 100644 --- a/api_docs/rule_registry.mdx +++ b/api_docs/rule_registry.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import ruleRegistryObj from './rule_registry.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 43 | 0 | 43 | 6 | + ## Server ### Setup diff --git a/api_docs/runtime_fields.mdx b/api_docs/runtime_fields.mdx index a1d1b548350eec..2b9585f558ad5a 100644 --- a/api_docs/runtime_fields.mdx +++ b/api_docs/runtime_fields.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import runtimeFieldsObj from './runtime_fields.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 24 | 0 | 19 | 2 | + ## Client ### Setup diff --git a/api_docs/saved_objects.mdx b/api_docs/saved_objects.mdx index 01d7f9fce991fc..66579c3e3b0ca7 100644 --- a/api_docs/saved_objects.mdx +++ b/api_docs/saved_objects.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import savedObjectsObj from './saved_objects.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 211 | 3 | 197 | 5 | + ## Client ### Setup diff --git a/api_docs/saved_objects_management.mdx b/api_docs/saved_objects_management.mdx index 916288f934b575..0ee0660609f14d 100644 --- a/api_docs/saved_objects_management.mdx +++ b/api_docs/saved_objects_management.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import savedObjectsManagementObj from './saved_objects_management.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 96 | 0 | 85 | 0 | + ## Client ### Setup diff --git a/api_docs/saved_objects_tagging.mdx b/api_docs/saved_objects_tagging.mdx index 52a8b19a8300bc..fe1d90171a2c17 100644 --- a/api_docs/saved_objects_tagging.mdx +++ b/api_docs/saved_objects_tagging.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import savedObjectsTaggingObj from './saved_objects_tagging.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 54 | 0 | 50 | 0 | + ## Client ### Start diff --git a/api_docs/saved_objects_tagging_oss.mdx b/api_docs/saved_objects_tagging_oss.mdx index 921ee5240bfe8b..6fe8b4c6d46981 100644 --- a/api_docs/saved_objects_tagging_oss.mdx +++ b/api_docs/saved_objects_tagging_oss.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import savedObjectsTaggingOssObj from './saved_objects_tagging_oss.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 89 | 3 | 50 | 0 | + ## Client ### Setup diff --git a/api_docs/screenshot_mode.mdx b/api_docs/screenshot_mode.mdx index cdb70b22b0837c..a098e5f296d69d 100644 --- a/api_docs/screenshot_mode.mdx +++ b/api_docs/screenshot_mode.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import screenshotModeObj from './screenshot_mode.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 21 | 0 | 16 | 1 | + ## Client ### Setup diff --git a/api_docs/security.mdx b/api_docs/security.mdx index 250ceff429207b..e31fa44014c941 100644 --- a/api_docs/security.mdx +++ b/api_docs/security.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import securityObj from './security.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 95 | 0 | 45 | 11 | + ## Client ### Setup diff --git a/api_docs/security_oss.mdx b/api_docs/security_oss.mdx index f8c49a56551cd3..ada97232ffe846 100644 --- a/api_docs/security_oss.mdx +++ b/api_docs/security_oss.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import securityOssObj from './security_oss.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 12 | 0 | 9 | 3 | + ## Client ### Setup diff --git a/api_docs/security_solution.mdx b/api_docs/security_solution.mdx index b38a877f7edd56..0667a98e3762bf 100644 --- a/api_docs/security_solution.mdx +++ b/api_docs/security_solution.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import securitySolutionObj from './security_solution.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 32 | 0 | 32 | 6 | + ## Client ### Setup diff --git a/api_docs/share.mdx b/api_docs/share.mdx index e2a9da26c0fc46..58886148bd4a7b 100644 --- a/api_docs/share.mdx +++ b/api_docs/share.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import shareObj from './share.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 67 | 1 | 61 | 4 | + ## Client ### Setup diff --git a/api_docs/snapshot_restore.mdx b/api_docs/snapshot_restore.mdx index a0fc3231baf4d9..ab2f9175987378 100644 --- a/api_docs/snapshot_restore.mdx +++ b/api_docs/snapshot_restore.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import snapshotRestoreObj from './snapshot_restore.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 22 | 1 | 22 | 1 | + ## Common ### Objects diff --git a/api_docs/spaces.mdx b/api_docs/spaces.mdx index ccaffdd3748b55..197fe460b47d35 100644 --- a/api_docs/spaces.mdx +++ b/api_docs/spaces.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import spacesObj from './spaces.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 96 | 0 | 0 | 0 | + ## Client ### Setup diff --git a/api_docs/spaces_oss.mdx b/api_docs/spaces_oss.mdx index e889a319f5f23c..b36b0b4c19aff4 100644 --- a/api_docs/spaces_oss.mdx +++ b/api_docs/spaces_oss.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import spacesOssObj from './spaces_oss.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 71 | 0 | 5 | 0 | + ## Client ### Setup diff --git a/api_docs/stack_alerts.mdx b/api_docs/stack_alerts.mdx index 9fbed513491dd0..eefe0a2dc76fe7 100644 --- a/api_docs/stack_alerts.mdx +++ b/api_docs/stack_alerts.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import stackAlertsObj from './stack_alerts.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 4 | 0 | 4 | 0 | + ## Server ### Consts, variables and types diff --git a/api_docs/task_manager.mdx b/api_docs/task_manager.mdx index b143323bf1c7a5..5c6d5b3d08ba48 100644 --- a/api_docs/task_manager.mdx +++ b/api_docs/task_manager.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import taskManagerObj from './task_manager.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 44 | 0 | 18 | 7 | + ## Server ### Setup diff --git a/api_docs/telemetry.mdx b/api_docs/telemetry.mdx index 995c9b22e268ab..f8d632c0d97082 100644 --- a/api_docs/telemetry.mdx +++ b/api_docs/telemetry.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import telemetryObj from './telemetry.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 42 | 0 | 0 | 0 | + ## Client ### Setup diff --git a/api_docs/telemetry_collection_manager.mdx b/api_docs/telemetry_collection_manager.mdx index d112897e1c4899..749ec3ba2bd71e 100644 --- a/api_docs/telemetry_collection_manager.mdx +++ b/api_docs/telemetry_collection_manager.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import telemetryCollectionManagerObj from './telemetry_collection_manager.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 29 | 0 | 29 | 4 | + ## Server ### Setup diff --git a/api_docs/telemetry_collection_xpack.mdx b/api_docs/telemetry_collection_xpack.mdx index 058a9d3fcb460e..53914260b037f3 100644 --- a/api_docs/telemetry_collection_xpack.mdx +++ b/api_docs/telemetry_collection_xpack.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import telemetryCollectionXpackObj from './telemetry_collection_xpack.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 1 | 0 | 1 | 0 | + ## Server ### Consts, variables and types diff --git a/api_docs/telemetry_management_section.mdx b/api_docs/telemetry_management_section.mdx index 78193e3485c591..71831a66284fc5 100644 --- a/api_docs/telemetry_management_section.mdx +++ b/api_docs/telemetry_management_section.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import telemetryManagementSectionObj from './telemetry_management_section.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 14 | 0 | 13 | 0 | + ## Client ### Setup diff --git a/api_docs/timelines.mdx b/api_docs/timelines.mdx index cb16e39419a438..e9d4a75e39991a 100644 --- a/api_docs/timelines.mdx +++ b/api_docs/timelines.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import timelinesObj from './timelines.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 6 | 0 | 6 | 1 | + ## Client ### Setup diff --git a/api_docs/triggers_actions_ui.mdx b/api_docs/triggers_actions_ui.mdx index 50a7a11abdf16c..91327ad1f990f3 100644 --- a/api_docs/triggers_actions_ui.mdx +++ b/api_docs/triggers_actions_ui.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import triggersActionsUiObj from './triggers_actions_ui.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 237 | 1 | 228 | 19 | + ## Client ### Setup diff --git a/api_docs/ui_actions.mdx b/api_docs/ui_actions.mdx index 9833f2a19e63ac..9045dc736bb2f8 100644 --- a/api_docs/ui_actions.mdx +++ b/api_docs/ui_actions.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import uiActionsObj from './ui_actions.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 127 | 0 | 88 | 11 | + ## Client ### Setup diff --git a/api_docs/ui_actions_enhanced.mdx b/api_docs/ui_actions_enhanced.mdx index 285232bf3fe0cd..3e9c9247532290 100644 --- a/api_docs/ui_actions_enhanced.mdx +++ b/api_docs/ui_actions_enhanced.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import uiActionsEnhancedObj from './ui_actions_enhanced.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 205 | 2 | 147 | 10 | + ## Client ### Setup diff --git a/api_docs/uptime.mdx b/api_docs/uptime.mdx index 8d63edcd18ecad..ceb7d854a8fecc 100644 --- a/api_docs/uptime.mdx +++ b/api_docs/uptime.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import uptimeObj from './uptime.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 6 | 0 | 6 | 3 | + ## Server ### Functions diff --git a/api_docs/url_forwarding.mdx b/api_docs/url_forwarding.mdx index a80a1e0e53f277..b457ca9eb331fa 100644 --- a/api_docs/url_forwarding.mdx +++ b/api_docs/url_forwarding.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import urlForwardingObj from './url_forwarding.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 15 | 0 | 15 | 0 | + ## Client ### Classes diff --git a/api_docs/usage_collection.mdx b/api_docs/usage_collection.mdx index 62db0389c2d5cd..197cfc72f17afb 100644 --- a/api_docs/usage_collection.mdx +++ b/api_docs/usage_collection.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import usageCollectionObj from './usage_collection.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 57 | 0 | 16 | 2 | + ## Client ### Setup diff --git a/api_docs/vis_type_timeseries.mdx b/api_docs/vis_type_timeseries.mdx index 041d01196bad9d..a904e00ef0efc5 100644 --- a/api_docs/vis_type_timeseries.mdx +++ b/api_docs/vis_type_timeseries.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import visTypeTimeseriesObj from './vis_type_timeseries.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 10 | 1 | 10 | 3 | + ## Server ### Setup diff --git a/api_docs/visualizations.mdx b/api_docs/visualizations.mdx index d3834b2d5f83f8..c6d9bdc741d4af 100644 --- a/api_docs/visualizations.mdx +++ b/api_docs/visualizations.mdx @@ -11,6 +11,16 @@ warning: This document is auto-generated and is meant to be viewed inside our ex import visualizationsObj from './visualizations.json'; + + + + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| 246 | 13 | 228 | 12 | + ## Client ### Setup diff --git a/docs/api/alerting/list_rule_types.asciidoc b/docs/api/alerting/list_rule_types.asciidoc index 98016c8cf82fa9..31c8416e750593 100644 --- a/docs/api/alerting/list_rule_types.asciidoc +++ b/docs/api/alerting/list_rule_types.asciidoc @@ -8,7 +8,7 @@ Retrieve a list of alerting rule types that the user is authorized to access. Each rule type includes a list of consumer features. Within these features, users are authorized to perform either `read` or `all` operations on rules of that type. This helps determine which rule types users can read, but not create or modify. -NOTE: Some rule types are limited to specific features. These rule types are not available when <> in <>. +NOTE: Some rule types are limited to specific features. These rule types are not available when <> in <>. [[list-rule-types-api-request]] ==== Request diff --git a/docs/apm/apm-alerts.asciidoc b/docs/apm/apm-alerts.asciidoc index b4afc2788895ce..3e3e2b178ff10b 100644 --- a/docs/apm/apm-alerts.asciidoc +++ b/docs/apm/apm-alerts.asciidoc @@ -15,7 +15,7 @@ and enables central management of all alerts from <>. +see Kibana's <>. The APM app supports four different types of alerts: @@ -126,4 +126,4 @@ See {kibana-ref}/alerting-getting-started.html[alerting and actions] for more in NOTE: If you are using an **on-premise** Elastic Stack deployment with security, communication between Elasticsearch and Kibana must have TLS configured. -More information is in the alerting {kibana-ref}/alerting-getting-started.html#alerting-setup-prerequisites[prerequisites]. \ No newline at end of file +More information is in the alerting {kibana-ref}/alerting-setup.html#alerting-prerequisites[prerequisites]. \ No newline at end of file diff --git a/docs/canvas/canvas-function-reference.asciidoc b/docs/canvas/canvas-function-reference.asciidoc index 67210c9d77057e..272cd524c2c200 100644 --- a/docs/canvas/canvas-function-reference.asciidoc +++ b/docs/canvas/canvas-function-reference.asciidoc @@ -2893,6 +2893,33 @@ Alias: `type` [[u_fns]] == U +[float] +[[uiSetting_fn]] +=== `uiSetting` + +Returns a UI settings parameter value. + +*Accepts:* `null` + +[cols="3*^<"] +|=== +|Argument |Type |Description + +|_Unnamed_ *** + +Aliases: `parameter` +|`string` +|The parameter name. + +|`default` +|`any` +|A default value in case of the parameter is not set. + +Default: `null` +|=== + +*Returns:* `ui_setting` + [float] [[urlparam_fn]] === `urlparam` diff --git a/docs/developer/getting-started/monorepo-packages.asciidoc b/docs/developer/getting-started/monorepo-packages.asciidoc index 029ee9ea4faf6c..0ae806618adc5d 100644 --- a/docs/developer/getting-started/monorepo-packages.asciidoc +++ b/docs/developer/getting-started/monorepo-packages.asciidoc @@ -97,6 +97,7 @@ yarn kbn watch-bazel - @kbn/securitysolution-list-utils - @kbn/securitysolution-utils - @kbn/server-http-tools +- @kbn/server-route-repository - @kbn/std - @kbn/telemetry-utils - @kbn/tinymath diff --git a/docs/developer/getting-started/sample-data.asciidoc b/docs/developer/getting-started/sample-data.asciidoc index 0d313cbabe64e4..2454c9d8a61468 100644 --- a/docs/developer/getting-started/sample-data.asciidoc +++ b/docs/developer/getting-started/sample-data.asciidoc @@ -6,7 +6,7 @@ There are a couple ways to easily get data ingested into {es}. [discrete] === Sample data packages available for one click installation -The easiest is to install one or more of our vailable sample data packages. If you have no data, you should be +The easiest is to install one or more of our available sample data packages. If you have no data, you should be prompted to install when running {kib} for the first time. You can also access and install the sample data packages by going to the home page and clicking "add sample data". @@ -27,5 +27,5 @@ Make sure to execute `node scripts/makelogs` *after* {es} is up and running! [discrete] === CSV upload -If running with a platinum or trial license, you can also use the CSV uploader provided inside the Machine learning app. -Navigate to the Data visualizer to upload your data from a file. \ No newline at end of file +You can also use the CSV uploader provided on the {kib} home page. +Navigate to **Add data** > **Upload file** to upload your data from a file. \ No newline at end of file diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.description.md b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.description.md new file mode 100644 index 00000000000000..b6bba3b5e356cd --- /dev/null +++ b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.description.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginManifest](./kibana-plugin-core-server.pluginmanifest.md) > [description](./kibana-plugin-core-server.pluginmanifest.description.md) + +## PluginManifest.description property + +TODO: make required once all plugins specify this. A brief description of what this plugin does and any capabilities it provides. + +Signature: + +```typescript +readonly description?: string; +``` diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md index bd15b95d73acea..b3e20bc7ed693a 100644 --- a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md +++ b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md @@ -21,10 +21,12 @@ Should never be used in code outside of Core but is exported for documentation p | Property | Type | Description | | --- | --- | --- | | [configPath](./kibana-plugin-core-server.pluginmanifest.configpath.md) | ConfigPath | Root used by the plugin, defaults to "id" in snake\_case format. | +| [description](./kibana-plugin-core-server.pluginmanifest.description.md) | string | TODO: make required once all plugins specify this. A brief description of what this plugin does and any capabilities it provides. | | [extraPublicDirs](./kibana-plugin-core-server.pluginmanifest.extrapublicdirs.md) | string[] | Specifies directory names that can be imported by other ui-plugins built using the same instance of the @kbn/optimizer. A temporary measure we plan to replace with better mechanisms for sharing static code between plugins | | [id](./kibana-plugin-core-server.pluginmanifest.id.md) | PluginName | Identifier of the plugin. Must be a string in camelCase. Part of a plugin public contract. Other plugins leverage it to access plugin API, navigate to the plugin, etc. | | [kibanaVersion](./kibana-plugin-core-server.pluginmanifest.kibanaversion.md) | string | The version of Kibana the plugin is compatible with, defaults to "version". | | [optionalPlugins](./kibana-plugin-core-server.pluginmanifest.optionalplugins.md) | readonly PluginName[] | An optional list of the other plugins that if installed and enabled \*\*may be\*\* leveraged by this plugin for some additional functionality but otherwise are not required for this plugin to work properly. | +| [owner](./kibana-plugin-core-server.pluginmanifest.owner.md) | {
readonly name: string;
readonly githubTeam?: string;
} | TODO: make required once all internal plugins have this specified. | | [requiredBundles](./kibana-plugin-core-server.pluginmanifest.requiredbundles.md) | readonly string[] | List of plugin ids that this plugin's UI code imports modules from that are not in requiredPlugins. | | [requiredPlugins](./kibana-plugin-core-server.pluginmanifest.requiredplugins.md) | readonly PluginName[] | An optional list of the other plugins that \*\*must be\*\* installed and enabled for this plugin to function properly. | | [server](./kibana-plugin-core-server.pluginmanifest.server.md) | boolean | Specifies whether plugin includes some server-side specific functionality. | diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.owner.md b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.owner.md new file mode 100644 index 00000000000000..a90af81aa186a4 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.owner.md @@ -0,0 +1,16 @@ + + +[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PluginManifest](./kibana-plugin-core-server.pluginmanifest.md) > [owner](./kibana-plugin-core-server.pluginmanifest.owner.md) + +## PluginManifest.owner property + +TODO: make required once all internal plugins have this specified. + +Signature: + +```typescript +readonly owner?: { + readonly name: string; + readonly githubTeam?: string; + }; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md index 449cc66cb3335f..34de4f9e13cda4 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md @@ -23,7 +23,7 @@ export interface ExpressionFunctionDefinitionstring | Help text displayed in the Expression editor. This text should be internationalized. | | [inputTypes](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.inputtypes.md) | Array<TypeToString<Input>> | List of allowed type names for input value of this function. If this property is set the input of function will be cast to the first possible type in this list. If this property is missing the input will be provided to the function as-is. | | [name](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.name.md) | Name | The name of the function, as will be used in expression. | -| [type](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.type.md) | TypeToString<UnwrapPromiseOrReturn<Output>> | Name of type of value this function outputs. | +| [type](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.type.md) | TypeString<Output> | UnmappedTypeStrings | Name of type of value this function outputs. | ## Methods diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.type.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.type.md index 4831f24a418bc6..01ad35b8a1ba5c 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.type.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.type.md @@ -9,5 +9,5 @@ Name of type of value this function outputs. Signature: ```typescript -type?: TypeToString>; +type?: TypeString | UnmappedTypeStrings; ``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md index 6ba0f0feb82b3a..9afd603bc48694 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md @@ -70,7 +70,7 @@ The actual function is defined in the fn key. The function can be \ | Method | Modifiers | Description | | --- | --- | --- | -| [setup()](./kibana-plugin-plugins-expressions-public.expressionsservice.setup.md) | | Returns Kibana Platform \*setup\* life-cycle contract. Useful to return the same contract on server-side and browser-side. | -| [start()](./kibana-plugin-plugins-expressions-public.expressionsservice.start.md) | | Returns Kibana Platform \*start\* life-cycle contract. Useful to return the same contract on server-side and browser-side. | +| [setup(args)](./kibana-plugin-plugins-expressions-public.expressionsservice.setup.md) | | Returns Kibana Platform \*setup\* life-cycle contract. Useful to return the same contract on server-side and browser-side. | +| [start(args)](./kibana-plugin-plugins-expressions-public.expressionsservice.start.md) | | Returns Kibana Platform \*start\* life-cycle contract. Useful to return the same contract on server-side and browser-side. | | [stop()](./kibana-plugin-plugins-expressions-public.expressionsservice.stop.md) | | | diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.setup.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.setup.md index a51f3f073d5181..991f1f717d5f56 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.setup.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.setup.md @@ -9,8 +9,15 @@ Returns Kibana Platform \*setup\* life-cycle contract. Useful to return the same Signature: ```typescript -setup(): ExpressionsServiceSetup; +setup(...args: unknown[]): ExpressionsServiceSetup; ``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| args | unknown[] | | + Returns: `ExpressionsServiceSetup` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.start.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.start.md index 766d703a0729da..34d33cacabebb6 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.start.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.start.md @@ -9,8 +9,15 @@ Returns Kibana Platform \*start\* life-cycle contract. Useful to return the same Signature: ```typescript -start(): ExpressionsServiceStart; +start(...args: unknown[]): ExpressionsServiceStart; ``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| args | unknown[] | | + Returns: `ExpressionsServiceStart` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md index 51240f094b181a..35248c01a4e29d 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md @@ -23,7 +23,7 @@ export interface ExpressionFunctionDefinitionstring | Help text displayed in the Expression editor. This text should be internationalized. | | [inputTypes](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.inputtypes.md) | Array<TypeToString<Input>> | List of allowed type names for input value of this function. If this property is set the input of function will be cast to the first possible type in this list. If this property is missing the input will be provided to the function as-is. | | [name](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.name.md) | Name | The name of the function, as will be used in expression. | -| [type](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.type.md) | TypeToString<UnwrapPromiseOrReturn<Output>> | Name of type of value this function outputs. | +| [type](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.type.md) | TypeString<Output> | UnmappedTypeStrings | Name of type of value this function outputs. | ## Methods diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.type.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.type.md index a73ded342f053d..2994b9547fd8c0 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.type.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.type.md @@ -9,5 +9,5 @@ Name of type of value this function outputs. Signature: ```typescript -type?: TypeToString>; +type?: TypeString | UnmappedTypeStrings; ``` diff --git a/docs/management/connectors/action-types/index.asciidoc b/docs/management/connectors/action-types/index.asciidoc index d3bd3d431748c9..7868085ef9c96f 100644 --- a/docs/management/connectors/action-types/index.asciidoc +++ b/docs/management/connectors/action-types/index.asciidoc @@ -119,7 +119,7 @@ When creating a new rule, add an <> and select [role="screenshot"] image::images/pre-configured-alert-history-connector.png[Select pre-configured alert history connectors] -Documents are indexed using a preconfigured schema that captures the <> available for the rule. By default, these documents are indexed into the `kibana-alert-history-default` index, but you can specify a different index. Index names must start with `kibana-alert-history-` to take advantage of the preconfigured alert history index template. +Documents are indexed using a preconfigured schema that captures the <> available for the rule. By default, these documents are indexed into the `kibana-alert-history-default` index, but you can specify a different index. Index names must start with `kibana-alert-history-` to take advantage of the preconfigured alert history index template. [IMPORTANT] ============================================== diff --git a/docs/management/connectors/action-types/webhook.asciidoc b/docs/management/connectors/action-types/webhook.asciidoc index aa52e8a3bdb433..02c3de139e0d5d 100644 --- a/docs/management/connectors/action-types/webhook.asciidoc +++ b/docs/management/connectors/action-types/webhook.asciidoc @@ -91,4 +91,4 @@ Body:: A JSON payload sent to the request URL. For example: Mustache template variables (the text enclosed in double braces, for example, `context.rule.name`) have their values escaped, so that the final JSON will be valid (escaping double quote characters). -For more information on Mustache template variables, refer to <>. +For more information on Mustache template variables, refer to <>. diff --git a/docs/rule-type-template.asciidoc b/docs/rule-type-template.asciidoc index 605bdd57c14920..5fe4de81bcddc1 100644 --- a/docs/rule-type-template.asciidoc +++ b/docs/rule-type-template.asciidoc @@ -6,7 +6,7 @@ Include a short description of the rule type. [float] ==== Create the rule -Fill in the <>, then select **. +Fill in the <>, then select **. [float] ==== Define the conditions @@ -25,7 +25,7 @@ Condition2:: This is another condition the user must define. [float] ==== Add action variables -<> to run when the rule condition is met. The following variables are specific to the rule. You can also specify <>. +<> to run when the rule condition is met. The following variables are specific to the rule. You can also specify <>. `context.variableA`:: A short description of the context variable defined by the rule type. `context.variableB`:: A short description of the context variable defined by the rule type with an example. Example: `this is what variableB outputs`. diff --git a/docs/setup/connect-to-elasticsearch.asciidoc b/docs/setup/connect-to-elasticsearch.asciidoc index 8c0aa12ffc4c61..5e18d934863aa9 100644 --- a/docs/setup/connect-to-elasticsearch.asciidoc +++ b/docs/setup/connect-to-elasticsearch.asciidoc @@ -46,8 +46,7 @@ image::images/add-data-fleet.png[Add data using Fleet] [[upload-data-kibana]] === Upload a file -experimental[] If your data is in a CSV, JSON, or log file, you can upload it using the File -Data Visualizer. You can upload a file up to 100 MB. This value is configurable up to 1 GB in +experimental[] If your data is in a CSV, JSON, or log file, you can upload it using the {file-data-viz}. You can upload a file up to 100 MB. This value is configurable up to 1 GB in <>. To upload a file with geospatial data, refer to <>. diff --git a/docs/setup/images/add-data-fv.png b/docs/setup/images/add-data-fv.png old mode 100755 new mode 100644 index 45313d133822c1..7e253cdd0229d7 Binary files a/docs/setup/images/add-data-fv.png and b/docs/setup/images/add-data-fv.png differ diff --git a/docs/setup/images/add-data-tutorials.png b/docs/setup/images/add-data-tutorials.png index 74deedc57b42ed..782b44e383772c 100644 Binary files a/docs/setup/images/add-data-tutorials.png and b/docs/setup/images/add-data-tutorials.png differ diff --git a/docs/user/alerting/alerting-getting-started.asciidoc b/docs/user/alerting/alerting-getting-started.asciidoc index bb11d2a0be4233..8c17f8ec93b965 100644 --- a/docs/user/alerting/alerting-getting-started.asciidoc +++ b/docs/user/alerting/alerting-getting-started.asciidoc @@ -11,7 +11,7 @@ image::images/alerting-overview.png[Rules and Connectors UI] [IMPORTANT] ============================================== -To make sure you can access alerting and actions, see the <> section. +To make sure you can access alerting and actions, see the <> section. ============================================== [float] @@ -22,7 +22,7 @@ Actions typically involve interaction with {kib} services or third party integra This section describes all of these elements and how they operate together. [float] -=== What is a rule? +=== Rules A rule specifies a background task that runs on the {kib} server to check for specific conditions. It consists of three main parts: @@ -30,7 +30,10 @@ A rule specifies a background task that runs on the {kib} server to check for sp * *Schedule*: when/how often should detection checks run? * *Actions*: what happens when a condition is detected? -For example, when monitoring a set of servers, a rule might check for average CPU usage > 0.9 on each server for the last two minutes (condition), checked every minute (schedule), sending a warning email message via SMTP with subject `CPU on {{server}} is high` (action). +For example, when monitoring a set of servers, a rule might: +* Check for average CPU usage > 0.9 on each server for the last two minutes (condition). +* Check every minute (schedule). +* Send a warning email message via SMTP with subject `CPU on {{server}} is high` (action). image::images/what-is-a-rule.svg[Three components of a rule] @@ -40,7 +43,7 @@ The following sections describe each part of the rule in more detail. [[alerting-concepts-conditions]] ==== Conditions -Under the hood, {kib} rules detect conditions by running a javascript function on the {kib} server, which gives it the flexibility to support a wide range of conditions, anything from the results of a simple {es} query to heavy computations involving data from multiple sources or external systems. +Under the hood, {kib} rules detect conditions by running a Javascript function on the {kib} server, which gives it the flexibility to support a wide range of conditions, anything from the results of a simple {es} query to heavy computations involving data from multiple sources or external systems. These conditions are packaged and exposed as *rule types*. A rule type hides the underlying details of the condition, and exposes a set of parameters to control the details of the conditions to detect. @@ -68,22 +71,22 @@ Actions are invocations of connectors, which allow interaction with {kib} servic When defining actions in a rule, you specify: -* the *connector type*: the type of service or integration to use -* the connection for that type by referencing a <> -* a mapping of rule values to properties exposed for that type of action +* The *connector type*: the type of service or integration to use +* The connection for that type by referencing a <> +* A mapping of rule values to properties exposed for that type of action The result is a template: all the parameters needed to invoke a service are supplied except for specific values that are only known at the time the rule condition is detected. In the server monitoring example, the `email` connector type is used, and `server` is mapped to the body of the email, using the template string `CPU on {{server}} is high`. -When the rule detects the condition, it creates an <> containing the details of the condition, renders the template with these details such as server name, and executes the action on the {kib} server by invoking the `email` connector type. +When the rule detects the condition, it creates an <> containing the details of the condition, renders the template with these details such as server name, and executes the action on the {kib} server by invoking the `email` connector type. image::images/what-is-an-action.svg[Actions are like templates that are rendered when an alert detects a condition] See <> for details on the types of connectors provided by {kib}. [float] -[[alerting-concepts-alert-instances]] +[[alerting-concepts-alerts]] === Alerts When checking for a condition, a rule might identify multiple occurrences of the condition. {kib} tracks each of these *alerts* separately and takes an action per alert. @@ -92,22 +95,6 @@ Using the server monitoring example, each server with average CPU > 0.9 is track image::images/alerts.svg[{kib} tracks each detected condition as an alert and takes action on each alert] -[float] -[[alerting-concepts-suppressing-duplicate-notifications]] -=== Suppressing duplicate notifications - -Since actions are executed per alert, a rule can end up generating a large number of actions. Take the following example where a rule is monitoring three servers every minute for CPU usage > 0.9: - -* Minute 1: server X123 > 0.9. *One email* is sent for server X123. -* Minute 2: X123 and Y456 > 0.9. *Two emails* are sent, one for X123 and one for Y456. -* Minute 3: X123, Y456, Z789 > 0.9. *Three emails* are sent, one for each of X123, Y456, Z789. - -In the above example, three emails are sent for server X123 in the span of 3 minutes for the same rule. Often it's desirable to suppress frequent re-notification. Operations like muting and throttling can be applied at the alert level. If we set the rule re-notify interval to 5 minutes, we reduce noise by only getting emails for new servers that exceed the threshold: - -* Minute 1: server X123 > 0.9. *One email* is sent for server X123. -* Minute 2: X123 and Y456 > 0.9. *One email* is sent for Y456. -* Minute 3: X123, Y456, Z789 > 0.9. *One email* is sent for Z789. - [float] [[alerting-concepts-connectors]] === Connectors @@ -120,7 +107,7 @@ Rather than repeatedly entering connection information and credentials for each image::images/rule-concepts-connectors.svg[Connectors provide a central place to store service connection settings] [float] -=== Summary +== Putting it all together A *rule* consists of conditions, *actions*, and a schedule. When conditions are met, *alerts* are created that render *actions* and invoke them. To make action setup and update easier, actions use *connectors* that centralize the information used to connect with {kib} services and third-party integrations. The following example ties these concepts together: @@ -131,7 +118,6 @@ image::images/rule-concepts-summary.svg[Rules, connectors, alerts and actions wo . {kib} invokes the actions, sending them to a third party *integration* like an email service. . If the third party integration has connection parameters or credentials, {kib} will fetch these from the *connector* referenced in the action. - [float] [[alerting-concepts-differences]] == Differences from Watcher @@ -152,63 +138,7 @@ Pre-packaged *rule types* simplify setup and hide the details of complex, domain [float] [[alerting-setup-prerequisites]] -== Setup and prerequisites - -If you are using an *on-premises* Elastic Stack deployment: - -* In the kibana.yml configuration file, add the <> setting. -* For emails to have a footer with a link back to {kib}, set the <> configuration setting. - -If you are using an *on-premises* Elastic Stack deployment with <>: - -* You must enable Transport Layer Security (TLS) for communication <>. {kib} alerting uses <> to secure background rule checks and actions, and API keys require {ref}/configuring-tls.html#tls-http[TLS on the HTTP interface]. A proxy will not suffice. - -[float] -[[alerting-setup-production]] -== Production considerations and scaling guidance - -When relying on alerting and actions as mission critical services, make sure you follow the <>. - -See <> for more information on the scalability of {kib} alerting. - -[float] -[[alerting-security]] -== Security +== Prerequisites +<> -To access alerting in a space, a user must have access to one of the following features: - -* Alerting -* <> -* <> -* <> -* <> -* <> -* <> - -See <> for more information on configuring roles that provide access to these features. -Also note that a user will need +read+ privileges for the *Actions and Connectors* feature to attach actions to a rule or to edit a rule that has an action attached to it. - -[float] -[[alerting-spaces]] -=== Space isolation - -Rules and connectors are isolated to the {kib} space in which they were created. A rule or connector created in one space will not be visible in another. - -[float] -[[alerting-authorization]] -=== Authorization - -Rules, including all background detection and the actions they generate are authorized using an <> associated with the last user to edit the rule. Upon creating or modifying a rule, an API key is generated for that user, capturing a snapshot of their privileges at that moment in time. The API key is then used to run all background tasks associated with the rule including detection checks and executing actions. - -[IMPORTANT] -============================================== -If a rule requires certain privileges to run, such as index privileges, keep in mind that if a user without those privileges updates the rule, the rule will no longer function. -============================================== - -[float] -[[alerting-restricting-actions]] -=== Restricting actions - -For security reasons you may wish to limit the extent to which {kib} can connect to external services. <> allows you to disable certain <> and allowlist the hostnames that {kib} can connect with. - --- +-- \ No newline at end of file diff --git a/docs/user/alerting/alerting-setup.asciidoc b/docs/user/alerting/alerting-setup.asciidoc new file mode 100644 index 00000000000000..39f1af0030e0aa --- /dev/null +++ b/docs/user/alerting/alerting-setup.asciidoc @@ -0,0 +1,68 @@ +[role="xpack"] +[[alerting-setup]] +== Alerting Setup +++++ +Setup +++++ + +The Alerting feature is automatically enabled in {kib}, but might require some additional configuration. + +[float] +[[alerting-prerequisites]] +=== Prerequisites +If you are using an *on-premises* Elastic Stack deployment: + +* In the kibana.yml configuration file, add the <> setting. +* For emails to have a footer with a link back to {kib}, set the <> configuration setting. + +If you are using an *on-premises* Elastic Stack deployment with <>: + +* You must enable Transport Layer Security (TLS) for communication <>. {kib} alerting uses <> to secure background rule checks and actions, and API keys require {ref}/configuring-tls.html#tls-http[TLS on the HTTP interface]. A proxy will not suffice. + +[float] +[[alerting-setup-production]] +=== Production considerations and scaling guidance + +When relying on alerting and actions as mission critical services, make sure you follow the <>. + +See <> for more information on the scalability of {kib} alerting. + +[float] +[[alerting-security]] +=== Security + +To access alerting in a space, a user must have access to one of the following features: + +* Alerting +* <> +* <> +* <> +* <> +* <> +* <> + +See <> for more information on configuring roles that provide access to these features. +Also note that a user will need +read+ privileges for the *Actions and Connectors* feature to attach actions to a rule or to edit a rule that has an action attached to it. + +[float] +[[alerting-restricting-actions]] +==== Restrict actions + +For security reasons you may wish to limit the extent to which {kib} can connect to external services. <> allows you to disable certain <> and allowlist the hostnames that {kib} can connect with. + +[float] +[[alerting-spaces]] +=== Space isolation + +Rules and connectors are isolated to the {kib} space in which they were created. A rule or connector created in one space will not be visible in another. + +[float] +[[alerting-authorization]] +=== Authorization + +Rules, including all background detection and the actions they generate are authorized using an <> associated with the last user to edit the rule. Upon creating or modifying a rule, an API key is generated for that user, capturing a snapshot of their privileges at that moment in time. The API key is then used to run all background tasks associated with the rule including detection checks and executing actions. + +[IMPORTANT] +============================================== +If a rule requires certain privileges to run, such as index privileges, keep in mind that if a user without those privileges updates the rule, the rule will no longer function. +============================================== diff --git a/docs/user/alerting/alerting-troubleshooting.asciidoc b/docs/user/alerting/alerting-troubleshooting.asciidoc index b7fd98d1c674ec..b7b0c749dfe149 100644 --- a/docs/user/alerting/alerting-troubleshooting.asciidoc +++ b/docs/user/alerting/alerting-troubleshooting.asciidoc @@ -1,6 +1,9 @@ [role="xpack"] [[alerting-troubleshooting]] == Alerting Troubleshooting +++++ +Troubleshooting +++++ This page describes how to resolve common problems you might encounter with Alerting. If your problem isn’t described here, please review open issues in the following GitHub repositories: diff --git a/docs/user/alerting/create-and-manage-rules.asciidoc b/docs/user/alerting/create-and-manage-rules.asciidoc new file mode 100644 index 00000000000000..af6714aef662ff --- /dev/null +++ b/docs/user/alerting/create-and-manage-rules.asciidoc @@ -0,0 +1,184 @@ +[role="xpack"] +[[create-and-manage-rules]] +== Create and manage rules + +The *Rules* UI provides a cross-app view of alerting. Different {kib} apps like {observability-guide}/create-alerts.html[*Observability*], {security-guide}/prebuilt-rules.html[*Security*], <> and <> can offer their own rules. The *Rules* UI provides a central place to: + +* <> rules +* <> including enabling/disabling, muting/unmuting, and deleting +* Drill-down to <> + +[role="screenshot"] +image:images/rules-and-connectors-ui.png[Example rule listing in the Rules and Connectors UI] + +For more information on alerting concepts and the types of rules and connectors available, see <>. + +[float] +=== Required permissions + +Access to rules is granted based on your privileges to alerting-enabled features. See <> for more information. + +[float] +[[create-edit-rules]] +=== Create and edit rules + +Many rules must be created within the context of a {kib} app like <>, <>, or <>, but others are generic. Generic rule types can be created in the *Rules* management UI by clicking the *Create* button. This will launch a flyout that guides you through selecting a rule type and configuring its conditions and action type. Refer to <> for details on what types of rules are available and how to configure them. + +After a rule is created, you can re-open the flyout and change a rule's properties by clicking the *Edit* button shown on each row of the rule listing. + +[float] +[[defining-rules-general-details]] +==== General rule details + +All rules share the following four properties. + +Name:: The name of the rule. While this name does not have to be unique, the name can be referenced in actions and also appears in the searchable rule listing in the *Management* UI. A distinctive name can help identify and find a rule. +Tags:: A list of tag names that can be applied to a rule. Tags can help you organize and find rules, because tags appear in the rule listing in the *Management* UI, which is searchable by tag. +Check every:: This value determines how frequently the rule conditions are checked. Note that the timing of background rule checks is not guaranteed, particularly for intervals of less than 10 seconds. See <> for more information. +Notify:: This value limits how often actions are repeated when an alert remains active across rule checks. See <> for more information. + +- **Only on status change**: Actions are not repeated when an alert remains active across checks. Actions run only when the alert status changes. +- **Every time alert is active**: Actions are repeated when an alert remains active across checks. +- **On a custom action interval**: Actions are suppressed for the throttle interval, but repeat when an alert remains active across checks for a duration longer than the throttle interval. + +[float] +[[alerting-concepts-suppressing-duplicate-notifications]] +[NOTE] +============================================== +Since actions are executed per alert, a rule can end up generating a large number of actions. Take the following example where a rule is monitoring three servers every minute for CPU usage > 0.9, and the rule is set to notify **Every time alert is active**: + +* Minute 1: server X123 > 0.9. *One email* is sent for server X123. +* Minute 2: X123 and Y456 > 0.9. *Two emails* are sent, one for X123 and one for Y456. +* Minute 3: X123, Y456, Z789 > 0.9. *Three emails* are sent, one for each of X123, Y456, Z789. + +In the above example, three emails are sent for server X123 in the span of 3 minutes for the same rule. Often, it's desirable to suppress these re-notifications. If you set the rule **Notify** setting to **On a custom action interval** with an interval of 5 minutes, you reduce noise by only getting emails every 5 minutes for servers that continue to exceed the threshold: + +* Minute 1: server X123 > 0.9. *One email* is sent for server X123. +* Minute 2: X123 and Y456 > 0.9. *One email* is sent for Y456. +* Minute 3: X123, Y456, Z789 > 0.9. *One email* is sent for Z789. + +To get notified **only once** when a server exceeds the threshold, you can set the rule's **Notify** setting to **Only on status change**. +============================================== + +[role="screenshot"] +image::images/rule-flyout-general-details.png[alt='All rules have name, tags, check every, and notify properties in common'] + +[float] +[[defining-rules-type-conditions]] +==== Rule type and conditions + +Depending upon the {kib} app and context, you might be prompted to choose the type of rule to create. Some apps will pre-select the type of rule for you. + +[role="screenshot"] +image::images/rule-flyout-rule-type-selection.png[Choosing the type of rule to create] + +Each rule type provides its own way of defining the conditions to detect, but an expression formed by a series of clauses is a common pattern. Each clause has a UI control that allows you to define the clause. For example, in an index threshold rule, the `WHEN` clause allows you to select an aggregation operation to apply to a numeric field. + +[role="screenshot"] +image::images/rule-flyout-rule-conditions.png[UI for defining rule conditions on an index threshold rule] + +[float] +[[defining-rules-actions-details]] +==== Action type and details + +To receive notifications when a rule meets the defined conditions, you must add one or more actions. Start by selecting a type of connector for your action: + +[role="screenshot"] +image::images/rule-flyout-connector-type-selection.png[UI for selecting an action type] + +Each action must specify a <> instance. If no connectors exist for the selected type, click **Add connector** to create one. + +[role="screenshot"] +image::images/rule-flyout-action-no-connector.png[UI for adding connector] + +Once you have selected a connector, use the **Run When** dropdown to choose the action group to associate with this action. When a rule meets the defined condition, it is marked as **Active** and alerts are created and assigned to an action group. In addition to the action groups defined by the selected rule type, each rule also has a **Recovered** action group that is assigned when a rule's conditions are no longer detected. + +Each action type exposes different properties. For example, an email action allows you to set the recipients, the subject, and a message body in markdown format. See <> for details on the types of actions provided by {kib} and their properties. + +[role="screenshot"] +image::images/rule-flyout-action-details.png[UI for defining an email action] + +[float] +[[defining-rules-actions-variables]] +===== Action variables +Using the https://mustache.github.io/[Mustache] template syntax `{{variable name}}`, you can pass rule values at the time a condition is detected to an action. You can access the list of available variables using the "add variable" button. Although available variables differ by rule type, all rule types pass the following variables: + +`rule.id`:: The ID of the rule. +`rule.name`:: The name of the rule. +`rule.spaceId`:: The ID of the space for the rule. +`rule.tags`:: The list of tags applied to the rule. +`date`:: The date the rule scheduled the action, in ISO format. +`alert.id`:: The ID of the alert that scheduled the action. +`alert.actionGroup`:: The ID of the action group of the alert that scheduled the action. +`alert.actionSubgroup`:: The action subgroup of the alert that scheduled the action. +`alert.actionGroupName`:: The name of the action group of the alert that scheduled the action. +`kibanaBaseUrl`:: The configured <>. If not configured, this will be empty. + +[role="screenshot"] +image::images/rule-flyout-action-variables.png[Passing rule values to an action] + +Some cases exist where the variable values will be "escaped", when used in a context where escaping is needed: + +- For the <> connector, the `message` action configuration property escapes any characters that would be interpreted as Markdown. +- For the <> connector, the `message` action configuration property escapes any characters that would be interpreted as Slack Markdown. +- For the <> connector, the `body` action configuration property escapes any characters that are invalid in JSON string values. + +Mustache also supports "triple braces" of the form `{{{variable name}}}`, which indicates no escaping should be done at all. Care should be used when using this form, as it could end up rendering the variable content in such a way as to make the resulting parameter invalid or formatted incorrectly. + +Each rule type defines additional variables as properties of the variable `context`. For example, if a rule type defines a variable `value`, it can be used in an action parameter as `{{context.value}}`. + +For diagnostic or exploratory purposes, action variables whose values are objects, such as `context`, can be referenced directly as variables. The resulting value will be a JSON representation of the object. For example, if an action parameter includes `{{context}}`, it will expand to the JSON representation of all the variables and values provided by the rule type. + +You can attach more than one action. Clicking the "Add action" button will prompt you to select another rule type and repeat the above steps again. + +[role="screenshot"] +image::images/rule-flyout-add-action.png[You can add multiple actions on a rule] + +[NOTE] +============================================== +Actions are not required on rules. You can run a rule without actions to understand its behavior, and then <> later. +============================================== + +[float] +[[controlling-rules]] +=== Mute and disable rules + +The rule listing allows you to quickly mute/unmute, disable/enable, and delete individual rules by clicking menu button to open the actions menu. Muting means that the rule checks continue to run on a schedule, but that alert will not trigger any action. + +[role="screenshot"] +image:images/individual-mute-disable.png[The actions button allows an individual rule to be muted, disabled, or deleted] + +You can perform these operations in bulk by multi-selecting rules, and then clicking the *Manage rules* button: + +[role="screenshot"] +image:images/bulk-mute-disable.png[The Manage rules button lets you mute/unmute, enable/disable, and delete in bulk,width=75%] + +[float] +[[rule-details]] +=== Drilldown to rule details + +Select a rule name from the rule listing to access the *Rule details* page, which tells you about the state of the rule and provides granular control over the actions it is taking. + +[role="screenshot"] +image::images/rule-details-alerts-active.png[Rule details page with three alerts] + +In this example, the rule detects when a site serves more than a threshold number of bytes in a 24 hour period. Three sites are above the threshold. These are called alerts - occurrences of the condition being detected - and the alert name, status, time of detection, and duration of the condition are shown in this view. + +Upon detection, each alert can trigger one or more actions. If the condition persists, the same actions will trigger either on the next scheduled rule check, or (if defined) after the re-notify period on the rule has passed. To prevent re-notification, you can suppress future actions by clicking on the switch to mute an individual alert. + +[role="screenshot"] +image::images/rule-details-alert-muting.png[Muting an alert,width=50%] + +Alerts will come and go from the list depending on whether they meet the rule conditions or not - unless they are muted. If a muted instance no longer meets the rule conditions, it will appear as inactive in the list. This prevents an alert from triggering actions if it reappears in the future. + +[role="screenshot"] +image::images/rule-details-alerts-inactive.png[Rule details page with three inactive alerts] + +If you want to suppress actions on all current and future alerts, you can mute the entire rule. Rule checks continue to run and the alert list will update as alerts activate or deactivate, but no actions will be triggered. + +[role="screenshot"] +image::images/rule-details-muting.png[Use the mute toggle to suppress all actions on current and future alerts,width=50%] + +You can also disable a rule altogether. When disabled, the rule stops running checks altogether and will clear any alerts it is tracking. You may want to disable rules that are not currently needed to reduce the load on {kib} and {es}. + +[role="screenshot"] +image::images/rule-details-disabling.png[Use the disable toggle to turn off rule checks and clear alerts tracked] diff --git a/docs/user/alerting/defining-rules.asciidoc b/docs/user/alerting/defining-rules.asciidoc index 05885f1af13ba2..686a7bbc8a37b9 100644 --- a/docs/user/alerting/defining-rules.asciidoc +++ b/docs/user/alerting/defining-rules.asciidoc @@ -2,114 +2,10 @@ [[defining-alerts]] == Defining rules -{kib} alerting rules can be created in a variety of apps including <>, <>, <>, <>, <> and from the <> UI. While alerting details may differ from app to app, they share a common interface for defining and configuring rules that this section describes in more detail. - -[float] -=== Create a rule - -When you create a rule, you must define the rule details, conditions, and actions. - -. <> -. <> -. <> - -image::images/rule-flyout-sections.png[The three sections of a rule definition] +This content has been moved to <>. [float] [[defining-alerts-general-details]] -=== General rule details - -All rules share the following four properties. - -[role="screenshot"] -image::images/rule-flyout-general-details.png[alt='All rules have name, tags, check every, and notify properties in common'] - -Name:: The name of the rule. While this name does not have to be unique, the name can be referenced in actions and also appears in the searchable rule listing in the management UI. A distinctive name can help identify and find a rule. -Tags:: A list of tag names that can be applied to a rule. Tags can help you organize and find rules, because tags appear in the rule listing in the management UI which is searchable by tag. -Check every:: This value determines how frequently the rule conditions below are checked. Note that the timing of background rule checks are not guaranteed, particularly for intervals of less than 10 seconds. See <> for more information. -Notify:: This value limits how often actions are repeated when an alert remains active across rule checks. See <> for more information. + -- **Only on status change**: Actions are not repeated when an alert remains active across checks. Actions run only when the alert status changes. -- **Every time alert is active**: Actions are repeated when an alert remains active across checks. -- **On a custom action interval**: Actions are suppressed for the throttle interval, but repeat when an alert remains active across checks for a duration longer than the throttle interval. - - -[float] -[[defining-alerts-type-conditions]] -=== Rule type and conditions - -Depending upon the {kib} app and context, you may be prompted to choose the type of rule you wish to create. Some apps will pre-select the type of rule for you. - -[role="screenshot"] -image::images/rule-flyout-rule-type-selection.png[Choosing the type of rule to create] - -Each rule type provides its own way of defining the conditions to detect, but an expression formed by a series of clauses is a common pattern. Each clause has a UI control that allows you to define the clause. For example, in an index threshold rule the `WHEN` clause allows you to select an aggregation operation to apply to a numeric field. - -[role="screenshot"] -image::images/rule-flyout-rule-conditions.png[UI for defining rule conditions on an index threshold rule] - -[float] -[[defining-alerts-actions-details]] -=== Action type and action details - -To add an action to a rule, you first select the type of connector: - -[role="screenshot"] -image::images/rule-flyout-connector-type-selection.png[UI for selecting an action type] - -When an alert matches a condition, the rule is marked as _Active_ and assigned an action group. The actions in that group are triggered. -When the condition is no longer detected, the rule is assigned to the _Recovered_ action group, which triggers any actions assigned to that group. - -**Run When** allows you to assign an action to an action group. This will trigger the action in accordance with your **Notify** setting. - -Each action must specify a <> instance. If no connectors exist for that action type, click *Add connector* to create one. - -Each action type exposes different properties. For example an email action allows you to set the recipients, the subject, and a message body in markdown format. See <> for details on the types of actions provided by {kib} and their properties. - -[role="screenshot"] -image::images/rule-flyout-action-details.png[UI for defining an email action] - -[float] -[[defining-alerts-actions-variables]] -==== Action variables -Using the https://mustache.github.io/[Mustache] template syntax `{{variable name}}`, you can pass rule values at the time a condition is detected to an action. You can access the list of available variables using the "add variable" button. Although available variables differ by rule type, all rule types pass the following variables: - -`rule.id`:: The ID of the rule. -`rule.name`:: The name of the rule. -`rule.spaceId`:: The ID of the space for the rule. -`rule.tags`:: The list of tags applied to the rule. -`date`:: The date the rule scheduled the action, in ISO format. -`alert.id`:: The ID of the alert that scheduled the action. -`alert.actionGroup`:: The ID of the action group of the alert that scheduled the action. -`alert.actionSubgroup`:: The action subgroup of the alert that scheduled the action. -`alert.actionGroupName`:: The name of the action group of the alert that scheduled the action. -`kibanaBaseUrl`:: The configured <>. If not configured, this will be empty. - -[role="screenshot"] -image::images/rule-flyout-action-variables.png[Passing rule values to an action] - -Some cases exist where the variable values will be "escaped", when used in a context where escaping is needed: - -- For the <> connector, the `message` action configuration property escapes any characters that would be interpreted as Markdown. -- For the <> connector, the `message` action configuration property escapes any characters that would be interpreted as Slack Markdown. -- For the <> connector, the `body` action configuration property escapes any characters that are invalid in JSON string values. - -Mustache also supports "triple braces" of the form `{{{variable name}}}`, which indicates no escaping should be done at all. Care should be used when using this form, as it could end up rendering the variable content in such a way as to make the resulting parameter invalid or formatted incorrectly. - -Each rule type defines additional variables as properties of the variable `context`. For example, if a rule type defines a variable `value`, it can be used in an action parameter as `{{context.value}}`. - -For diagnostic or exploratory purposes, action variables whose values are objects, such as `context`, can be referenced directly as variables. The resulting value will be a JSON representation of the object. For example, if an action parameter includes `{{context}}`, it will expand to the JSON representation of all the variables and values provided by the rule type. - -You can attach more than one action. Clicking the "Add action" button will prompt you to select another rule type and repeat the above steps again. - -[role="screenshot"] -image::images/rule-flyout-add-action.png[You can add multiple actions on a rule] - -[NOTE] -============================================== -Actions are not required on rules. You can run a rule without actions to understand its behavior, and then <> later. -============================================== - -[float] -=== Manage rules +==== General rule details -To modify a rule after it was created, including muting or disabling it, use the <>. +This content has been moved to <>. \ No newline at end of file diff --git a/docs/user/alerting/images/individual-mute-disable.png b/docs/user/alerting/images/individual-mute-disable.png index 0ed2bfc0186c08..c9d8cd666f1d84 100644 Binary files a/docs/user/alerting/images/individual-mute-disable.png and b/docs/user/alerting/images/individual-mute-disable.png differ diff --git a/docs/user/alerting/images/rule-flyout-action-no-connector.png b/docs/user/alerting/images/rule-flyout-action-no-connector.png new file mode 100644 index 00000000000000..b8b0864e04226d Binary files /dev/null and b/docs/user/alerting/images/rule-flyout-action-no-connector.png differ diff --git a/docs/user/alerting/index.asciidoc b/docs/user/alerting/index.asciidoc index f8a5aacce8f0e1..68cf3ee070b089 100644 --- a/docs/user/alerting/index.asciidoc +++ b/docs/user/alerting/index.asciidoc @@ -1,7 +1,8 @@ include::alerting-getting-started.asciidoc[] +include::alerting-setup.asciidoc[] +include::create-and-manage-rules.asciidoc[] include::defining-rules.asciidoc[] include::rule-management.asciidoc[] -include::rule-details.asciidoc[] include::stack-rules.asciidoc[] include::domain-specific-rules.asciidoc[] include::alerting-troubleshooting.asciidoc[] diff --git a/docs/user/alerting/map-rules/geo-rule-types.asciidoc b/docs/user/alerting/map-rules/geo-rule-types.asciidoc index 4b17145c2d1493..eee7b592522054 100644 --- a/docs/user/alerting/map-rules/geo-rule-types.asciidoc +++ b/docs/user/alerting/map-rules/geo-rule-types.asciidoc @@ -30,8 +30,8 @@ than the current time minus the amount of the interval. If data older than [float] ==== Creating a geo rule -Click the *Create* button in the <>. -Complete the <>. +Click the *Create* button in the <>. +Complete the <>. [role="screenshot"] image::user/alerting/images/alert-types-tracking-select.png[Choosing a tracking rule type] diff --git a/docs/user/alerting/rule-details.asciidoc b/docs/user/alerting/rule-details.asciidoc deleted file mode 100644 index 6e743595e5c33b..00000000000000 --- a/docs/user/alerting/rule-details.asciidoc +++ /dev/null @@ -1,33 +0,0 @@ -[role="xpack"] -[[rule-details]] -== Rule details - - -The *Rule details* page tells you about the state of the rule and provides granular control over the actions it is taking. - -[role="screenshot"] -image::images/rule-details-alerts-active.png[Rule details page with three alerts] - -In this example, the rule detects when a site serves more than a threshold number of bytes in a 24 hour period. Three sites are above the threshold. These are called alerts - occurrences of the condition being detected - and the alert name, status, time of detection, and duration of the condition are shown in this view. - -Upon detection, each alert can trigger one or more actions. If the condition persists, the same actions will trigger either on the next scheduled rule check, or (if defined) after the re-notify period on the rule has passed. To prevent re-notification, you can suppress future actions by clicking on the eye icon to mute an individual alert. Muting means that the rule checks continue to run on a schedule, but that alert will not trigger any action. - -[role="screenshot"] -image::images/rule-details-alert-muting.png[Muting an alert] - -Alerts will come and go from the list depending on whether they meet the rule conditions or not - unless they are muted. If a muted instance no longer meets the rule conditions, it will appear as inactive in the list. This prevents an alert from triggering actions if it reappears in the future. - -[role="screenshot"] -image::images/rule-details-alerts-inactive.png[Rule details page with three inactive alerts] - -If you want to suppress actions on all current and future alerts, you can mute the entire rule. Rule checks continue to run and the alert list will update as alerts activate or deactivate, but no actions will be triggered. - -[role="screenshot"] -image::images/rule-details-muting.png[Use the mute toggle to suppress all actions on current and future alerts] - -You can also disable a rule altogether. When disabled, the rule stops running checks altogether and will clear any alerts it is tracking. You may want to disable rules that are not currently needed to reduce the load on {kib} and {es}. - -[role="screenshot"] -image::images/rule-details-disabling.png[Use the disable toggle to turn off rule checks and clear alerts tracked] - -* For further information on alerting concepts and examples, see <>. diff --git a/docs/user/alerting/rule-management.asciidoc b/docs/user/alerting/rule-management.asciidoc index b908bd03b09927..d6349a60e08eb7 100644 --- a/docs/user/alerting/rule-management.asciidoc +++ b/docs/user/alerting/rule-management.asciidoc @@ -2,62 +2,4 @@ [[alert-management]] == Managing rules - -The *Rules* tab provides a cross-app view of alerting. Different {kib} apps like {observability-guide}/create-alerts.html[*Observability*], {security-guide}/prebuilt-rules.html[*Security*], <> and <> can offer their own rules. The *Rules* tab provides a central place to: - -* <> rules -* <> including enabling/disabling, muting/unmuting, and deleting -* Drill-down to <> - -[role="screenshot"] -image:images/rules-and-connectors-ui.png[Example rule listing in the Rules and Connectors UI] - -For more information on alerting concepts and the types of rules and connectors available, see <>. - -[float] -=== Finding rules - -The *Rules* tab lists all rules in the current space, including summary information about their execution frequency, tags, and type. - -The *search bar* can be used to quickly find rules by name or tag. - -[role="screenshot"] -image::images/rules-filter-by-search.png[Filtering the rules list using the search bar] - -The *type* dropdown lets you filter to a subset of rule types. - -[role="screenshot"] -image::images/rules-filter-by-type.png[Filtering the rules list by types of rule] - -The *Action type* dropdown lets you filter by the type of action used in the rule. - -[role="screenshot"] -image::images/rules-filter-by-action-type.png[Filtering the rule list by type of action] - -[float] -[[create-edit-rules]] -=== Creating and editing rules - -Many rules must be created within the context of a {kib} app like <>, <>, or <>, but others are generic. Generic rule types can be created in the *Rules* management UI by clicking the *Create* button. This will launch a flyout that guides you through selecting a rule type and configuring its properties. Refer to <> for details on what types of rules are available and how to configure them. - -After a rule is created, you can re-open the flyout and change a rule's properties by clicking the *Edit* button shown on each row of the rule listing. - - -[float] -[[controlling-rules]] -=== Controlling rules - -The rule listing allows you to quickly mute/unmute, disable/enable, and delete individual rules by clicking the action button. - -[role="screenshot"] -image:images/individual-mute-disable.png[The actions button allows an individual rule to be muted, disabled, or deleted] - -These operations can also be performed in bulk by multi-selecting rules and clicking the *Manage rules* button: - -[role="screenshot"] -image:images/bulk-mute-disable.png[The Manage rules button lets you mute/unmute, enable/disable, and delete in bulk] - -[float] -=== Required permissions - -Access to rules is granted based on your privileges to alerting-enabled features. See <> for more information. +This content has been moved to <>. \ No newline at end of file diff --git a/docs/user/alerting/stack-rules/es-query.asciidoc b/docs/user/alerting/stack-rules/es-query.asciidoc index c62ebbf4bf2bcc..5615c79a6c9c74 100644 --- a/docs/user/alerting/stack-rules/es-query.asciidoc +++ b/docs/user/alerting/stack-rules/es-query.asciidoc @@ -7,7 +7,7 @@ The {es} query rule type runs a user-configured {es} query, compares the number [float] ==== Create the rule -Fill in the <>, then select *{es} query*. +Fill in the <>, then select *{es} query*. [float] ==== Define the conditions @@ -22,12 +22,12 @@ Size:: This clause specifies the number of documents to pass to the configured a {es} query:: This clause specifies the ES DSL query to execute. The number of documents that match this query will be evaulated against the threshold condition. Aggregations are not supported at this time. Threshold:: This clause defines a threshold value and a comparison operator (`is above`, `is above or equals`, `is below`, `is below or equals`, or `is between`). The number of documents that match the specified query is compared to this threshold. -Time window:: This clause determines how far back to search for documents, using the *time field* set in the *index* clause. Generally this value should be set to a value higher than the *check every* value in the <>, to avoid gaps in detection. +Time window:: This clause determines how far back to search for documents, using the *time field* set in the *index* clause. Generally this value should be set to a value higher than the *check every* value in the <>, to avoid gaps in detection. [float] ==== Add action variables -<> to run when the rule condition is met. The following variables are specific to the {es} query rule. You can also specify <>. +<> to run when the rule condition is met. The following variables are specific to the {es} query rule. You can also specify <>. `context.title`:: A preconstructed title for the rule. Example: `rule term match alert query matched`. `context.message`:: A preconstructed message for the rule. Example: + diff --git a/docs/user/alerting/stack-rules/index-threshold.asciidoc b/docs/user/alerting/stack-rules/index-threshold.asciidoc index 43b750b85fb3bd..8c45c158414f4b 100644 --- a/docs/user/alerting/stack-rules/index-threshold.asciidoc +++ b/docs/user/alerting/stack-rules/index-threshold.asciidoc @@ -7,7 +7,7 @@ The index threshold rule type runs an {es} query. It aggregates field values fro [float] ==== Create the rule -Fill in the <>, then select *Index Threshold*. +Fill in the <>, then select *Index Threshold*. [float] ==== Define the conditions @@ -19,9 +19,9 @@ image::user/alerting/images/rule-types-index-threshold-conditions.png[Five claus Index:: This clause requires an *index or index pattern* and a *time field* that will be used for the *time window*. When:: This clause specifies how the value to be compared to the threshold is calculated. The value is calculated by aggregating a numeric field a the *time window*. The aggregation options are: `count`, `average`, `sum`, `min`, and `max`. When using `count` the document count is used, and an aggregation field is not necessary. -Over/Grouped Over:: This clause lets you configure whether the aggregation is applied over all documents, or should be split into groups using a grouping field. If grouping is used, an <> will be created for each group when it exceeds the threshold. To limit the number of alerts on high cardinality fields, you must specify the number of groups to check against the threshold. Only the *top* groups are checked. +Over/Grouped Over:: This clause lets you configure whether the aggregation is applied over all documents, or should be split into groups using a grouping field. If grouping is used, an <> will be created for each group when it exceeds the threshold. To limit the number of alerts on high cardinality fields, you must specify the number of groups to check against the threshold. Only the *top* groups are checked. Threshold:: This clause defines a threshold value and a comparison operator (one of `is above`, `is above or equals`, `is below`, `is below or equals`, or `is between`). The result of the aggregation is compared to this threshold. -Time window:: This clause determines how far back to search for documents, using the *time field* set in the *index* clause. Generally this value should be to a value higher than the *check every* value in the <>, to avoid gaps in detection. +Time window:: This clause determines how far back to search for documents, using the *time field* set in the *index* clause. Generally this value should be to a value higher than the *check every* value in the <>, to avoid gaps in detection. If data is available and all clauses have been defined, a preview chart will render the threshold value and display a line chart showing the value for the last 30 intervals. This can provide an indication of recent values and their proximity to the threshold, and help you tune the clauses. @@ -31,7 +31,7 @@ image::user/alerting/images/rule-types-index-threshold-preview.png[Five clauses [float] ==== Add action variables -<> to run when the rule condition is met. The following variables are specific to the index threshold rule. You can also specify <>. +<> to run when the rule condition is met. The following variables are specific to the index threshold rule. You can also specify <>. `context.title`:: A preconstructed title for the rule. Example: `rule kibana sites - high egress met threshold`. `context.message`:: A preconstructed message for the rule. Example: + diff --git a/docs/user/dashboard/aggregation-reference.asciidoc b/docs/user/dashboard/aggregation-reference.asciidoc index 7d5547fe3c3c50..39e596df4af347 100644 --- a/docs/user/dashboard/aggregation-reference.asciidoc +++ b/docs/user/dashboard/aggregation-reference.asciidoc @@ -188,6 +188,12 @@ For information about {es} metrics aggregations, refer to {ref}/search-aggregati | Type | Agg-based | Markdown | Lens | TSVB +| Metrics with filters +| +^| X +| +| + | Average ^| X ^| X @@ -221,7 +227,7 @@ For information about {es} metrics aggregations, refer to {ref}/search-aggregati | Percentiles ^| X ^| X -| +^| X ^| X | Percentiles Rank @@ -230,10 +236,10 @@ For information about {es} metrics aggregations, refer to {ref}/search-aggregati | ^| X -| Top hit +| Top hit (Last value) +^| X ^| X ^| X -| ^| X | Value count @@ -266,7 +272,7 @@ For information about {es} pipeline aggregations, refer to {ref}/search-aggregat | Derivative ^| X ^| X -| +^| X ^| X | Max bucket @@ -290,13 +296,13 @@ For information about {es} pipeline aggregations, refer to {ref}/search-aggregat | Moving average ^| X ^| X -| +^| X ^| X | Cumulative sum ^| X ^| X -| +^| X ^| X | Bucket script diff --git a/docs/user/dashboard/lens.asciidoc b/docs/user/dashboard/lens.asciidoc index 3b3a7a9ee527d4..9f17a380bc209a 100644 --- a/docs/user/dashboard/lens.asciidoc +++ b/docs/user/dashboard/lens.asciidoc @@ -147,14 +147,24 @@ For the answers to common *Lens* questions, review the following. [float] [[kql-]] -===== When should I use the Filter function instead of KQL filters? +===== When should I use the top filter bar, filters function, or "Filter by"? -The easiest way to apply KQL filters is to use <>, but you can also use the *Filters* function in the following scenarios: +Using the top <> bar is best when you want to focus on a known set of +data for all the visualization results. These top level filters are combined with other filters +using AND logic. + +Use the *Filters* function in the following scenarios: * When you want to apply more than one KQL filter to the visualization. * When you want to apply the KQL filter to a single layer, which allows you to visualize filtered and unfiltered data. +Use the *Filter by* advanced option in the following scenarios: + +* When you want to assign a custom color to each filter in a bar, line or area chart. + +* When you want to build a complex table, such as showing both failure rate and overall. + [float] [[when-should-i-normalize-the-data-by-unit-or-use-a-custom-interval]] ===== When should I normalize the data by unit or use a custom interval? diff --git a/docs/user/introduction.asciidoc b/docs/user/introduction.asciidoc index 25780d303eec41..82ca11f2162fda 100644 --- a/docs/user/introduction.asciidoc +++ b/docs/user/introduction.asciidoc @@ -195,7 +195,7 @@ When the rule triggers, you can send a notification to a system that is part of your daily workflow. {kib} integrates with email, Slack, PagerDuty, and ServiceNow, to name a few. -A dedicated view for creating, searching, and editing rules is in <>. +A dedicated view for creating, searching, and editing rules is in <>. [role="screenshot"] image::images/rules-and-connectors.png[Rules and Connectors view] @@ -437,7 +437,7 @@ the <>. |< Data>> |Set up rules -|< Rules and Connectors>> +|< Rules and Connectors>> |Organize your workspace and users |< Spaces>> diff --git a/docs/user/management.asciidoc b/docs/user/management.asciidoc index c5fabb15dc4de2..b86fa82c30381b 100644 --- a/docs/user/management.asciidoc +++ b/docs/user/management.asciidoc @@ -75,7 +75,7 @@ You can add and remove remote clusters, and check their connectivity. |=== | <> -| Centrally <> across {kib}. Create and <> across {kib}. Create and <> for triggering actions. | <> diff --git a/docs/user/monitoring/images/monitoring-kibana-alerting-notification.png b/docs/user/monitoring/images/monitoring-kibana-alerting-notification.png new file mode 100644 index 00000000000000..90951d18e667b6 Binary files /dev/null and b/docs/user/monitoring/images/monitoring-kibana-alerting-notification.png differ diff --git a/docs/user/monitoring/images/monitoring-kibana-alerting-setup-mode.png b/docs/user/monitoring/images/monitoring-kibana-alerting-setup-mode.png new file mode 100644 index 00000000000000..146992da5837ab Binary files /dev/null and b/docs/user/monitoring/images/monitoring-kibana-alerting-setup-mode.png differ diff --git a/docs/user/monitoring/kibana-alerts.asciidoc b/docs/user/monitoring/kibana-alerts.asciidoc index 58bf419d8d54a9..6046e67db62f1d 100644 --- a/docs/user/monitoring/kibana-alerts.asciidoc +++ b/docs/user/monitoring/kibana-alerts.asciidoc @@ -1,100 +1,109 @@ [role="xpack"] [[kibana-alerts]] -= {kib} Alerts += {kib} alerts The {stack} {monitor-features} provide -<> out-of-the box to notify you of -potential issues in the {stack}. These alerts are preconfigured based on the +<> out-of-the box to notify you +of potential issues in the {stack}. These rules are preconfigured based on the best practices recommended by Elastic. However, you can tailor them to meet your specific needs. -When you open *{stack-monitor-app}*, the preconfigured {kib} alerts are -created automatically. If you collect monitoring data from multiple clusters, -these alerts can search, detect, and notify on various conditions across the -clusters. The alerts are visible alongside your existing {watcher} cluster -alerts. You can view details about the alerts that are active and view health -and performance data for {es}, {ls}, and Beats in real time, as well as -analyze past performance. You can also modify active alerts. +[role="screenshot"] +image::user/monitoring/images/monitoring-kibana-alerts.png["{kib} alerts in {stack-monitor-app}"] + +When you open *{stack-monitor-app}*, the preconfigured rules are created +automatically. They are initially configured to detect and notify on various +conditions across your monitored clusters. You can view notifications for: *Cluster health*, *Resource utilization*, and *Errors and exceptions* for {es} +in real time. + +NOTE: The default {watcher} based "cluster alerts" for {stack-monitor-app} have +been recreated as rules in {kib} {alert-features}. For this reason, the existing +{watcher} email action +`monitoring.cluster_alerts.email_notifications.email_address` no longer works. +The default action for all {stack-monitor-app} rules is to write to {kib} logs +and display a notification in the UI. [role="screenshot"] -image::user/monitoring/images/monitoring-kibana-alerts.png["Kibana alerts in the Stack Monitoring app"] +image::user/monitoring/images/monitoring-kibana-alerting-notification.png["{kib} alerting notifications in {stack-monitor-app}"] -To review and modify all the available alerts, use -<> in *{stack-manage-app}*. + +[role="screenshot"] +image::user/monitoring/images/monitoring-kibana-alerting-setup-mode.png["Modify {kib} alerting rules in {stack-monitor-app}"] [discrete] [[kibana-alerts-cpu-threshold]] -== CPU threshold +== CPU usage threshold -This alert is triggered when a node runs a consistently high CPU load. By -default, the trigger condition is set at 85% or more averaged over the last 5 -minutes. The alert is grouped across all the nodes of the cluster by running -checks on a schedule time of 1 minute with a re-notify interval of 1 day. +This rule checks for {es} nodes that run a consistently high CPU load. By +default, the condition is set at 85% or more averaged over the last 5 minutes. +The rule is grouped across all the nodes of the cluster by running checks on a +schedule time of 1 minute with a re-notify interval of 1 day. [discrete] [[kibana-alerts-disk-usage-threshold]] == Disk usage threshold -This alert is triggered when a node is nearly at disk capacity. By -default, the trigger condition is set at 80% or more averaged over the last 5 -minutes. The alert is grouped across all the nodes of the cluster by running -checks on a schedule time of 1 minute with a re-notify interval of 1 day. +This rule checks for {es} nodes that are nearly at disk capacity. By default, +the condition is set at 80% or more averaged over the last 5 minutes. The rule +is grouped across all the nodes of the cluster by running checks on a schedule +time of 1 minute with a re-notify interval of 1 day. [discrete] [[kibana-alerts-jvm-memory-threshold]] == JVM memory threshold -This alert is triggered when a node runs a consistently high JVM memory usage. By -default, the trigger condition is set at 85% or more averaged over the last 5 -minutes. The alert is grouped across all the nodes of the cluster by running -checks on a schedule time of 1 minute with a re-notify interval of 1 day. +This rule checks for {es} nodes that use a high amount of JVM memory. By +default, the condition is set at 85% or more averaged over the last 5 minutes. +The rule is grouped across all the nodes of the cluster by running checks on a +schedule time of 1 minute with a re-notify interval of 1 day. [discrete] [[kibana-alerts-missing-monitoring-data]] == Missing monitoring data -This alert is triggered when any stack products nodes or instances stop sending -monitoring data. By default, the trigger condition is set to missing for 15 minutes -looking back 1 day. The alert is grouped across all the nodes of the cluster by running -checks on a schedule time of 1 minute with a re-notify interval of 6 hours. +This rule checks for {es} nodes that stop sending monitoring data. By default, +the condition is set to missing for 15 minutes looking back 1 day. The rule is +grouped across all the {es} nodes of the cluster by running checks on a schedule +time of 1 minute with a re-notify interval of 6 hours. [discrete] [[kibana-alerts-thread-pool-rejections]] == Thread pool rejections (search/write) -This alert is triggered when a node experiences thread pool rejections. By -default, the trigger condition is set at 300 or more over the last 5 -minutes. The alert is grouped across all the nodes of the cluster by running -checks on a schedule time of 1 minute with a re-notify interval of 1 day. -Thresholds can be set independently for `search` and `write` type rejections. +This rule checks for {es} nodes that experience thread pool rejections. By +default, the condition is set at 300 or more over the last 5 minutes. The rule +is grouped across all the nodes of the cluster by running checks on a schedule +time of 1 minute with a re-notify interval of 1 day. Thresholds can be set +independently for `search` and `write` type rejections. [discrete] [[kibana-alerts-ccr-read-exceptions]] == CCR read exceptions -This alert is triggered if a read exception has been detected on any of the -replicated clusters. The trigger condition is met if 1 or more read exceptions -are detected in the last hour. The alert is grouped across all replicated clusters -by running checks on a schedule time of 1 minute with a re-notify interval of 6 hours. +This rule checks for read exceptions on any of the replicated {es} clusters. The +condition is met if 1 or more read exceptions are detected in the last hour. The +rule is grouped across all replicated clusters by running checks on a schedule +time of 1 minute with a re-notify interval of 6 hours. [discrete] [[kibana-alerts-large-shard-size]] == Large shard size -This alert is triggered if a large average shard size (across associated primaries) is found on any of the -specified index patterns. The trigger condition is met if an index's average shard size is -55gb or higher in the last 5 minutes. The alert is grouped across all indices that match -the default pattern of `*` by running checks on a schedule time of 1 minute with a re-notify -interval of 12 hours. +This rule checks for a large average shard size (across associated primaries) on +any of the specified index patterns in an {es} cluster. The condition is met if +an index's average shard size is 55gb or higher in the last 5 minutes. The rule +is grouped across all indices that match the default pattern of `-.*` by running +checks on a schedule time of 1 minute with a re-notify interval of 12 hours. [discrete] [[kibana-alerts-cluster-alerts]] -== Cluster alerts +== Cluster alerting -These alerts summarize the current status of your {stack}. You can drill down into the metrics -to view more information about your cluster and specific nodes, instances, and indices. +These rules check the current status of your {stack}. You can drill down into +the metrics to view more information about your cluster and specific nodes, instances, and indices. -An alert will be triggered if any of the following conditions are met within the last minute: +An action is triggered if any of the following conditions are met within the +last minute: * {es} cluster health status is yellow (missing at least one replica) or red (missing at least one primary). @@ -110,7 +119,7 @@ versions reporting stats to the same monitoring cluster. -- If you do not preserve the data directory when upgrading a {kib} or Logstash node, the instance is assigned a new persistent UUID and shows up -as a new instance +as a new instance. -- * Subscription license expiration. When the expiration date approaches, you will get notifications with a severity level relative to how diff --git a/docs/user/production-considerations/alerting-production-considerations.asciidoc b/docs/user/production-considerations/alerting-production-considerations.asciidoc index 6294a4fe6f14ae..bd19a11435a99d 100644 --- a/docs/user/production-considerations/alerting-production-considerations.asciidoc +++ b/docs/user/production-considerations/alerting-production-considerations.asciidoc @@ -19,7 +19,7 @@ When relying on rules and actions as mission critical services, make sure you fo By default, each {kib} instance polls for work at three second intervals, and can run a maximum of ten concurrent tasks. These tasks are then run on the {kib} server. -Rules are recurring background tasks which are rescheduled according to the <> on completion. +Rules are recurring background tasks which are rescheduled according to the <> on completion. Actions are non-recurring background tasks which are deleted on completion. For more details on Task Manager, see <>. @@ -42,7 +42,7 @@ As rules and actions leverage background tasks to perform the majority of work, When estimating the required task throughput, keep the following in mind: -* Each rule uses a single recurring task that is scheduled to run at the cadence defined by its <>. +* Each rule uses a single recurring task that is scheduled to run at the cadence defined by its <>. * Each action uses a single task. However, because <>, alerts can generate a large number of non-recurring tasks. It is difficult to predict how much throughput is needed to ensure all rules and actions are executed at consistent schedules. diff --git a/docs/user/production-considerations/task-manager-health-monitoring.asciidoc b/docs/user/production-considerations/task-manager-health-monitoring.asciidoc index d6b90a4f19e112..8f2c8d106c77cf 100644 --- a/docs/user/production-considerations/task-manager-health-monitoring.asciidoc +++ b/docs/user/production-considerations/task-manager-health-monitoring.asciidoc @@ -92,10 +92,18 @@ a| Runtime | This section tracks excution performance of Task Manager, tracking task _drift_, worker _load_, and execution stats broken down by type, including duration and execution results. +a| Capacity Estimation + +| This section provides a rough estimate about the sufficiency of its capacity. As the name suggests, these are estimates based on historical data and should not be used as predictions. Use these estimations when following the Task Manager <>. + |=== Each section has a `timestamp` and a `status` that indicates when the last update to this section took place and whether the health of this section was evaluated as `OK`, `Warning` or `Error`. The root `status` indicates the `status` of the system overall. +The Runtime `status` indicates whether task executions have exceeded any of the <>. An `OK` status means none of the threshold have been exceeded. A `Warning` status means that at least one warning threshold has been exceeded. An `Error` status means that at least one error threshold has been exceeded. + +The Capacity Estimation `status` indicates the sufficiency of the observed capacity. An `OK` status means capacity is sufficient. A `Warning` status means that capacity is sufficient for the scheduled recurring tasks, but non-recurring tasks often cause the cluster to exceed capacity. An `Error` status means that there is insufficient capacity across all types of tasks. + By monitoring the `status` of the system overall, and the `status` of specific task types of interest, you can evaluate the health of the {kib} Task Management system. diff --git a/docs/user/production-considerations/task-manager-production-considerations.asciidoc b/docs/user/production-considerations/task-manager-production-considerations.asciidoc index 606f113b2274f1..17eae59ff2f9c2 100644 --- a/docs/user/production-considerations/task-manager-production-considerations.asciidoc +++ b/docs/user/production-considerations/task-manager-production-considerations.asciidoc @@ -68,11 +68,7 @@ This means that you can expect a single {kib} instance to support up to 200 _tas In practice, a {kib} instance will only achieve the upper bound of `200/tpm` if the duration of task execution is below the polling rate of 3 seconds. For the most part, the duration of tasks is below that threshold, but it can vary greatly as {es} and {kib} usage grow and task complexity increases (such as alerts executing heavy queries across large datasets). -By <>, you can make a rough estimate as to the required throughput as a _tasks per minute_ measurement. - -For example, suppose your current workload reveals a required throughput of `440/tpm`. You can address this scale by provisioning 3 {kib} instances, with an upper throughput of `600/tpm`. This scale would provide aproximately 25% additional capacity to handle ad-hoc non-recurring tasks and potential growth in recurring tasks. - -It is highly recommended that you maintain at least 20% additional capacity, beyond your expected workload, as spikes in ad-hoc tasks is possible at times of high activity (such as a spike in actions in response to an active alert). +By <>, you can estimate the number of {kib} instances required to reliably execute tasks in a timely manner. An appropriate number of {kib} instances can be estimated to match the required scale. For details on monitoring the health of {kib} Task Manager, follow the guidance in <>. @@ -126,6 +122,35 @@ Throughput is best thought of as a measurements in tasks per minute. A default {kib} instance can support up to `200/tpm`. +[float] +===== Automatic estimation + +experimental[] + +As demonstrated in <>, the Task Manager <> performs these estimations automatically. + +These estimates are based on historical data and should not be used as predictions, but can be used as a rough guide when scaling the system. + +We recommend provisioning enough {kib} instances to ensure a buffer between the observed maximum throughput (as estimated under `observed.max_throughput_per_minute`) and the average required throughput (as estimated under `observed.avg_required_throughput_per_minute`). Otherwise there might be insufficient capacity to handle spikes of ad-hoc tasks. How much of a buffer is needed largely depends on your use case, but keep in mind that estimated throughput takes into account recent spikes and, as long as they are representative of your system's behaviour, shouldn't require much of a buffer. + +We recommend provisioning at least as many {kib} instances as proposed by `proposed.provisioned_kibana`, but keep in mind that this number is based on the estimated required throughput, which is based on average historical performance, and cannot accurately predict future requirements. + +[WARNING] +============================================================================ +Automatic capacity estimation is performed by each {kib} instance independently. This estimation is performed by observing the task throughput in that instance, the number of {kib} instances executing tasks at that moment in time, and the recurring workload in {es}. + +If a {kib} instance is idle at the moment of capacity estimation, the number of active {kib} instances might be miscounted and the available throughput miscalculated. + +When evaluating the proposed {kib} instance number under `proposed.provisioned_kibana`, we highly recommend verifying that the `observed.observed_kibana_instances` matches the number of provisioned {kib} instances. +============================================================================ + +[float] +===== Manual estimation + +By <>, you can make a rough estimate as to the required throughput as a _tasks per minute_ measurement. + +For example, suppose your current workload reveals a required throughput of `440/tpm`. You can address this scale by provisioning 3 {kib} instances, with an upper throughput of `600/tpm`. This scale would provide aproximately 25% additional capacity to handle ad-hoc non-recurring tasks and potential growth in recurring tasks. + Given a deployment of 100 recurring tasks, estimating the required throughput depends on the scheduled cadence. Suppose you expect to run 50 tasks at a cadence of `10s`, the other 50 tasks at `20m`. In addition, you expect a couple dozen non-recurring tasks every minute. @@ -136,8 +161,11 @@ A recurring task requires as many executions as its cadence can fit in a minute. For this reason, we recommend grouping tasks by _tasks per minute_ and _tasks per hour_, as demonstrated in <>, averaging the _per hour_ measurement across all minutes. +It is highly recommended that you maintain at least 20% additional capacity, beyond your expected workload, as spikes in ad-hoc tasks is possible at times of high activity (such as a spike in actions in response to an active alert). + Given the predicted workload, you can estimate a lower bound throughput of `340/tpm` (`6/tpm` * 50 + `3/tph` * 50 + 20% buffer). As a default, a {kib} instance provides a throughput of `200/tpm`. A good starting point for your deployment is to provision 2 {kib} instances. You could then monitor their performance and reassess as the required throughput becomes clearer. Although this is a _rough_ estimate, the _tasks per minute_ provides the lower bound needed to execute tasks on time. -Once you calculate the rough _tasks per minute_ estimate, add a 20% buffer for non-recurring tasks. How much of a buffer is required largely depends on your use case, so <> as it grows to ensure enough of a buffer is provisioned. + +Once you estimate _tasks per minute_ , add a buffer for non-recurring tasks. How much of a buffer is required largely depends on your use case. Ensure enough of a buffer is provisioned by <> as it grows and tracking the ratio of recurring to non-recurring tasks by <>. diff --git a/docs/user/production-considerations/task-manager-troubleshooting.asciidoc b/docs/user/production-considerations/task-manager-troubleshooting.asciidoc index c6a7b7f3d53fdc..4b63313b2b96e0 100644 --- a/docs/user/production-considerations/task-manager-troubleshooting.asciidoc +++ b/docs/user/production-considerations/task-manager-troubleshooting.asciidoc @@ -74,6 +74,7 @@ By analyzing the different sections of the output, you can evaluate different th ** <> ** <> * <> +* <> Retrieve the latest monitored health stats of a {kib} instance Task Manager: @@ -178,6 +179,11 @@ The API returns the following: "p99": 166 } }, + "persistence": { + "recurring": 88, + "non_recurring": 4, + "ephemeral": 8 + }, "result_frequency_percent_as_number": { "alerting:.index-threshold": { "Success": 100, @@ -233,12 +239,44 @@ The API returns the following: ["1m", 2], ["60s", 2], ["5m", 2], - ["60m", 4] + ["60m", 4], + ["3600s", 1], + ["720m", 1] ], - "overdue": 0, - "estimated_schedule_density": [0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 3, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0] + "non_recurring": 18, + "owner_ids": 0, + "overdue": 10, + "overdue_non_recurring": 10, + "estimated_schedule_density": [0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 3, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0], + "capacity_requirments": { + "per_minute": 6, + "per_hour": 28, + "per_day": 2 + } }, "status": "OK" + }, + "capacity_estimation": { + "timestamp": "2021-02-16T11:38:06.826Z", + "value": { + "observed": { + "observed_kibana_instances": 1, + "max_throughput_per_minute_per_kibana": 200, + "max_throughput_per_minute": 200, + "minutes_to_drain_overdue": 1, + "avg_recurring_required_throughput_per_minute": 28, + "avg_recurring_required_throughput_per_minute_per_kibana": 28, + "avg_required_throughput_per_minute": 28, + "avg_required_throughput_per_minute_per_kibana": 28 + }, + "proposed": { + "min_required_kibana": 1, + "provisioned_kibana": 1, + "avg_recurring_required_throughput_per_minute_per_kibana": 28, + "avg_required_throughput_per_minute_per_kibana": 28 + } + } + "status": "OK" } } } @@ -530,7 +568,7 @@ Evaluating the health stats in this hypothetical scenario, you see the following You can infer from these stats that the high drift the Task Manager is experiencing is most likely due to Elasticsearch query alerts that are running for a long time. Resolving this issue is context dependent and changes from case to case. -In the preceding example above, this would be resolved by modifying the queries in these alerts to make them faster, or improving the {es} throughput to speed up the exiting query. +In the preceding example, this would be resolved by modifying the queries in these alerts to make them faster, or improving the {es} throughput to speed up the exiting query. [[task-manager-theory-high-fail-rate]] *Theory*: @@ -571,6 +609,82 @@ Evaluating the preceding health stats, you see the following output under `stats You can infer from these stats that most `actions:.index` tasks, which back the ES Index {kib} action, fail. Resolving that would require deeper investigation into the {kib} Server Log, where the exact errors are logged, and addressing these specific errors. +[[task-manager-theory-spikes-in-non-recurring-tasks]] +*Theory*: +Spikes in non-recurring and ephemeral tasks are consuming a high percentage of the available capacity + +*Diagnosis*: +Task Manager uses ad-hoc non-recurring tasks to load balance operations across multiple {kib} instances. +Additionally, {kib} can use Task Manager to allocate resources for expensive operations by executing an ephemeral task. Ephemeral tasks are identical in operation to non-recurring tasks, but are not persisted and cannot be load balanced across {kib} instances. + +Evaluating the preceding health stats, you see the following output under `stats.runtime.value.execution.persistence`: + +[source,json] +-------------------------------------------------- +{ + "recurring": 88, # <1> + "non_recurring": 4, # <2> + "ephemeral": 8 # <3> +}, +-------------------------------------------------- +<1> 88% of executed tasks are recurring tasks +<2> 4% of executed tasks are non-recurring tasks +<3> 8% of executed tasks are ephemeral tasks + +You can infer from these stats that the majority of executions consist of recurring tasks at 88%. +You can use the `execution.persistence` stats to evaluate the ratio of consumed capacity, but on their own, you should not make assumptions about the sufficiency of the available capacity. + +To assess the capacity, you should evaluate these stats against the `load` under `stats.runtime.value`: + +[source,json] +-------------------------------------------------- +{ + "load": { # <2> + "p50": 40, + "p90": 40, + "p95": 60, + "p99": 80 + } +} +-------------------------------------------------- + +You can infer from these stats that it is very unusual for Task Manager to run out of capacity, so the capacity is likely sufficient to handle the amount of non-recurring and ephemeral tasks. + +Suppose you have an alternate scenario, where you see the following output under `stats.runtime.value.execution.persistence`: + +[source,json] +-------------------------------------------------- +{ + "recurring": 60, # <1> + "non_recurring": 30, # <2> + "ephemeral": 10 # <3> +}, +-------------------------------------------------- +<1> 60% of executed tasks are recurring tasks +<2> 30% of executed tasks are non-recurring tasks +<3> 10% of executed tasks are ephemeral tasks + +You can infer from these stats that even though most executions are recurring tasks, a substantial percentage of executions are non-recurring and ephemeral tasks at 40%. + +Evaluating the `load` under `stats.runtime.value`, you see the following: + +[source,json] +-------------------------------------------------- +{ + "load": { # <2> + "p50": 70, + "p90": 100, + "p95": 100, + "p99": 100 + } +} +-------------------------------------------------- + +You can infer from these stats that it is quite common for this {kib} instance to run out of capacity. +Given the high rate of non-recurring and ephemeral tasks, it would be reasonable to assess that there is insufficient capacity in the {kib} cluster to handle the amount of tasks. + +Keep in mind that these stats give you a glimpse at a moment in time, and even though there has been insufficient capacity in recent minutes, this might not be true in other times where fewer non-recurring or ephemeral tasks are used. We recommend tracking these stats over time and identifying the source of these tasks before making sweeping changes to your infrastructure. + [[task-manager-health-evaluate-the-workload]] ===== Evaluate the Workload @@ -579,7 +693,7 @@ Predicting the required throughput a deplyment might need to support Task Manage <> provides statistics that make it easier to monitor the adequacy of the existing throughput. By evaluating the workload, the required throughput can be estimated, which is used when following the Task Manager <>. -Evaluating the preceding health stats above, you see the following output under `stats.workload.value`: +Evaluating the preceding health stats in the previous example, you see the following output under `stats.workload.value`: [source,json] -------------------------------------------------- @@ -607,27 +721,39 @@ Evaluating the preceding health stats above, you see the following output under } }, }, - "schedule": [ # <4> + "non_recurring": 0, # <4> + "owner_ids": 1, # <5> + "schedule": [ # <6> ["10s", 2], ["1m", 2], ["90s", 2], ["5m", 8] ], - "overdue": 0, # <5> - "estimated_schedule_density": [ # <6> + "overdue_non_recurring": 0, # <7> + "overdue": 0, # <8> + "estimated_schedule_density": [ # <9> 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 3, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0 - ] + ], + "capacity_requirments": { # <10> + "per_minute": 14, + "per_hour": 240, + "per_day": 0 + } } -------------------------------------------------- <1> There are 26 tasks in the system, including regular tasks, recurring tasks, and failed tasks. <2> There are 2 `idle` index threshold alert tasks, meaning they are scheduled to run at some point in the future. <3> Of the 14 tasks backing the ES index action, 10 have failed and 2 are running. -<4> A histogram of all scheduled recurring tasks shows that 2 tasks are scheduled to run every 10 seconds, 2 tasks are scheduled to run once a minute, and so on. -<5> There are no tasks overdue, which means that all tasks that *should* have run by now *have* run. -<6> This histogram shows the tasks scheduled to run throughout the upcoming 20 polling cycles. The histogram represents the entire deployment, rather than just this {kib} instance +<4> There are no non-recurring tasks in the queue. +<5> There is one Task Manager actively executing tasks. There might be additional idle Task Managers, but they aren't actively executing tasks at this moment in time. +<6> A histogram of all scheduled recurring tasks shows that 2 tasks are scheduled to run every 10 seconds, 2 tasks are scheduled to run once a minute, and so on. +<7> There are no overdue non-recurring tasks. Non-recurring tasks are usually scheduled to execute immediately, so overdue non-recurring tasks are often a symptom of a congested system. +<8> There are no overdue tasks, which means that all tasks that *should* have run by now *have* run. +<9> This histogram shows the tasks scheduled to run throughout the upcoming 20 polling cycles. The histogram represents the entire deployment, rather than just this {kib} instance. +<10> The capacity required to handle the recurring tasks in the system. These are buckets, rather than aggregated sums, and we recommend <> section, rather than evaluating these buckets yourself. The `workload` section summarizes the work load across the cluster, listing the tasks in the system, their types, schedules, and current status. @@ -674,6 +800,8 @@ Suppose the output of `stats.workload.value` looked something like this: } }, }, + "non_recurring": 0, + "owner_ids": 1, "schedule": [ # <2> ["10s", 38], ["1m", 101], @@ -683,32 +811,133 @@ Suppose the output of `stats.workload.value` looked something like this: ["60m", 106], ["1d", 61] ], + "overdue_non_recurring": 0, "overdue": 0, # <5> "estimated_schedule_density": [ # <3> 10, 1, 0, 10, 0, 20, 0, 1, 0, 1, 9, 0, 3, 10, 0, 0, 10, 10, 7, 0, 0, 31, 0, 12, 16, 31, 0, 10, 0, 10, 3, 22, 0, 10, 0, 2, 10, 10, 1, 0 - ] + ], + "capacity_requirments": { + "per_minute": 329, # <4> + "per_hour": 4272, # <5> + "per_day": 61 # <6> + } } -------------------------------------------------- <1> There are 2,191 tasks in the system. <2> The scheduled tasks are distributed across a variety of cadences. <3> The schedule density shows that you expect to exceed the default 10 concurrent tasks. +<4> There are 329 task executions that recur within the space of every minute. +<5> There are 4,273 task executions that recur within the space of every hour. +<6> There are 61 task executions that recur within the space of every day. You can infer several important attributes of your workload from this output: * There are many tasks in your system and ensuring these tasks run on their scheduled cadence will require attention to the Task Manager throughput. -* Assessing the high frequency tasks (tasks that recur at a cadence of a couple of minutes or less), you must support a throughput of approximately 400 tasks per minute (38 every 10 seconds + 101 every minute + 55 every 90 seconds). -* Assessing the medium frequency tasks (tasks that recur at a cadence of an hour or less), you must support an additional throughput of over 2000 tasks per hour (89 every 5 minutes, + 62 every 20 minutes + 106 each hour). You can average the needed throughput for the hour by counting these tasks as an additional 30 to 40 tasks per minute. +* Assessing the high frequency tasks (tasks that recur at a cadence of a couple of minutes or less), you must support a throughput of approximately 330 task executions per minute (38 every 10 seconds + 101 every minute). +* Assessing the medium frequency tasks (tasks that recur at a cadence of an hour or less), you must support an additional throughput of over 4,272 task executions per hour (55 every 90 seconds + 89 every 5 minutes, + 62 every 20 minutes + 106 each hour). You can average the needed throughput for the hour by counting these tasks as an additional 70 - 80 tasks per minute. * Assessing the estimated schedule density, there are cycles that are due to run upwards of 31 tasks concurrently, and along side these cycles, there are empty cycles. You can expect Task Manager to load balance these tasks throughout the empty cycles, but this won't leave much capacity to handle spikes in fresh tasks that might be scheduled in the future. -These rough calculations give you a lower bound to the required throughput, which is _at least_ 440 tasks per minute to ensure recurring tasks are executed, at their scheduled time. This throughput doesn't account for nonrecurring tasks that might have been scheduled, nor does it account for tasks (recurring or otherwise) that might be scheduled in the future. +These rough calculations give you a lower bound to the required throughput, which is _at least_ 410 tasks per minute to ensure recurring tasks are executed, at their scheduled time. This throughput doesn't account for nonrecurring tasks that might have been scheduled, nor does it account for tasks (recurring or otherwise) that might be scheduled in the future. Given these inferred attributes, it would be safe to assume that a single {kib} instance with default settings **would not** provide the required throughput. It is possible that scaling horizontally by adding a couple more {kib} instances will. For details on scaling Task Manager, see <>. + +[[task-manager-health-evaluate-the-capacity-estimation]] +===== Evaluate the Capacity Estimation + +Task Manager is constantly evaluating its runtime operations and workload. This enables Task Manager to make rough estimates about the sufficiency of its capacity. + +As the name suggests, these are estimates based on historical data and should not be used as predictions. These estimations should be evaluated alongside the detailed <> stats before making changes to infrastructure. These estimations assume all {kib} instances are configured identically. + +We recommend using these estimations when following the Task Manager <>. + +Evaluating the health stats in the previous example, you can see the following output under `stats.capacity_estimation.value`: + +[source,json] +-------------------------------------------------- +{ + "observed": { + "observed_kibana_instances": 1, # <1> + "minutes_to_drain_overdue": 1, # <2> + "max_throughput_per_minute_per_kibana": 200, + "max_throughput_per_minute": 200, # <3> + "avg_recurring_required_throughput_per_minute": 28, # <4> + "avg_recurring_required_throughput_per_minute_per_kibana": 28, + "avg_required_throughput_per_minute": 28, # <5> + "avg_required_throughput_per_minute_per_kibana": 28 + }, + "proposed": { + "min_required_kibana": 1, # <6> + "provisioned_kibana": 1, # <7> + "avg_recurring_required_throughput_per_minute_per_kibana": 28, + "avg_required_throughput_per_minute_per_kibana": 28 + } +} +-------------------------------------------------- +<1> These estimates assume that there is one {kib} instance actively executing tasks. +<2> Based on past throughput the overdue tasks in the system could be executed within 1 minute. +<3> Assuming all {kib} instances in the cluster are configured the same as this instance, the maximum available throughput is 200 tasks per minute. +<4> On average, the recurring tasks in the system have historically required a throughput of 28 tasks per minute. +<5> On average, regardless of whether they are recurring or otherwise, the tasks in the system have historically required a throughput of 28 tasks per minute. +<6> One {kib} instance should be sufficient to run the current recurring workload. +<7> We propose waiting for the workload to change before additional {kib} instances are provisioned. + +The `capacity_estimation` section is made up of two subsections: + +* `observed` estimates the current capacity by observing historical runtime and workload statistics +* `proposed` estimates the baseline {kib} cluster size and the expected throughput under such a deployment strategy + +You can infer from these estimates that the current system is under-utilized and has enough capacity to handle many more tasks than it currently does. + +Suppose an alternate scenario, where you see the following output under `stats.capacity_estimation.value`: + +[source,json] +-------------------------------------------------- +{ + "observed": { + "observed_kibana_instances": 2, # <1> + "max_throughput_per_minute_per_kibana": 200, + "max_throughput_per_minute": 400, # <2> + "minutes_to_drain_overdue": 12, # <3> + "avg_recurring_required_throughput_per_minute": 354, # <4> + "avg_recurring_required_throughput_per_minute_per_kibana": 177, # <5> + "avg_required_throughput_per_minute": 434, # <6> + "avg_required_throughput_per_minute_per_kibana": 217 + }, + "proposed": { + "min_required_kibana": 2, # <7> + "provisioned_kibana": 3, # <8> + "avg_recurring_required_throughput_per_minute_per_kibana": 118, # <9> + "avg_required_throughput_per_minute_per_kibana": 145 # <10> + } +} +-------------------------------------------------- +<1> These estimates assume that there are two {kib} instance actively executing tasks. +<2> The maximum available throughput in the system currently is 400 tasks per minute. +<3> Based on past throughput the overdue tasks in the system should be executed within 12 minutes. +<4> On average, the recurring tasks in the system have historically required a throughput of 354 tasks per minute. +<5> On average, each {kib} instance utilizes 177 tasks per minute of its capacity to execute recurring tasks. +<6> On average the tasks in the system have historically required a throughput of 434 tasks per minute. +<7> The system estimates that at least two {kib} instances are required to run the current recurring workload. +<8> The system recommends provisioning three {kib} instances to handle the workload. +<9> Once a third {kib} instance is provisioned, the capacity utilized by each instance to execute recurring tasks should drop from 177 to 118 tasks per minute. +<10> Taking into account historical ad-hoc task execution, we estimate the throughput required of each {kib} instance will drop from 217 task per minute to 145, once a third {kib} instance is provisioned. + +Evaluating by these estimates, we can infer some interesting attributes of our system: + +* These estimates are produced based on the assumption that there are two {kib} instances in the cluster. This number is based on the number of {kib} instances actively executing tasks in recent minutes. At times this number might fluctuate if {kib} instances remain idle, so validating these estimates against what you know about the system is recommended. +* There appear to be so many overdue tasks that it would take 12 minutes of executions to catch up with that backlog. This does not take into account tasks that might become overdue during those 12 minutes. Although this congestion might be temporary, the system could also remain consistently under provisioned and might never drain the backlog entirely. +* Evaluating the recurring tasks in the workload, the system requires a throughput of 354 tasks per minute on average to execute tasks on time, which is lower then the estimated maximum throughput of 400 tasks per minute. Once we take into account historical throughput though, we estimate the required throughput at 434 tasks per minute. This suggests that, historically, approximately 20% of tasks have been ad-hoc non-recurring tasks, the scale of which are harder to predict than recurring tasks. + +You can infer from these estimates that the capacity in the current system is insufficient and at least one additional {kib} instance is required to keep up with the workload. + +For details on scaling Task Manager, see <>. + [float] [[task-manager-cannot-operate-when-inline-scripts-are-disabled]] ==== Inline scripts are disabled in {es} diff --git a/examples/index_pattern_field_editor_example/README.md b/examples/index_pattern_field_editor_example/README.md new file mode 100644 index 00000000000000..35ae814fc10e25 --- /dev/null +++ b/examples/index_pattern_field_editor_example/README.md @@ -0,0 +1,7 @@ +## index pattern field editor example + +This example index pattern field editor app shows how to: + - Edit index pattern fields via flyout + - Delete index pattern runtime fields with modal confirm prompt + +To run this example, use the command `yarn start --run-examples`. \ No newline at end of file diff --git a/examples/index_pattern_field_editor_example/kibana.json b/examples/index_pattern_field_editor_example/kibana.json new file mode 100644 index 00000000000000..c522e6698ac3d6 --- /dev/null +++ b/examples/index_pattern_field_editor_example/kibana.json @@ -0,0 +1,10 @@ +{ + "id": "indexPatternFieldEditorExample", + "version": "0.0.1", + "kibanaVersion": "kibana", + "server": false, + "ui": true, + "requiredPlugins": ["data", "indexPatternFieldEditor", "developerExamples"], + "optionalPlugins": [], + "requiredBundles": [] +} diff --git a/examples/index_pattern_field_editor_example/public/app.tsx b/examples/index_pattern_field_editor_example/public/app.tsx new file mode 100644 index 00000000000000..bd725759380aae --- /dev/null +++ b/examples/index_pattern_field_editor_example/public/app.tsx @@ -0,0 +1,145 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { useState } from 'react'; +import ReactDOM from 'react-dom'; +import { + EuiPage, + EuiPageHeader, + EuiPageBody, + EuiPageContent, + EuiPageContentBody, + EuiButton, + EuiInMemoryTable, + EuiText, + DefaultItemAction, +} from '@elastic/eui'; +import { AppMountParameters } from '../../../src/core/public'; +import { + DataPublicPluginStart, + IndexPattern, + IndexPatternField, +} from '../../../src/plugins/data/public'; +import { IndexPatternFieldEditorStart } from '../../../src/plugins/index_pattern_field_editor/public'; + +interface Props { + indexPattern?: IndexPattern; + indexPatternFieldEditor: IndexPatternFieldEditorStart; +} + +const IndexPatternFieldEditorExample = ({ indexPattern, indexPatternFieldEditor }: Props) => { + const [fields, setFields] = useState( + indexPattern?.getNonScriptedFields() || [] + ); + const refreshFields = () => setFields(indexPattern?.getNonScriptedFields() || []); + const columns = [ + { + field: 'name', + name: 'Field name', + }, + { + name: 'Actions', + actions: [ + { + name: 'Edit', + description: 'Edit this field', + icon: 'pencil', + type: 'icon', + 'data-test-subj': 'editField', + onClick: (fld: IndexPatternField) => + indexPatternFieldEditor.openEditor({ + ctx: { indexPattern: indexPattern! }, + fieldName: fld.name, + onSave: refreshFields, + }), + }, + { + name: 'Delete', + description: 'Delete this field', + icon: 'trash', + type: 'icon', + 'data-test-subj': 'deleteField', + available: (fld) => !!fld.runtimeField, + onClick: (fld: IndexPatternField) => + indexPatternFieldEditor.openDeleteModal({ + fieldName: fld.name, + ctx: { + indexPattern: indexPattern!, + }, + onDelete: refreshFields, + }), + }, + ] as Array>, + }, + ]; + + const content = indexPattern ? ( + <> + Index pattern: {indexPattern?.title} +
+ + indexPatternFieldEditor.openEditor({ + ctx: { indexPattern: indexPattern! }, + onSave: refreshFields, + }) + } + data-test-subj="addField" + > + Add field + +
+ + items={fields} + columns={columns} + pagination={true} + hasActions={true} + sorting={{ + sort: { + field: 'name', + direction: 'asc', + }, + }} + /> + + ) : ( +

Please create an index pattern

+ ); + + return ( + + + Index pattern field editor demo + + {content} + + + + ); +}; + +interface RenderAppDependencies { + data: DataPublicPluginStart; + indexPatternFieldEditor: IndexPatternFieldEditorStart; +} + +export const renderApp = async ( + { data, indexPatternFieldEditor }: RenderAppDependencies, + { element }: AppMountParameters +) => { + const indexPattern = (await data.indexPatterns.getDefault()) || undefined; + ReactDOM.render( + , + element + ); + + return () => ReactDOM.unmountComponentAtNode(element); +}; diff --git a/examples/index_pattern_field_editor_example/public/index.ts b/examples/index_pattern_field_editor_example/public/index.ts new file mode 100644 index 00000000000000..cc509da31d25fb --- /dev/null +++ b/examples/index_pattern_field_editor_example/public/index.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { IndexPatternFieldEditorPlugin } from './plugin'; + +export const plugin = () => new IndexPatternFieldEditorPlugin(); diff --git a/examples/index_pattern_field_editor_example/public/plugin.tsx b/examples/index_pattern_field_editor_example/public/plugin.tsx new file mode 100644 index 00000000000000..ccbb93e3acf956 --- /dev/null +++ b/examples/index_pattern_field_editor_example/public/plugin.tsx @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Plugin, CoreSetup, AppMountParameters, AppNavLinkStatus } from '../../../src/core/public'; +import { DeveloperExamplesSetup } from '../../developer_examples/public'; +import { DataPublicPluginStart } from '../../../src/plugins/data/public'; +import { IndexPatternFieldEditorStart } from '../../../src/plugins/index_pattern_field_editor/public'; + +interface StartDeps { + data: DataPublicPluginStart; + indexPatternFieldEditor: IndexPatternFieldEditorStart; +} + +interface SetupDeps { + developerExamples: DeveloperExamplesSetup; +} + +export class IndexPatternFieldEditorPlugin implements Plugin { + public setup(core: CoreSetup, deps: SetupDeps) { + core.application.register({ + id: 'indexPatternFieldEditorExample', + title: 'Index pattern field editor example', + navLinkStatus: AppNavLinkStatus.hidden, + async mount(params: AppMountParameters) { + const [, depsStart] = await core.getStartServices(); + const { renderApp } = await import('./app'); + return renderApp(depsStart, params); + }, + }); + + deps.developerExamples.register({ + appId: 'indexPatternFieldEditorExample', + title: 'Index pattern field editor', + description: `IndexPatternFieldEditor provides a UI for editing index pattern fields directly from Kibana apps. This example plugin demonstrates integration.`, + links: [ + { + label: 'README', + href: + 'https://github.com/elastic/kibana/blob/master/src/plugins/index_pattern_field_editor/README.md', + iconType: 'logoGithub', + size: 's', + target: '_blank', + }, + ], + }); + } + + public start() {} + + public stop() {} +} diff --git a/examples/index_pattern_field_editor_example/tsconfig.json b/examples/index_pattern_field_editor_example/tsconfig.json new file mode 100644 index 00000000000000..1f6d52ed5260e4 --- /dev/null +++ b/examples/index_pattern_field_editor_example/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./target", + "skipLibCheck": true + }, + "include": [ + "index.ts", + "public/**/*.ts", + "public/**/*.tsx", + "../../typings/**/*", + ], + "exclude": [], + "references": [ + { "path": "../../src/core/tsconfig.json" }, + { "path": "../../src/plugins/kibana_react/tsconfig.json" }, + ] +} \ No newline at end of file diff --git a/examples/screenshot_mode_example/kibana.json b/examples/screenshot_mode_example/kibana.json index 4cb8c1a1393fbd..28e5b39e5337f9 100644 --- a/examples/screenshot_mode_example/kibana.json +++ b/examples/screenshot_mode_example/kibana.json @@ -4,6 +4,6 @@ "kibanaVersion": "kibana", "server": true, "ui": true, - "requiredPlugins": ["navigation", "screenshotMode", "usageCollection"], + "requiredPlugins": ["navigation", "screenshotMode", "usageCollection", "developerExamples"], "optionalPlugins": [] } diff --git a/examples/screenshot_mode_example/public/plugin.ts b/examples/screenshot_mode_example/public/plugin.ts index 91bcc2410b5fc5..4108924ca3b8d8 100644 --- a/examples/screenshot_mode_example/public/plugin.ts +++ b/examples/screenshot_mode_example/public/plugin.ts @@ -6,7 +6,13 @@ * Side Public License, v 1. */ -import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public'; +import { + AppMountParameters, + CoreSetup, + CoreStart, + Plugin, + AppNavLinkStatus, +} from '../../../src/core/public'; import { AppPluginSetupDependencies, AppPluginStartDependencies } from './types'; import { MetricsTracking } from './services'; import { PLUGIN_NAME } from '../common'; @@ -15,7 +21,7 @@ export class ScreenshotModeExamplePlugin implements Plugin { uiTracking = new MetricsTracking(); public setup(core: CoreSetup, depsSetup: AppPluginSetupDependencies): void { - const { screenshotMode, usageCollection } = depsSetup; + const { screenshotMode, usageCollection, developerExamples } = depsSetup; const isScreenshotMode = screenshotMode.isScreenshotMode(); this.uiTracking.setup({ @@ -27,6 +33,7 @@ export class ScreenshotModeExamplePlugin implements Plugin { core.application.register({ id: 'screenshotModeExample', title: PLUGIN_NAME, + navLinkStatus: AppNavLinkStatus.hidden, async mount(params: AppMountParameters) { // Load application bundle const { renderApp } = await import('./application'); @@ -40,6 +47,13 @@ export class ScreenshotModeExamplePlugin implements Plugin { return renderApp(coreStart, depsSetup, depsStart as AppPluginStartDependencies, params); }, }); + + developerExamples.register({ + appId: 'screenshotModeExample', + title: 'Screenshot mode integration', + description: + 'Demonstrate how a plugin can adapt appearance based on whether we are in screenshot mode', + }); } public start(core: CoreStart): void {} diff --git a/examples/screenshot_mode_example/public/types.ts b/examples/screenshot_mode_example/public/types.ts index 88812a4a507c91..2eb9bd8e144a0f 100644 --- a/examples/screenshot_mode_example/public/types.ts +++ b/examples/screenshot_mode_example/public/types.ts @@ -9,10 +9,12 @@ import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public'; import { ScreenshotModePluginSetup } from '../../../src/plugins/screenshot_mode/public'; import { UsageCollectionSetup } from '../../../src/plugins/usage_collection/public'; +import { DeveloperExamplesSetup } from '../../developer_examples/public'; export interface AppPluginSetupDependencies { usageCollection: UsageCollectionSetup; screenshotMode: ScreenshotModePluginSetup; + developerExamples: DeveloperExamplesSetup; } export interface AppPluginStartDependencies { diff --git a/package.json b/package.json index 6f5994a8679d68..b4f9109503261c 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ "@kbn/securitysolution-list-utils": "link:bazel-bin/packages/kbn-securitysolution-list-utils", "@kbn/securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils", "@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools", - "@kbn/server-route-repository": "link:packages/kbn-server-route-repository", + "@kbn/server-route-repository": "link:bazel-bin/packages/kbn-server-route-repository", "@kbn/std": "link:bazel-bin/packages/kbn-std", "@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath", "@kbn/ui-framework": "link:packages/kbn-ui-framework", @@ -318,7 +318,7 @@ "pegjs": "0.10.0", "pluralize": "3.1.0", "pngjs": "^3.4.0", - "polished": "^1.9.2", + "polished": "^3.7.2", "prop-types": "^15.7.2", "proper-lockfile": "^3.2.0", "proxy-from-env": "1.0.0", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 083ae90a031f50..3e17d471a3cac0 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -40,6 +40,7 @@ filegroup( "//packages/kbn-securitysolution-utils:build", "//packages/kbn-securitysolution-es-utils:build", "//packages/kbn-server-http-tools:build", + "//packages/kbn-server-route-repository:build", "//packages/kbn-std:build", "//packages/kbn-telemetry-tools:build", "//packages/kbn-tinymath:build", diff --git a/packages/kbn-dev-utils/src/plugins/parse_kibana_platform_plugin.ts b/packages/kbn-dev-utils/src/plugins/parse_kibana_platform_plugin.ts index 8d3fdb0f390c5e..62231f8221a957 100644 --- a/packages/kbn-dev-utils/src/plugins/parse_kibana_platform_plugin.ts +++ b/packages/kbn-dev-utils/src/plugins/parse_kibana_platform_plugin.ts @@ -29,6 +29,16 @@ interface Manifest { server: boolean; kibanaVersion: string; version: string; + // TODO: make this required. + owner?: { + // Internally, this should be a team name. + name: string; + // All internally owned plugins should have a github team specified that can be pinged in issues, or used to look up + // members who can be asked questions regarding the plugin. + githubTeam?: string; + }; + // TODO: make required. + description?: string; serviceFolders: readonly string[]; requiredPlugins: readonly string[]; optionalPlugins: readonly string[]; @@ -66,6 +76,8 @@ export function parseKibanaPlatformPlugin(manifestPath: string): KibanaPlatformP version: manifest.version, kibanaVersion: manifest.kibanaVersion || manifest.version, serviceFolders: manifest.serviceFolders || [], + owner: manifest.owner, + description: manifest.description, requiredPlugins: isValidDepsDeclaration(manifest.requiredPlugins, 'requiredPlugins'), optionalPlugins: isValidDepsDeclaration(manifest.optionalPlugins, 'optionalPlugins'), requiredBundles: isValidDepsDeclaration(manifest.requiredBundles, 'requiredBundles'), diff --git a/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts b/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts index 0e3d209d6398c5..55a466a430b696 100644 --- a/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts +++ b/packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts @@ -13,20 +13,12 @@ import { REPO_ROOT, run, CiStatsReporter, createFlagError } from '@kbn/dev-utils import { Project } from 'ts-morph'; import { writePluginDocs } from './mdx/write_plugin_mdx_docs'; -import { ApiDeclaration, PluginApi, TypeKind } from './types'; +import { ApiDeclaration, ApiStats, MissingApiItemMap, PluginApi, TypeKind } from './types'; import { findPlugins } from './find_plugins'; import { pathsOutsideScopes } from './build_api_declarations/utils'; import { getPluginApiMap } from './get_plugin_api_map'; import { writeDeprecationDoc } from './mdx/write_deprecations_doc'; -export interface PluginInfo { - apiCount: number; - apiCountMissingComments: number; - id: string; - missingApiItems: string[]; - percentApiMissingComments: number; -} - function isStringArray(arr: unknown | string[]): arr is string[] { return Array.isArray(arr) && arr.every((p) => typeof p === 'string'); } @@ -95,14 +87,13 @@ export function runBuildApiDocsCli() { const id = plugin.manifest.id; const pluginApi = pluginApiMap[id]; - const apiCount = countApiForPlugin(pluginApi); - const pluginStats = collectApiStatsForPlugin(pluginApi); + const pluginStats = collectApiStatsForPlugin(pluginApi, missingApiItems); reporter.metrics([ { id, group: 'API count', - value: apiCount, + value: pluginStats.apiCount, }, { id, @@ -202,8 +193,8 @@ export function runBuildApiDocsCli() { } } - if (apiCount > 0) { - writePluginDocs(outputFolder, pluginApi, log); + if (pluginStats.apiCount > 0) { + writePluginDocs(outputFolder, { doc: pluginApi, plugin, pluginStats, log }); } writeDeprecationDoc(outputFolder, referencedDeprecations, log); }); @@ -239,27 +230,27 @@ function getTsProject(repoPath: string) { return project; } -interface ApiStats { - missingComments: ApiDeclaration[]; - isAnyType: ApiDeclaration[]; - noReferences: ApiDeclaration[]; -} - -function collectApiStatsForPlugin(doc: PluginApi): ApiStats { - const stats: ApiStats = { missingComments: [], isAnyType: [], noReferences: [] }; +function collectApiStatsForPlugin(doc: PluginApi, missingApiItems: MissingApiItemMap): ApiStats { + const stats: ApiStats = { + missingComments: [], + isAnyType: [], + noReferences: [], + apiCount: countApiForPlugin(doc), + missingExports: Object.values(missingApiItems[doc.id] ?? {}).length, + }; Object.values(doc.client).forEach((def) => { - collectStatsForApi(def, stats); + collectStatsForApi(def, stats, doc); }); Object.values(doc.server).forEach((def) => { - collectStatsForApi(def, stats); + collectStatsForApi(def, stats, doc); }); Object.values(doc.common).forEach((def) => { - collectStatsForApi(def, stats); + collectStatsForApi(def, stats, doc); }); return stats; } -function collectStatsForApi(doc: ApiDeclaration, stats: ApiStats): void { +function collectStatsForApi(doc: ApiDeclaration, stats: ApiStats, pluginApi: PluginApi): void { const missingComment = doc.description === undefined || doc.description.length === 0; if (missingComment) { stats.missingComments.push(doc); @@ -269,7 +260,7 @@ function collectStatsForApi(doc: ApiDeclaration, stats: ApiStats): void { } if (doc.children) { doc.children.forEach((child) => { - collectStatsForApi(child, stats); + collectStatsForApi(child, stats, pluginApi); }); } if (!doc.references || doc.references.length === 0) { diff --git a/packages/kbn-docs-utils/src/api_docs/mdx/types.ts b/packages/kbn-docs-utils/src/api_docs/mdx/types.ts new file mode 100644 index 00000000000000..38c25fe68f7bb2 --- /dev/null +++ b/packages/kbn-docs-utils/src/api_docs/mdx/types.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { KibanaPlatformPlugin, ToolingLog } from '@kbn/dev-utils'; +import { ApiStats, PluginApi } from '../types'; + +export interface WritePluginDocsOpts { + doc: PluginApi; + plugin: KibanaPlatformPlugin; + pluginStats: ApiStats; + log: ToolingLog; +} diff --git a/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_mdx_docs.ts b/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_mdx_docs.ts index 86ddf38cba4b66..557277331b099b 100644 --- a/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_mdx_docs.ts +++ b/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_mdx_docs.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import { ToolingLog } from '@kbn/dev-utils'; import fs from 'fs'; import Path from 'path'; import dedent from 'dedent'; @@ -19,6 +18,7 @@ import { groupPluginApi, } from '../utils'; import { writePluginDocSplitByFolder } from './write_plugin_split_by_folder'; +import { WritePluginDocsOpts } from './types'; /** * Converts the plugin doc to mdx and writes it into the file system. If the plugin, @@ -28,12 +28,15 @@ import { writePluginDocSplitByFolder } from './write_plugin_split_by_folder'; * @param doc Contains the information of the plugin that will be written into mdx. * @param log Used for logging debug and error information. */ -export function writePluginDocs(folder: string, doc: PluginApi, log: ToolingLog): void { +export function writePluginDocs( + folder: string, + { doc, plugin, pluginStats, log }: WritePluginDocsOpts +): void { if (doc.serviceFolders) { log.debug(`Splitting plugin ${doc.id}`); - writePluginDocSplitByFolder(folder, doc, log); + writePluginDocSplitByFolder(folder, { doc, log, plugin, pluginStats }); } else { - writePluginDoc(folder, doc, log); + writePluginDoc(folder, { doc, plugin, pluginStats, log }); } } @@ -50,7 +53,10 @@ function hasPublicApi(doc: PluginApi): boolean { * @param doc Contains the information of the plugin that will be written into mdx. * @param log Used for logging debug and error information. */ -export function writePluginDoc(folder: string, doc: PluginApi, log: ToolingLog): void { +export function writePluginDoc( + folder: string, + { doc, log, plugin, pluginStats }: WritePluginDocsOpts +): void { if (!hasPublicApi(doc)) { log.debug(`${doc.id} does not have a public api. Skipping.`); return; @@ -62,6 +68,7 @@ export function writePluginDoc(folder: string, doc: PluginApi, log: ToolingLog): // Append "obj" to avoid special names in here. 'case' is one in particular that // caused issues. const json = getJsonName(fileName) + 'Obj'; + const name = plugin.manifest.owner?.name; let mdx = dedent(` --- @@ -74,9 +81,26 @@ date: 2020-11-16 tags: ['contributor', 'dev', 'apidocs', 'kibana', '${doc.id}'] warning: This document is auto-generated and is meant to be viewed inside our experimental, new docs system. Reach out in #docs-engineering for more info. --- - import ${json} from './${fileName}.json'; +${plugin.manifest.description ?? ''} + +${ + plugin.manifest.owner?.githubTeam && name + ? `Contact [${name}](https://github.com/orgs/elastic/teams/${plugin.manifest.owner?.githubTeam}) for questions regarding this plugin.` + : name + ? `Contact ${name} for questions regarding this plugin.` + : '' +} + +**Code health stats** + +| Public API count | Any count | Items lacking comments | Missing exports | +|-------------------|-----------|------------------------|-----------------| +| ${pluginStats.apiCount} | ${pluginStats.isAnyType.length} | ${ + pluginStats.missingComments.length + } | ${pluginStats.missingExports} | + `) + '\n\n'; const scopedDoc = { diff --git a/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_split_by_folder.ts b/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_split_by_folder.ts index f5d547fc03520d..1a9037df0aa253 100644 --- a/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_split_by_folder.ts +++ b/packages/kbn-docs-utils/src/api_docs/mdx/write_plugin_split_by_folder.ts @@ -6,17 +6,22 @@ * Side Public License, v 1. */ -import { ToolingLog } from '@kbn/dev-utils'; import { snakeToCamel } from '../utils'; import { PluginApi, ApiDeclaration } from '../types'; import { writePluginDoc } from './write_plugin_mdx_docs'; +import { WritePluginDocsOpts } from './types'; -export function writePluginDocSplitByFolder(folder: string, doc: PluginApi, log: ToolingLog) { +export function writePluginDocSplitByFolder( + folder: string, + { doc, plugin, pluginStats, log }: WritePluginDocsOpts +) { const apisByFolder = splitApisByFolder(doc); log.debug(`Split ${doc.id} into ${apisByFolder.length} services`); apisByFolder.forEach((docDef) => { - writePluginDoc(folder, docDef, log); + // TODO: we should probably see if we can break down these stats by service folder. As it is, they will represent stats for + // the entire plugin. + writePluginDoc(folder, { doc: docDef, plugin, pluginStats, log }); }); } diff --git a/packages/kbn-docs-utils/src/api_docs/tests/api_doc_suite.test.ts b/packages/kbn-docs-utils/src/api_docs/tests/api_doc_suite.test.ts index ff71b0efc79d1c..c5538b9da229ea 100644 --- a/packages/kbn-docs-utils/src/api_docs/tests/api_doc_suite.test.ts +++ b/packages/kbn-docs-utils/src/api_docs/tests/api_doc_suite.test.ts @@ -13,7 +13,7 @@ import { Project } from 'ts-morph'; import { ToolingLog, KibanaPlatformPlugin } from '@kbn/dev-utils'; import { writePluginDocs } from '../mdx/write_plugin_mdx_docs'; -import { ApiDeclaration, PluginApi, Reference, TextWithLinks, TypeKind } from '../types'; +import { ApiDeclaration, ApiStats, PluginApi, Reference, TextWithLinks, TypeKind } from '../types'; import { getKibanaPlatformPlugin } from './kibana_platform_plugin_mock'; import { groupPluginApi } from '../utils'; import { getPluginApiMap } from '../get_plugin_api_map'; @@ -99,11 +99,23 @@ beforeAll(() => { const plugins: KibanaPlatformPlugin[] = [pluginA, pluginB]; const { pluginApiMap } = getPluginApiMap(project, plugins, log, { collectReferences: false }); + const pluginStats: ApiStats = { + missingComments: [], + isAnyType: [], + noReferences: [], + apiCount: 3, + missingExports: 0, + }; doc = pluginApiMap.pluginA; mdxOutputFolder = Path.resolve(__dirname, 'snapshots'); - writePluginDocs(mdxOutputFolder, doc, log); - writePluginDocs(mdxOutputFolder, pluginApiMap.pluginB, log); + writePluginDocs(mdxOutputFolder, { doc, plugin: pluginA, pluginStats, log }); + writePluginDocs(mdxOutputFolder, { + doc: pluginApiMap.pluginB, + plugin: pluginB, + pluginStats, + log, + }); }); it('Setup type is extracted', () => { diff --git a/packages/kbn-docs-utils/src/api_docs/types.ts b/packages/kbn-docs-utils/src/api_docs/types.ts index 007b8c824d3c26..de53993fe30366 100644 --- a/packages/kbn-docs-utils/src/api_docs/types.ts +++ b/packages/kbn-docs-utils/src/api_docs/types.ts @@ -231,3 +231,10 @@ export interface ApiReference { export interface ReferencedDeprecations { [key: string]: Array<{ deprecatedApi: ApiDeclaration; ref: ApiReference }>; } +export interface ApiStats { + missingComments: ApiDeclaration[]; + isAnyType: ApiDeclaration[]; + noReferences: ApiDeclaration[]; + apiCount: number; + missingExports: number; +} diff --git a/packages/kbn-monaco/src/monaco_imports.ts b/packages/kbn-monaco/src/monaco_imports.ts index 872ac46352cf31..92ea23347c374c 100644 --- a/packages/kbn-monaco/src/monaco_imports.ts +++ b/packages/kbn-monaco/src/monaco_imports.ts @@ -21,5 +21,6 @@ import 'monaco-editor/esm/vs/editor/contrib/folding/folding.js'; // Needed for f import 'monaco-editor/esm/vs/editor/contrib/suggest/suggestController.js'; // Needed for suggestions import 'monaco-editor/esm/vs/editor/contrib/hover/hover.js'; // Needed for hover import 'monaco-editor/esm/vs/editor/contrib/parameterHints/parameterHints.js'; // Needed for signature +import 'monaco-editor/esm/vs/editor/contrib/bracketMatching/bracketMatching.js'; // Needed for brackets matching highlight export { monaco }; diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index e455f487d13843..1311eb4d7c6388 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -48479,7 +48479,7 @@ async function runBazelCommandWithRunner(bazelCommandRunner, bazelArgs, offline stdio: 'pipe' }); - if (offline) { + if (offline || !offline) { bazelArgs = [...bazelArgs, '--config=offline']; } diff --git a/packages/kbn-pm/src/utils/bazel/run.ts b/packages/kbn-pm/src/utils/bazel/run.ts index c030081e53daaf..5f3743876e0e4a 100644 --- a/packages/kbn-pm/src/utils/bazel/run.ts +++ b/packages/kbn-pm/src/utils/bazel/run.ts @@ -29,7 +29,7 @@ async function runBazelCommandWithRunner( stdio: 'pipe', }; - if (offline) { + if (offline || !offline) { bazelArgs = [...bazelArgs, '--config=offline']; } diff --git a/packages/kbn-server-route-repository/BUILD.bazel b/packages/kbn-server-route-repository/BUILD.bazel new file mode 100644 index 00000000000000..3a146086e80bc3 --- /dev/null +++ b/packages/kbn-server-route-repository/BUILD.bazel @@ -0,0 +1,89 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") + +PKG_BASE_NAME = "kbn-server-route-repository" +PKG_REQUIRE_NAME = "@kbn/server-route-repository" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", + "README.md" +] + +SRC_DEPS = [ + "//packages/kbn-config-schema", + "//packages/kbn-io-ts-utils", + "@npm//@hapi/boom", + "@npm//fp-ts", + "@npm//io-ts", + "@npm//lodash", + "@npm//utility-types" +] + +TYPES_DEPS = [ + "@npm//@types/jest", + "@npm//@types/lodash", + "@npm//@types/node", +] + +DEPS = SRC_DEPS + TYPES_DEPS + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + ], +) + +ts_project( + name = "tsc", + args = ['--pretty'], + srcs = SRCS, + deps = DEPS, + declaration = True, + declaration_map = True, + incremental = True, + out_dir = "target", + source_map = True, + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_BASE_NAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = DEPS + [":tsc"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [ + ":%s" % PKG_BASE_NAME, + ] +) + +filegroup( + name = "build", + srcs = [ + ":npm_module", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-server-route-repository/package.json b/packages/kbn-server-route-repository/package.json index 4ae625d83a7003..cfeab275e19cf6 100644 --- a/packages/kbn-server-route-repository/package.json +++ b/packages/kbn-server-route-repository/package.json @@ -4,10 +4,5 @@ "types": "./target/index.d.ts", "version": "1.0.0", "license": "SSPL-1.0 OR Elastic License 2.0", - "private": true, - "scripts": { - "build": "../../node_modules/.bin/tsc", - "kbn:bootstrap": "yarn build", - "kbn:watch": "yarn build --watch" - } + "private": true } diff --git a/packages/kbn-server-route-repository/tsconfig.json b/packages/kbn-server-route-repository/tsconfig.json index 8f1e72172c6759..7614a9411602ef 100644 --- a/packages/kbn-server-route-repository/tsconfig.json +++ b/packages/kbn-server-route-repository/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": false, + "incremental": true, "outDir": "./target", "stripInternal": false, "declaration": true, diff --git a/packages/kbn-test/src/kbn_archiver_cli.ts b/packages/kbn-test/src/kbn_archiver_cli.ts index 04581a83546686..6eb1d4bf68dadc 100644 --- a/packages/kbn-test/src/kbn_archiver_cli.ts +++ b/packages/kbn-test/src/kbn_archiver_cli.ts @@ -43,13 +43,11 @@ export function runKbnArchiverCli() { new RunWithCommands({ description: 'Import/export saved objects from archives, for testing', globalFlags: { - string: ['config', 'space', 'kibana-url', 'dir'], + string: ['config', 'space', 'kibana-url'], help: ` --space space id to operate on, defaults to the default space --config optional path to an FTR config file that will be parsed and used for defaults --kibana-url set the url that kibana can be reached at, uses the "servers.kibana" setting from --config by default - --dir directory that contains exports to be imported, or where exports will be saved, uses the "kbnArchiver.directory" - setting from --config by default `, }, async extendContext({ log, flags }) { @@ -79,23 +77,6 @@ export function runKbnArchiverCli() { ); } - let importExportDir; - if (flags.dir) { - if (typeof flags.dir !== 'string') { - throw createFlagError('expected --dir to be a string'); - } - - importExportDir = flags.dir; - } else if (config) { - importExportDir = config.get('kbnArchiver.directory'); - } - - if (!importExportDir) { - throw createFlagError( - '--config does not include a kbnArchiver.directory, specify it or include --dir flag' - ); - } - const space = flags.space; if (!(space === undefined || typeof space === 'string')) { throw createFlagError('--space must be a string'); @@ -106,7 +87,7 @@ export function runKbnArchiverCli() { kbnClient: new KbnClient({ log, url: kibanaUrl, - importExportDir, + importExportBaseDir: process.cwd(), }), }; }, diff --git a/packages/kbn-test/src/kbn_client/kbn_client.ts b/packages/kbn-test/src/kbn_client/kbn_client.ts index ac14a399918cb9..e44f5005933002 100644 --- a/packages/kbn-test/src/kbn_client/kbn_client.ts +++ b/packages/kbn-test/src/kbn_client/kbn_client.ts @@ -22,7 +22,7 @@ export interface KbnClientOptions { certificateAuthorities?: Buffer[]; log: ToolingLog; uiSettingDefaults?: UiSettingValues; - importExportDir?: string; + importExportBaseDir?: string; } export class KbnClient { @@ -67,7 +67,7 @@ export class KbnClient { this.log, this.requester, this.savedObjects, - options.importExportDir + options.importExportBaseDir ); } diff --git a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts index fe67fbb70fa3ca..88953cdbaed7c9 100644 --- a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts +++ b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts @@ -8,10 +8,11 @@ import { inspect } from 'util'; import Fs from 'fs/promises'; +import { existsSync } from 'fs'; import Path from 'path'; import FormData from 'form-data'; -import { ToolingLog, isAxiosResponseError, createFailError } from '@kbn/dev-utils'; +import { ToolingLog, isAxiosResponseError, createFailError, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClientRequester, uriencode, ReqOptions } from './kbn_client_requester'; import { KbnClientSavedObjects } from './kbn_client_saved_objects'; @@ -39,7 +40,7 @@ export class KbnClientImportExport { public readonly log: ToolingLog, public readonly requester: KbnClientRequester, public readonly savedObjects: KbnClientSavedObjects, - public readonly dir?: string + public readonly baseDir: string = REPO_ROOT ) {} private resolvePath(path: string) { @@ -47,18 +48,24 @@ export class KbnClientImportExport { path = `${path}.json`; } - if (!this.dir && !Path.isAbsolute(path)) { + return Path.resolve(this.baseDir, path); + } + + private resolveAndValidatePath(path: string) { + const absolutePath = this.resolvePath(path); + + if (!existsSync(absolutePath)) { throw new Error( - 'unable to resolve relative path to import/export without a configured dir, either path absolute path or specify --dir' + `unable to resolve path [${path}] to import/export, resolved relative to [${this.baseDir}]` ); } - return this.dir ? Path.resolve(this.dir, path) : path; + return absolutePath; } - async load(name: string, options?: { space?: string }) { - const src = this.resolvePath(name); - this.log.debug('resolved import for', name, 'to', src); + async load(path: string, options?: { space?: string }) { + const src = this.resolveAndValidatePath(path); + this.log.debug('resolved import for', path, 'to', src); const objects = await parseArchive(src); this.log.info('importing', objects.length, 'saved objects', { space: options?.space }); @@ -91,8 +98,8 @@ export class KbnClientImportExport { } } - async unload(name: string, options?: { space?: string }) { - const src = this.resolvePath(name); + async unload(path: string, options?: { space?: string }) { + const src = this.resolveAndValidatePath(path); this.log.debug('unloading docs from archive at', src); const objects = await parseArchive(src); @@ -110,8 +117,8 @@ export class KbnClientImportExport { this.log.success(deleted, 'saved objects deleted'); } - async save(name: string, options: { types: string[]; space?: string }) { - const dest = this.resolvePath(name); + async save(path: string, options: { types: string[]; space?: string }) { + const dest = this.resolvePath(path); this.log.debug('saving export to', dest); const resp = await this.req(options.space, { @@ -141,6 +148,7 @@ export class KbnClientImportExport { }) .join('\n\n'); + await Fs.mkdir(Path.dirname(dest), { recursive: true }); await Fs.writeFile(dest, fileContents, 'utf-8'); this.log.success('Exported', objects.length, 'saved objects to', dest); diff --git a/packages/kbn-tinymath/grammar/grammar.peggy b/packages/kbn-tinymath/grammar/grammar.peggy index cbcb0b91bfea90..1c6f8c3334c234 100644 --- a/packages/kbn-tinymath/grammar/grammar.peggy +++ b/packages/kbn-tinymath/grammar/grammar.peggy @@ -1,16 +1,16 @@ // tinymath parsing grammar { - function simpleLocation (location) { - // Returns an object representing the position of the function within the expression, - // demarcated by the position of its first character and last character. We calculate these values - // using the offset because the expression could span multiple lines, and we don't want to deal - // with column and line values. - return { - min: location.start.offset, - max: location.end.offset + function simpleLocation (location) { + // Returns an object representing the position of the function within the expression, + // demarcated by the position of its first character and last character. We calculate these values + // using the offset because the expression could span multiple lines, and we don't want to deal + // with column and line values. + return { + min: location.start.offset, + max: location.end.offset + } } - } } start @@ -74,26 +74,34 @@ Expression = AddSubtract AddSubtract - = _ left:MultiplyDivide rest:(('+' / '-') MultiplyDivide)* _ { - return rest.reduce((acc, curr) => ({ + = _ left:MultiplyDivide rest:(('+' / '-') MultiplyDivide)+ _ { + const topLevel = rest.reduce((acc, curr) => ({ type: 'function', name: curr[0] === '+' ? 'add' : 'subtract', args: [acc, curr[1]], - location: simpleLocation(location()), - text: text() - }), left) + }), left); + if (typeof topLevel === 'object') { + topLevel.location = simpleLocation(location()); + topLevel.text = text(); + } + return topLevel; } + / MultiplyDivide MultiplyDivide = _ left:Factor rest:(('*' / '/') Factor)* _ { - return rest.reduce((acc, curr) => ({ + const topLevel = rest.reduce((acc, curr) => ({ type: 'function', name: curr[0] === '*' ? 'multiply' : 'divide', args: [acc, curr[1]], - location: simpleLocation(location()), - text: text() - }), left) + }), left); + if (typeof topLevel === 'object') { + topLevel.location = simpleLocation(location()); + topLevel.text = text(); + } + return topLevel; } + / Factor Factor = Group diff --git a/packages/kbn-tinymath/index.d.ts b/packages/kbn-tinymath/index.d.ts index c3c32a59fa15ad..8e15d86c88fc84 100644 --- a/packages/kbn-tinymath/index.d.ts +++ b/packages/kbn-tinymath/index.d.ts @@ -24,9 +24,11 @@ export interface TinymathLocation { export interface TinymathFunction { type: 'function'; name: string; - text: string; args: TinymathAST[]; - location: TinymathLocation; + // Location is not guaranteed because PEG grammars are not left-recursive + location?: TinymathLocation; + // Text is not guaranteed because PEG grammars are not left-recursive + text?: string; } export interface TinymathVariable { diff --git a/packages/kbn-tinymath/test/library.test.js b/packages/kbn-tinymath/test/library.test.js index bf1c7a9dbc5fb5..bbc8503684fd40 100644 --- a/packages/kbn-tinymath/test/library.test.js +++ b/packages/kbn-tinymath/test/library.test.js @@ -41,6 +41,35 @@ describe('Parser', () => { }); }); + describe('Math', () => { + it('converts basic symbols into left-to-right pairs', () => { + expect(parse('a + b + c - d')).toEqual({ + args: [ + { + name: 'add', + type: 'function', + args: [ + { + name: 'add', + type: 'function', + args: [ + expect.objectContaining({ location: { min: 0, max: 2 } }), + expect.objectContaining({ location: { min: 3, max: 6 } }), + ], + }, + expect.objectContaining({ location: { min: 7, max: 10 } }), + ], + }, + expect.objectContaining({ location: { min: 11, max: 13 } }), + ], + name: 'subtract', + type: 'function', + text: 'a + b + c - d', + location: { min: 0, max: 13 }, + }); + }); + }); + describe('Variables', () => { it('strings', () => { expect(parse('f')).toEqual(variableEqual('f')); @@ -263,6 +292,8 @@ describe('Evaluate', () => { expect(evaluate('5/20')).toEqual(0.25); expect(evaluate('1 + 1 + 2 + 3 + 12')).toEqual(19); expect(evaluate('100 / 10 / 10')).toEqual(1); + expect(evaluate('0 * 1 - 100 / 10 / 10')).toEqual(-1); + expect(evaluate('100 / (10 / 10)')).toEqual(100); }); it('equations with functions', () => { diff --git a/src/cli_plugin/install/index.js b/src/cli_plugin/install/index.js index 2683dd41d2bb32..dbad6bc8ba19c9 100644 --- a/src/cli_plugin/install/index.js +++ b/src/cli_plugin/install/index.js @@ -24,7 +24,7 @@ function processCommand(command, options) { const logger = new Logger(settings); - logWarnings(settings, logger); + logWarnings(logger); install(settings, logger); } diff --git a/src/cli_plugin/remove/index.js b/src/cli_plugin/remove/index.js index 329f506520c245..3f571e605028f3 100644 --- a/src/cli_plugin/remove/index.js +++ b/src/cli_plugin/remove/index.js @@ -24,7 +24,7 @@ function processCommand(command, options) { const logger = new Logger(settings); - logWarnings(settings, logger); + logWarnings(logger); remove(settings, logger); } diff --git a/src/core/public/application/integration_tests/router.test.tsx b/src/core/public/application/integration_tests/router.test.tsx index 55c18e49cba131..2543d22ee6d31b 100644 --- a/src/core/public/application/integration_tests/router.test.tsx +++ b/src/core/public/application/integration_tests/router.test.tsx @@ -96,7 +96,7 @@ describe('AppRouter', () => { expect(app1.mounter.mount).toHaveBeenCalled(); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /app/app1 html: App 1
" @@ -108,7 +108,7 @@ describe('AppRouter', () => { expect(app1Unmount).toHaveBeenCalled(); expect(app2.mounter.mount).toHaveBeenCalled(); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /app/app2 html:
App 2
" @@ -122,7 +122,7 @@ describe('AppRouter', () => { expect(standardApp.mounter.mount).toHaveBeenCalled(); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /app/app1 html: App 1
" @@ -134,7 +134,7 @@ describe('AppRouter', () => { expect(standardAppUnmount).toHaveBeenCalled(); expect(chromelessApp.mounter.mount).toHaveBeenCalled(); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /chromeless-a/path html:
Chromeless A
" @@ -146,7 +146,7 @@ describe('AppRouter', () => { expect(chromelessAppUnmount).toHaveBeenCalled(); expect(standardApp.mounter.mount).toHaveBeenCalledTimes(2); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /app/app1 html: App 1
" @@ -160,7 +160,7 @@ describe('AppRouter', () => { expect(chromelessAppA.mounter.mount).toHaveBeenCalled(); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /chromeless-a/path html:
Chromeless A
" @@ -172,7 +172,7 @@ describe('AppRouter', () => { expect(chromelessAppAUnmount).toHaveBeenCalled(); expect(chromelessAppB.mounter.mount).toHaveBeenCalled(); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /chromeless-b/path html:
Chromeless B
" @@ -184,7 +184,7 @@ describe('AppRouter', () => { expect(chromelessAppBUnmount).toHaveBeenCalled(); expect(chromelessAppA.mounter.mount).toHaveBeenCalledTimes(2); expect(dom?.html()).toMatchInlineSnapshot(` - "
+ "
basename: /chromeless-a/path html:
Chromeless A
" diff --git a/src/core/public/application/ui/app_container.scss b/src/core/public/application/ui/app_container.scss index 4f8fec10a97e15..d30db740505d18 100644 --- a/src/core/public/application/ui/app_container.scss +++ b/src/core/public/application/ui/app_container.scss @@ -1,5 +1,5 @@ .appContainer__loading { - position: fixed; + position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); diff --git a/src/core/public/application/ui/app_container.tsx b/src/core/public/application/ui/app_container.tsx index 02d321095b3735..0312c707e10498 100644 --- a/src/core/public/application/ui/app_container.tsx +++ b/src/core/public/application/ui/app_container.tsx @@ -5,6 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import './app_container.scss'; import React, { Fragment, @@ -16,11 +17,12 @@ import React, { } from 'react'; import { EuiLoadingElastic } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import type { MountPoint } from '../../types'; import { AppLeaveHandler, AppStatus, AppUnmount, Mounter } from '../types'; import { AppNotFound } from './app_not_found_screen'; import { ScopedHistory } from '../scoped_history'; -import './app_container.scss'; +import { APP_WRAPPER_CLASS } from '../../../utils'; interface Props { /** Path application is mounted on without the global basePath */ @@ -107,12 +109,16 @@ export const AppContainer: FunctionComponent = ({ return ( {appNotFound && } - {showSpinner && ( -
- -
+ {showSpinner && !appNotFound && ( + )} -
+
); }; diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index d4ab8f624f7111..53428edf4b345f 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -253,7 +253,7 @@ export class DocLinksService { guide: `${ELASTIC_WEBSITE_URL}guide/en/observability/${DOC_LINK_VERSION}/index.html`, }, alerting: { - guide: `${KIBANA_DOCS}alert-management.html`, + guide: `${KIBANA_DOCS}create-and-manage-rules.html`, actionTypes: `${KIBANA_DOCS}action-types.html`, emailAction: `${KIBANA_DOCS}email-action-type.html`, emailActionConfig: `${KIBANA_DOCS}email-action-type.html`, @@ -265,7 +265,7 @@ export class DocLinksService { preconfiguredConnectors: `${KIBANA_DOCS}pre-configured-connectors.html`, preconfiguredAlertHistoryConnector: `${KIBANA_DOCS}index-action-type.html#preconfigured-connector-alert-history`, serviceNowAction: `${KIBANA_DOCS}servicenow-action-type.html#configuring-servicenow`, - setupPrerequisites: `${KIBANA_DOCS}alerting-getting-started.html#alerting-setup-prerequisites`, + setupPrerequisites: `${KIBANA_DOCS}alerting-setup.html#alerting-prerequisites`, slackAction: `${KIBANA_DOCS}slack-action-type.html#configuring-slack`, teamsAction: `${KIBANA_DOCS}teams-action-type.html#configuring-teams`, }, diff --git a/src/core/public/rendering/_base.scss b/src/core/public/rendering/_base.scss index 3a748f3ceb6fd3..4bd6afe90d3429 100644 --- a/src/core/public/rendering/_base.scss +++ b/src/core/public/rendering/_base.scss @@ -35,27 +35,12 @@ position: relative; // This is temporary for apps that relied on this being present on `.application` } -// TODO: This is problematic because it doesn't stay in line with EUI: -// adapted from euiHeaderAffordForFixed as we need to handle the top banner @mixin kbnAffordForHeader($headerHeight) { - padding-top: $headerHeight; + @include euiHeaderAffordForFixed($headerHeight); #app-fixed-viewport { top: $headerHeight; } - - .euiFlyout, - .euiCollapsibleNav { - top: $headerHeight; - height: calc(100% - #{$headerHeight}); - } - - @include euiBreakpoint('m', 'l', 'xl') { - .euiPageSideBar--sticky { - max-height: calc(100vh - #{$headerHeight}); - top: #{$headerHeight}; - } - } } .kbnBody { diff --git a/src/core/server/http/lifecycle/on_pre_routing.ts b/src/core/server/http/lifecycle/on_pre_routing.ts index dbd00df13707b3..be0af8c118627f 100644 --- a/src/core/server/http/lifecycle/on_pre_routing.ts +++ b/src/core/server/http/lifecycle/on_pre_routing.ts @@ -102,24 +102,7 @@ export function adoptToHapiOnRequest(fn: OnPreRoutingHandler, log: Logger) { appState.rewrittenUrl = appState.rewrittenUrl ?? request.url; const { url } = result; - - // TODO: Remove once we upgrade to Node.js 12! - // - // Warning: The following for-loop took 10 days to write, and is a hack - // to force V8 to make a copy of the string in memory. - // - // The reason why we need this is because of what appears to be a bug - // in V8 that caused some URL paths to not be routed correctly once - // `request.setUrl` was called with the path. - // - // The details can be seen in this discussion on Twitter: - // https://twitter.com/wa7son/status/1319992632366518277 - let urlCopy = ''; - for (let i = 0; i < url.length; i++) { - urlCopy += url[i]; - } - - request.setUrl(urlCopy); + request.setUrl(url); // We should update raw request as well since it can be proxied to the old platform request.raw.req.url = url; diff --git a/src/core/server/plugins/discovery/plugin_manifest_parser.ts b/src/core/server/plugins/discovery/plugin_manifest_parser.ts index 7ac629534ba089..b59418a67219e0 100644 --- a/src/core/server/plugins/discovery/plugin_manifest_parser.ts +++ b/src/core/server/plugins/discovery/plugin_manifest_parser.ts @@ -48,6 +48,8 @@ const KNOWN_MANIFEST_FIELDS = (() => { extraPublicDirs: true, requiredBundles: true, serviceFolders: true, + owner: true, + description: true, }; return new Set(Object.keys(manifestFields)); @@ -187,6 +189,8 @@ export async function parseManifest( ui: includesUiPlugin, server: includesServerPlugin, extraPublicDirs: manifest.extraPublicDirs, + owner: manifest.owner, + description: manifest.description, }; } diff --git a/src/core/server/plugins/types.ts b/src/core/server/plugins/types.ts index 6b50b5e820665e..0cdc806e997ef7 100644 --- a/src/core/server/plugins/types.ts +++ b/src/core/server/plugins/types.ts @@ -208,6 +208,27 @@ export interface PluginManifest { * folders will cause your plugin API reference to be broken up into sub sections. */ readonly serviceFolders?: readonly string[]; + + /** + * TODO: make required once all internal plugins have this specified. + */ + readonly owner?: { + /** + * The name of the team that currently owns this plugin. + */ + readonly name: string; + /** + * All internal plugins should have a github team specified. GitHub teams can be viewed here: + * https://github.com/orgs/elastic/teams + */ + readonly githubTeam?: string; + }; + + /** + * TODO: make required once all plugins specify this. + * A brief description of what this plugin does and any capabilities it provides. + */ + readonly description?: string; } /** diff --git a/src/core/server/rendering/views/styles.tsx b/src/core/server/rendering/views/styles.tsx index 105f94df9218fc..fbeab4fb4388fa 100644 --- a/src/core/server/rendering/views/styles.tsx +++ b/src/core/server/rendering/views/styles.tsx @@ -52,7 +52,6 @@ const InlineStyles: FC<{ darkMode: boolean }> = ({ darkMode }) => { .kbnWelcomeView { line-height: 1.5; - background-color: ${darkMode ? '#1D1E24' : '#FFF'}; height: 100%; display: -webkit-box; display: -webkit-flex; diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_so_with_multiple_namespaces.zip b/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_so_with_multiple_namespaces.zip deleted file mode 100644 index a92211c16c5593..00000000000000 Binary files a/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_so_with_multiple_namespaces.zip and /dev/null differ diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_with_corrupted_so.zip b/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_with_corrupted_so.zip index c6c89ac2879b2e..44f2fc9ba19eb5 100644 Binary files a/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_with_corrupted_so.zip and b/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.0_with_corrupted_so.zip differ diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.2_so_with_multiple_namespaces.zip b/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.2_so_with_multiple_namespaces.zip new file mode 100644 index 00000000000000..e4dce85f15e38e Binary files /dev/null and b/src/core/server/saved_objects/migrationsv2/integration_tests/archives/7.13.2_so_with_multiple_namespaces.zip differ diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts index 91d86353b48fac..83d97555a47987 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts @@ -53,8 +53,7 @@ function createRoot() { ); } -// FAILING: https://github.com/elastic/kibana/issues/98352 -describe.skip('migration v2', () => { +describe('migration v2', () => { let esServer: kbnTestServer.TestElasticsearchUtils; let root: Root; @@ -78,7 +77,7 @@ describe.skip('migration v2', () => { adjustTimeout: (t: number) => jest.setTimeout(t), settings: { es: { - license: 'trial', + license: 'basic', // original SO: // { // _index: '.kibana_7.13.0_001', diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts index 0f4085f6186be4..759a9572d733b2 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts @@ -89,7 +89,7 @@ function createRoot() { } // FAILING: https://github.com/elastic/kibana/issues/98351 -describe.skip('migration v2', () => { +describe('migration v2', () => { let esServer: kbnTestServer.TestElasticsearchUtils; let root: Root; @@ -114,7 +114,7 @@ describe.skip('migration v2', () => { adjustTimeout: (t: number) => jest.setTimeout(t), settings: { es: { - license: 'trial', + license: 'basic', // original SO: // [ // { id: 'foo:1', type: 'foo', foo: { name: 'Foo 1 default' } }, @@ -133,7 +133,7 @@ describe.skip('migration v2', () => { // namespace: 'spacex', // }, // ]; - dataArchive: Path.join(__dirname, 'archives', '7.13.0_so_with_multiple_namespaces.zip'), + dataArchive: Path.join(__dirname, 'archives', '7.13.2_so_with_multiple_namespaces.zip'), }, }, }); diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index acec03902bf6aa..ce13174ee19cc2 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -1917,11 +1917,16 @@ export interface PluginInitializerContext { export interface PluginManifest { // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported readonly configPath: ConfigPath; + readonly description?: string; // @deprecated readonly extraPublicDirs?: string[]; readonly id: PluginName; readonly kibanaVersion: string; readonly optionalPlugins: readonly PluginName[]; + readonly owner?: { + readonly name: string; + readonly githubTeam?: string; + }; readonly requiredBundles: readonly string[]; readonly requiredPlugins: readonly PluginName[]; readonly server: boolean; @@ -3260,9 +3265,9 @@ export const validBodyOutput: readonly ["data", "stream"]; // // src/core/server/elasticsearch/client/types.ts:94:7 - (ae-forgotten-export) The symbol "Explanation" needs to be exported by the entry point index.d.ts // src/core/server/http/router/response.ts:301:3 - (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts -// src/core/server/plugins/types.ts:326:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts -// src/core/server/plugins/types.ts:326:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts -// src/core/server/plugins/types.ts:329:3 - (ae-forgotten-export) The symbol "SavedObjectsConfigType" needs to be exported by the entry point index.d.ts -// src/core/server/plugins/types.ts:434:5 - (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "create" +// src/core/server/plugins/types.ts:347:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts +// src/core/server/plugins/types.ts:347:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts +// src/core/server/plugins/types.ts:350:3 - (ae-forgotten-export) The symbol "SavedObjectsConfigType" needs to be exported by the entry point index.d.ts +// src/core/server/plugins/types.ts:455:5 - (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "create" ``` diff --git a/src/plugins/bfetch/kibana.json b/src/plugins/bfetch/kibana.json index 9f9f2176af671f..6d37d68ffd584f 100644 --- a/src/plugins/bfetch/kibana.json +++ b/src/plugins/bfetch/kibana.json @@ -3,5 +3,10 @@ "version": "kibana", "server": true, "ui": true, - "requiredBundles": ["kibanaUtils"] + "requiredBundles": ["kibanaUtils"], + "owner": { + "name": "App Services", + "githubTeam": "kibana-app-services" + }, + "description": "Considering using bfetch capabilities when fetching large amounts of data. This services supports batching HTTP requests and streaming responses back." } diff --git a/src/plugins/dashboard/server/usage/dashboard_telemetry.test.ts b/src/plugins/dashboard/server/usage/dashboard_telemetry.test.ts index 1cfa9d862e6b95..60f1f7eb0955c0 100644 --- a/src/plugins/dashboard/server/usage/dashboard_telemetry.test.ts +++ b/src/plugins/dashboard/server/usage/dashboard_telemetry.test.ts @@ -72,6 +72,22 @@ const lensXYSeriesB = ({ visualization: { preferredSeriesType: 'seriesB', }, + datasourceStates: { + indexpattern: { + layers: { + first: { + columns: { + first: { + operationType: 'terms', + }, + second: { + operationType: 'formula', + }, + }, + }, + }, + }, + }, }, }, }, @@ -144,6 +160,7 @@ describe('dashboard telemetry', () => { expect(collectorData.lensByValue.a).toBe(3); expect(collectorData.lensByValue.seriesA).toBe(2); expect(collectorData.lensByValue.seriesB).toBe(1); + expect(collectorData.lensByValue.formula).toBe(1); }); it('handles misshapen lens panels', () => { diff --git a/src/plugins/dashboard/server/usage/dashboard_telemetry.ts b/src/plugins/dashboard/server/usage/dashboard_telemetry.ts index 912dc04d16d092..fb1ddff469f578 100644 --- a/src/plugins/dashboard/server/usage/dashboard_telemetry.ts +++ b/src/plugins/dashboard/server/usage/dashboard_telemetry.ts @@ -27,6 +27,16 @@ interface LensPanel extends SavedDashboardPanel730ToLatest { visualization?: { preferredSeriesType?: string; }; + datasourceStates?: { + indexpattern?: { + layers: Record< + string, + { + columns: Record; + } + >; + }; + }; }; }; }; @@ -109,6 +119,19 @@ export const collectByValueLensInfo: DashboardCollectorFunction = (panels, colle } collectorData.lensByValue[type] = collectorData.lensByValue[type] + 1; + + const hasFormula = Object.values( + lensPanel.embeddableConfig.attributes.state?.datasourceStates?.indexpattern?.layers || {} + ).some((layer) => + Object.values(layer.columns).some((column) => column.operationType === 'formula') + ); + + if (hasFormula && !collectorData.lensByValue.formula) { + collectorData.lensByValue.formula = 0; + } + if (hasFormula) { + collectorData.lensByValue.formula++; + } } } }; diff --git a/src/plugins/data/common/field_formats/converters/duration.test.ts b/src/plugins/data/common/field_formats/converters/duration.test.ts index 72551f4b7b236f..9ea9919e757de8 100644 --- a/src/plugins/data/common/field_formats/converters/duration.test.ts +++ b/src/plugins/data/common/field_formats/converters/duration.test.ts @@ -130,11 +130,11 @@ describe('Duration Format', () => { fixtures: [ { input: -60, - output: '-60 Seconds', + output: '-60 seconds', }, { input: -32.333, - output: '-32 Seconds', + output: '-32 seconds', }, ], }); @@ -147,15 +147,15 @@ describe('Duration Format', () => { fixtures: [ { input: 1988, - output: '0.00 Milliseconds', + output: '0.00 milliseconds', }, { input: 658, - output: '0.00 Milliseconds', + output: '0.00 milliseconds', }, { input: 3857, - output: '0.00 Milliseconds', + output: '0.00 milliseconds', }, ], }); @@ -168,15 +168,15 @@ describe('Duration Format', () => { fixtures: [ { input: 1988, - output: '1.99 Milliseconds', + output: '1.99 milliseconds', }, { input: 658, - output: '0.66 Milliseconds', + output: '0.66 milliseconds', }, { input: 3857, - output: '3.86 Milliseconds', + output: '3.86 milliseconds', }, ], }); @@ -189,19 +189,19 @@ describe('Duration Format', () => { fixtures: [ { input: 1988, - output: '2.0 Milliseconds', + output: '2.0 milliseconds', }, { input: 0, - output: '0.0 Milliseconds', + output: '0.0 milliseconds', }, { input: 658, - output: '0.7 Milliseconds', + output: '0.7 milliseconds', }, { input: 3857, - output: '3.9 Milliseconds', + output: '3.9 milliseconds', }, ], }); @@ -214,15 +214,15 @@ describe('Duration Format', () => { fixtures: [ { input: 600, - output: '10 Minutes', + output: '10 minutes', }, { input: 30, - output: '30 Seconds', + output: '30 seconds', }, { input: 3000, - output: '50 Minutes', + output: '50 minutes', }, ], }); diff --git a/src/plugins/data/common/field_formats/converters/duration.ts b/src/plugins/data/common/field_formats/converters/duration.ts index c9a7091db84716..71ac022ba5e5cb 100644 --- a/src/plugins/data/common/field_formats/converters/duration.ts +++ b/src/plugins/data/common/field_formats/converters/duration.ts @@ -263,7 +263,7 @@ export class DurationFormat extends FieldFormat { const precise = human || humanPrecise ? formatted : formatted.toFixed(outputPrecision); const type = outputFormats.find(({ method }) => method === outputFormat); - const unitText = useShortSuffix ? type?.shortText : type?.text; + const unitText = useShortSuffix ? type?.shortText : type?.text.toLowerCase(); const suffix = showSuffix && unitText && !human ? `${includeSpace}${unitText}` : ''; @@ -294,7 +294,7 @@ function formatDuration( const getUnitText = (method: string) => { const type = outputFormats.find(({ method: methodT }) => method === methodT); - return useShortSuffix ? type?.shortText : type?.text; + return useShortSuffix ? type?.shortText : type?.text.toLowerCase(); }; for (let i = 0; i < units.length; i++) { diff --git a/src/plugins/data/common/search/expressions/filters_to_ast.test.ts b/src/plugins/data/common/search/expressions/filters_to_ast.test.ts index 108b48f9ea77ea..5d191a94d4c8d1 100644 --- a/src/plugins/data/common/search/expressions/filters_to_ast.test.ts +++ b/src/plugins/data/common/search/expressions/filters_to_ast.test.ts @@ -24,6 +24,9 @@ describe('interpreter/functions#filtersToAst', () => { expect(actual[0].functions[0]).toHaveProperty('name', 'kibanaFilter'); expect(actual[0].functions[0].arguments).toMatchInlineSnapshot(` Object { + "disabled": Array [ + false, + ], "negate": Array [ false, ], @@ -35,6 +38,9 @@ describe('interpreter/functions#filtersToAst', () => { expect(actual[1].functions[0]).toHaveProperty('name', 'kibanaFilter'); expect(actual[1].functions[0].arguments).toMatchInlineSnapshot(` Object { + "disabled": Array [ + false, + ], "negate": Array [ true, ], diff --git a/src/plugins/data/common/search/expressions/filters_to_ast.ts b/src/plugins/data/common/search/expressions/filters_to_ast.ts index a4dd959caecf6f..edcf884b3ed312 100644 --- a/src/plugins/data/common/search/expressions/filters_to_ast.ts +++ b/src/plugins/data/common/search/expressions/filters_to_ast.ts @@ -17,6 +17,7 @@ export const filtersToAst = (filters: Filter[] | Filter) => { buildExpressionFunction('kibanaFilter', { query: JSON.stringify(restOfFilter), negate: filter.meta.negate, + disabled: filter.meta.disabled, }), ]); }); diff --git a/src/plugins/data/common/search/expressions/kibana_filter.ts b/src/plugins/data/common/search/expressions/kibana_filter.ts index 6d6f70fa8d1d6b..c94a3763ee084e 100644 --- a/src/plugins/data/common/search/expressions/kibana_filter.ts +++ b/src/plugins/data/common/search/expressions/kibana_filter.ts @@ -13,6 +13,7 @@ import { KibanaFilter } from './kibana_context_type'; interface Arguments { query: string; negate?: boolean; + disabled?: boolean; } export type ExpressionFunctionKibanaFilter = ExpressionFunctionDefinition< @@ -45,6 +46,13 @@ export const kibanaFilterFunction: ExpressionFunctionKibanaFilter = { defaultMessage: 'Should the filter be negated', }), }, + disabled: { + types: ['boolean'], + default: false, + help: i18n.translate('data.search.functions.kibanaFilter.disabled.help', { + defaultMessage: 'Should the filter be disabled', + }), + }, }, fn(input, args) { @@ -53,7 +61,7 @@ export const kibanaFilterFunction: ExpressionFunctionKibanaFilter = { meta: { negate: args.negate || false, alias: '', - disabled: false, + disabled: args.disabled || false, }, ...JSON.parse(args.query), }; diff --git a/src/plugins/data/kibana.json b/src/plugins/data/kibana.json index 4e9e4c318c9575..e425d0701155bd 100644 --- a/src/plugins/data/kibana.json +++ b/src/plugins/data/kibana.json @@ -3,19 +3,14 @@ "version": "kibana", "server": true, "ui": true, - "requiredPlugins": [ - "bfetch", - "expressions", - "uiActions", - "share", - "inspector" - ], + "requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector"], "serviceFolders": ["search", "index_patterns", "query", "autocomplete", "ui", "field_formats"], "optionalPlugins": ["usageCollection"], "extraPublicDirs": ["common"], - "requiredBundles": [ - "kibanaUtils", - "kibanaReact", - "inspector" - ] + "requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"], + "owner": { + "name": "App Services", + "githubTeam": "kibana-app-services" + }, + "description": "Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters." } diff --git a/src/plugins/discover/public/application/angular/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/angular/create_discover_grid_directive.tsx index 1fc8edcb4d0659..810be94ce24b06 100644 --- a/src/plugins/discover/public/application/angular/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/angular/create_discover_grid_directive.tsx @@ -51,5 +51,6 @@ export function createDiscoverGridDirective(reactDirective: any) { ['settings', { watchDepth: 'reference' }], ['showTimeCol', { watchDepth: 'value' }], ['sort', { watchDepth: 'value' }], + ['className', { watchDepth: 'value' }], ]); } diff --git a/src/plugins/discover/public/application/angular/doc_table/create_doc_table_embeddable.tsx b/src/plugins/discover/public/application/angular/doc_table/create_doc_table_embeddable.tsx new file mode 100644 index 00000000000000..19913ed6de8704 --- /dev/null +++ b/src/plugins/discover/public/application/angular/doc_table/create_doc_table_embeddable.tsx @@ -0,0 +1,85 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { useRef, useEffect } from 'react'; +import { I18nProvider } from '@kbn/i18n/react'; +import { IScope } from 'angular'; +import { getServices } from '../../../kibana_services'; +import { DocTableLegacyProps, injectAngularElement } from './create_doc_table_react'; + +type AngularEmbeddableScope = IScope & { renderProps?: DocTableEmbeddableProps }; + +export interface DocTableEmbeddableProps extends Partial { + refs: HTMLElement; +} + +function getRenderFn(domNode: Element, props: DocTableEmbeddableProps) { + const directive = { + template: ``, + }; + + return async () => { + try { + const injector = await getServices().getEmbeddableInjector(); + return await injectAngularElement(domNode, directive.template, props, injector); + } catch (e) { + // eslint-disable-next-line no-console + console.error(e); + throw e; + } + }; +} + +export function DiscoverDocTableEmbeddable(props: DocTableEmbeddableProps) { + return ( + + + + ); +} + +function DocTableLegacyInner(renderProps: DocTableEmbeddableProps) { + const scope = useRef(); + + useEffect(() => { + if (renderProps.refs && !scope.current) { + const fn = getRenderFn(renderProps.refs, renderProps); + fn().then((newScope) => { + scope.current = newScope; + }); + } else if (scope?.current) { + scope.current.renderProps = { ...renderProps }; + scope.current.$applyAsync(); + } + }, [renderProps]); + + useEffect(() => { + return () => { + scope.current?.$destroy(); + }; + }, []); + return ; +} diff --git a/src/plugins/discover/public/application/angular/doc_table/index.ts b/src/plugins/discover/public/application/angular/doc_table/index.ts index 2aaf5a8bda7b69..3a8f170f8680d5 100644 --- a/src/plugins/discover/public/application/angular/doc_table/index.ts +++ b/src/plugins/discover/public/application/angular/doc_table/index.ts @@ -9,3 +9,4 @@ export { createDocTableDirective } from './doc_table'; export { getSort, getSortArray } from './lib/get_sort'; export { getSortForSearchSource } from './lib/get_sort_for_search_source'; +export { getDefaultSort } from './lib/get_default_sort'; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 65a6ee80564e9f..f1c56b7a57195b 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -51,6 +51,10 @@ export interface DiscoverGridProps { * Determines which element labels the grid for ARIA */ ariaLabelledBy: string; + /** + * Optional class name to apply + */ + className?: string; /** * Determines which columns are displayed */ @@ -175,6 +179,7 @@ export const DiscoverGrid = ({ isSortEnabled = true, isPaginationEnabled = true, controlColumnIds = ['openDetails', 'select'], + className, }: DiscoverGridProps) => { const [selectedDocs, setSelectedDocs] = useState([]); const [isFilterActive, setIsFilterActive] = useState(false); @@ -284,6 +289,7 @@ export const DiscoverGrid = ({ ), [displayedColumns, indexPattern, showTimeCol, settings, defaultColumns, isSortEnabled] ); + const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const columnsVisibility = useMemo( () => ({ @@ -368,6 +374,7 @@ export const DiscoverGrid = ({ data-title={searchTitle} data-description={searchDescription} data-document-number={displayedRows.length} + className={className} > { + const props = getProps(); + const component = mountWithIntl(); + findTestSubject(component, 'docTableDetailsFlyout').simulate('keydown', { key: 'ArrowRight' }); + expect(props.setExpandedDoc).toHaveBeenCalledWith(expect.objectContaining({ _id: '2' })); + component.setProps({ ...props, hit: props.hits[1] }); + findTestSubject(component, 'docTableDetailsFlyout').simulate('keydown', { key: 'ArrowLeft' }); + expect(props.setExpandedDoc).toHaveBeenCalledWith(expect.objectContaining({ _id: '1' })); + }); + + it('should not navigate with keypresses when already at the border of documents', () => { + const props = getProps(); + const component = mountWithIntl(); + findTestSubject(component, 'docTableDetailsFlyout').simulate('keydown', { key: 'ArrowLeft' }); + expect(props.setExpandedDoc).not.toHaveBeenCalled(); + component.setProps({ ...props, hit: props.hits[props.hits.length - 1] }); + findTestSubject(component, 'docTableDetailsFlyout').simulate('keydown', { key: 'ArrowRight' }); + expect(props.setExpandedDoc).not.toHaveBeenCalled(); + }); }); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 3894127891041c..aaae9afe6531a5 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -21,6 +21,7 @@ import { EuiPortal, EuiPagination, EuiHideFor, + keys, } from '@elastic/eui'; import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; @@ -87,9 +88,25 @@ export function DiscoverGridFlyout({ [hits, setExpandedDoc] ); + const onKeyDown = useCallback( + (ev: React.KeyboardEvent) => { + if (ev.key === keys.ARROW_LEFT || ev.key === keys.ARROW_RIGHT) { + ev.preventDefault(); + ev.stopPropagation(); + setPage(activePage + (ev.key === keys.ARROW_RIGHT ? 1 : -1)); + } + }, + [activePage, setPage] + ); + return ( - + { settings?: DiscoverGridSettings; description?: string; - sort?: SortOrder[]; sharedItemTitle?: string; inspectorAdapters?: Adapters; - setSortOrder?: (sortPair: SortOrder[]) => void; - setColumns?: (columns: string[]) => void; - removeColumn?: (column: string) => void; - addColumn?: (column: string) => void; - moveColumn?: (column: string, index: number) => void; + filter?: (field: IFieldType, value: string[], operator: string) => void; hits?: ElasticSearchHit[]; - indexPattern?: IndexPattern; totalHitCount?: number; - isLoading?: boolean; - showTimeCol?: boolean; - useNewFieldsApi?: boolean; + onMoveColumn?: (column: string, index: number) => void; } interface SearchEmbeddableConfig { - $rootScope: ng.IRootScopeService; - $compile: ng.ICompileService; savedSearch: SavedSearch; editUrl: string; editPath: string; @@ -77,17 +66,13 @@ interface SearchEmbeddableConfig { services: DiscoverServices; } -export class SearchEmbeddable +export class SavedSearchEmbeddable extends Embeddable implements ISearchEmbeddable { private readonly savedSearch: SavedSearch; - private $rootScope: ng.IRootScopeService; - private $compile: ng.ICompileService; private inspectorAdapters: Adapters; - private searchScope?: SearchScope; private panelTitle: string = ''; - private filtersSearchSource?: ISearchSource; - private searchInstance?: JQLite; + private filtersSearchSource!: ISearchSource; private subscription?: Subscription; public readonly type = SEARCH_EMBEDDABLE_TYPE; private filterManager: FilterManager; @@ -98,11 +83,12 @@ export class SearchEmbeddable private prevFilters?: Filter[]; private prevQuery?: Query; private prevSearchSessionId?: string; + private searchProps?: SearchProps; + + private node?: HTMLElement; constructor( { - $rootScope, - $compile, savedSearch, editUrl, editPath, @@ -130,164 +116,24 @@ export class SearchEmbeddable this.services = services; this.filterManager = filterManager; this.savedSearch = savedSearch; - this.$rootScope = $rootScope; - this.$compile = $compile; this.inspectorAdapters = { requests: new RequestAdapter(), }; - this.initializeSearchScope(); + this.initializeSearchEmbeddableProps(); this.subscription = this.getUpdated$().subscribe(() => { this.panelTitle = this.output.title || ''; - if (this.searchScope) { - this.pushContainerStateParamsToScope(this.searchScope); + if (this.searchProps) { + this.pushContainerStateParamsToProps(this.searchProps); } }); } - public getInspectorAdapters() { - return this.inspectorAdapters; - } - - public getSavedSearch() { - return this.savedSearch; - } - - /** - * - * @param {Element} domNode - */ - public render(domNode: HTMLElement) { - if (!this.searchScope) { - throw new Error('Search scope not defined'); - } - this.searchInstance = this.$compile( - this.services.uiSettings.get('doc_table:legacy') ? searchTemplate : searchTemplateGrid - )(this.searchScope); - const rootNode = angular.element(domNode); - rootNode.append(this.searchInstance); - - this.pushContainerStateParamsToScope(this.searchScope); - } - - public destroy() { - super.destroy(); - this.savedSearch.destroy(); - if (this.searchInstance) { - this.searchInstance.remove(); - } - if (this.searchScope) { - this.searchScope.$destroy(); - delete this.searchScope; - } - if (this.subscription) { - this.subscription.unsubscribe(); - } - - if (this.abortController) this.abortController.abort(); - } - - private initializeSearchScope() { - const searchScope: SearchScope = (this.searchScope = this.$rootScope.$new()); - - searchScope.description = this.savedSearch.description; - searchScope.inspectorAdapters = this.inspectorAdapters; - - const { searchSource } = this.savedSearch; - const indexPattern = (searchScope.indexPattern = searchSource.getField('index'))!; - - if (!this.savedSearch.sort || !this.savedSearch.sort.length) { - this.savedSearch.sort = getDefaultSort( - indexPattern, - getServices().uiSettings.get(SORT_DEFAULT_ORDER_SETTING, 'desc') - ); - } - - const timeRangeSearchSource = searchSource.create(); - timeRangeSearchSource.setField('filter', () => { - if (!this.searchScope || !this.input.timeRange) return; - return this.services.timefilter.createFilter(indexPattern, this.input.timeRange); - }); - - this.filtersSearchSource = searchSource.create(); - this.filtersSearchSource.setParent(timeRangeSearchSource); - - searchSource.setParent(this.filtersSearchSource); - - this.pushContainerStateParamsToScope(searchScope); - - searchScope.setSortOrder = (sort) => { - this.updateInput({ sort }); - }; - - searchScope.isLoading = true; - - const useNewFieldsApi = !getServices().uiSettings.get(SEARCH_FIELDS_FROM_SOURCE, false); - searchScope.useNewFieldsApi = useNewFieldsApi; - - searchScope.addColumn = (columnName: string) => { - if (!searchScope.columns) { - return; - } - const columns = columnActions.addColumn(searchScope.columns, columnName, useNewFieldsApi); - this.updateInput({ columns }); - }; - - searchScope.removeColumn = (columnName: string) => { - if (!searchScope.columns) { - return; - } - const columns = columnActions.removeColumn(searchScope.columns, columnName, useNewFieldsApi); - this.updateInput({ columns }); - }; - - searchScope.moveColumn = (columnName, newIndex: number) => { - if (!searchScope.columns) { - return; - } - const columns = columnActions.moveColumn(searchScope.columns, columnName, newIndex); - this.updateInput({ columns }); - }; - - searchScope.setColumns = (columns: string[]) => { - this.updateInput({ columns }); - }; - - if (this.savedSearch.grid) { - searchScope.settings = this.savedSearch.grid; - } - searchScope.showTimeCol = !this.services.uiSettings.get(DOC_HIDE_TIME_COLUMN_SETTING, false); - - searchScope.filter = async (field, value, operator) => { - let filters = esFilters.generateFilters( - this.filterManager, - field, - value, - operator, - indexPattern.id! - ); - filters = filters.map((filter) => ({ - ...filter, - $state: { store: esFilters.FilterStateStore.APP_STATE }, - })); - - await this.executeTriggerActions(APPLY_FILTER_TRIGGER, { - embeddable: this, - filters, - }); - }; - } - - public reload() { - if (this.searchScope) - this.pushContainerStateParamsToScope(this.searchScope, { forceFetch: true }); - } - private fetch = async () => { const searchSessionId = this.input.searchSessionId; const useNewFieldsApi = !this.services.uiSettings.get(SEARCH_FIELDS_FROM_SOURCE, false); - if (!this.searchScope) return; + if (!this.searchProps) return; const { searchSource } = this.savedSearch; @@ -299,8 +145,8 @@ export class SearchEmbeddable searchSource.setField( 'sort', getSortForSearchSource( - this.searchScope.sort, - this.searchScope.indexPattern, + this.searchProps!.sort, + this.searchProps!.indexPattern, this.services.uiSettings.get(SORT_DEFAULT_ORDER_SETTING) ) ); @@ -310,8 +156,8 @@ export class SearchEmbeddable searchSource.setField('fields', [fields]); } else { searchSource.removeField('fields'); - if (this.searchScope.indexPattern) { - const fieldNames = this.searchScope.indexPattern.fields.map((field) => field.name); + if (this.searchProps.indexPattern) { + const fieldNames = this.searchProps.indexPattern.fields.map((field) => field.name); searchSource.setField('fieldsFromSource', fieldNames); } } @@ -319,9 +165,8 @@ export class SearchEmbeddable // Log request to inspector this.inspectorAdapters.requests!.reset(); - this.searchScope.$apply(() => { - this.searchScope!.isLoading = true; - }); + this.searchProps!.isLoading = true; + this.updateOutput({ loading: true, error: undefined }); try { @@ -344,64 +189,222 @@ export class SearchEmbeddable .toPromise(); this.updateOutput({ loading: false, error: undefined }); - // Apply the changes to the angular scope - this.searchScope.$apply(() => { - this.searchScope!.hits = resp.hits.hits; - this.searchScope!.totalHitCount = resp.hits.total as number; - this.searchScope!.isLoading = false; - }); + this.searchProps!.rows = resp.hits.hits; + this.searchProps!.totalHitCount = resp.hits.total as number; + this.searchProps!.isLoading = false; } catch (error) { this.updateOutput({ loading: false, error }); - this.searchScope.$apply(() => { - this.searchScope!.isLoading = false; - }); + + this.searchProps!.isLoading = false; } }; - private pushContainerStateParamsToScope( - searchScope: SearchScope, + private initializeSearchEmbeddableProps() { + const { searchSource } = this.savedSearch; + + const indexPattern = searchSource.getField('index'); + + if (!indexPattern) { + return; + } + + if (!this.savedSearch.sort || !this.savedSearch.sort.length) { + this.savedSearch.sort = getDefaultSort( + indexPattern, + getServices().uiSettings.get(SORT_DEFAULT_ORDER_SETTING, 'desc') + ); + } + + const props: SearchProps = { + columns: this.savedSearch.columns, + indexPattern, + isLoading: false, + sort: getDefaultSort( + indexPattern, + getServices().uiSettings.get(SORT_DEFAULT_ORDER_SETTING, 'desc') + ), + rows: [], + searchDescription: this.savedSearch.description, + description: this.savedSearch.description, + inspectorAdapters: this.inspectorAdapters, + searchTitle: this.savedSearch.lastSavedTitle, + services: this.services, + onAddColumn: (columnName: string) => { + if (!props.columns) { + return; + } + const updatedColumns = columnActions.addColumn(props.columns, columnName, true); + this.updateInput({ columns: updatedColumns }); + }, + onRemoveColumn: (columnName: string) => { + if (!props.columns) { + return; + } + const updatedColumns = columnActions.removeColumn(props.columns, columnName, true); + this.updateInput({ columns: updatedColumns }); + }, + onMoveColumn: (columnName: string, newIndex: number) => { + if (!props.columns) { + return; + } + const columns = columnActions.moveColumn(props.columns, columnName, newIndex); + this.updateInput({ columns }); + }, + onSetColumns: (columns: string[]) => { + this.updateInput({ columns }); + }, + onSort: (sort: string[][]) => { + const sortOrderArr: SortOrder[] = []; + sort.forEach((arr) => { + sortOrderArr.push(arr as SortOrder); + }); + this.updateInput({ sort: sortOrderArr }); + }, + sampleSize: 500, + onFilter: async (field, value, operator) => { + let filters = esFilters.generateFilters( + this.filterManager, + // @ts-expect-error + field, + value, + operator, + indexPattern.id! + ); + filters = filters.map((filter) => ({ + ...filter, + $state: { store: esFilters.FilterStateStore.APP_STATE }, + })); + + await this.executeTriggerActions(APPLY_FILTER_TRIGGER, { + embeddable: this, + filters, + }); + }, + useNewFieldsApi: !this.services.uiSettings.get(SEARCH_FIELDS_FROM_SOURCE, false), + showTimeCol: !this.services.uiSettings.get(DOC_HIDE_TIME_COLUMN_SETTING, false), + ariaLabelledBy: 'documentsAriaLabel', + }; + + const timeRangeSearchSource = searchSource.create(); + timeRangeSearchSource.setField('filter', () => { + if (!this.searchProps || !this.input.timeRange) return; + return this.services.timefilter.createFilter(indexPattern, this.input.timeRange); + }); + + this.filtersSearchSource = searchSource.create(); + this.filtersSearchSource.setParent(timeRangeSearchSource); + + searchSource.setParent(this.filtersSearchSource); + + this.pushContainerStateParamsToProps(props); + + props.isLoading = true; + + if (this.savedSearch.grid) { + props.settings = this.savedSearch.grid; + } + } + + private async pushContainerStateParamsToProps( + searchProps: SearchProps, { forceFetch = false }: { forceFetch: boolean } = { forceFetch: false } ) { const isFetchRequired = !esFilters.onlyDisabledFiltersChanged(this.input.filters, this.prevFilters) || - !_.isEqual(this.prevQuery, this.input.query) || - !_.isEqual(this.prevTimeRange, this.input.timeRange) || - !_.isEqual(searchScope.sort, this.input.sort || this.savedSearch.sort) || + !isEqual(this.prevQuery, this.input.query) || + !isEqual(this.prevTimeRange, this.input.timeRange) || + !isEqual(searchProps.sort, this.input.sort || this.savedSearch.sort) || this.prevSearchSessionId !== this.input.searchSessionId; // If there is column or sort data on the panel, that means the original columns or sort settings have // been overridden in a dashboard. - searchScope.columns = handleSourceColumnState( + searchProps.columns = handleSourceColumnState( { columns: this.input.columns || this.savedSearch.columns }, this.services.core.uiSettings ).columns; + const savedSearchSort = this.savedSearch.sort && this.savedSearch.sort.length ? this.savedSearch.sort : getDefaultSort( - this.searchScope?.indexPattern, + this.searchProps?.indexPattern, getServices().uiSettings.get(SORT_DEFAULT_ORDER_SETTING, 'desc') ); - searchScope.sort = this.input.sort || savedSearchSort; - searchScope.sharedItemTitle = this.panelTitle; - + searchProps.sort = this.input.sort || savedSearchSort; + searchProps.sharedItemTitle = this.panelTitle; if (forceFetch || isFetchRequired) { - this.filtersSearchSource!.setField('filter', this.input.filters); - this.filtersSearchSource!.setField('query', this.input.query); + this.filtersSearchSource.setField('filter', this.input.filters); + this.filtersSearchSource.setField('query', this.input.query); if (this.input.query?.query || this.input.filters?.length) { - this.filtersSearchSource!.setField('highlightAll', true); + this.filtersSearchSource.setField('highlightAll', true); } else { - this.filtersSearchSource!.removeField('highlightAll'); + this.filtersSearchSource.removeField('highlightAll'); } this.prevFilters = this.input.filters; this.prevQuery = this.input.query; this.prevTimeRange = this.input.timeRange; this.prevSearchSessionId = this.input.searchSessionId; - this.fetch(); - } else if (this.searchScope) { - // trigger a digest cycle to make sure non-fetch relevant changes are propagated - this.searchScope.$applyAsync(); + this.searchProps = searchProps; + await this.fetch(); + } else if (this.searchProps && this.node) { + this.searchProps = searchProps; + } + + if (this.node) { + this.renderReactComponent(this.node, this.searchProps!); + } + } + + /** + * + * @param {Element} domNode + */ + public async render(domNode: HTMLElement) { + if (!this.searchProps) { + throw new Error('Search props not defined'); + } + if (this.node) { + ReactDOM.unmountComponentAtNode(this.node); + } + this.node = domNode; + } + + private renderReactComponent(domNode: HTMLElement, searchProps: SearchProps) { + if (!this.searchProps) { + return; + } + const useLegacyTable = this.services.uiSettings.get(DOC_TABLE_LEGACY); + const props = { + searchProps, + useLegacyTable, + refs: domNode, + }; + ReactDOM.render(, domNode); + } + + public reload() { + if (this.searchProps) { + this.pushContainerStateParamsToProps(this.searchProps, { forceFetch: true }); } } + + public getSavedSearch(): SavedSearch { + return this.savedSearch; + } + + public getInspectorAdapters() { + return this.inspectorAdapters; + } + + public destroy() { + super.destroy(); + this.savedSearch.destroy(); + if (this.searchProps) { + delete this.searchProps; + } + this.subscription?.unsubscribe(); + + if (this.abortController) this.abortController.abort(); + } } diff --git a/src/plugins/discover/public/application/embeddable/saved_search_embeddable_component.tsx b/src/plugins/discover/public/application/embeddable/saved_search_embeddable_component.tsx new file mode 100644 index 00000000000000..5b2a2635d04bdf --- /dev/null +++ b/src/plugins/discover/public/application/embeddable/saved_search_embeddable_component.tsx @@ -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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; + +import { DiscoverGridEmbeddable } from '../angular/create_discover_grid_directive'; +import { DiscoverDocTableEmbeddable } from '../angular/doc_table/create_doc_table_embeddable'; +import { DiscoverGridProps } from '../components/discover_grid/discover_grid'; +import { SearchProps } from './saved_search_embeddable'; + +interface SavedSearchEmbeddableComponentProps { + searchProps: SearchProps; + useLegacyTable: boolean; + refs: HTMLElement; +} + +const DiscoverDocTableEmbeddableMemoized = React.memo(DiscoverDocTableEmbeddable); +const DiscoverGridEmbeddableMemoized = React.memo(DiscoverGridEmbeddable); + +export function SavedSearchEmbeddableComponent({ + searchProps, + useLegacyTable, + refs, +}: SavedSearchEmbeddableComponentProps) { + if (useLegacyTable) { + const docTableProps = { + ...searchProps, + refs, + }; + return ; + } + const discoverGridProps = searchProps as DiscoverGridProps; + return ; +} diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts index 77da138d118dd0..360844976284eb 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts @@ -18,8 +18,9 @@ import { import { TimeRange } from '../../../../data/public'; -import { SearchInput, SearchOutput, SearchEmbeddable } from './types'; +import { SearchInput, SearchOutput } from './types'; import { SEARCH_EMBEDDABLE_TYPE } from './constants'; +import { SavedSearchEmbeddable } from './saved_search_embeddable'; interface StartServices { executeTriggerActions: UiActionsStart['executeTriggerActions']; @@ -27,7 +28,7 @@ interface StartServices { } export class SearchEmbeddableFactory - implements EmbeddableFactoryDefinition { + implements EmbeddableFactoryDefinition { public readonly type = SEARCH_EMBEDDABLE_TYPE; private $injector: auto.IInjectorService | null; private getInjector: () => Promise | null; @@ -65,14 +66,11 @@ export class SearchEmbeddableFactory savedObjectId: string, input: Partial & { id: string; timeRange: TimeRange }, parent?: Container - ): Promise => { + ): Promise => { if (!this.$injector) { this.$injector = await this.getInjector(); } - const $injector = this.$injector as auto.IInjectorService; - const $compile = $injector.get('$compile'); - const $rootScope = $injector.get('$rootScope'); const filterManager = getServices().filterManager; const url = await getServices().getSavedSearchUrlById(savedObjectId); @@ -81,12 +79,12 @@ export class SearchEmbeddableFactory const savedObject = await getServices().getSavedSearchById(savedObjectId); const indexPattern = savedObject.searchSource.getField('index'); const { executeTriggerActions } = await this.getStartServices(); - const { SearchEmbeddable: SearchEmbeddableClass } = await import('./search_embeddable'); - return new SearchEmbeddableClass( + const { SavedSearchEmbeddable: SavedSearchEmbeddableClass } = await import( + './saved_search_embeddable' + ); + return new SavedSearchEmbeddableClass( { savedSearch: savedObject, - $rootScope, - $compile, editUrl, editPath: url, filterManager, diff --git a/src/plugins/discover/public/application/embeddable/search_template.html b/src/plugins/discover/public/application/embeddable/search_template.html deleted file mode 100644 index 3e37b3645650f2..00000000000000 --- a/src/plugins/discover/public/application/embeddable/search_template.html +++ /dev/null @@ -1,21 +0,0 @@ - - diff --git a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html deleted file mode 100644 index 8ad7938350d9c5..00000000000000 --- a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html +++ /dev/null @@ -1,19 +0,0 @@ - diff --git a/src/plugins/expressions/common/executor/executor.test.ts b/src/plugins/expressions/common/executor/executor.test.ts index 6175c9e170a906..3c24a3c24e01bc 100644 --- a/src/plugins/expressions/common/executor/executor.test.ts +++ b/src/plugins/expressions/common/executor/executor.test.ts @@ -52,12 +52,6 @@ describe('Executor', () => { executor.registerFunction(expressionFunctions.clog); }); - test('can register all functions', () => { - const executor = new Executor(); - for (const functionDefinition of expressionFunctions.functionSpecs) - executor.registerFunction(functionDefinition); - }); - test('can retrieve all functions', () => { const executor = new Executor(); executor.registerFunction(expressionFunctions.clog); @@ -67,12 +61,24 @@ describe('Executor', () => { test('can retrieve all functions - 2', () => { const executor = new Executor(); - for (const functionDefinition of expressionFunctions.functionSpecs) + const functionSpecs = [ + expressionFunctions.clog, + expressionFunctions.font, + expressionFunctions.variableSet, + expressionFunctions.variable, + expressionFunctions.theme, + expressionFunctions.cumulativeSum, + expressionFunctions.derivative, + expressionFunctions.movingAverage, + expressionFunctions.mapColumn, + expressionFunctions.math, + ]; + for (const functionDefinition of functionSpecs) { executor.registerFunction(functionDefinition); + } const functions = executor.getFunctions(); - expect(Object.keys(functions).sort()).toEqual( - expressionFunctions.functionSpecs.map((spec) => spec.name).sort() - ); + + expect(Object.keys(functions).sort()).toEqual(functionSpecs.map((spec) => spec.name).sort()); }); }); diff --git a/src/plugins/expressions/common/executor/executor.ts b/src/plugins/expressions/common/executor/executor.ts index 1eea51a0e1ec45..a307172aff9737 100644 --- a/src/plugins/expressions/common/executor/executor.ts +++ b/src/plugins/expressions/common/executor/executor.ts @@ -19,7 +19,6 @@ import { ExpressionType } from '../expression_types/expression_type'; import { AnyExpressionTypeDefinition } from '../expression_types/types'; import { ExpressionAstExpression, ExpressionAstFunction } from '../ast'; import { ExpressionValueError, typeSpecs } from '../expression_types/specs'; -import { functionSpecs } from '../expression_functions/specs'; import { getByAlias } from '../util'; import { SavedObjectReference } from '../../../../core/types'; import { PersistableStateService, SerializableState } from '../../../kibana_utils/common'; @@ -85,7 +84,7 @@ export class Executor = Record { const executor = new Executor(state); for (const type of typeSpecs) executor.registerType(type); - for (const func of functionSpecs) executor.registerFunction(func); + return executor; } diff --git a/src/plugins/expressions/common/expression_functions/specs/index.ts b/src/plugins/expressions/common/expression_functions/specs/index.ts index 9408b3a4337120..20a6f9aac45674 100644 --- a/src/plugins/expressions/common/expression_functions/specs/index.ts +++ b/src/plugins/expressions/common/expression_functions/specs/index.ts @@ -6,31 +6,6 @@ * Side Public License, v 1. */ -import { clog } from './clog'; -import { font } from './font'; -import { variableSet } from './var_set'; -import { variable } from './var'; -import { AnyExpressionFunctionDefinition } from '../types'; -import { theme } from './theme'; -import { cumulativeSum } from './cumulative_sum'; -import { derivative } from './derivative'; -import { movingAverage } from './moving_average'; -import { mapColumn } from './map_column'; -import { math } from './math'; - -export const functionSpecs: AnyExpressionFunctionDefinition[] = [ - clog, - font, - variableSet, - variable, - theme, - cumulativeSum, - derivative, - movingAverage, - mapColumn, - math, -]; - export * from './clog'; export * from './font'; export * from './var_set'; @@ -39,5 +14,6 @@ export * from './theme'; export * from './cumulative_sum'; export * from './derivative'; export * from './moving_average'; +export * from './ui_setting'; export { mapColumn, MapColumnArguments } from './map_column'; export { math, MathArguments, MathInput } from './math'; diff --git a/src/plugins/expressions/common/expression_functions/specs/map_column.ts b/src/plugins/expressions/common/expression_functions/specs/map_column.ts index 7939441ff0d602..7ea96ee7fdde82 100644 --- a/src/plugins/expressions/common/expression_functions/specs/map_column.ts +++ b/src/plugins/expressions/common/expression_functions/specs/map_column.ts @@ -6,16 +6,16 @@ * Side Public License, v 1. */ -import { Observable } from 'rxjs'; -import { take } from 'rxjs/operators'; +import { Observable, defer, of, zip } from 'rxjs'; +import { map } from 'rxjs/operators'; import { i18n } from '@kbn/i18n'; import { ExpressionFunctionDefinition } from '../types'; -import { Datatable, getType } from '../../expression_types'; +import { Datatable, DatatableColumn, getType } from '../../expression_types'; export interface MapColumnArguments { id?: string | null; name: string; - expression?(datatable: Datatable): Observable; + expression(datatable: Datatable): Observable; copyMetaFrom?: string | null; } @@ -23,7 +23,7 @@ export const mapColumn: ExpressionFunctionDefinition< 'mapColumn', Datatable, MapColumnArguments, - Promise + Observable > = { name: 'mapColumn', aliases: ['mc'], // midnight commander. So many times I've launched midnight commander instead of moving a file. @@ -80,57 +80,56 @@ export const mapColumn: ExpressionFunctionDefinition< default: null, }, }, - fn: (input, args) => { - const expression = (...params: Parameters['expression']>) => - args - .expression?.(...params) - .pipe(take(1)) - .toPromise() ?? Promise.resolve(null); + fn(input, args) { + const existingColumnIndex = input.columns.findIndex(({ id, name }) => + args.id ? id === args.id : name === args.name + ); + const id = input.columns[existingColumnIndex]?.id ?? args.id ?? args.name; - const columns = [...input.columns]; - const existingColumnIndex = columns.findIndex(({ id, name }) => { - if (args.id) { - return id === args.id; - } - return name === args.name; - }); - const columnId = - existingColumnIndex === -1 ? args.id ?? args.name : columns[existingColumnIndex].id; - - const rowPromises = input.rows.map((row) => { - return expression({ - type: 'datatable', - columns, - rows: [row], - }).then((val) => ({ - ...row, - [columnId]: val, - })); - }); + return defer(() => { + const rows$ = input.rows.length + ? zip( + ...input.rows.map((row) => + args + .expression({ + type: 'datatable', + columns: [...input.columns], + rows: [row], + }) + .pipe(map((value) => ({ ...row, [id]: value }))) + ) + ) + : of([]); - return Promise.all(rowPromises).then((rows) => { - const type = rows.length ? getType(rows[0][columnId]) : 'null'; - const newColumn = { - id: columnId, - name: args.name, - meta: { type }, - }; - if (args.copyMetaFrom) { - const metaSourceFrom = columns.find(({ id }) => id === args.copyMetaFrom); - newColumn.meta = { ...newColumn.meta, ...(metaSourceFrom?.meta || {}) }; - } + return rows$.pipe( + map((rows) => { + const type = getType(rows[0]?.[id]); + const newColumn: DatatableColumn = { + id, + name: args.name, + meta: { type, params: { id: type } }, + }; + if (args.copyMetaFrom) { + const metaSourceFrom = input.columns.find( + ({ id: columnId }) => columnId === args.copyMetaFrom + ); + newColumn.meta = { ...newColumn.meta, ...(metaSourceFrom?.meta ?? {}) }; + } - if (existingColumnIndex === -1) { - columns.push(newColumn); - } else { - columns[existingColumnIndex] = newColumn; - } + const columns = [...input.columns]; + if (existingColumnIndex === -1) { + columns.push(newColumn); + } else { + columns[existingColumnIndex] = newColumn; + } - return { - type: 'datatable', - columns, - rows, - } as Datatable; + return { + columns, + rows, + type: 'datatable', + }; + }) + ); }); }, }; diff --git a/src/plugins/expressions/common/expression_functions/specs/tests/map_column.test.ts b/src/plugins/expressions/common/expression_functions/specs/tests/map_column.test.ts index f5c1f3838f66c7..bd934745fed723 100644 --- a/src/plugins/expressions/common/expression_functions/specs/tests/map_column.test.ts +++ b/src/plugins/expressions/common/expression_functions/specs/tests/map_column.test.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { of } from 'rxjs'; +import { of, Observable } from 'rxjs'; +import { TestScheduler } from 'rxjs/testing'; import { Datatable } from '../../../expression_types'; import { mapColumn, MapColumnArguments } from '../map_column'; import { emptyTable, functionWrapper, testTable } from './utils'; @@ -16,138 +17,227 @@ const pricePlusTwo = (datatable: Datatable) => of(datatable.rows[0].price + 2); describe('mapColumn', () => { const fn = functionWrapper(mapColumn); const runFn = (input: Datatable, args: MapColumnArguments) => - fn(input, args) as Promise; + fn(input, args) as Observable; + let testScheduler: TestScheduler; - it('returns a datatable with a new column with the values from mapping a function over each row in a datatable', async () => { - const arbitraryRowIndex = 2; - const result = await runFn(testTable, { - id: 'pricePlusTwo', - name: 'pricePlusTwo', - expression: pricePlusTwo, - }); - - expect(result.type).toBe('datatable'); - expect(result.columns).toEqual([ - ...testTable.columns, - { id: 'pricePlusTwo', name: 'pricePlusTwo', meta: { type: 'number' } }, - ]); - expect(result.columns[result.columns.length - 1]).toHaveProperty('name', 'pricePlusTwo'); - expect(result.rows[arbitraryRowIndex]).toHaveProperty('pricePlusTwo'); + beforeEach(() => { + testScheduler = new TestScheduler((actual, expected) => expect(actual).toStrictEqual(expected)); }); - it('allows the id arg to be optional, looking up by name instead', async () => { - const result = await runFn(testTable, { name: 'name label', expression: pricePlusTwo }); - const nameColumnIndex = result.columns.findIndex(({ name }) => name === 'name label'); - const arbitraryRowIndex = 4; - - expect(result.type).toBe('datatable'); - expect(result.columns).toHaveLength(testTable.columns.length); - expect(result.columns[nameColumnIndex]).toHaveProperty('id', 'name'); - expect(result.columns[nameColumnIndex]).toHaveProperty('name', 'name label'); - expect(result.columns[nameColumnIndex].meta).toHaveProperty('type', 'number'); - expect(result.rows[arbitraryRowIndex]).toHaveProperty('name', 202); - expect(result.rows[arbitraryRowIndex]).not.toHaveProperty('name label'); + it('returns a datatable with a new column with the values from mapping a function over each row in a datatable', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + runFn(testTable, { + id: 'pricePlusTwo', + name: 'pricePlusTwo', + expression: pricePlusTwo, + }) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: [ + ...testTable.columns, + { + id: 'pricePlusTwo', + name: 'pricePlusTwo', + meta: { type: 'number', params: { id: 'number' } }, + }, + ], + rows: expect.arrayContaining([ + expect.objectContaining({ + pricePlusTwo: expect.anything(), + }), + ]), + }), + ]); + }); }); - it('allows a duplicate name when the ids are different', async () => { - const result = await runFn(testTable, { - id: 'new', - name: 'name label', - expression: pricePlusTwo, + it('allows the id arg to be optional, looking up by name instead', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable(runFn(testTable, { name: 'name label', expression: pricePlusTwo })).toBe( + '(0|)', + [ + expect.objectContaining({ + type: 'datatable', + columns: expect.arrayContaining([ + expect.objectContaining({ + id: 'name', + name: 'name label', + meta: expect.objectContaining({ type: 'number' }), + }), + ]), + rows: expect.arrayContaining([ + expect.objectContaining({ + name: 202, + }), + ]), + }), + ] + ); }); - const nameColumnIndex = result.columns.findIndex(({ id }) => id === 'new'); - const arbitraryRowIndex = 4; - - expect(result.type).toBe('datatable'); - expect(result.columns).toHaveLength(testTable.columns.length + 1); - expect(result.columns[nameColumnIndex]).toHaveProperty('id', 'new'); - expect(result.columns[nameColumnIndex]).toHaveProperty('name', 'name label'); - expect(result.columns[nameColumnIndex].meta).toHaveProperty('type', 'number'); - expect(result.rows[arbitraryRowIndex]).toHaveProperty('new', 202); }); - it('adds a column to empty tables', async () => { - const result = await runFn(emptyTable, { name: 'name', expression: pricePlusTwo }); + it('allows a duplicate name when the ids are different', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + runFn(testTable, { + id: 'new', + name: 'name label', + expression: pricePlusTwo, + }) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: expect.arrayContaining([ + expect.objectContaining({ + id: 'new', + name: 'name label', + meta: expect.objectContaining({ type: 'number' }), + }), + ]), + rows: expect.arrayContaining([ + expect.objectContaining({ + new: 202, + }), + ]), + }), + ]); + }); + }); - expect(result.type).toBe('datatable'); - expect(result.columns).toHaveLength(1); - expect(result.columns[0]).toHaveProperty('name', 'name'); - expect(result.columns[0].meta).toHaveProperty('type', 'null'); + it('overwrites existing column with the new column if an existing column name is provided', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable(runFn(testTable, { name: 'name', expression: pricePlusTwo })).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: expect.arrayContaining([ + expect.objectContaining({ + name: 'name', + meta: expect.objectContaining({ type: 'number' }), + }), + ]), + rows: expect.arrayContaining([ + expect.objectContaining({ + name: 202, + }), + ]), + }), + ]); + }); }); - it('should assign specific id, different from name, when id arg is passed for new columns', async () => { - const result = await runFn(emptyTable, { name: 'name', id: 'myid', expression: pricePlusTwo }); + it('adds a column to empty tables', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable(runFn(emptyTable, { name: 'name', expression: pricePlusTwo })).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: [ + expect.objectContaining({ + name: 'name', + meta: expect.objectContaining({ type: 'null' }), + }), + ], + }), + ]); + }); + }); - expect(result.type).toBe('datatable'); - expect(result.columns).toHaveLength(1); - expect(result.columns[0]).toHaveProperty('name', 'name'); - expect(result.columns[0]).toHaveProperty('id', 'myid'); - expect(result.columns[0].meta).toHaveProperty('type', 'null'); + it('should assign specific id, different from name, when id arg is passed for copied column', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + runFn(testTable, { name: 'name', id: 'myid', expression: pricePlusTwo }) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: expect.arrayContaining([ + expect.objectContaining({ + id: 'myid', + name: 'name', + meta: expect.objectContaining({ type: 'number' }), + }), + ]), + }), + ]); + }); }); - it('should copy over the meta information from the specified column', async () => { - const result = await runFn( - { - ...testTable, - columns: [ - ...testTable.columns, - // add a new entry + it('should copy over the meta information from the specified column', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + runFn( { - id: 'myId', - name: 'myName', - meta: { type: 'date', params: { id: 'number', params: { digits: 2 } } }, + ...testTable, + columns: [ + ...testTable.columns, + // add a new entry + { + id: 'myId', + name: 'myName', + meta: { type: 'date', params: { id: 'number', params: { digits: 2 } } }, + }, + ], + rows: testTable.rows.map((row) => ({ ...row, myId: Date.now() })), }, - ], - rows: testTable.rows.map((row) => ({ ...row, myId: Date.now() })), - }, - { name: 'name', copyMetaFrom: 'myId', expression: pricePlusTwo } - ); - const nameColumnIndex = result.columns.findIndex(({ name }) => name === 'name'); - - expect(result.type).toBe('datatable'); - expect(result.columns[nameColumnIndex]).toEqual({ - id: 'name', - name: 'name', - meta: { type: 'date', params: { id: 'number', params: { digits: 2 } } }, + { name: 'name', copyMetaFrom: 'myId', expression: pricePlusTwo } + ) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: expect.arrayContaining([ + expect.objectContaining({ + id: 'name', + name: 'name', + meta: { type: 'date', params: { id: 'number', params: { digits: 2 } } }, + }), + ]), + }), + ]); }); }); - it('should be resilient if the references column for meta information does not exists', async () => { - const result = await runFn(emptyTable, { - name: 'name', - copyMetaFrom: 'time', - expression: pricePlusTwo, + it('should be resilient if the references column for meta information does not exists', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + runFn(emptyTable, { + name: 'name', + copyMetaFrom: 'time', + expression: pricePlusTwo, + }) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: [ + expect.objectContaining({ + id: 'name', + name: 'name', + meta: expect.objectContaining({ type: 'null' }), + }), + ], + }), + ]); }); - - expect(result.type).toBe('datatable'); - expect(result.columns).toHaveLength(1); - expect(result.columns[0]).toHaveProperty('name', 'name'); - expect(result.columns[0]).toHaveProperty('id', 'name'); - expect(result.columns[0].meta).toHaveProperty('type', 'null'); }); - it('should correctly infer the type fromt he first row if the references column for meta information does not exists', async () => { - const result = await runFn( - { ...emptyTable, rows: [...emptyTable.rows, { value: 5 }] }, - { name: 'value', copyMetaFrom: 'time', expression: pricePlusTwo } - ); - - expect(result.type).toBe('datatable'); - expect(result.columns).toHaveLength(1); - expect(result.columns[0]).toHaveProperty('name', 'value'); - expect(result.columns[0]).toHaveProperty('id', 'value'); - expect(result.columns[0].meta).toHaveProperty('type', 'number'); - }); - - describe('expression', () => { - it('maps null values to the new column', async () => { - const result = await runFn(testTable, { name: 'empty' }); - const emptyColumnIndex = result.columns.findIndex(({ name }) => name === 'empty'); - const arbitraryRowIndex = 8; - - expect(result.columns[emptyColumnIndex]).toHaveProperty('name', 'empty'); - expect(result.columns[emptyColumnIndex].meta).toHaveProperty('type', 'null'); - expect(result.rows[arbitraryRowIndex]).toHaveProperty('empty', null); + it('should correctly infer the type fromt he first row if the references column for meta information does not exists', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + runFn( + { ...emptyTable, rows: [...emptyTable.rows, { value: 5 }] }, + { name: 'value', copyMetaFrom: 'time', expression: pricePlusTwo } + ) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: [ + expect.objectContaining({ + id: 'value', + name: 'value', + meta: expect.objectContaining({ type: 'number' }), + }), + ], + }), + ]); }); }); }); diff --git a/src/plugins/expressions/common/expression_functions/specs/tests/ui_setting.test.ts b/src/plugins/expressions/common/expression_functions/specs/tests/ui_setting.test.ts new file mode 100644 index 00000000000000..fb2c87588a4d47 --- /dev/null +++ b/src/plugins/expressions/common/expression_functions/specs/tests/ui_setting.test.ts @@ -0,0 +1,78 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +jest.mock('../../../../common'); + +import { IUiSettingsClient } from 'src/core/public'; +import { getUiSettingFn } from '../ui_setting'; + +describe('uiSetting', () => { + describe('fn', () => { + let getStartDependencies: jest.MockedFunction< + Parameters[0]['getStartDependencies'] + >; + let uiSetting: ReturnType; + let uiSettings: jest.Mocked; + + beforeEach(() => { + uiSettings = ({ + get: jest.fn(), + } as unknown) as jest.Mocked; + getStartDependencies = (jest.fn(async () => ({ + uiSettings, + })) as unknown) as typeof getStartDependencies; + + uiSetting = getUiSettingFn({ getStartDependencies }); + }); + + it('should return a value', () => { + uiSettings.get.mockReturnValueOnce('value'); + + expect(uiSetting.fn(null, { parameter: 'something' }, {} as any)).resolves.toEqual({ + type: 'ui_setting', + key: 'something', + value: 'value', + }); + }); + + it('should pass a default value', async () => { + await uiSetting.fn(null, { parameter: 'something', default: 'default' }, {} as any); + + expect(uiSettings.get).toHaveBeenCalledWith('something', 'default'); + }); + + it('should throw an error when parameter does not exist', () => { + uiSettings.get.mockImplementationOnce(() => { + throw new Error(); + }); + + expect(uiSetting.fn(null, { parameter: 'something' }, {} as any)).rejects.toEqual( + new Error('Invalid parameter "something".') + ); + }); + + it('should get a request instance on the server-side', async () => { + const request = {}; + await uiSetting.fn(null, { parameter: 'something' }, { + getKibanaRequest: () => request, + } as any); + + const [[getKibanaRequest]] = getStartDependencies.mock.calls; + + expect(getKibanaRequest()).toBe(request); + }); + + it('should throw an error if request is not provided on the server-side', async () => { + await uiSetting.fn(null, { parameter: 'something' }, {} as any); + + const [[getKibanaRequest]] = getStartDependencies.mock.calls; + + expect(getKibanaRequest).toThrow(); + }); + }); +}); diff --git a/src/plugins/expressions/common/expression_functions/specs/ui_setting.ts b/src/plugins/expressions/common/expression_functions/specs/ui_setting.ts new file mode 100644 index 00000000000000..8e352e12d49c59 --- /dev/null +++ b/src/plugins/expressions/common/expression_functions/specs/ui_setting.ts @@ -0,0 +1,94 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import type { KibanaRequest } from 'src/core/server'; +import { i18n } from '@kbn/i18n'; +import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common'; +import { UiSetting } from '../../expression_types/specs/ui_setting'; + +interface UiSettingsClient { + get(key: string, defaultValue?: T): T | Promise; +} + +interface UiSettingStartDependencies { + uiSettings: UiSettingsClient; +} + +interface UiSettingFnArguments { + getStartDependencies(getKibanaRequest: () => KibanaRequest): Promise; +} + +export interface UiSettingArguments { + default?: unknown; + parameter: string; +} + +export type ExpressionFunctionUiSetting = ExpressionFunctionDefinition< + 'uiSetting', + unknown, + UiSettingArguments, + Promise +>; + +export function getUiSettingFn({ + getStartDependencies, +}: UiSettingFnArguments): ExpressionFunctionUiSetting { + return { + name: 'uiSetting', + help: i18n.translate('expressions.functions.uiSetting.help', { + defaultMessage: 'Returns a UI settings parameter value.', + }), + args: { + default: { + help: i18n.translate('expressions.functions.uiSetting.args.default', { + defaultMessage: 'A default value in case of the parameter is not set.', + }), + }, + parameter: { + aliases: ['_'], + help: i18n.translate('expressions.functions.uiSetting.args.parameter', { + defaultMessage: 'The parameter name.', + }), + required: true, + types: ['string'], + }, + }, + async fn(input, { default: defaultValue, parameter }, { getKibanaRequest }) { + const { uiSettings } = await getStartDependencies(() => { + const request = getKibanaRequest?.(); + if (!request) { + throw new Error( + i18n.translate('expressions.functions.uiSetting.error.kibanaRequest', { + defaultMessage: + 'A KibanaRequest is required to get UI settings on the server. ' + + 'Please provide a request object to the expression execution params.', + }) + ); + } + + return request; + }); + + try { + return { + type: 'ui_setting', + key: parameter, + value: await uiSettings.get(parameter, defaultValue), + }; + } catch { + throw new Error( + i18n.translate('expressions.functions.uiSetting.error.parameter', { + defaultMessage: 'Invalid parameter "{parameter}".', + values: { parameter }, + }) + ); + } + }, + }; +} diff --git a/src/plugins/expressions/common/expression_functions/types.ts b/src/plugins/expressions/common/expression_functions/types.ts index b91e16d1804aa6..e1378a27bdfc29 100644 --- a/src/plugins/expressions/common/expression_functions/types.ts +++ b/src/plugins/expressions/common/expression_functions/types.ts @@ -6,9 +6,8 @@ * Side Public License, v 1. */ -import { UnwrapPromiseOrReturn } from '@kbn/utility-types'; import { ArgumentType } from './arguments'; -import { TypeToString } from '../types/common'; +import { TypeToString, TypeString, UnmappedTypeStrings } from '../types/common'; import { ExecutionContext } from '../execution/types'; import { ExpressionFunctionClog, @@ -47,7 +46,7 @@ export interface ExpressionFunctionDefinition< /** * Name of type of value this function outputs. */ - type?: TypeToString>; + type?: TypeString | UnmappedTypeStrings; /** * List of allowed type names for input value of this function. If this diff --git a/src/plugins/expressions/common/expression_types/specs/index.ts b/src/plugins/expressions/common/expression_types/specs/index.ts index 70427f8b337d89..c990d74672fcc4 100644 --- a/src/plugins/expressions/common/expression_types/specs/index.ts +++ b/src/plugins/expressions/common/expression_types/specs/index.ts @@ -21,6 +21,7 @@ import { shape } from './shape'; import { string } from './string'; import { style } from './style'; import { AnyExpressionTypeDefinition } from '../types'; +import { uiSetting } from './ui_setting'; export const typeSpecs: AnyExpressionTypeDefinition[] = [ boolean, @@ -37,6 +38,7 @@ export const typeSpecs: AnyExpressionTypeDefinition[] = [ shape, string, style, + uiSetting, ]; export * from './boolean'; @@ -53,3 +55,4 @@ export * from './render'; export * from './shape'; export * from './string'; export * from './style'; +export * from './ui_setting'; diff --git a/src/plugins/expressions/common/expression_types/specs/tests/ui_setting.test.ts b/src/plugins/expressions/common/expression_types/specs/tests/ui_setting.test.ts new file mode 100644 index 00000000000000..a0a3d0d396b6e6 --- /dev/null +++ b/src/plugins/expressions/common/expression_types/specs/tests/ui_setting.test.ts @@ -0,0 +1,79 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { UiSetting, uiSetting } from '../ui_setting'; + +function createUiSetting(value: unknown, key = 'something'): UiSetting { + return { + key, + value, + type: 'ui_setting', + }; +} + +describe('uiSetting', () => { + describe('to', () => { + describe('render', () => { + it.each` + value | expected + ${{ a: 'b' }} | ${JSON.stringify({ a: 'b' })} + ${null} | ${''} + ${'something'} | ${'something'} + `('should render "$value" as "$expected"', ({ expected, value }) => { + expect(uiSetting.to?.render(createUiSetting(value), {})).toHaveProperty( + 'value.text', + expected + ); + }); + }); + + describe('datatable', () => { + it('should use parameter name as a datatable column', () => { + expect(uiSetting.to?.datatable(createUiSetting('value', 'column'), {})).toHaveProperty( + 'columns.0', + expect.objectContaining({ id: 'column', name: 'column' }) + ); + }); + + it.each` + value | type + ${null} | ${'null'} + ${undefined} | ${'null'} + ${'something'} | ${'string'} + ${['123']} | ${'string'} + ${123} | ${'number'} + ${[123]} | ${'number'} + ${true} | ${'boolean'} + ${{ a: 'b' }} | ${'object'} + ${[]} | ${'unknown'} + `('should determine $type type', ({ value, type }) => { + expect(uiSetting.to?.datatable(createUiSetting(value, 'column'), {})).toHaveProperty( + 'columns.0.meta.type', + type + ); + }); + + it('should put a value into a row', () => { + expect(uiSetting.to?.datatable(createUiSetting('value'), {})).toHaveProperty( + 'rows.0.something', + 'value' + ); + }); + + it('should put an array value into multiple rows', () => { + expect(uiSetting.to?.datatable(createUiSetting(['a', 'b']), {})).toHaveProperty( + 'rows', + expect.arrayContaining([ + expect.objectContaining({ something: 'a' }), + expect.objectContaining({ something: 'b' }), + ]) + ); + }); + }); + }); +}); diff --git a/src/plugins/expressions/common/expression_types/specs/ui_setting.ts b/src/plugins/expressions/common/expression_types/specs/ui_setting.ts new file mode 100644 index 00000000000000..aaea92e89a8325 --- /dev/null +++ b/src/plugins/expressions/common/expression_types/specs/ui_setting.ts @@ -0,0 +1,65 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Datatable, DatatableColumnType } from './datatable'; +import { ExpressionTypeDefinition, ExpressionValueBoxed } from '../types'; +import { ExpressionValueRender } from './render'; + +const name = 'ui_setting'; + +function getType(value: unknown): DatatableColumnType { + if (value == null) { + return 'null'; + } + + if (Array.isArray(value)) { + return value.length ? getType(value[0]) : 'unknown'; + } + + if (['boolean', 'number', 'object', 'string'].includes(typeof value)) { + return typeof value as DatatableColumnType; + } + + return 'unknown'; +} + +export type UiSetting = ExpressionValueBoxed<'ui_setting', { key: string; value: unknown }>; + +export const uiSetting: ExpressionTypeDefinition<'ui_setting', UiSetting> = { + name, + to: { + boolean({ value }) { + return Boolean(value); + }, + number({ value }) { + return Number(value); + }, + string({ value }) { + return String(value ?? ''); + }, + render({ value }): ExpressionValueRender<{ text: string }> { + return { + type: 'render', + as: 'text', + value: { + text: + typeof value === 'object' && value !== null + ? JSON.stringify(value) + : String(value ?? ''), + }, + }; + }, + datatable({ key, value }): Datatable { + return { + type: 'datatable', + columns: [{ id: key, name: key, meta: { type: getType(value) } }], + rows: (Array.isArray(value) ? value : [value]).map((cell) => ({ [key]: cell })), + }; + }, + }, +}; diff --git a/src/plugins/expressions/common/service/expressions_services.ts b/src/plugins/expressions/common/service/expressions_services.ts index d57c1748954abf..a8839c9b0d71e1 100644 --- a/src/plugins/expressions/common/service/expressions_services.ts +++ b/src/plugins/expressions/common/service/expressions_services.ts @@ -19,6 +19,18 @@ import { AnyExpressionFunctionDefinition } from '../expression_functions'; import { SavedObjectReference } from '../../../../core/types'; import { PersistableStateService, SerializableState } from '../../../kibana_utils/common'; import { Adapters } from '../../../inspector/common/adapters'; +import { + clog, + font, + variableSet, + variable, + theme, + cumulativeSum, + derivative, + movingAverage, + mapColumn, + math, +} from '../expression_functions'; /** * The public contract that `ExpressionsService` provides to other plugins @@ -269,7 +281,7 @@ export class ExpressionsService implements PersistableStateService { const executor = this.executor.fork(); const renderers = this.renderers; - const fork = new ExpressionsService({ executor, renderers }); + const fork = new (this.constructor as typeof ExpressionsService)({ executor, renderers }); return fork; }; @@ -318,7 +330,22 @@ export class ExpressionsService implements PersistableStateService) { + return getCommonUiSettingFn({ + async getStartDependencies() { + const [{ uiSettings }] = await getStartServices(); + + return { uiSettings }; + }, + }); +} diff --git a/src/plugins/expressions/public/plugin.test.ts b/src/plugins/expressions/public/plugin.test.ts index b83c92f5d1a96b..93353ebbb51b61 100644 --- a/src/plugins/expressions/public/plugin.test.ts +++ b/src/plugins/expressions/public/plugin.test.ts @@ -8,7 +8,7 @@ import { expressionsPluginMock } from './mocks'; import { add } from '../common/test_helpers/expression_functions/add'; -import { ExpressionsService } from '../common'; +import { ExpressionsService } from './services'; describe('ExpressionsPublicPlugin', () => { test('can instantiate from mocks', async () => { diff --git a/src/plugins/expressions/public/plugin.ts b/src/plugins/expressions/public/plugin.ts index 2410ad87413129..37d519ac451336 100644 --- a/src/plugins/expressions/public/plugin.ts +++ b/src/plugins/expressions/public/plugin.ts @@ -6,9 +6,15 @@ * Side Public License, v 1. */ +import { pick } from 'lodash'; import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public'; -import { ExpressionsService, ExpressionsServiceSetup, ExpressionsServiceStart } from '../common'; -import { setRenderersRegistry, setNotifications, setExpressionsService } from './services'; +import { ExpressionsServiceSetup, ExpressionsServiceStart } from '../common'; +import { + ExpressionsService, + setRenderersRegistry, + setNotifications, + setExpressionsService, +} from './services'; import { ReactExpressionRenderer } from './react_expression_renderer'; import { ExpressionLoader, IExpressionLoader, loader } from './loader'; import { render, ExpressionRenderHandler } from './render'; @@ -51,7 +57,7 @@ export class ExpressionsPublicPlugin implements Plugin>; name: Name; - type?: TypeToString>; + type?: TypeString | UnmappedTypeStrings; } // @public @@ -612,8 +612,8 @@ export class ExpressionsService implements PersistableStateService) => Record; diff --git a/src/plugins/expressions/public/services/expressions_services.ts b/src/plugins/expressions/public/services/expressions_services.ts new file mode 100644 index 00000000000000..388af81629c31d --- /dev/null +++ b/src/plugins/expressions/public/services/expressions_services.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { CoreSetup } from 'src/core/public'; +import { ExpressionsService as CommonExpressionsService } from '../../common'; +import { getUiSettingFn } from '../expression_functions'; + +export class ExpressionsService extends CommonExpressionsService { + setup({ getStartServices }: Pick) { + this.registerFunction(getUiSettingFn({ getStartServices })); + + return super.setup(); + } +} diff --git a/src/plugins/expressions/public/services.ts b/src/plugins/expressions/public/services/index.ts similarity index 87% rename from src/plugins/expressions/public/services.ts rename to src/plugins/expressions/public/services/index.ts index a700e54d77e190..db473037a0a4a6 100644 --- a/src/plugins/expressions/public/services.ts +++ b/src/plugins/expressions/public/services/index.ts @@ -7,8 +7,8 @@ */ import { NotificationsStart } from 'kibana/public'; -import { createGetterSetter } from '../../kibana_utils/public'; -import { ExpressionsService, ExpressionRendererRegistry } from '../common'; +import { createGetterSetter } from '../../../kibana_utils/public'; +import { ExpressionsService, ExpressionRendererRegistry } from '../../common'; export const [getNotifications, setNotifications] = createGetterSetter( 'Notifications' @@ -23,3 +23,5 @@ export const [ getExpressionsService, setExpressionsService, ] = createGetterSetter('ExpressionsService'); + +export * from './expressions_services'; diff --git a/src/plugins/expressions/server/expression_functions/index.ts b/src/plugins/expressions/server/expression_functions/index.ts new file mode 100644 index 00000000000000..eb36291c613c67 --- /dev/null +++ b/src/plugins/expressions/server/expression_functions/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './ui_setting'; diff --git a/src/plugins/expressions/server/expression_functions/ui_setting.ts b/src/plugins/expressions/server/expression_functions/ui_setting.ts new file mode 100644 index 00000000000000..0d3d5b1c1f997b --- /dev/null +++ b/src/plugins/expressions/server/expression_functions/ui_setting.ts @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { CoreSetup } from 'src/core/server'; +import { getUiSettingFn as getCommonUiSettingFn } from '../../common'; + +export function getUiSettingFn({ getStartServices }: Pick) { + return getCommonUiSettingFn({ + async getStartDependencies(getKibanaRequest) { + const [{ savedObjects, uiSettings }] = await getStartServices(); + const savedObjectsClient = savedObjects.getScopedClient(getKibanaRequest()); + const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient); + + return { uiSettings: uiSettingsClient }; + }, + }); +} diff --git a/src/plugins/expressions/server/plugin.ts b/src/plugins/expressions/server/plugin.ts index 2c638d496ece62..2e45daf6e0f8c0 100644 --- a/src/plugins/expressions/server/plugin.ts +++ b/src/plugins/expressions/server/plugin.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import { pick } from 'lodash'; import { CoreStart, CoreSetup, Plugin, PluginInitializerContext } from 'src/core/server'; import { ExpressionsService, ExpressionsServiceSetup, ExpressionsServiceStart } from '../common'; @@ -24,7 +25,7 @@ export class ExpressionsServerPlugin environment: 'server', }); - const setup = this.expressions.setup(); + const setup = this.expressions.setup(pick(core, 'getStartServices')); return Object.freeze(setup); } diff --git a/src/plugins/expressions/server/server.api.md b/src/plugins/expressions/server/server.api.md index 12af0480fac93f..bc0980121b827e 100644 --- a/src/plugins/expressions/server/server.api.md +++ b/src/plugins/expressions/server/server.api.md @@ -347,7 +347,7 @@ export interface ExpressionFunctionDefinition>; name: Name; - type?: TypeToString>; + type?: TypeString | UnmappedTypeStrings; } // @public diff --git a/src/plugins/expressions/server/services/expressions_services.ts b/src/plugins/expressions/server/services/expressions_services.ts new file mode 100644 index 00000000000000..914745436f1518 --- /dev/null +++ b/src/plugins/expressions/server/services/expressions_services.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { CoreSetup } from 'src/core/server'; +import { ExpressionsService as CommonExpressionsService } from '../../common'; +import { getUiSettingFn } from '../expression_functions'; + +export class ExpressionsService extends CommonExpressionsService { + setup({ getStartServices }: Pick) { + this.registerFunction(getUiSettingFn({ getStartServices })); + + return super.setup(); + } +} diff --git a/src/plugins/expressions/server/services/index.ts b/src/plugins/expressions/server/services/index.ts new file mode 100644 index 00000000000000..c239c4efdb02cc --- /dev/null +++ b/src/plugins/expressions/server/services/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './expressions_services'; diff --git a/src/plugins/kibana_react/public/code_editor/__snapshots__/code_editor.test.tsx.snap b/src/plugins/kibana_react/public/code_editor/__snapshots__/code_editor.test.tsx.snap index a779ef540d72ec..d4fb5a708e4405 100644 --- a/src/plugins/kibana_react/public/code_editor/__snapshots__/code_editor.test.tsx.snap +++ b/src/plugins/kibana_react/public/code_editor/__snapshots__/code_editor.test.tsx.snap @@ -11,6 +11,7 @@ exports[`is rendered 1`] = ` onChange={[Function]} options={ Object { + "matchBrackets": "never", "minimap": Object { "enabled": false, }, @@ -39,6 +40,7 @@ exports[`is rendered 1`] = ` nodeType="div" onResize={[Function]} querySelector={null} + refreshMode="debounce" refreshRate={1000} skipOnMount={false} targetDomEl={null} diff --git a/src/plugins/kibana_react/public/code_editor/code_editor.tsx b/src/plugins/kibana_react/public/code_editor/code_editor.tsx index 55e10e7861e518..251f05950da227 100644 --- a/src/plugins/kibana_react/public/code_editor/code_editor.tsx +++ b/src/plugins/kibana_react/public/code_editor/code_editor.tsx @@ -187,10 +187,16 @@ export class CodeEditor extends React.Component { wordBasedSuggestions: false, wordWrap: 'on', wrappingIndent: 'indent', + matchBrackets: 'never', ...options, }} /> - + ); } diff --git a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts index 1fa7d8e846c9da..e7c6b53ff97b3c 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/application_usage/schema.ts @@ -148,6 +148,7 @@ export const applicationUsageSchema = { maps: commonSchema, ml: commonSchema, monitoring: commonSchema, + observabilityCases: commonSchema, 'observability-overview': commonSchema, osquery: commonSchema, security_account: commonSchema, diff --git a/src/plugins/management/common/locator.test.ts b/src/plugins/management/common/locator.test.ts new file mode 100644 index 00000000000000..dda393a4203ecd --- /dev/null +++ b/src/plugins/management/common/locator.test.ts @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { MANAGEMENT_APP_ID } from './contants'; +import { ManagementAppLocator, MANAGEMENT_APP_LOCATOR } from './locator'; + +test('locator has the right ID', () => { + const locator = new ManagementAppLocator(); + + expect(locator.id).toBe(MANAGEMENT_APP_LOCATOR); +}); + +test('returns management app ID', async () => { + const locator = new ManagementAppLocator(); + const location = await locator.getLocation({ + sectionId: 'a', + appId: 'b', + }); + + expect(location).toMatchObject({ + app: MANAGEMENT_APP_ID, + }); +}); + +test('returns Kibana location for section ID and app ID pair', async () => { + const locator = new ManagementAppLocator(); + const location = await locator.getLocation({ + sectionId: 'ingest', + appId: 'index', + }); + + expect(location).toMatchObject({ + route: '/ingest/index', + state: {}, + }); +}); + +test('when app ID is not provided, returns path to just the section ID', async () => { + const locator = new ManagementAppLocator(); + const location = await locator.getLocation({ + sectionId: 'data', + }); + + expect(location).toMatchObject({ + route: '/data', + state: {}, + }); +}); diff --git a/src/plugins/management/common/locator.ts b/src/plugins/management/common/locator.ts new file mode 100644 index 00000000000000..4a4a50f468adc6 --- /dev/null +++ b/src/plugins/management/common/locator.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { SerializableState } from 'src/plugins/kibana_utils/common'; +import { LocatorDefinition } from 'src/plugins/share/common'; +import { MANAGEMENT_APP_ID } from './contants'; + +export const MANAGEMENT_APP_LOCATOR = 'MANAGEMENT_APP_LOCATOR'; + +export interface ManagementAppLocatorParams extends SerializableState { + sectionId: string; + appId?: string; +} + +export class ManagementAppLocator implements LocatorDefinition { + public readonly id = MANAGEMENT_APP_LOCATOR; + + public readonly getLocation = async (params: ManagementAppLocatorParams) => { + const route = `/${params.sectionId}${params.appId ? '/' + params.appId : ''}`; + + return { + app: MANAGEMENT_APP_ID, + route, + state: {}, + }; + }; +} diff --git a/src/plugins/management/kibana.json b/src/plugins/management/kibana.json index 6c8574f0242290..44c3f861709cee 100644 --- a/src/plugins/management/kibana.json +++ b/src/plugins/management/kibana.json @@ -3,6 +3,6 @@ "version": "kibana", "server": true, "ui": true, - "optionalPlugins": ["home"], + "optionalPlugins": ["home", "share"], "requiredBundles": ["kibanaReact", "kibanaUtils", "home"] } diff --git a/src/plugins/management/public/mocks/index.ts b/src/plugins/management/public/mocks/index.ts index 4dcdd22d5d2095..70d853f32dfcc3 100644 --- a/src/plugins/management/public/mocks/index.ts +++ b/src/plugins/management/public/mocks/index.ts @@ -30,6 +30,14 @@ const createSetupContract = (): ManagementSetup => ({ stack: createManagementSectionMock(), } as unknown) as DefinedSections, }, + locator: { + getLocation: jest.fn(async () => ({ + app: 'MANAGEMENT', + route: '', + state: {}, + })), + navigate: jest.fn(), + }, }); const createStartContract = (): ManagementStart => ({ diff --git a/src/plugins/management/public/plugin.ts b/src/plugins/management/public/plugin.ts index 1f96ec87171c5c..3289b2f6f5446a 100644 --- a/src/plugins/management/public/plugin.ts +++ b/src/plugins/management/public/plugin.ts @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import { BehaviorSubject } from 'rxjs'; +import type { SharePluginSetup, SharePluginStart } from 'src/plugins/share/public'; import { ManagementSetup, ManagementStart } from './types'; import { FeatureCatalogueCategory, HomePublicPluginSetup } from '../../home/public'; import { @@ -24,6 +25,7 @@ import { } from '../../../core/public'; import { MANAGEMENT_APP_ID } from '../common/contants'; +import { ManagementAppLocator } from '../common/locator'; import { ManagementSectionsService, getSectionsServiceStartPrivate, @@ -32,9 +34,21 @@ import { ManagementSection } from './utils'; interface ManagementSetupDependencies { home?: HomePublicPluginSetup; + share: SharePluginSetup; } -export class ManagementPlugin implements Plugin { +interface ManagementStartDependencies { + share: SharePluginStart; +} + +export class ManagementPlugin + implements + Plugin< + ManagementSetup, + ManagementStart, + ManagementSetupDependencies, + ManagementStartDependencies + > { private readonly managementSections = new ManagementSectionsService(); private readonly appUpdater = new BehaviorSubject(() => { @@ -58,8 +72,9 @@ export class ManagementPlugin implements Plugin; } export interface DefinedSections { diff --git a/src/plugins/management/server/plugin.ts b/src/plugins/management/server/plugin.ts index 5bb6a14e0b4504..349cab6206babc 100644 --- a/src/plugins/management/server/plugin.ts +++ b/src/plugins/management/server/plugin.ts @@ -7,21 +7,37 @@ */ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin, Logger } from 'kibana/server'; +import { LocatorPublic } from 'src/plugins/share/common'; +import type { SharePluginSetup } from 'src/plugins/share/server'; +import { ManagementAppLocator, ManagementAppLocatorParams } from '../common/locator'; import { capabilitiesProvider } from './capabilities_provider'; -export class ManagementServerPlugin implements Plugin { +interface ManagementSetupDependencies { + share: SharePluginSetup; +} + +export interface ManagementSetup { + locator: LocatorPublic; +} + +export class ManagementServerPlugin + implements Plugin { private readonly logger: Logger; constructor(initializerContext: PluginInitializerContext) { this.logger = initializerContext.logger.get(); } - public setup(core: CoreSetup) { + public setup(core: CoreSetup, { share }: ManagementSetupDependencies) { this.logger.debug('management: Setup'); + const locator = share.url.locators.create(new ManagementAppLocator()); + core.capabilities.registerProvider(capabilitiesProvider); - return {}; + return { + locator, + }; } public start(core: CoreStart) { diff --git a/src/plugins/share/common/index.ts b/src/plugins/share/common/index.ts new file mode 100644 index 00000000000000..8b5d8d45571942 --- /dev/null +++ b/src/plugins/share/common/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { LocatorDefinition, LocatorPublic } from './url_service'; diff --git a/src/plugins/share/public/index.ts b/src/plugins/share/public/index.ts index 46fad0dee13b01..d13bb15f8c72ca 100644 --- a/src/plugins/share/public/index.ts +++ b/src/plugins/share/public/index.ts @@ -7,10 +7,12 @@ */ export { CSV_QUOTE_VALUES_SETTING, CSV_SEPARATOR_SETTING } from '../common/constants'; +export { LocatorDefinition } from '../common/url_service'; export { UrlGeneratorStateMapping } from './url_generators/url_generator_definition'; export { SharePluginSetup, SharePluginStart } from './plugin'; + export { ShareContext, ShareMenuProvider, diff --git a/src/plugins/share/server/index.ts b/src/plugins/share/server/index.ts index d1a0ed1f016f03..d820a362131a49 100644 --- a/src/plugins/share/server/index.ts +++ b/src/plugins/share/server/index.ts @@ -9,6 +9,8 @@ import { PluginInitializerContext } from '../../../core/server'; import { SharePlugin } from './plugin'; +export { SharePluginSetup, SharePluginStart } from './plugin'; + export { CSV_QUOTE_VALUES_SETTING, CSV_SEPARATOR_SETTING } from '../common/constants'; export function plugin(initializerContext: PluginInitializerContext) { diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index 7b6c4ba9788f14..51df1d3162b7c3 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -3970,6 +3970,137 @@ } } }, + "observabilityCases": { + "properties": { + "appId": { + "type": "keyword", + "_meta": { + "description": "The application being tracked" + } + }, + "viewId": { + "type": "keyword", + "_meta": { + "description": "Always `main`" + } + }, + "clicks_total": { + "type": "long", + "_meta": { + "description": "General number of clicks in the application since we started counting them" + } + }, + "clicks_7_days": { + "type": "long", + "_meta": { + "description": "General number of clicks in the application over the last 7 days" + } + }, + "clicks_30_days": { + "type": "long", + "_meta": { + "description": "General number of clicks in the application over the last 30 days" + } + }, + "clicks_90_days": { + "type": "long", + "_meta": { + "description": "General number of clicks in the application over the last 90 days" + } + }, + "minutes_on_screen_total": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen since we started counting them." + } + }, + "minutes_on_screen_7_days": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen over the last 7 days" + } + }, + "minutes_on_screen_30_days": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen over the last 30 days" + } + }, + "minutes_on_screen_90_days": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen over the last 90 days" + } + }, + "views": { + "type": "array", + "items": { + "properties": { + "appId": { + "type": "keyword", + "_meta": { + "description": "The application being tracked" + } + }, + "viewId": { + "type": "keyword", + "_meta": { + "description": "The application view being tracked" + } + }, + "clicks_total": { + "type": "long", + "_meta": { + "description": "General number of clicks in the application sub view since we started counting them" + } + }, + "clicks_7_days": { + "type": "long", + "_meta": { + "description": "General number of clicks in the active application sub view over the last 7 days" + } + }, + "clicks_30_days": { + "type": "long", + "_meta": { + "description": "General number of clicks in the active application sub view over the last 30 days" + } + }, + "clicks_90_days": { + "type": "long", + "_meta": { + "description": "General number of clicks in the active application sub view over the last 90 days" + } + }, + "minutes_on_screen_total": { + "type": "float", + "_meta": { + "description": "Minutes the application sub view is active and on-screen since we started counting them." + } + }, + "minutes_on_screen_7_days": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen active application sub view over the last 7 days" + } + }, + "minutes_on_screen_30_days": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen active application sub view over the last 30 days" + } + }, + "minutes_on_screen_90_days": { + "type": "float", + "_meta": { + "description": "Minutes the application is active and on-screen active application sub view over the last 90 days" + } + } + } + } + } + } + }, "observability-overview": { "properties": { "appId": { diff --git a/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js b/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js index 2fb2be0ace7cdc..eb575457146c5d 100644 --- a/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js +++ b/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js @@ -150,7 +150,8 @@ describe('tag cloud tests', () => { }); [5, 100, 200, 300, 500].forEach((timeout) => { - describe(`should only send single renderComplete event at the very end, using ${timeout}ms timeout`, () => { + // FLAKY: https://github.com/elastic/kibana/issues/94043 + describe.skip(`should only send single renderComplete event at the very end, using ${timeout}ms timeout`, () => { beforeEach(async () => { //TagCloud takes at least 600ms to complete (due to d3 animation) //renderComplete should only notify at the last one diff --git a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts index 09e36b9078792a..5770ed0866a900 100644 --- a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts +++ b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts @@ -17,8 +17,16 @@ export default function ({ getService }: FtrProviderContext) { const es = getService('es'); describe('telemetry API', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should increment the opt *in* counter in the .kibana/kql-telemetry document', async () => { await supertest diff --git a/test/api_integration/apis/saved_objects/bulk_create.ts b/test/api_integration/apis/saved_objects/bulk_create.ts index 1f76567e973b22..5867b8125303a5 100644 --- a/test/api_integration/apis/saved_objects/bulk_create.ts +++ b/test/api_integration/apis/saved_objects/bulk_create.ts @@ -39,7 +39,10 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load('saved_objects/basic', { space: SPACE_ID }); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', + { space: SPACE_ID } + ); }); after(() => kibanaServer.spaces.delete(SPACE_ID)); diff --git a/test/api_integration/apis/saved_objects/bulk_get.ts b/test/api_integration/apis/saved_objects/bulk_get.ts index 81e86913aaf86f..e349482960678b 100644 --- a/test/api_integration/apis/saved_objects/bulk_get.ts +++ b/test/api_integration/apis/saved_objects/bulk_get.ts @@ -34,10 +34,16 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.importExport.load('saved_objects/basic'); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); }); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200 with individual responses', async () => await supertest diff --git a/test/api_integration/apis/saved_objects/bulk_update.ts b/test/api_integration/apis/saved_objects/bulk_update.ts index 8740652fc39538..cf402bf2f62217 100644 --- a/test/api_integration/apis/saved_objects/bulk_update.ts +++ b/test/api_integration/apis/saved_objects/bulk_update.ts @@ -15,8 +15,16 @@ export default function ({ getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); describe('bulkUpdate', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200', async () => { const response = await supertest diff --git a/test/api_integration/apis/saved_objects/create.ts b/test/api_integration/apis/saved_objects/create.ts index dfa7ceb503dfd4..00018e47c9dd36 100644 --- a/test/api_integration/apis/saved_objects/create.ts +++ b/test/api_integration/apis/saved_objects/create.ts @@ -19,10 +19,16 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.importExport.load('saved_objects/basic'); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); }); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200', async () => { await supertest diff --git a/test/api_integration/apis/saved_objects/delete.ts b/test/api_integration/apis/saved_objects/delete.ts index 9a4525df1b5f75..fc38050deabffe 100644 --- a/test/api_integration/apis/saved_objects/delete.ts +++ b/test/api_integration/apis/saved_objects/delete.ts @@ -14,8 +14,16 @@ export default function ({ getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); describe('delete', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200 when deleting a doc', async () => await supertest diff --git a/test/api_integration/apis/saved_objects/export.ts b/test/api_integration/apis/saved_objects/export.ts index c42afd4e773c53..6314fbbe675d0e 100644 --- a/test/api_integration/apis/saved_objects/export.ts +++ b/test/api_integration/apis/saved_objects/export.ts @@ -24,7 +24,10 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load('saved_objects/basic', { space: SPACE_ID }); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', + { space: SPACE_ID } + ); }); after(() => kibanaServer.spaces.delete(SPACE_ID)); diff --git a/test/api_integration/apis/saved_objects/find.ts b/test/api_integration/apis/saved_objects/find.ts index 02fa2d325f1713..a38043c7c93524 100644 --- a/test/api_integration/apis/saved_objects/find.ts +++ b/test/api_integration/apis/saved_objects/find.ts @@ -18,12 +18,18 @@ export default function ({ getService }: FtrProviderContext) { describe('find', () => { before(async () => { await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load('saved_objects/basic', { space: SPACE_ID }); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', + { space: SPACE_ID } + ); await kibanaServer.spaces.create({ id: `${SPACE_ID}-foo`, name: `${SPACE_ID}-foo` }); - await kibanaServer.importExport.load('saved_objects/basic/foo-ns', { - space: `${SPACE_ID}-foo`, - }); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic/foo-ns.json', + { + space: `${SPACE_ID}-foo`, + } + ); }); after(async () => { @@ -255,10 +261,18 @@ export default function ({ getService }: FtrProviderContext) { }); describe('`has_reference` and `has_reference_operator` parameters', () => { - before(() => kibanaServer.importExport.load('saved_objects/references', { space: SPACE_ID })); - after(() => - kibanaServer.importExport.unload('saved_objects/references', { space: SPACE_ID }) - ); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json', + { space: SPACE_ID } + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json', + { space: SPACE_ID } + ); + }); it('search for a reference', async () => { await supertest @@ -319,12 +333,18 @@ export default function ({ getService }: FtrProviderContext) { }); describe('searching for special characters', () => { - before(() => - kibanaServer.importExport.load('saved_objects/find_edgecases', { space: SPACE_ID }) - ); - after(() => - kibanaServer.importExport.unload('saved_objects/find_edgecases', { space: SPACE_ID }) - ); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json', + { space: SPACE_ID } + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/find_edgecases.json', + { space: SPACE_ID } + ); + }); it('can search for objects with dashes', async () => await supertest diff --git a/test/api_integration/apis/saved_objects/get.ts b/test/api_integration/apis/saved_objects/get.ts index 77d7b4faacb414..8122308e449303 100644 --- a/test/api_integration/apis/saved_objects/get.ts +++ b/test/api_integration/apis/saved_objects/get.ts @@ -19,9 +19,15 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { KIBANA_VERSION = await getKibanaVersion(getService); - await kibanaServer.importExport.load('saved_objects/basic'); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); }); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); it('should return 200', async () => await supertest diff --git a/test/api_integration/apis/saved_objects/import.ts b/test/api_integration/apis/saved_objects/import.ts index 8d3c0b7bbcea3f..c899f082ec4d3f 100644 --- a/test/api_integration/apis/saved_objects/import.ts +++ b/test/api_integration/apis/saved_objects/import.ts @@ -43,8 +43,16 @@ export default function ({ getService }: FtrProviderContext) { }; describe('with basic data existing', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 415 when no file passed in', async () => { await supertest diff --git a/test/api_integration/apis/saved_objects/resolve.ts b/test/api_integration/apis/saved_objects/resolve.ts index fcfef0aeb6b582..a00a44f98223d0 100644 --- a/test/api_integration/apis/saved_objects/resolve.ts +++ b/test/api_integration/apis/saved_objects/resolve.ts @@ -22,8 +22,16 @@ export default function ({ getService }: FtrProviderContext) { }); describe('with kibana index', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200', async () => await supertest diff --git a/test/api_integration/apis/saved_objects/resolve_import_errors.ts b/test/api_integration/apis/saved_objects/resolve_import_errors.ts index 43ff01d321f9fa..7ca61a26a11c1e 100644 --- a/test/api_integration/apis/saved_objects/resolve_import_errors.ts +++ b/test/api_integration/apis/saved_objects/resolve_import_errors.ts @@ -36,7 +36,10 @@ export default function ({ getService }: FtrProviderContext) { describe('with basic data existing', () => { before(async () => { await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID }); - await kibanaServer.importExport.load('saved_objects/basic', { space: SPACE_ID }); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json', + { space: SPACE_ID } + ); }); after(() => kibanaServer.spaces.delete(SPACE_ID)); diff --git a/test/api_integration/apis/saved_objects/update.ts b/test/api_integration/apis/saved_objects/update.ts index 75b8651ee64a7c..1c73d0788e51ca 100644 --- a/test/api_integration/apis/saved_objects/update.ts +++ b/test/api_integration/apis/saved_objects/update.ts @@ -14,8 +14,16 @@ export default function ({ getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); describe('update', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200', async () => { await supertest .put(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`) diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts index 6aefd74f0f36b2..6e36303cc1fe07 100644 --- a/test/api_integration/apis/saved_objects_management/find.ts +++ b/test/api_integration/apis/saved_objects_management/find.ts @@ -25,8 +25,16 @@ export default function ({ getService }: FtrProviderContext) { }); describe('with kibana index', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200 with individual responses', async () => await supertest @@ -85,8 +93,16 @@ export default function ({ getService }: FtrProviderContext) { }); describe('`hasReference` and `hasReferenceOperator` parameters', () => { - before(() => kibanaServer.importExport.load('saved_objects/references')); - after(() => kibanaServer.importExport.unload('saved_objects/references')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/references.json' + ); + }); it('search for a reference', async () => { await supertest diff --git a/test/api_integration/apis/saved_objects_management/get.ts b/test/api_integration/apis/saved_objects_management/get.ts index eb0b832cb2ed14..3b49a28ca40223 100644 --- a/test/api_integration/apis/saved_objects_management/get.ts +++ b/test/api_integration/apis/saved_objects_management/get.ts @@ -18,8 +18,16 @@ export default function ({ getService }: FtrProviderContext) { const existingObject = 'visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab'; const nonexistentObject = 'wigwags/foo'; - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('should return 200 for object that exists and inject metadata', async () => await supertest diff --git a/test/api_integration/apis/saved_objects_management/relationships.ts b/test/api_integration/apis/saved_objects_management/relationships.ts index ffc97b13859571..aa488942edbeb7 100644 --- a/test/api_integration/apis/saved_objects_management/relationships.ts +++ b/test/api_integration/apis/saved_objects_management/relationships.ts @@ -43,8 +43,16 @@ export default function ({ getService }: FtrProviderContext) { }); describe('relationships', () => { - before(() => kibanaServer.importExport.load('management/saved_objects/relationships')); - after(() => kibanaServer.importExport.unload('management/saved_objects/relationships')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/management/saved_objects/relationships.json' + ); + }); const baseApiUrl = `/api/kibana/management/saved_objects/relationships`; const defaultTypes = ['visualization', 'index-pattern', 'search', 'dashboard']; diff --git a/test/api_integration/apis/shorten/index.js b/test/api_integration/apis/shorten/index.js index 9af979b6af95d7..86c39426205ad3 100644 --- a/test/api_integration/apis/shorten/index.js +++ b/test/api_integration/apis/shorten/index.js @@ -13,8 +13,16 @@ export default function ({ getService }) { const kibanaServer = getService('kibanaServer'); describe('url shortener', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); it('generates shortened urls', async () => { const resp = await supertest diff --git a/test/api_integration/apis/stats/stats.js b/test/api_integration/apis/stats/stats.js index 2ba14e29a3d1a8..61936a73da38da 100644 --- a/test/api_integration/apis/stats/stats.js +++ b/test/api_integration/apis/stats/stats.js @@ -47,8 +47,16 @@ export default function ({ getService }) { const kibanaServer = getService('kibanaServer'); describe('kibana stats api', () => { - before(() => kibanaServer.importExport.load('saved_objects/basic')); - after(() => kibanaServer.importExport.unload('saved_objects/basic')); + before(async () => { + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); + after(async () => { + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/saved_objects/basic.json' + ); + }); describe('basic', () => { it('should return the stats without cluster_uuid with no query string params', () => { diff --git a/test/api_integration/apis/suggestions/suggestions.js b/test/api_integration/apis/suggestions/suggestions.js index 526cb9669f2788..292e3f599d81a1 100644 --- a/test/api_integration/apis/suggestions/suggestions.js +++ b/test/api_integration/apis/suggestions/suggestions.js @@ -14,13 +14,17 @@ export default function ({ getService }) { describe('Suggestions API', function () { before(async () => { await esArchiver.load('test/api_integration/fixtures/es_archiver/index_patterns/basic_index'); - await kibanaServer.importExport.load('index_patterns/basic_kibana'); + await kibanaServer.importExport.load( + 'test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json' + ); }); after(async () => { await esArchiver.unload( 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index' ); - await kibanaServer.importExport.unload('index_patterns/basic_kibana'); + await kibanaServer.importExport.unload( + 'test/api_integration/fixtures/kbn_archiver/index_patterns/basic_kibana.json' + ); }); it('should return 200 with special characters', () => diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/data.json b/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/data.json new file mode 100644 index 00000000000000..349545be443162 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/data.json @@ -0,0 +1,239 @@ +{ + "type": "doc", + "value": { + "id": "index-pattern:8963ca30-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "index-pattern": { + "fields": "[{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", + "title": "saved_objects*" + }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], + "type": "index-pattern", + "updated_at": "2018-03-28T01:08:34.290Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "config:7.0.0-alpha1", + "index": ".kibana", + "source": { + "config": { + "buildNum": 8467, + "defaultIndex": "8963ca30-3224-11e8-a572-ffca06da1357", + "telemetry:optIn": false + }, + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "config": "7.13.0" + }, + "references": [ + ], + "type": "config", + "updated_at": "2018-03-28T01:08:39.248Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "search:960372e0-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "8963ca30-3224-11e8-a572-ffca06da1357", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "_source" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"id:3\",\"language\":\"lucene\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "_score", + "desc" + ] + ], + "title": "OneRecord", + "version": 1 + }, + "type": "search", + "updated_at": "2018-03-28T01:08:55.182Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:a42c0580-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "960372e0-3224-11e8-a572-ffca06da1357", + "name": "search_0", + "type": "search" + } + ], + "type": "visualization", + "updated_at": "2018-03-28T01:09:18.936Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + }, + "savedSearchRefName": "search_0", + "title": "VisualizationFromSavedSearch", + "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", + "version": 1, + "visState": "{\"title\":\"VisualizationFromSavedSearch\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\",\"showToolbar\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:add810b0-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "8963ca30-3224-11e8-a572-ffca06da1357", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-03-28T01:09:35.163Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Amazing Visualization", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Visualization\",\"type\":\"metric\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\",\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:b70c7ae0-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_0\"},{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"}]", + "timeRestore": false, + "title": "Dashboard", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "add810b0-3224-11e8-a572-ffca06da1357", + "name": "panel_0", + "type": "visualization" + }, + { + "id": "a42c0580-3224-11e8-a572-ffca06da1357", + "name": "panel_1", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-03-28T01:09:50.606Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:d70c7ae0-3224-11e8-a572-ffca82da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_0\"},{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"}]", + "timeRestore": false, + "title": "Amazing Dashboard", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "add810b0-3224-11e8-a572-ffca06da1357", + "name": "panel_0", + "type": "visualization" + }, + { + "id": "a42c0580-3224-11e8-a572-ffca06da1357", + "name": "panel_1", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-03-28T01:09:50.606Z" + }, + "type": "_doc" + } +} \ No newline at end of file diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/data.json.gz b/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/data.json.gz deleted file mode 100644 index 1c327e7e0769b5..00000000000000 Binary files a/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/data.json.gz and /dev/null differ diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/mappings.json b/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/mappings.json index d2177481130a2c..f44bb7463e9ebc 100644 --- a/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/mappings.json +++ b/test/api_integration/fixtures/es_archiver/management/saved_objects/scroll_count/mappings.json @@ -2,140 +2,331 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", - "settings": { - "index": { - "number_of_shards": "1", - "auto_expand_replicas": "0-1", - "number_of_replicas": "0" - } - }, + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, "dynamic": "strict", "properties": { + "application_usage_daily": { + "dynamic": "false", + "properties": { + "timestamp": { + "type": "date" + } + } + }, + "application_usage_totals": { + "dynamic": "false", + "type": "object" + }, + "application_usage_transactional": { + "dynamic": "false", + "type": "object" + }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { "buildNum": { "type": "keyword" - }, - "defaultIndex": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "telemetry:optIn": { - "type": "boolean" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, "index-pattern": { + "dynamic": "false", "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { + "title": { "type": "text" }, - "intervalName": { + "type": { "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "notExpandable": { + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { "type": "boolean" }, - "sourceFilters": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "timeFieldName": { + "targetType": { "type": "keyword" + } + } + }, + "migrationVersion": { + "dynamic": "true", + "properties": { + "config": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "dashboard": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "index-pattern": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "search": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "visualization": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { + "properties": { + "description": { + "type": "text" + }, + "filters": { + "enabled": false, + "type": "object" + }, + "query": { + "properties": { + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" + } + } + }, + "timefilter": { + "enabled": false, + "type": "object" }, "title": { "type": "text" } } }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "sample-data-telemetry": { + "properties": { + "installCount": { + "type": "long" + }, + "unInstallCount": { + "type": "long" + } + } + }, "search": { "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -146,16 +337,100 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { + "dynamic": "false", + "type": "object" + }, + "telemetry": { "properties": { - "uuid": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { + "type": "keyword" + }, + "reportFailureCount": { + "type": "integer" + }, + "reportFailureVersion": { "type": "keyword" + }, + "sendUsageFrom": { + "type": "keyword" + }, + "userHasSeenNotice": { + "type": "boolean" + } + } + }, + "timelion-sheet": { + "properties": { + "description": { + "type": "text" + }, + "hits": { + "type": "integer" + }, + "kibanaSavedObjectMeta": { + "properties": { + "searchSourceJSON": { + "type": "text" + } + } + }, + "timelion_chart_height": { + "type": "integer" + }, + "timelion_columns": { + "type": "integer" + }, + "timelion_interval": { + "type": "keyword" + }, + "timelion_other_interval": { + "type": "keyword" + }, + "timelion_rows": { + "type": "integer" + }, + "timelion_sheet": { + "type": "text" + }, + "title": { + "type": "text" + }, + "version": { + "type": "integer" } } }, "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, "updated_at": { "type": "date" }, @@ -171,13 +446,21 @@ "type": "date" }, "url": { - "type": "text", "fields": { "keyword": { - "type": "keyword", - "ignore_above": 2048 + "ignore_above": 2048, + "type": "keyword" } - } + }, + "type": "text" + } + } + }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" } } }, @@ -189,28 +472,43 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } } } + }, + "settings": { + "index": { + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" + } } } -} +} \ No newline at end of file diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/search/data.json b/test/api_integration/fixtures/es_archiver/management/saved_objects/search/data.json new file mode 100644 index 00000000000000..6402a255afd376 --- /dev/null +++ b/test/api_integration/fixtures/es_archiver/management/saved_objects/search/data.json @@ -0,0 +1,227 @@ +{ + "type": "doc", + "value": { + "id": "timelion-sheet:190f3e90-2ec3-11e8-ba48-69fc4e41e1f6", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "timelion-sheet": { + "description": "", + "hits": 0, + "timelion_chart_height": 275, + "timelion_columns": 2, + "timelion_interval": "auto", + "timelion_rows": 2, + "timelion_sheet": [ + ".es(*)" + ], + "title": "New TimeLion Sheet", + "version": 1 + }, + "type": "timelion-sheet", + "updated_at": "2018-03-23T17:53:30.872Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "index-pattern:8963ca30-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "index-pattern": { + "fields": "[{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", + "title": "saved_objects*" + }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], + "type": "index-pattern", + "updated_at": "2018-03-28T01:08:34.290Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "config:7.0.0-alpha1", + "index": ".kibana", + "source": { + "config": { + "buildNum": 8467, + "defaultIndex": "8963ca30-3224-11e8-a572-ffca06da1357", + "telemetry:optIn": false + }, + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "config": "7.13.0" + }, + "references": [ + ], + "type": "config", + "updated_at": "2018-03-28T01:08:39.248Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "search:960372e0-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "8963ca30-3224-11e8-a572-ffca06da1357", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "_source" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"id:3\",\"language\":\"lucene\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "_score", + "desc" + ] + ], + "title": "OneRecord", + "version": 1 + }, + "type": "search", + "updated_at": "2018-03-28T01:08:55.182Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:a42c0580-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "960372e0-3224-11e8-a572-ffca06da1357", + "name": "search_0", + "type": "search" + } + ], + "type": "visualization", + "updated_at": "2018-03-28T01:09:18.936Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + }, + "savedSearchRefName": "search_0", + "title": "VisualizationFromSavedSearch", + "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", + "version": 1, + "visState": "{\"title\":\"VisualizationFromSavedSearch\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\",\"showToolbar\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:add810b0-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "8963ca30-3224-11e8-a572-ffca06da1357", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-03-28T01:09:35.163Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Visualization", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Visualization\",\"type\":\"metric\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\",\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:b70c7ae0-3224-11e8-a572-ffca06da1357", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_0\"},{\"version\":\"7.0.0-alpha1\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"}]", + "timeRestore": false, + "title": "Dashboard", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "add810b0-3224-11e8-a572-ffca06da1357", + "name": "panel_0", + "type": "visualization" + }, + { + "id": "a42c0580-3224-11e8-a572-ffca06da1357", + "name": "panel_1", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-03-28T01:09:50.606Z" + }, + "type": "_doc" + } +} \ No newline at end of file diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/search/data.json.gz b/test/api_integration/fixtures/es_archiver/management/saved_objects/search/data.json.gz deleted file mode 100644 index 0834567abb66b6..00000000000000 Binary files a/test/api_integration/fixtures/es_archiver/management/saved_objects/search/data.json.gz and /dev/null differ diff --git a/test/api_integration/fixtures/es_archiver/management/saved_objects/search/mappings.json b/test/api_integration/fixtures/es_archiver/management/saved_objects/search/mappings.json index 7a6d752eafb08e..7699a72ff7120b 100644 --- a/test/api_integration/fixtures/es_archiver/management/saved_objects/search/mappings.json +++ b/test/api_integration/fixtures/es_archiver/management/saved_objects/search/mappings.json @@ -2,169 +2,335 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", - "settings": { - "index": { - "number_of_shards": "1", - "auto_expand_replicas": "0-1", - "number_of_replicas": "0" - } - }, + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, "dynamic": "strict", "properties": { + "application_usage_daily": { + "dynamic": "false", + "properties": { + "timestamp": { + "type": "date" + } + } + }, + "application_usage_totals": { + "dynamic": "false", + "type": "object" + }, + "application_usage_transactional": { + "dynamic": "false", + "type": "object" + }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { "buildNum": { "type": "keyword" - }, - "defaultIndex": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "telemetry:optIn": { - "type": "boolean" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, "graph-workspace": { + "dynamic": "false", + "type": "object" + }, + "index-pattern": { + "dynamic": "false", "properties": { - "description": { + "title": { "type": "text" }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } + "type": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "numLinks": { - "type": "integer" + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { + "type": "boolean" }, - "numVertices": { - "type": "integer" + "sourceId": { + "type": "keyword" }, - "title": { + "targetType": { + "type": "keyword" + } + } + }, + "migrationVersion": { + "dynamic": "true", + "properties": { + "config": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, "type": "text" }, - "version": { - "type": "integer" + "dashboard": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "index-pattern": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "search": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" }, - "wsState": { + "visualization": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, "type": "text" } } }, - "index-pattern": { + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { "properties": { - "fieldFormatMap": { + "description": { "type": "text" }, - "fields": { - "type": "text" + "filters": { + "enabled": false, + "type": "object" }, - "intervalName": { - "type": "keyword" + "query": { + "properties": { + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" + } + } }, - "notExpandable": { - "type": "boolean" + "timefilter": { + "enabled": false, + "type": "object" }, - "sourceFilters": { + "title": { "type": "text" + } + } + }, + "references": { + "properties": { + "id": { + "type": "keyword" }, - "timeFieldName": { + "name": { "type": "keyword" }, - "title": { - "type": "text" + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "sample-data-telemetry": { + "properties": { + "installCount": { + "type": "long" + }, + "unInstallCount": { + "type": "long" } } }, "search": { "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -175,10 +341,39 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { + "dynamic": "false", + "type": "object" + }, + "telemetry": { "properties": { - "uuid": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { + "type": "keyword" + }, + "reportFailureCount": { + "type": "integer" + }, + "reportFailureVersion": { "type": "keyword" + }, + "sendUsageFrom": { + "type": "keyword" + }, + "userHasSeenNotice": { + "type": "boolean" } } }, @@ -226,6 +421,20 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, "updated_at": { "type": "date" }, @@ -241,13 +450,21 @@ "type": "date" }, "url": { - "type": "text", "fields": { "keyword": { - "type": "keyword", - "ignore_above": 2048 + "ignore_above": 2048, + "type": "keyword" } - } + }, + "type": "text" + } + } + }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" } } }, @@ -259,28 +476,43 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } } } + }, + "settings": { + "index": { + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" + } } } } \ No newline at end of file diff --git a/test/common/services/kibana_server/kibana_server.ts b/test/common/services/kibana_server/kibana_server.ts index 63803bd511bd14..f20fa4cafa55e2 100644 --- a/test/common/services/kibana_server/kibana_server.ts +++ b/test/common/services/kibana_server/kibana_server.ts @@ -22,7 +22,6 @@ export function KibanaServerProvider({ getService }: FtrProviderContext): KbnCli url, certificateAuthorities: config.get('servers.kibana.certificateAuthorities'), uiSettingDefaults: defaults, - importExportDir: config.get('kbnArchiver.directory'), }); if (defaults) { diff --git a/test/examples/config.js b/test/examples/config.js index cb6c487c564c3b..d47748e5f22a97 100644 --- a/test/examples/config.js +++ b/test/examples/config.js @@ -28,6 +28,7 @@ export default async function ({ readConfigFile }) { require.resolve('./state_sync'), require.resolve('./routing'), require.resolve('./expressions_explorer'), + require.resolve('./index_pattern_field_editor_example'), ], services: { ...functionalConfig.get('services'), diff --git a/test/examples/index_pattern_field_editor_example/index.ts b/test/examples/index_pattern_field_editor_example/index.ts new file mode 100644 index 00000000000000..0cd23a33c84762 --- /dev/null +++ b/test/examples/index_pattern_field_editor_example/index.ts @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { PluginFunctionalProviderContext } from 'test/plugin_functional/services'; + +// eslint-disable-next-line import/no-default-export +export default function ({ + getService, + getPageObjects, + loadTestFile, +}: PluginFunctionalProviderContext) { + const browser = getService('browser'); + const es = getService('es'); + const PageObjects = getPageObjects(['common', 'header', 'settings']); + + describe('index pattern field editor example', function () { + this.tags('ciGroup2'); + before(async () => { + await browser.setWindowSize(1300, 900); + await es.transport.request({ + path: '/blogs/_doc', + method: 'POST', + body: { user: 'matt', message: 20 }, + }); + + await PageObjects.settings.navigateTo(); + await PageObjects.settings.createIndexPattern('blogs', null); + await PageObjects.common.navigateToApp('indexPatternFieldEditorExample'); + }); + + loadTestFile(require.resolve('./index_pattern_field_editor_example')); + }); +} diff --git a/test/examples/index_pattern_field_editor_example/index_pattern_field_editor_example.ts b/test/examples/index_pattern_field_editor_example/index_pattern_field_editor_example.ts new file mode 100644 index 00000000000000..5744c8e64f5c11 --- /dev/null +++ b/test/examples/index_pattern_field_editor_example/index_pattern_field_editor_example.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { PluginFunctionalProviderContext } from 'test/plugin_functional/services'; + +// eslint-disable-next-line import/no-default-export +export default function ({ getService }: PluginFunctionalProviderContext) { + const testSubjects = getService('testSubjects'); + + describe('', () => { + it('finds an index pattern', async () => { + await testSubjects.existOrFail('indexPatternTitle'); + }); + it('opens the field editor', async () => { + await testSubjects.click('addField'); + await testSubjects.existOrFail('flyoutTitle'); + }); + }); +} diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts index eaefb3ba38f050..efd97fce3f7f5d 100644 --- a/test/functional/apps/discover/_data_grid.ts +++ b/test/functional/apps/discover/_data_grid.ts @@ -24,7 +24,7 @@ export default function ({ before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts index bfce69ca08d552..3d9e01e1dee19d 100644 --- a/test/functional/apps/discover/_data_grid_context.ts +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover data grid context tests', () => { before(async () => { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); diff --git a/test/functional/apps/discover/_data_grid_doc_table.ts b/test/functional/apps/discover/_data_grid_doc_table.ts index bbd633df6fa1ed..00e6a5025e2af6 100644 --- a/test/functional/apps/discover/_data_grid_doc_table.ts +++ b/test/functional/apps/discover/_data_grid_doc_table.ts @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); diff --git a/test/functional/apps/discover/_data_grid_field_data.ts b/test/functional/apps/discover/_data_grid_field_data.ts index 8296b518bee32c..94e8e942f86ba2 100644 --- a/test/functional/apps/discover/_data_grid_field_data.ts +++ b/test/functional/apps/discover/_data_grid_field_data.ts @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags('includeFirefox'); before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); diff --git a/test/functional/apps/discover/_discover.ts b/test/functional/apps/discover/_discover.ts index f26d1f4536e558..dce6bfba9cd99c 100644 --- a/test/functional/apps/discover/_discover.ts +++ b/test/functional/apps/discover/_discover.ts @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { log.debug('load kibana index with default index pattern'); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); diff --git a/test/functional/apps/discover/_discover_fields_api.ts b/test/functional/apps/discover/_discover_fields_api.ts index d3df79dc8658b6..614a0794ffb3b2 100644 --- a/test/functional/apps/discover/_discover_fields_api.ts +++ b/test/functional/apps/discover/_discover_fields_api.ts @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); log.debug('discover'); diff --git a/test/functional/apps/discover/_doc_table.ts b/test/functional/apps/discover/_doc_table.ts index ffe989f8d498ce..b5a40030b26016 100644 --- a/test/functional/apps/discover/_doc_table.ts +++ b/test/functional/apps/discover/_doc_table.ts @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); diff --git a/test/functional/apps/discover/_field_data.ts b/test/functional/apps/discover/_field_data.ts index e8698b984f6cc0..338d17ba31ff49 100644 --- a/test/functional/apps/discover/_field_data.ts +++ b/test/functional/apps/discover/_field_data.ts @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags('includeFirefox'); before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', diff --git a/test/functional/apps/discover/_field_data_with_fields_api.ts b/test/functional/apps/discover/_field_data_with_fields_api.ts index 7de123bb44f2a6..110e255d18c756 100644 --- a/test/functional/apps/discover/_field_data_with_fields_api.ts +++ b/test/functional/apps/discover/_field_data_with_fields_api.ts @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags('includeFirefox'); before(async function () { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', diff --git a/test/functional/apps/discover/_filter_editor.ts b/test/functional/apps/discover/_filter_editor.ts index 4e9839d4e799ae..8bcb4382bb3bf3 100644 --- a/test/functional/apps/discover/_filter_editor.ts +++ b/test/functional/apps/discover/_filter_editor.ts @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); diff --git a/test/functional/apps/discover/_inspector.ts b/test/functional/apps/discover/_inspector.ts index 9d4fd93eb3a9f0..17f358ec748714 100644 --- a/test/functional/apps/discover/_inspector.ts +++ b/test/functional/apps/discover/_inspector.ts @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); // delete .kibana index and update configDoc await kibanaServer.uiSettings.replace({ diff --git a/test/functional/apps/discover/_large_string.ts b/test/functional/apps/discover/_large_string.ts index 3e426c6237d89b..de3f0f2c40ae10 100644 --- a/test/functional/apps/discover/_large_string.ts +++ b/test/functional/apps/discover/_large_string.ts @@ -23,7 +23,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { await security.testUser.setRoles(['kibana_admin', 'kibana_large_strings']); - await kibanaServer.importExport.load('testlargestring'); + await kibanaServer.importExport.load( + 'test/functional/fixtures/kbn_archiver/testlargestring.json' + ); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/hamlet'); await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring' }); }); diff --git a/test/functional/apps/discover/_runtime_fields_editor.ts b/test/functional/apps/discover/_runtime_fields_editor.ts index fd2ca4dd4b5cf1..648fa3efe337c0 100644 --- a/test/functional/apps/discover/_runtime_fields_editor.ts +++ b/test/functional/apps/discover/_runtime_fields_editor.ts @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await fieldEditor.save(); }; - describe('discover integration with runtime fields editor', function describeIndexTests() { + describe.skip('discover integration with runtime fields editor', function describeIndexTests() { before(async function () { await esArchiver.load('test/functional/fixtures/es_archiver/discover'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); @@ -104,6 +104,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); }); + // flaky https://github.com/elastic/kibana/issues/100966 it('doc view includes runtime fields', async function () { // navigate to doc view const table = await PageObjects.discover.getDocTable(); diff --git a/test/functional/apps/discover/_saved_queries.ts b/test/functional/apps/discover/_saved_queries.ts index 67806c9d16a940..20f2cab907d9bf 100644 --- a/test/functional/apps/discover/_saved_queries.ts +++ b/test/functional/apps/discover/_saved_queries.ts @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); diff --git a/test/functional/apps/discover/_shared_links.ts b/test/functional/apps/discover/_shared_links.ts index 151e8555eea77e..62364739db311b 100644 --- a/test/functional/apps/discover/_shared_links.ts +++ b/test/functional/apps/discover/_shared_links.ts @@ -38,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('load kibana index with default index pattern'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await kibanaServer.importExport.load('discover'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ diff --git a/test/functional/apps/discover/_sidebar.ts b/test/functional/apps/discover/_sidebar.ts index d8701261126c46..8179f4e44e8b81 100644 --- a/test/functional/apps/discover/_sidebar.ts +++ b/test/functional/apps/discover/_sidebar.ts @@ -14,7 +14,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); const testSubjects = getService('testSubjects'); - describe('discover sidebar', function describeIndexTests() { + // Failing: See https://github.com/elastic/kibana/issues/101449 + describe.skip('discover sidebar', function describeIndexTests() { before(async function () { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/discover'); diff --git a/test/functional/apps/visualize/legacy/index.ts b/test/functional/apps/visualize/legacy/index.ts index 4e43ec90d16999..d474287860b25e 100644 --- a/test/functional/apps/visualize/legacy/index.ts +++ b/test/functional/apps/visualize/legacy/index.ts @@ -23,7 +23,7 @@ export default function ({ getPageObjects, getService, loadTestFile }: FtrProvid await browser.setWindowSize(1280, 800); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); - await kibanaServer.importExport.load('visualize'); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/visualize.json'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', [UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN]: '0,0.[000]b', diff --git a/test/functional/config.js b/test/functional/config.js index 4a6791a3bc62fb..eac21e5a456184 100644 --- a/test/functional/config.js +++ b/test/functional/config.js @@ -97,6 +97,9 @@ export default async function ({ readConfigFile }) { pathname: '/app/home', hash: '/', }, + observabilityCases: { + pathname: '/app/observability/cases', + }, }, junit: { reportName: 'Chrome UI Functional Tests', diff --git a/test/functional/fixtures/es_archiver/dashboard/current/kibana/data.json b/test/functional/fixtures/es_archiver/dashboard/current/kibana/data.json new file mode 100644 index 00000000000000..139da89e58d128 --- /dev/null +++ b/test/functional/fixtures/es_archiver/dashboard/current/kibana/data.json @@ -0,0 +1,3471 @@ +{ + "type": "doc", + "value": { + "id": "search:a16d1990-3dca-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "animal", + "isDog", + "name", + "sound", + "weightLbs" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"language\":\"lucene\",\"query\":\"weightLbs:>40\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "weightLbs", + "desc" + ] + ], + "title": "animal weights", + "version": 1 + }, + "type": "search", + "updated_at": "2018-04-11T20:55:26.317Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "config:6.3.0", + "index": ".kibana", + "source": { + "config": { + "buildNum": 8467, + "defaultIndex": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c" + }, + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "config": "7.13.0" + }, + "references": [ + ], + "type": "config", + "updated_at": "2018-04-11T20:43:55.434Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:61c58ad0-3dd3-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"animal\",\"value\":\"dog\",\"params\":{\"query\":\"dog\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"animal\":{\"query\":\"dog\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"search\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"}]", + "refreshInterval": { + "display": "Off", + "pause": false, + "value": 0 + }, + "timeFrom": "Mon Apr 09 2018 17:56:08 GMT-0400", + "timeRestore": true, + "timeTo": "Wed Apr 11 2018 17:56:08 GMT-0400", + "title": "dashboard with filter", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + }, + { + "id": "50643b60-3dd3-11e8-b2b9-5d5dc1715159", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "a16d1990-3dca-11e8-8660-4d65aa086b3c", + "name": "2:panel_2", + "type": "search" + } + ], + "type": "dashboard", + "updated_at": "2018-04-11T21:57:52.253Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:2ae34a60-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"}]", + "timeRestore": false, + "title": "couple panels", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "145ced90-3dcb-11e8-8660-4d65aa086b3c", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "e2023110-3dcb-11e8-8660-4d65aa086b3c", + "name": "2:panel_2", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:03:29.670Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:76d03330-3dd3-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "and_descriptions_has_underscores", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "dashboard_with_underscores", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T21:58:27.555Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:9b780cd0-3dd3-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "* hi & $%!!@# 漢字 ^--=++[]{};'~`~<>?,./:\";'\\|\\\\ special chars", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:00:07.322Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:6c0b16e0-3dd3-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "dashboard-name-has-dashes", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T21:58:09.486Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:19523860-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "im empty too", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:03:00.198Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:14616b50-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "im empty", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:02:51.909Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:33bb8ad0-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":15,\"w\":24,\"h\":15,\"i\":\"3\"},\"panelIndex\":\"3\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_3\"}]", + "timeRestore": false, + "title": "few panels", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "145ced90-3dcb-11e8-8660-4d65aa086b3c", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "e2023110-3dcb-11e8-8660-4d65aa086b3c", + "name": "2:panel_2", + "type": "visualization" + }, + { + "id": "4b5d6ef0-3dcb-11e8-8660-4d65aa086b3c", + "name": "3:panel_3", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:03:44.509Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:60659030-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz 2", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:04:59.443Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:65227c00-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz 3", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:07.392Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:6803a2f0-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz 4", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:12.223Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:6b18f940-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz 5", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:17.396Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:6e12ff60-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz 6", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:22.390Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:4f0fd980-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:04:30.360Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:3de0bda0-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "1", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:04:01.530Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:46c8b580-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "2", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:04:16.472Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:708fe640-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "zz 7", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:26.564Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:7b8d50a0-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "Hi i have a lot of words in my dashboard name! It's pretty long i wonder what it'll look like", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:45.002Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:7e42d3b0-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "bye", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:49.547Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:846988b0-3dd4-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[]", + "timeRestore": false, + "title": "last", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + ], + "type": "dashboard", + "updated_at": "2018-04-11T22:05:59.867Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:cbd3bc30-3e5a-11e8-9fc3-39e49624228e", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"weightLbs:<50\",\"language\":\"lucene\"},\"filter\":[{\"meta\":{\"negate\":true,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"name.keyword\",\"value\":\"Fee Fee\",\"params\":{\"query\":\"Fee Fee\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"name.keyword\":{\"query\":\"Fee Fee\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":true,\"useMargins\":true,\"hidePanelTitles\":true}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":15,\"w\":24,\"h\":15,\"i\":\"3\"},\"panelIndex\":\"3\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_3\"}]", + "timeRestore": false, + "title": "bug", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + }, + { + "id": "771b4f10-3e59-11e8-9fc3-39e49624228e", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "befdb6b0-3e59-11e8-9fc3-39e49624228e", + "name": "2:panel_2", + "type": "visualization" + }, + { + "id": "4c0c3f90-3e5a-11e8-9fc3-39e49624228e", + "name": "3:panel_3", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-04-12T14:07:12.243Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:5bac3a80-3e5b-11e8-9fc3-39e49624228e", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "dashboard with scripted filter, negated filter and query", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"language\":\"lucene\",\"query\":\"weightLbs:<50\"},\"filter\":[{\"$state\":{\"store\":\"appState\"},\"meta\":{\"alias\":null,\"disabled\":false,\"key\":\"name.keyword\",\"negate\":true,\"params\":{\"query\":\"Fee Fee\",\"type\":\"phrase\"},\"type\":\"phrase\",\"value\":\"Fee Fee\",\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"name.keyword\":{\"query\":\"Fee Fee\",\"type\":\"phrase\"}}}},{\"$state\":{\"store\":\"appState\"},\"meta\":{\"alias\":\"is dog\",\"disabled\":false,\"field\":\"isDog\",\"key\":\"isDog\",\"negate\":false,\"params\":{\"value\":true},\"type\":\"phrase\",\"value\":\"true\",\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[1].meta.index\"},\"script\":{\"script\":{\"inline\":\"boolean compare(Supplier s, def v) {return s.get() == v;}compare(() -> { return doc['animal.keyword'].value == 'dog' }, params.value);\",\"lang\":\"painless\",\"params\":{\"value\":true}}}}],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":true,\"hidePanelTitles\":false,\"useMargins\":true}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"3\"},\"panelIndex\":\"3\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_3\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":15,\"w\":24,\"h\":15,\"i\":\"4\"},\"panelIndex\":\"4\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_4\"}]", + "refreshInterval": { + "display": "Off", + "pause": false, + "section": 0, + "value": 0 + }, + "timeFrom": "Wed Apr 12 2017 10:06:21 GMT-0400", + "timeRestore": true, + "timeTo": "Thu Apr 12 2018 10:06:21 GMT-0400", + "title": "filters", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[1].meta.index", + "type": "index-pattern" + }, + { + "id": "771b4f10-3e59-11e8-9fc3-39e49624228e", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "4c0c3f90-3e5a-11e8-9fc3-39e49624228e", + "name": "3:panel_3", + "type": "visualization" + }, + { + "id": "50643b60-3dd3-11e8-b2b9-5d5dc1715159", + "name": "4:panel_4", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-04-12T14:11:13.576Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "index-pattern:f908c8e0-3e6d-11e8-bbb9-e15942d5d48c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "index-pattern": { + "fields": "[{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"activity level\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"barking level\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"breed\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"breed.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"size\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"size.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"trainability\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", + "title": "dogbreeds" + }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], + "type": "index-pattern", + "updated_at": "2018-04-12T16:24:29.357Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:5e085850-3e6e-11e8-bbb9-e15942d5d48c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "f908c8e0-3e6d-11e8-bbb9-e15942d5d48c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-12T16:27:17.973Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "non timebased line chart - dog data", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"non timebased line chart - dog data\",\"type\":\"line\",\"params\":{\"type\":\"line\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100,\"filter\":true},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Max trainability\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"line\",\"mode\":\"normal\",\"data\":{\"label\":\"Max trainability\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true},{\"show\":true,\"mode\":\"normal\",\"type\":\"line\",\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"data\":{\"id\":\"3\",\"label\":\"Max barking level\"},\"valueAxis\":\"ValueAxis-1\"},{\"show\":true,\"mode\":\"normal\",\"type\":\"line\",\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"data\":{\"id\":\"4\",\"label\":\"Max activity level\"},\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"trainability\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"breed.keyword\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}},{\"id\":\"3\",\"enabled\":true,\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"barking level\"}},{\"id\":\"4\",\"enabled\":true,\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"activity level\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:a5d56330-3e6e-11e8-bbb9-e15942d5d48c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "I have two visualizations that are created off a non time based index", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"useMargins\":true,\"hidePanelTitles\":false}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"}]", + "timeRestore": false, + "title": "Non time based", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "5e085850-3e6e-11e8-bbb9-e15942d5d48c", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "8bc8d6c0-3e6e-11e8-bbb9-e15942d5d48c", + "name": "2:panel_2", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-04-12T16:29:18.435Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:d2525040-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "I have one of every visualization type since the last time I was created!", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"hidePanelTitles\":false,\"useMargins\":true}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":15,\"w\":24,\"h\":15,\"i\":\"3\"},\"panelIndex\":\"3\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_3\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":15,\"w\":24,\"h\":15,\"i\":\"4\"},\"panelIndex\":\"4\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_4\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":30,\"w\":24,\"h\":15,\"i\":\"5\"},\"panelIndex\":\"5\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_5\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":30,\"w\":24,\"h\":15,\"i\":\"6\"},\"panelIndex\":\"6\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_6\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":45,\"w\":24,\"h\":15,\"i\":\"7\"},\"panelIndex\":\"7\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_7\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":45,\"w\":24,\"h\":15,\"i\":\"8\"},\"panelIndex\":\"8\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_8\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":60,\"w\":24,\"h\":15,\"i\":\"9\"},\"panelIndex\":\"9\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_9\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":60,\"w\":24,\"h\":15,\"i\":\"10\"},\"panelIndex\":\"10\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_10\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":75,\"w\":24,\"h\":15,\"i\":\"11\"},\"panelIndex\":\"11\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_11\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":75,\"w\":24,\"h\":15,\"i\":\"12\"},\"panelIndex\":\"12\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_12\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":90,\"w\":24,\"h\":15,\"i\":\"13\"},\"panelIndex\":\"13\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_13\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":90,\"w\":24,\"h\":15,\"i\":\"14\"},\"panelIndex\":\"14\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_14\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":105,\"w\":24,\"h\":15,\"i\":\"15\"},\"panelIndex\":\"15\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_15\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":105,\"w\":24,\"h\":15,\"i\":\"16\"},\"panelIndex\":\"16\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_16\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":120,\"w\":24,\"h\":15,\"i\":\"17\"},\"panelIndex\":\"17\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_17\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":120,\"w\":24,\"h\":15,\"i\":\"18\"},\"panelIndex\":\"18\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_18\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":135,\"w\":24,\"h\":15,\"i\":\"19\"},\"panelIndex\":\"19\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_19\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":135,\"w\":24,\"h\":15,\"i\":\"20\"},\"panelIndex\":\"20\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_20\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":150,\"w\":24,\"h\":15,\"i\":\"21\"},\"panelIndex\":\"21\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_21\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":150,\"w\":24,\"h\":15,\"i\":\"22\"},\"panelIndex\":\"22\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_22\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":165,\"w\":24,\"h\":15,\"i\":\"23\"},\"panelIndex\":\"23\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_23\"},{\"version\":\"7.3.0\",\"type\":\"search\",\"gridData\":{\"x\":24,\"y\":165,\"w\":24,\"h\":15,\"i\":\"24\"},\"panelIndex\":\"24\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_24\"},{\"version\":\"7.3.0\",\"type\":\"search\",\"gridData\":{\"x\":0,\"y\":180,\"w\":24,\"h\":15,\"i\":\"25\"},\"panelIndex\":\"25\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_25\"},{\"version\":\"7.3.0\",\"type\":\"search\",\"gridData\":{\"x\":24,\"y\":180,\"w\":24,\"h\":15,\"i\":\"26\"},\"panelIndex\":\"26\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_26\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":195,\"w\":24,\"h\":15,\"i\":\"27\"},\"panelIndex\":\"27\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_27\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":195,\"w\":24,\"h\":15,\"i\":\"28\"},\"panelIndex\":\"28\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_28\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":210,\"w\":24,\"h\":15,\"i\":\"29\"},\"panelIndex\":\"29\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_29\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":210,\"i\":\"30\"},\"panelIndex\":\"30\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_30\"}]", + "refreshInterval": { + "display": "Off", + "pause": false, + "value": 0 + }, + "timeFrom": "Mon Apr 09 2018 17:56:08 GMT-0400", + "timeRestore": true, + "timeTo": "Wed Apr 11 2018 17:56:08 GMT-0400", + "title": "dashboard with everything", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "e6140540-3dca-11e8-8660-4d65aa086b3c", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "3525b840-3dcb-11e8-8660-4d65aa086b3c", + "name": "2:panel_2", + "type": "visualization" + }, + { + "id": "4b5d6ef0-3dcb-11e8-8660-4d65aa086b3c", + "name": "3:panel_3", + "type": "visualization" + }, + { + "id": "37a541c0-3dcc-11e8-8660-4d65aa086b3c", + "name": "4:panel_4", + "type": "visualization" + }, + { + "id": "ffa2e0c0-3dcb-11e8-8660-4d65aa086b3c", + "name": "5:panel_5", + "type": "visualization" + }, + { + "id": "e2023110-3dcb-11e8-8660-4d65aa086b3c", + "name": "6:panel_6", + "type": "visualization" + }, + { + "id": "145ced90-3dcb-11e8-8660-4d65aa086b3c", + "name": "7:panel_7", + "type": "visualization" + }, + { + "id": "2d1b1620-3dcd-11e8-8660-4d65aa086b3c", + "name": "8:panel_8", + "type": "visualization" + }, + { + "id": "42535e30-3dcd-11e8-8660-4d65aa086b3c", + "name": "9:panel_9", + "type": "visualization" + }, + { + "id": "42535e30-3dcd-11e8-8660-4d65aa086b3c", + "name": "10:panel_10", + "type": "visualization" + }, + { + "id": "4c0f47e0-3dcd-11e8-8660-4d65aa086b3c", + "name": "11:panel_11", + "type": "visualization" + }, + { + "id": "11ae2bd0-3dcc-11e8-8660-4d65aa086b3c", + "name": "12:panel_12", + "type": "visualization" + }, + { + "id": "3fe22200-3dcb-11e8-8660-4d65aa086b3c", + "name": "13:panel_13", + "type": "visualization" + }, + { + "id": "4ca00ba0-3dcc-11e8-8660-4d65aa086b3c", + "name": "14:panel_14", + "type": "visualization" + }, + { + "id": "78803be0-3dcd-11e8-8660-4d65aa086b3c", + "name": "15:panel_15", + "type": "visualization" + }, + { + "id": "b92ae920-3dcc-11e8-8660-4d65aa086b3c", + "name": "16:panel_16", + "type": "visualization" + }, + { + "id": "e4d8b430-3dcc-11e8-8660-4d65aa086b3c", + "name": "17:panel_17", + "type": "visualization" + }, + { + "id": "f81134a0-3dcc-11e8-8660-4d65aa086b3c", + "name": "18:panel_18", + "type": "visualization" + }, + { + "id": "cc43fab0-3dcc-11e8-8660-4d65aa086b3c", + "name": "19:panel_19", + "type": "visualization" + }, + { + "id": "02a2e4e0-3dcd-11e8-8660-4d65aa086b3c", + "name": "20:panel_20", + "type": "visualization" + }, + { + "id": "df815d20-3dcc-11e8-8660-4d65aa086b3c", + "name": "21:panel_21", + "type": "visualization" + }, + { + "id": "c40f4d40-3dcc-11e8-8660-4d65aa086b3c", + "name": "22:panel_22", + "type": "visualization" + }, + { + "id": "7fda8ee0-3dcd-11e8-8660-4d65aa086b3c", + "name": "23:panel_23", + "type": "visualization" + }, + { + "id": "a16d1990-3dca-11e8-8660-4d65aa086b3c", + "name": "24:panel_24", + "type": "search" + }, + { + "id": "be5accf0-3dca-11e8-8660-4d65aa086b3c", + "name": "25:panel_25", + "type": "search" + }, + { + "id": "ca5ada40-3dca-11e8-8660-4d65aa086b3c", + "name": "26:panel_26", + "type": "search" + }, + { + "id": "771b4f10-3e59-11e8-9fc3-39e49624228e", + "name": "27:panel_27", + "type": "visualization" + }, + { + "id": "5e085850-3e6e-11e8-bbb9-e15942d5d48c", + "name": "28:panel_28", + "type": "visualization" + }, + { + "id": "8bc8d6c0-3e6e-11e8-bbb9-e15942d5d48c", + "name": "29:panel_29", + "type": "visualization" + }, + { + "id": "befdb6b0-3e59-11e8-9fc3-39e49624228e", + "name": "30:panel_30", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-04-16T16:05:02.915Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:29bd0240-4197-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-16T16:56:53.092Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"geo.src\",\"value\":\"CN\",\"params\":{\"query\":\"CN\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"geo.src\":{\"query\":\"CN\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"bytes >= 10000\",\"language\":\"kuery\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Kuery: pie bytes with kuery and filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Kuery: pie bytes with kuery and filter\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"bytes\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "index-pattern:0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "index-pattern": { + "fieldFormatMap": "{\"machine.ram\":{\"id\":\"number\",\"params\":{\"pattern\":\"0,0.[000] b\"}}}", + "fields": "[{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@message.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@tags.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"agent\",\"type\":\"string\",\"count\":2,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"agent.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":3,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":3,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"extension.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"headings.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"host.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"index.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"links.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"machine.os.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:section.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:tag.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:description.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:height.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:width.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:site_name.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:title.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:type.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:url.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:card.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:description.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:image.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:site.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:title.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.url.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"request.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"response.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"spaces.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"url.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"xss.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", + "timeFieldName": "@timestamp", + "title": "logstash-*" + }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], + "type": "index-pattern", + "updated_at": "2018-04-16T16:57:12.263Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "search:55d37a30-4197-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "agent", + "bytes", + "clientip" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"clientip : 73.14.212.83\",\"language\":\"kuery\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"range\",\"key\":\"bytes\",\"value\":\"100 to 1,000\",\"params\":{\"gte\":100,\"lt\":1000},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"range\":{\"bytes\":{\"gte\":100,\"lt\":1000}},\"$state\":{\"store\":\"appState\"}}],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "@timestamp", + "desc" + ] + ], + "title": "Bytes and kuery in saved search with filter", + "version": 1 + }, + "type": "search", + "updated_at": "2018-04-16T16:58:07.059Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:b60de070-4197-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "Bytes bytes and more bytes", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"hidePanelTitles\":false,\"useMargins\":true}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"2\"},\"panelIndex\":\"2\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_2\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":15,\"w\":24,\"h\":15,\"i\":\"3\"},\"panelIndex\":\"3\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_3\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":15,\"w\":17,\"h\":8,\"i\":\"4\"},\"panelIndex\":\"4\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_4\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":30,\"w\":18,\"h\":13,\"i\":\"5\"},\"panelIndex\":\"5\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_5\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":37,\"w\":24,\"h\":12,\"i\":\"6\"},\"panelIndex\":\"6\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_6\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":18,\"y\":30,\"w\":9,\"h\":7,\"i\":\"7\"},\"panelIndex\":\"7\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_7\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":28,\"y\":23,\"w\":15,\"h\":13,\"i\":\"8\"},\"panelIndex\":\"8\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_8\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":43,\"w\":24,\"h\":15,\"i\":\"9\"},\"panelIndex\":\"9\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_9\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":49,\"w\":18,\"h\":12,\"i\":\"10\"},\"panelIndex\":\"10\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_10\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":58,\"w\":24,\"h\":15,\"i\":\"11\"},\"panelIndex\":\"11\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_11\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":61,\"w\":5,\"h\":4,\"i\":\"12\"},\"panelIndex\":\"12\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_12\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":73,\"w\":17,\"h\":6,\"i\":\"13\"},\"panelIndex\":\"13\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_13\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":65,\"w\":24,\"h\":15,\"i\":\"14\"},\"panelIndex\":\"14\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_14\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":79,\"w\":24,\"h\":6,\"i\":\"15\"},\"panelIndex\":\"15\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_15\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":24,\"y\":80,\"w\":24,\"h\":15,\"i\":\"16\"},\"panelIndex\":\"16\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_16\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":85,\"w\":13,\"h\":11,\"i\":\"17\"},\"panelIndex\":\"17\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_17\"},{\"version\":\"7.3.0\",\"type\":\"search\",\"gridData\":{\"x\":24,\"y\":95,\"w\":23,\"h\":11,\"i\":\"18\"},\"panelIndex\":\"18\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_18\"}]", + "refreshInterval": { + "display": "Off", + "pause": false, + "value": 0 + }, + "timeFrom": "Mon Apr 09 2018 17:56:08 GMT-0400", + "timeRestore": true, + "timeTo": "Wed Apr 11 2018 17:56:08 GMT-0400", + "title": "All about those bytes", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "7ff2c4c0-4191-11e8-bb13-d53698fb349a", + "name": "1:panel_1", + "type": "visualization" + }, + { + "id": "03d2afd0-4192-11e8-bb13-d53698fb349a", + "name": "2:panel_2", + "type": "visualization" + }, + { + "id": "63983430-4192-11e8-bb13-d53698fb349a", + "name": "3:panel_3", + "type": "visualization" + }, + { + "id": "0ca8c600-4195-11e8-bb13-d53698fb349a", + "name": "4:panel_4", + "type": "visualization" + }, + { + "id": "c10c6b00-4191-11e8-bb13-d53698fb349a", + "name": "5:panel_5", + "type": "visualization" + }, + { + "id": "760a9060-4190-11e8-bb13-d53698fb349a", + "name": "6:panel_6", + "type": "visualization" + }, + { + "id": "1dcdfe30-4192-11e8-bb13-d53698fb349a", + "name": "7:panel_7", + "type": "visualization" + }, + { + "id": "584c0300-4191-11e8-bb13-d53698fb349a", + "name": "8:panel_8", + "type": "visualization" + }, + { + "id": "b3e70d00-4190-11e8-bb13-d53698fb349a", + "name": "9:panel_9", + "type": "visualization" + }, + { + "id": "df72ad40-4194-11e8-bb13-d53698fb349a", + "name": "10:panel_10", + "type": "visualization" + }, + { + "id": "9bebe980-4192-11e8-bb13-d53698fb349a", + "name": "11:panel_11", + "type": "visualization" + }, + { + "id": "9fb4c670-4194-11e8-bb13-d53698fb349a", + "name": "12:panel_12", + "type": "visualization" + }, + { + "id": "35417e50-4194-11e8-bb13-d53698fb349a", + "name": "13:panel_13", + "type": "visualization" + }, + { + "id": "039e4770-4194-11e8-bb13-d53698fb349a", + "name": "14:panel_14", + "type": "visualization" + }, + { + "id": "76c7f020-4194-11e8-bb13-d53698fb349a", + "name": "15:panel_15", + "type": "visualization" + }, + { + "id": "8090dcb0-4195-11e8-bb13-d53698fb349a", + "name": "16:panel_16", + "type": "visualization" + }, + { + "id": "29bd0240-4197-11e8-bb13-d53698fb349a", + "name": "17:panel_17", + "type": "visualization" + }, + { + "id": "55d37a30-4197-11e8-bb13-d53698fb349a", + "name": "18:panel_18", + "type": "search" + } + ], + "type": "dashboard", + "updated_at": "2018-04-16T17:00:48.503Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:78803be0-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:32.127Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: tag cloud", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tag cloud\",\"type\":\"tagcloud\",\"params\":{\"scale\":\"linear\",\"orientation\":\"single\",\"minFontSize\":18,\"maxFontSize\":72,\"showLabel\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:3fe22200-3dcb-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:32.130Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: pie", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: pie\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"bytes\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:4ca00ba0-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:32.131Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: region map", + "uiStateJSON": "{\"mapZoom\":2,\"mapCenter\":[8.754794702435618,-9.140625000000002]}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: region map\",\"type\":\"region_map\",\"params\":{\"legendPosition\":\"bottomright\",\"addTooltip\":true,\"colorSchema\":\"Yellow to Red\",\"selectedLayer\":{\"attribution\":\"

Made with NaturalEarth | Elastic Maps Service

\",\"name\":\"World Countries\",\"weight\":1,\"format\":{\"type\":\"geojson\"},\"url\":\"https://staging-dot-elastic-layer.appspot.com/blob/5715999101812736?elastic_tile_service_tos=agree&my_app_version=6.3.0\",\"fields\":[{\"name\":\"iso2\",\"description\":\"Two letter abbreviation\"},{\"name\":\"iso3\",\"description\":\"Three letter abbreviation\"},{\"name\":\"name\",\"description\":\"Country name\"}],\"created_at\":\"2017-07-31T16:00:19.996450\",\"tags\":[],\"id\":5715999101812736,\"layerId\":\"elastic_maps_service.World Countries\"},\"selectedJoinField\":{\"name\":\"iso2\",\"description\":\"Two letter abbreviation\"},\"isDisplayWarning\":true,\"wms\":{\"enabled\":false,\"options\":{\"format\":\"image/png\",\"transparent\":true},\"baseLayersAreLoaded\":{},\"tmsLayers\":[{\"id\":\"road_map\",\"url\":\"https://tiles-stage.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=6.3.0\",\"minZoom\":0,\"maxZoom\":10,\"attribution\":\"

© OpenStreetMap contributors | Elastic Maps Service

\",\"subdomains\":[]}],\"selectedTmsLayer\":{\"id\":\"road_map\",\"url\":\"https://tiles-stage.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=6.3.0\",\"minZoom\":0,\"maxZoom\":10,\"attribution\":\"

© OpenStreetMap contributors | Elastic Maps Service

\",\"subdomains\":[]}},\"mapZoom\":2,\"mapCenter\":[0,0],\"outlineWeight\":1,\"showAllShapes\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:11ae2bd0-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:32.133Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: metric", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: metric\",\"type\":\"metric\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\",\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:145ced90-3dcb-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:32.134Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: heatmap", + "uiStateJSON": "{\"vis\":{\"defaultColors\":{\"0 - 15\":\"rgb(247,252,245)\",\"15 - 30\":\"rgb(199,233,192)\",\"30 - 45\":\"rgb(116,196,118)\",\"45 - 60\":\"rgb(35,139,69)\"}}}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: heatmap\",\"type\":\"heatmap\",\"params\":{\"type\":\"heatmap\",\"addTooltip\":true,\"addLegend\":true,\"enableHover\":false,\"legendPosition\":\"right\",\"times\":[],\"colorsNumber\":4,\"colorSchema\":\"Greens\",\"setColorRange\":false,\"colorsRange\":[],\"invertColors\":false,\"percentageMode\":false,\"valueAxes\":[{\"show\":false,\"id\":\"ValueAxis-1\",\"type\":\"value\",\"scale\":{\"type\":\"linear\",\"defaultYExtents\":false},\"labels\":{\"show\":false,\"rotate\":0,\"overwriteColor\":false,\"color\":\"#555\"}}]},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"bytes\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:e2023110-3dcb-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:32.135Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: guage", + "uiStateJSON": "{\"vis\":{\"colors\":{\"0 - 50000\":\"#EF843C\",\"75000 - 10000000\":\"#3F6833\"},\"defaultColors\":{\"0 - 5000000\":\"rgb(0,104,55)\",\"50000000 - 74998990099\":\"rgb(165,0,38)\"}}}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: guage\",\"type\":\"gauge\",\"params\":{\"addLegend\":true,\"addTooltip\":true,\"gauge\":{\"backStyle\":\"Full\",\"colorSchema\":\"Green to Red\",\"colorsRange\":[{\"from\":0,\"to\":5000000},{\"from\":50000000,\"to\":74998990099}],\"extendRange\":true,\"gaugeColorMode\":\"Labels\",\"gaugeStyle\":\"Full\",\"gaugeType\":\"Arc\",\"invertColors\":false,\"labels\":{\"color\":\"black\",\"show\":true},\"orientation\":\"vertical\",\"percentageMode\":false,\"scale\":{\"color\":\"#333\",\"labels\":false,\"show\":true},\"style\":{\"bgColor\":false,\"bgFill\":\"#eee\",\"bgMask\":false,\"bgWidth\":0.9,\"fontSize\":60,\"labelColor\":true,\"mask\":false,\"maskBars\":50,\"subText\":\"\",\"width\":0.9},\"type\":\"meter\",\"alignment\":\"horizontal\"},\"isDisplayWarning\":false,\"type\":\"gauge\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"machine.ram\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:b92ae920-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:31.110Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: timelion", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: timelion\",\"type\":\"timelion\",\"params\":{\"expression\":\".es(*, metric=avg:bytes, split=ip:5)\",\"interval\":\"auto\"},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:e4d8b430-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:31.106Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: tsvb-guage", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tsvb-guage\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"gauge\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"split_color_mode\":\"gradient\"},{\"id\":\"d18e5970-3dcc-11e8-a2f6-c162ca6cf6ea\",\"color\":\"rgba(160,70,216,1)\",\"split_mode\":\"filter\",\"metrics\":[{\"id\":\"d18e5971-3dcc-11e8-a2f6-c162ca6cf6ea\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"filter\":{\"query\":\"bytes:>1000\",\"language\":\"lucene\"},\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"c50bd5b0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"bar_color_rules\":[{\"id\":\"cd25a820-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"gauge_color_rules\":[{\"id\":\"e0be22e0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"gauge_width\":10,\"gauge_inner_width\":10,\"gauge_style\":\"half\",\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:4c0f47e0-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:31.111Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: markdown", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: markdown\",\"type\":\"markdown\",\"params\":{\"fontSize\":20,\"openLinksInNewTab\":false,\"markdown\":\"I'm a markdown!\"},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:2d1b1620-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "control_0_index_pattern", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "control_1_index_pattern", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "control_2_index_pattern", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:31.123Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: input control", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: input control\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1523481142694\",\"fieldName\":\"bytes\",\"parent\":\"\",\"label\":\"Bytes Input List\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1523481163654\",\"fieldName\":\"bytes\",\"parent\":\"\",\"label\":\"Bytes range\",\"type\":\"range\",\"options\":{\"decimalPlaces\":0,\"step\":1},\"indexPatternRefName\":\"control_1_index_pattern\"},{\"id\":\"1523481176519\",\"fieldName\":\"sound.keyword\",\"parent\":\"\",\"label\":\"Animal sounds\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_2_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:8bc8d6c0-3e6e-11e8-bbb9-e15942d5d48c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "f908c8e0-3e6d-11e8-bbb9-e15942d5d48c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "f908c8e0-3e6d-11e8-bbb9-e15942d5d48c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:31.173Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"size.keyword\",\"value\":\"extra large\",\"params\":{\"query\":\"extra large\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"size.keyword\":{\"query\":\"extra large\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: non timebased line chart - dog data - with filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"aggs\":[{\"enabled\":true,\"id\":\"1\",\"params\":{\"field\":\"trainability\"},\"schema\":\"metric\",\"type\":\"max\"},{\"enabled\":true,\"id\":\"2\",\"params\":{\"field\":\"breed.keyword\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"order\":\"desc\",\"orderBy\":\"1\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"size\":5},\"schema\":\"segment\",\"type\":\"terms\"},{\"enabled\":true,\"id\":\"3\",\"params\":{\"field\":\"barking level\"},\"schema\":\"metric\",\"type\":\"max\"},{\"enabled\":true,\"id\":\"4\",\"params\":{\"field\":\"activity level\"},\"schema\":\"metric\",\"type\":\"max\"}],\"params\":{\"addLegend\":true,\"addTimeMarker\":false,\"addTooltip\":true,\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"labels\":{\"show\":true,\"truncate\":100,\"filter\":true},\"position\":\"bottom\",\"scale\":{\"type\":\"linear\"},\"show\":true,\"style\":{},\"title\":{},\"type\":\"category\"}],\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"legendPosition\":\"right\",\"seriesParams\":[{\"data\":{\"id\":\"1\",\"label\":\"Max trainability\"},\"drawLinesBetweenPoints\":true,\"mode\":\"normal\",\"show\":\"true\",\"showCircles\":true,\"type\":\"line\",\"valueAxis\":\"ValueAxis-1\"},{\"data\":{\"id\":\"3\",\"label\":\"Max barking level\"},\"drawLinesBetweenPoints\":true,\"mode\":\"normal\",\"show\":true,\"showCircles\":true,\"type\":\"line\",\"valueAxis\":\"ValueAxis-1\"},{\"data\":{\"id\":\"4\",\"label\":\"Max activity level\"},\"drawLinesBetweenPoints\":true,\"mode\":\"normal\",\"show\":true,\"showCircles\":true,\"type\":\"line\",\"valueAxis\":\"ValueAxis-1\"}],\"times\":[],\"type\":\"line\",\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"labels\":{\"filter\":false,\"rotate\":0,\"show\":true,\"truncate\":100},\"name\":\"LeftAxis-1\",\"position\":\"left\",\"scale\":{\"mode\":\"normal\",\"type\":\"linear\"},\"show\":true,\"style\":{},\"title\":{\"text\":\"Max trainability\"},\"type\":\"value\"}],\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"title\":\"Rendering Test: non timebased line chart - dog data - with filter\",\"type\":\"line\"}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:42535e30-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "control_0_index_pattern", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "control_1_index_pattern", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:31.124Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: input control parent", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: input control parent\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1523481216736\",\"fieldName\":\"animal.keyword\",\"parent\":\"\",\"label\":\"Animal type\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1523481176519\",\"fieldName\":\"sound.keyword\",\"parent\":\"1523481216736\",\"label\":\"Animal sounds\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_1_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:7fda8ee0-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:30.344Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: vega", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: vega\",\"type\":\"vega\",\"params\":{\"spec\":\"{\\n/*\\n\\nWelcome to Vega visualizations. Here you can design your own dataviz from scratch using a declarative language called Vega, or its simpler form Vega-Lite. In Vega, you have the full control of what data is loaded, even from multiple sources, how that data is transformed, and what visual elements are used to show it. Use help icon to view Vega examples, tutorials, and other docs. Use the wrench icon to reformat this text, or to remove comments.\\n\\nThis example graph shows the document count in all indexes in the current time range. You might need to adjust the time filter in the upper right corner.\\n*/\\n\\n $schema: https://vega.github.io/schema/vega-lite/v2.json\\n title: Event counts from all indexes\\n\\n // Define the data source\\n data: {\\n url: {\\n/*\\nAn object instead of a string for the \\\"url\\\" param is treated as an Elasticsearch query. Anything inside this object is not part of the Vega language, but only understood by Kibana and Elasticsearch server. This query counts the number of documents per time interval, assuming you have a @timestamp field in your data.\\n\\nKibana has a special handling for the fields surrounded by \\\"%\\\". They are processed before the the query is sent to Elasticsearch. This way the query becomes context aware, and can use the time range and the dashboard filters.\\n*/\\n\\n // Apply dashboard context filters when set\\n %context%: true\\n // Filter the time picker (upper right corner) with this field\\n %timefield%: @timestamp\\n\\n/*\\nSee .search() documentation for : https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search\\n*/\\n\\n // Which index to search\\n index: _all\\n // Aggregate data by the time field into time buckets, counting the number of documents in each bucket.\\n body: {\\n aggs: {\\n time_buckets: {\\n date_histogram: {\\n // Use date histogram aggregation on @timestamp field\\n field: @timestamp\\n // The interval value will depend on the daterange picker (true), or use an integer to set an approximate bucket count\\n interval: {%autointerval%: true}\\n // Make sure we get an entire range, even if it has no data\\n extended_bounds: {\\n // Use the current time range's start and end\\n min: {%timefilter%: \\\"min\\\"}\\n max: {%timefilter%: \\\"max\\\"}\\n }\\n // Use this for linear (e.g. line, area) graphs. Without it, empty buckets will not show up\\n min_doc_count: 0\\n }\\n }\\n }\\n // Speed up the response by only including aggregation results\\n size: 0\\n }\\n }\\n/*\\nElasticsearch will return results in this format:\\n\\naggregations: {\\n time_buckets: {\\n buckets: [\\n {\\n key_as_string: 2015-11-30T22:00:00.000Z\\n key: 1448920800000\\n doc_count: 0\\n },\\n {\\n key_as_string: 2015-11-30T23:00:00.000Z\\n key: 1448924400000\\n doc_count: 0\\n }\\n ...\\n ]\\n }\\n}\\n\\nFor our graph, we only need the list of bucket values. Use the format.property to discard everything else.\\n*/\\n format: {property: \\\"aggregations.time_buckets.buckets\\\"}\\n }\\n\\n // \\\"mark\\\" is the graphics element used to show our data. Other mark values are: area, bar, circle, line, point, rect, rule, square, text, and tick. See https://vega.github.io/vega-lite/docs/mark.html\\n mark: line\\n\\n // \\\"encoding\\\" tells the \\\"mark\\\" what data to use and in what way. See https://vega.github.io/vega-lite/docs/encoding.html\\n encoding: {\\n x: {\\n // The \\\"key\\\" value is the timestamp in milliseconds. Use it for X axis.\\n field: key\\n type: temporal\\n axis: {title: false} // Customize X axis format\\n }\\n y: {\\n // The \\\"doc_count\\\" is the count per bucket. Use it for Y axis.\\n field: doc_count\\n type: quantitative\\n axis: {title: \\\"Document count\\\"}\\n }\\n }\\n}\\n\"},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:02a2e4e0-3dcd-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:30.351Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: tsvb-table", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tsvb-table\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"table\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"split_color_mode\":\"gradient\"},{\"id\":\"d18e5970-3dcc-11e8-a2f6-c162ca6cf6ea\",\"color\":\"rgba(160,70,216,1)\",\"split_mode\":\"filter\",\"metrics\":[{\"id\":\"d18e5971-3dcc-11e8-a2f6-c162ca6cf6ea\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"filter\":{\"query\":\"bytes:>1000\",\"language\":\"lucene\"},\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"c50bd5b0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"bar_color_rules\":[{\"id\":\"cd25a820-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"gauge_color_rules\":[{\"id\":\"e0be22e0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"gauge_width\":10,\"gauge_inner_width\":10,\"gauge_style\":\"half\",\"markdown\":\"\\nHi Avg last bytes: {{ average_of_bytes.last.raw }}\",\"pivot_id\":\"bytes\",\"pivot_label\":\"Hello\",\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:f81134a0-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:30.355Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: tsvb-markdown", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tsvb-markdown\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"markdown\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"split_color_mode\":\"gradient\"},{\"id\":\"d18e5970-3dcc-11e8-a2f6-c162ca6cf6ea\",\"color\":\"rgba(160,70,216,1)\",\"split_mode\":\"filter\",\"metrics\":[{\"id\":\"d18e5971-3dcc-11e8-a2f6-c162ca6cf6ea\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"filter\":{\"query\":\"bytes:>1000\",\"language\":\"lucene\"},\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"c50bd5b0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"bar_color_rules\":[{\"id\":\"cd25a820-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"gauge_color_rules\":[{\"id\":\"e0be22e0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"gauge_width\":10,\"gauge_inner_width\":10,\"gauge_style\":\"half\",\"markdown\":\"\\nHi Avg last bytes: {{ average_of_bytes.last.raw }}\",\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:df815d20-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:30.349Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: tsvb-topn", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tsvb-topn\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"top_n\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"split_color_mode\":\"gradient\"},{\"id\":\"d18e5970-3dcc-11e8-a2f6-c162ca6cf6ea\",\"color\":\"rgba(160,70,216,1)\",\"split_mode\":\"filter\",\"metrics\":[{\"id\":\"d18e5971-3dcc-11e8-a2f6-c162ca6cf6ea\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"filter\":{\"query\":\"bytes:>1000\",\"language\":\"lucene\"},\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"c50bd5b0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"bar_color_rules\":[{\"id\":\"cd25a820-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:cc43fab0-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:30.353Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: tsvb-metric", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tsvb-metric\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"metric\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"sum_of_squares\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"c50bd5b0-3dcc-11e8-a2f6-c162ca6cf6ea\"}],\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:c40f4d40-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:30.347Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Rendering Test: tsvb-ts", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: tsvb-ts\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"timeseries\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"count\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"use_kibana_indexes\":false},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:ffa2e0c0-3dcb-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:33.153Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: goal", + "uiStateJSON": "{\"vis\":{\"defaultColors\":{\"0 - 100\":\"rgb(0,104,55)\"}}}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: goal\",\"type\":\"goal\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"isDisplayWarning\":false,\"type\":\"gauge\",\"gauge\":{\"verticalSplit\":false,\"autoExtend\":false,\"percentageMode\":true,\"gaugeType\":\"Arc\",\"gaugeStyle\":\"Full\",\"backStyle\":\"Full\",\"orientation\":\"vertical\",\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"gaugeColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":4000}],\"invertColors\":false,\"labels\":{\"show\":true,\"color\":\"black\"},\"scale\":{\"show\":false,\"labels\":false,\"color\":\"#333\",\"width\":2},\"type\":\"meter\",\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":2,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:37a541c0-3dcc-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:33.156Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":true,\"disabled\":false,\"alias\":null,\"type\":\"range\",\"key\":\"bytes\",\"value\":\"0 to 10,000\",\"params\":{\"gte\":0,\"lt\":10000},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"range\":{\"bytes\":{\"gte\":0,\"lt\":10000}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: geo map", + "uiStateJSON": "{\"mapZoom\":4,\"mapCenter\":[35.460669951495305,-85.60546875000001]}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: geo map\",\"type\":\"tile_map\",\"params\":{\"mapType\":\"Scaled Circle Markers\",\"isDesaturated\":true,\"addTooltip\":true,\"heatClusterSize\":1.5,\"legendPosition\":\"bottomright\",\"mapZoom\":2,\"mapCenter\":[0,0],\"wms\":{\"enabled\":false,\"options\":{\"format\":\"image/png\",\"transparent\":true},\"baseLayersAreLoaded\":{},\"tmsLayers\":[{\"id\":\"road_map\",\"url\":\"https://tiles-stage.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=6.3.0\",\"minZoom\":0,\"maxZoom\":10,\"attribution\":\"

© OpenStreetMap contributors | Elastic Maps Service

\",\"subdomains\":[]}],\"selectedTmsLayer\":{\"id\":\"road_map\",\"url\":\"https://tiles-stage.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=6.3.0\",\"minZoom\":0,\"maxZoom\":10,\"attribution\":\"

© OpenStreetMap contributors | Elastic Maps Service

\",\"subdomains\":[]}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"geohash_grid\",\"schema\":\"segment\",\"params\":{\"field\":\"geo.coordinates\",\"autoPrecision\":true,\"isFilteredByCollar\":true,\"useGeocentroid\":true,\"precision\":3}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:4b5d6ef0-3dcb-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:33.162Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: datatable", + "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: datatable\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\",\"showToolbar\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"clientip\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:3525b840-3dcb-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:33.163Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: bar", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: bar\",\"type\":\"horizontal_bar\",\"params\":{\"type\":\"histogram\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":200},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":75,\"filter\":true,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":true,\"type\":\"histogram\",\"mode\":\"normal\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"valueAxis\":\"ValueAxis-1\",\"drawLinesBetweenPoints\":true,\"showCircles\":true}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":3,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:e6140540-3dca-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:33.165Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":true,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"geo.src\",\"value\":\"CN\",\"params\":{\"query\":\"CN\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"geo.src\":{\"query\":\"CN\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: area with not filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: area with not filter\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100,\"filter\":true},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"filters\",\"schema\":\"group\",\"params\":{\"filters\":[{\"input\":{\"query\":\"bytes:>1000\",\"language\":\"lucene\"},\"label\":\"\"},{\"input\":{\"query\":\"bytes:>10\",\"language\":\"lucene\"}}]}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:4c0c3f90-3e5a-11e8-9fc3-39e49624228e", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:33.166Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"field\":\"isDog\",\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"isDog\",\"value\":\"true\",\"params\":{\"value\":true},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"script\":{\"script\":{\"inline\":\"boolean compare(Supplier s, def v) {return s.get() == v;}compare(() -> { return doc['animal.keyword'].value == 'dog' }, params.value);\",\"lang\":\"painless\",\"params\":{\"value\":true}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"weightLbs:>40\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: scripted filter and query", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: scripted filter and query\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"sound.keyword\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:50643b60-3dd3-11e8-b2b9-5d5dc1715159", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:34.195Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Rendering Test: animal sounds pie", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: animal sounds pie\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"sound.keyword\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:771b4f10-3e59-11e8-9fc3-39e49624228e", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a16d1990-3dca-11e8-8660-4d65aa086b3c", + "name": "search_0", + "type": "search" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:34.200Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}" + }, + "savedSearchRefName": "search_0", + "title": "Rendering Test: animal weights linked to search", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Rendering Test: animal weights linked to search\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"name.keyword\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:76c7f020-4194-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:34.583Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: tsvb top n with bytes filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: tsvb top n with bytes filter\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"top_n\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"filters\",\"metrics\":[{\"id\":\"482d6560-4194-11e8-a461-7d278185cba4\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"terms_field\":\"clientip\",\"filter\":{\"query\":\"Filter Bytes Test:>1000\",\"language\":\"lucene\"},\"override_index_pattern\":0,\"series_index_pattern\":\"logstash-*\",\"series_time_field\":\"utc_time\",\"series_interval\":\"1m\",\"value_template\":\"\",\"split_filters\":[{\"filter\":{\"query\":\"Filter Bytes Test:>100\",\"language\":\"lucene\"},\"label\":\"\",\"color\":\"#68BC00\",\"id\":\"39a107e0-4194-11e8-a461-7d278185cba4\"}],\"split_color_mode\":\"gradient\"},{\"id\":\"4fd5b150-4194-11e8-a461-7d278185cba4\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"4fd5b151-4194-11e8-a461-7d278185cba4\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"filter\":{\"query\":\"Filter Bytes Test:>3000\",\"language\":\"lucene\"},\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"06893260-4194-11e8-a461-7d278185cba4\"}],\"bar_color_rules\":[{\"id\":\"36a0e740-4194-11e8-a461-7d278185cba4\"}],\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:0ca8c600-4195-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "control_0_index_pattern", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:35.229Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: input control with filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: input control with filter\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1523896850250\",\"fieldName\":\"bytes\",\"parent\":\"\",\"label\":\"Byte Options\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"size\":10,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:039e4770-4194-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:35.220Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: tsvb time series with bytes filter split by clientip", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: tsvb time series with bytes filter split by clientip\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"timeseries\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"terms\",\"metrics\":[{\"value\":\"\",\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"sum\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"terms_field\":\"clientip\",\"filter\":{\"query\":\"Filter Bytes Test:>1000\",\"language\":\"lucene\"},\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"use_kibana_indexes\":false},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:760a9060-4190-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:35.235Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"geo.src\",\"value\":\"US\",\"params\":{\"query\":\"US\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"geo.src\":{\"query\":\"US\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: max bytes in US - area chart with filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: max bytes in US - area chart with filter\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100,\"filter\":true},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Max bytes\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Max bytes\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1,\"extended_bounds\":{}}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:b3e70d00-4190-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:35.236Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: standard deviation heatmap with other bucket", + "uiStateJSON": "{\"vis\":{\"defaultColors\":{\"-4,000 - 1,000\":\"rgb(247,252,245)\",\"1,000 - 6,000\":\"rgb(199,233,192)\",\"6,000 - 11,000\":\"rgb(116,196,118)\",\"11,000 - 16,000\":\"rgb(35,139,69)\"}}}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: standard deviation heatmap with other bucket\",\"type\":\"heatmap\",\"params\":{\"type\":\"heatmap\",\"addTooltip\":true,\"addLegend\":true,\"enableHover\":false,\"legendPosition\":\"right\",\"times\":[],\"colorsNumber\":4,\"colorSchema\":\"Greens\",\"setColorRange\":false,\"colorsRange\":[],\"invertColors\":false,\"percentageMode\":false,\"valueAxes\":[{\"show\":false,\"id\":\"ValueAxis-1\",\"type\":\"value\",\"scale\":{\"type\":\"linear\",\"defaultYExtents\":false},\"labels\":{\"show\":false,\"rotate\":0,\"overwriteColor\":false,\"color\":\"#555\"}}]},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"std_dev\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":true,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"_term\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:c10c6b00-4191-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:36.267Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: max bytes guage percent mode", + "uiStateJSON": "{\"vis\":{\"defaultColors\":{\"0 - 1\":\"rgb(0,104,55)\",\"1 - 15\":\"rgb(255,255,190)\",\"15 - 100\":\"rgb(165,0,38)\"}}}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: max bytes guage percent mode\",\"type\":\"gauge\",\"params\":{\"type\":\"gauge\",\"addTooltip\":true,\"addLegend\":true,\"isDisplayWarning\":false,\"gauge\":{\"extendRange\":true,\"percentageMode\":true,\"gaugeType\":\"Arc\",\"gaugeStyle\":\"Full\",\"backStyle\":\"Full\",\"orientation\":\"vertical\",\"colorSchema\":\"Green to Red\",\"gaugeColorMode\":\"Labels\",\"colorsRange\":[{\"from\":0,\"to\":500},{\"from\":500,\"to\":7500},{\"from\":7500,\"to\":50000}],\"invertColors\":false,\"labels\":{\"show\":true,\"color\":\"black\"},\"scale\":{\"show\":true,\"labels\":false,\"color\":\"#333\"},\"type\":\"meter\",\"style\":{\"bgWidth\":0.9,\"width\":0.9,\"mask\":false,\"bgMask\":false,\"maskBars\":50,\"bgFill\":\"#eee\",\"bgColor\":false,\"subText\":\"Im subtext\",\"fontSize\":60,\"labelColor\":true},\"alignment\":\"horizontal\"}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:03d2afd0-4192-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:36.269Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: Goal unique count", + "uiStateJSON": "{\"vis\":{\"defaultColors\":{\"0 - 10000\":\"rgb(0,104,55)\"}}}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: Goal unique count\",\"type\":\"goal\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"isDisplayWarning\":false,\"type\":\"gauge\",\"gauge\":{\"verticalSplit\":false,\"autoExtend\":false,\"percentageMode\":false,\"gaugeType\":\"Arc\",\"gaugeStyle\":\"Full\",\"backStyle\":\"Full\",\"orientation\":\"vertical\",\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"gaugeColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"invertColors\":false,\"labels\":{\"show\":true,\"color\":\"black\"},\"scale\":{\"show\":false,\"labels\":false,\"color\":\"#333\",\"width\":2},\"type\":\"meter\",\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:7ff2c4c0-4191-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:36.270Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: Data table top hit with significant terms geo.src", + "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: Data table top hit with significant terms geo.src\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\",\"showToolbar\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"top_hits\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\",\"aggregate\":\"average\",\"size\":1,\"sortField\":\"@timestamp\",\"sortOrder\":\"desc\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"significant_terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"geo.src\",\"size\":10}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:df72ad40-4194-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:36.276Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":true,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"bytes\",\"value\":\"0\",\"params\":{\"query\":0,\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"bytes\":{\"query\":0,\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: tag cloud with not 0 bytes filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: tag cloud with not 0 bytes filter\",\"type\":\"tagcloud\",\"params\":{\"scale\":\"linear\",\"orientation\":\"single\",\"minFontSize\":18,\"maxFontSize\":72,\"showLabel\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"bytes\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:63983430-4192-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:06:36.275Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"geo.src\",\"value\":\"US\",\"params\":{\"query\":\"US\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"geo.src\":{\"query\":\"US\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"Filter Bytes Test:>5000\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: geo map with filter and query bytes > 5000 in US geo.src, heatmap setting", + "uiStateJSON": "{\"mapZoom\":7,\"mapCenter\":[42.98857645832184,-75.49804687500001]}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: geo map with filter and query bytes > 5000 in US geo.src, heatmap setting\",\"type\":\"tile_map\",\"params\":{\"mapType\":\"Heatmap\",\"isDesaturated\":true,\"addTooltip\":true,\"heatClusterSize\":1.5,\"legendPosition\":\"bottomright\",\"mapZoom\":2,\"mapCenter\":[0,0],\"wms\":{\"enabled\":false,\"options\":{\"format\":\"image/png\",\"transparent\":true},\"baseLayersAreLoaded\":{},\"tmsLayers\":[{\"id\":\"road_map\",\"url\":\"https://tiles-stage.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=6.3.0\",\"minZoom\":0,\"maxZoom\":10,\"attribution\":\"

© OpenStreetMap contributors | Elastic Maps Service

\",\"subdomains\":[]}],\"selectedTmsLayer\":{\"id\":\"road_map\",\"url\":\"https://tiles-stage.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=6.3.0\",\"minZoom\":0,\"maxZoom\":10,\"attribution\":\"

© OpenStreetMap contributors | Elastic Maps Service

\",\"subdomains\":[]}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"geohash_grid\",\"schema\":\"segment\",\"params\":{\"field\":\"geo.coordinates\",\"autoPrecision\":true,\"isFilteredByCollar\":true,\"useGeocentroid\":true,\"precision\":4}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "search:be5accf0-3dca-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "agent", + "bytes", + "clientip" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "@timestamp", + "desc" + ] + ], + "title": "Rendering Test: saved search", + "version": 1 + }, + "type": "search", + "updated_at": "2018-04-17T15:09:39.805Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "search:ca5ada40-3dca-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "agent", + "bytes", + "clientip" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[{\"meta\":{\"negate\":false,\"type\":\"phrase\",\"key\":\"bytes\",\"value\":\"1,607\",\"params\":{\"query\":1607,\"type\":\"phrase\"},\"disabled\":false,\"alias\":null,\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"bytes\":{\"query\":1607,\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "@timestamp", + "desc" + ] + ], + "title": "Filter Bytes Test: search with filter", + "version": 1 + }, + "type": "search", + "updated_at": "2018-04-17T15:09:55.976Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:9bebe980-4192-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T15:59:42.648Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: timelion split 5 on bytes", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: timelion split 5 on bytes\",\"type\":\"timelion\",\"params\":{\"expression\":\".es(*, split=bytes:5)\",\"interval\":\"auto\"},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:1dcdfe30-4192-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T15:59:56.976Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"bytes:>100\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: min bytes metric with query", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: min bytes metric with query\",\"type\":\"metric\",\"params\":{\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\",\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"min\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:35417e50-4194-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T16:06:03.785Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: tsvb metric with custom interval and bytes filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: tsvb metric with custom interval and bytes filter\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"metric\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"value\":\"\",\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"sum\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"terms_field\":\"clientip\",\"filter\":{\"query\":\"Filter Bytes Test:>1000\",\"language\":\"lucene\"},\"override_index_pattern\":1,\"series_index_pattern\":\"logstash-*\",\"series_time_field\":\"utc_time\",\"series_interval\":\"1d\",\"value_template\":\"{{value}} custom template\",\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"06893260-4194-11e8-a461-7d278185cba4\"}],\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:9fb4c670-4194-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T16:32:59.086Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: tsvb markdown", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: tsvb markdown\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"markdown\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"filters\",\"metrics\":[{\"id\":\"482d6560-4194-11e8-a461-7d278185cba4\",\"type\":\"avg\",\"field\":\"bytes\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"terms_field\":\"clientip\",\"filter\":{\"query\":\"Filter Bytes Test:>1000\",\"language\":\"lucene\"},\"override_index_pattern\":0,\"series_index_pattern\":\"logstash-*\",\"series_time_field\":\"utc_time\",\"series_interval\":\"1m\",\"value_template\":\"\",\"split_filters\":[{\"filter\":{\"query\":\"bytes:>1000\",\"language\":\"lucene\"},\"label\":\"\",\"color\":\"#68BC00\",\"id\":\"39a107e0-4194-11e8-a461-7d278185cba4\"}],\"label\":\"\",\"var_name\":\"\",\"split_color_mode\":\"gradient\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"logstash-*\",\"interval\":\"auto\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":1,\"background_color_rules\":[{\"id\":\"06893260-4194-11e8-a461-7d278185cba4\"}],\"bar_color_rules\":[{\"id\":\"36a0e740-4194-11e8-a461-7d278185cba4\"}],\"markdown\":\"{{bytes_1000.last.formatted}}\",\"use_kibana_indexes\":false,\"hide_last_value_indicator\":true},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:befdb6b0-3e59-11e8-9fc3-39e49624228e", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + }, + { + "id": "a16d1990-3dca-11e8-8660-4d65aa086b3c", + "name": "search_0", + "type": "search" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T17:16:27.743Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"animal.keyword\",\"value\":\"dog\",\"params\":{\"query\":\"dog\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"animal.keyword\":{\"query\":\"dog\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"language\":\"lucene\",\"query\":\"\"}}" + }, + "savedSearchRefName": "search_0", + "title": "Filter Test: animals: linked to search with filter", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Test: animals: linked to search with filter\",\"type\":\"pie\",\"params\":{\"addLegend\":true,\"addTooltip\":true,\"isDonut\":true,\"labels\":{\"last_level\":true,\"show\":false,\"truncate\":100,\"values\":true},\"legendPosition\":\"right\",\"type\":\"pie\",\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"name.keyword\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:584c0300-4191-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-04-17T18:36:30.315Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"bytes:>9000\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Filter Bytes Test: split by geo with query", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: split by geo with query\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"bytes\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"geo.src\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "config:7.0.0-alpha1", + "index": ".kibana", + "source": { + "config": { + "buildNum": null, + "dateFormat:tz": "UTC", + "defaultIndex": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "notifications:lifetime:banner": 3600000, + "notifications:lifetime:error": 3600000, + "notifications:lifetime:info": 3600000, + "notifications:lifetime:warning": 3600000 + }, + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "config": "7.13.0" + }, + "references": [ + ], + "type": "config", + "updated_at": "2018-04-17T19:25:03.632Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:8090dcb0-4195-11e8-bb13-d53698fb349a", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], + "type": "visualization", + "updated_at": "2018-04-17T19:28:21.967Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{}" + }, + "title": "Filter Bytes Test: vega", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Filter Bytes Test: vega\",\"type\":\"vega\",\"params\":{\"spec\":\"{ \\nconfig: { kibana: { renderer: \\\"svg\\\" }},\\n/*\\n\\nWelcome to Vega visualizations. Here you can design your own dataviz from scratch using a declarative language called Vega, or its simpler form Vega-Lite. In Vega, you have the full control of what data is loaded, even from multiple sources, how that data is transformed, and what visual elements are used to show it. Use help icon to view Vega examples, tutorials, and other docs. Use the wrench icon to reformat this text, or to remove comments.\\n\\nThis example graph shows the document count in all indexes in the current time range. You might need to adjust the time filter in the upper right corner.\\n*/\\n\\n $schema: https://vega.github.io/schema/vega-lite/v2.json\\n title: Event counts from all indexes\\n\\n // Define the data source\\n data: {\\n url: {\\n/*\\nAn object instead of a string for the \\\"url\\\" param is treated as an Elasticsearch query. Anything inside this object is not part of the Vega language, but only understood by Kibana and Elasticsearch server. This query counts the number of documents per time interval, assuming you have a @timestamp field in your data.\\n\\nKibana has a special handling for the fields surrounded by \\\"%\\\". They are processed before the the query is sent to Elasticsearch. This way the query becomes context aware, and can use the time range and the dashboard filters.\\n*/\\n\\n // Apply dashboard context filters when set\\n %context%: true\\n // Filter the time picker (upper right corner) with this field\\n %timefield%: @timestamp\\n\\n/*\\nSee .search() documentation for : https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search\\n*/\\n\\n // Which index to search\\n index: _all\\n // Aggregate data by the time field into time buckets, counting the number of documents in each bucket.\\n body: {\\n aggs: {\\n time_buckets: {\\n date_histogram: {\\n // Use date histogram aggregation on @timestamp field\\n field: @timestamp\\n // The interval value will depend on the daterange picker (true), or use an integer to set an approximate bucket count\\n interval: {%autointerval%: true}\\n // Make sure we get an entire range, even if it has no data\\n extended_bounds: {\\n // Use the current time range's start and end\\n min: {%timefilter%: \\\"min\\\"}\\n max: {%timefilter%: \\\"max\\\"}\\n }\\n // Use this for linear (e.g. line, area) graphs. Without it, empty buckets will not show up\\n min_doc_count: 0\\n }\\n }\\n }\\n // Speed up the response by only including aggregation results\\n size: 0\\n }\\n }\\n/*\\nElasticsearch will return results in this format:\\n\\naggregations: {\\n time_buckets: {\\n buckets: [\\n {\\n key_as_string: 2015-11-30T22:00:00.000Z\\n key: 1448920800000\\n doc_count: 0\\n },\\n {\\n key_as_string: 2015-11-30T23:00:00.000Z\\n key: 1448924400000\\n doc_count: 0\\n }\\n ...\\n ]\\n }\\n}\\n\\nFor our graph, we only need the list of bucket values. Use the format.property to discard everything else.\\n*/\\n format: {property: \\\"aggregations.time_buckets.buckets\\\"}\\n }\\n\\n // \\\"mark\\\" is the graphics element used to show our data. Other mark values are: area, bar, circle, line, point, rect, rule, square, text, and tick. See https://vega.github.io/vega-lite/docs/mark.html\\n mark: line\\n\\n // \\\"encoding\\\" tells the \\\"mark\\\" what data to use and in what way. See https://vega.github.io/vega-lite/docs/encoding.html\\n encoding: {\\n x: {\\n // The \\\"key\\\" value is the timestamp in milliseconds. Use it for X axis.\\n field: key\\n type: temporal\\n axis: {title: false} // Customize X axis format\\n }\\n y: {\\n // The \\\"doc_count\\\" is the count per bucket. Use it for Y axis.\\n field: doc_count\\n type: quantitative\\n axis: {title: \\\"Document count\\\"}\\n }\\n }\\n}\\n\"},\"aggs\":[]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "config:6.2.4", + "index": ".kibana", + "source": { + "config": { + "buildNum": 16627, + "defaultIndex": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "xPackMonitoring:showBanner": false + }, + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "config": "7.13.0" + }, + "references": [ + ], + "type": "config", + "updated_at": "2018-05-09T20:50:57.021Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:edb65990-53ca-11e8-b481-c9426d020fcd", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-05-09T20:52:47.144Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "table created in 6_2", + "uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}", + "version": 1, + "visState": "{\"title\":\"table created in 6_2\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false,\"sort\":{\"columnIndex\":null,\"direction\":null},\"showTotal\":false,\"totalFunc\":\"sum\",\"showToolbar\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"weightLbs\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"animal.keyword\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:0644f890-53cb-11e8-b481-c9426d020fcd", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2018-05-09T20:53:28.345Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[],\"query\":{\"query\":\"weightLbs:>10\",\"language\":\"lucene\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "Weight in lbs pie created in 6.2", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"Weight in lbs pie created in 6.2\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"weightLbs\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}]}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:1b2f47b0-53cb-11e8-b481-c9426d020fcd", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"language\":\"lucene\",\"query\":\"weightLbs:>15\"},\"filter\":[{\"meta\":{\"field\":\"isDog\",\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"isDog\",\"value\":\"true\",\"params\":{\"value\":true},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"script\":{\"script\":{\"inline\":\"boolean compare(Supplier s, def v) {return s.get() == v;}compare(() -> { return doc['animal.keyword'].value == 'dog' }, params.value);\",\"lang\":\"painless\",\"params\":{\"value\":true}}},\"$state\":{\"store\":\"appState\"}}],\"highlightAll\":true,\"version\":true}" + }, + "optionsJSON": "{\"darkTheme\":false,\"hidePanelTitles\":false,\"useMargins\":true}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":12,\"x\":24,\"y\":0,\"i\":\"4\"},\"panelIndex\":\"4\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_4\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"w\":24,\"h\":12,\"x\":0,\"y\":0,\"i\":\"5\"},\"panelIndex\":\"5\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_5\"}]", + "refreshInterval": { + "display": "Off", + "pause": false, + "value": 0 + }, + "timeFrom": "Mon Apr 09 2018 17:56:08 GMT-0400", + "timeRestore": true, + "timeTo": "Wed Apr 11 2018 17:56:08 GMT-0400", + "title": "Animal Weights (created in 6.2)", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + }, + { + "id": "edb65990-53ca-11e8-b481-c9426d020fcd", + "name": "4:panel_4", + "type": "visualization" + }, + { + "id": "0644f890-53cb-11e8-b481-c9426d020fcd", + "name": "5:panel_5", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2018-05-09T20:54:03.435Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "index-pattern:a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "index-pattern": { + "fieldFormatMap": "{\"weightLbs\":{\"id\":\"number\",\"params\":{\"pattern\":\"0,0.0\"}},\"is_dog\":{\"id\":\"boolean\"},\"isDog\":{\"id\":\"boolean\"}}", + "fields": "[{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"animal\",\"type\":\"string\",\"count\":3,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"animal.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"name\",\"type\":\"string\",\"count\":1,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"name.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"sound\",\"type\":\"string\",\"count\":2,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"sound.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"weightLbs\",\"type\":\"number\",\"count\":2,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"isDog\",\"type\":\"boolean\",\"count\":0,\"scripted\":true,\"script\":\"return doc['animal.keyword'].value == 'dog'\",\"lang\":\"painless\",\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false}]", + "timeFieldName": "@timestamp", + "title": "animals-*" + }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], + "type": "index-pattern", + "updated_at": "2018-05-09T20:55:44.314Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "search:6351c590-53cb-11e8-b481-c9426d020fcd", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + } + ], + "search": { + "columns": [ + "animal", + "sound", + "weightLbs" + ], + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"highlightAll\":true,\"version\":true,\"query\":{\"language\":\"lucene\",\"query\":\"weightLbs:>10\"},\"filter\":[{\"meta\":{\"negate\":false,\"disabled\":false,\"alias\":null,\"type\":\"phrase\",\"key\":\"sound.keyword\",\"value\":\"growl\",\"params\":{\"query\":\"growl\",\"type\":\"phrase\"},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"match\":{\"sound.keyword\":{\"query\":\"growl\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "sort": [ + [ + "@timestamp", + "desc" + ] + ], + "title": "Search created in 6.2", + "version": 1 + }, + "type": "search", + "updated_at": "2018-05-09T20:56:04.457Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "visualization:47b5cf60-9e93-11ea-853e-adc0effaf76d", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "1b1789d0-9e93-11ea-853e-adc0effaf76d", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], + "type": "visualization", + "updated_at": "2020-05-25T15:16:27.743Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" + }, + "title": "vis with missing index pattern", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"type\":\"pie\",\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}],\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"distinctColors\":true},\"title\":\"vis with missing index pattern\"}" + } + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:502e63a0-9e93-11ea-853e-adc0effaf76d", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"language\":\"kuery\",\"query\":\"\"},\"filter\":[]}" + }, + "optionsJSON": "{\"hidePanelTitles\":false,\"useMargins\":true}", + "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"6cfbe6cc-1872-4cb4-9455-a02eeb75127e\"},\"panelIndex\":\"6cfbe6cc-1872-4cb4-9455-a02eeb75127e\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_6cfbe6cc-1872-4cb4-9455-a02eeb75127e\"}]", + "timeRestore": false, + "title": "dashboard with missing index pattern", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "47b5cf60-9e93-11ea-853e-adc0effaf76d", + "name": "6cfbe6cc-1872-4cb4-9455-a02eeb75127e:panel_6cfbe6cc-1872-4cb4-9455-a02eeb75127e", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2020-05-25T15:16:27.743Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "dashboard:6eb8a840-a32e-11ea-88c2-d56dd2b14bd7", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "dashboard": { + "description": "", + "hits": 0, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\n \"query\": {\n \"language\": \"kuery\",\n \"query\": \"\"\n },\n \"filter\": [\n {\n \"meta\": {\n \"alias\": null,\n \"negate\": false,\n \"disabled\": true,\n \"type\": \"phrase\",\n \"key\": \"name\",\n \"params\": {\n \"query\": \"moo\"\n },\n \"indexRefName\": \"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"\n },\n \"query\": {\n \"match_phrase\": {\n \"name\": \"moo\"\n }\n },\n \"$state\": {\n \"store\": \"appState\"\n }\n },\n {\n \"meta\": {\n \"alias\": null,\n \"negate\": false,\n \"disabled\": true,\n \"type\": \"phrase\",\n \"key\": \"baad-field\",\n \"params\": {\n \"query\": \"moo\"\n },\n \"indexRefName\": \"kibanaSavedObjectMeta.searchSourceJSON.filter[1].meta.index\"\n },\n \"query\": {\n \"match_phrase\": {\n \"baad-field\": \"moo\"\n }\n },\n \"$state\": {\n \"store\": \"appState\"\n }\n },\n {\n \"meta\": {\n \"alias\": null,\n \"negate\": false,\n \"disabled\": false,\n \"type\": \"phrase\",\n \"key\": \"@timestamp\",\n \"params\": {\n \"query\": \"123\"\n },\n \"indexRefName\": \"kibanaSavedObjectMeta.searchSourceJSON.filter[2].meta.index\"\n },\n \"query\": {\n \"match_phrase\": {\n \"@timestamp\": \"123\"\n }\n },\n \"$state\": {\n \"store\": \"appState\"\n }\n },\n {\n \"meta\": {\n \"alias\": null,\n \"negate\": false,\n \"disabled\": false,\n \"type\": \"exists\",\n \"key\": \"extension\",\n \"value\": \"exists\",\n \"indexRefName\": \"kibanaSavedObjectMeta.searchSourceJSON.filter[3].meta.index\"\n },\n \"exists\": {\n \"field\": \"extension\"\n },\n \"$state\": {\n \"store\": \"appState\"\n }\n },\n {\n \"meta\": {\n \"alias\": null,\n \"negate\": false,\n \"disabled\": false,\n \"type\": \"phrase\",\n \"key\": \"banana\",\n \"params\": {\n \"query\": \"yellow\"\n }\n },\n \"query\": {\n \"match_phrase\": {\n \"banana\": \"yellow\"\n }\n },\n \"$state\": {\n \"store\": \"appState\"\n }\n }\n ]\n}" + }, + "optionsJSON": "{\n \"hidePanelTitles\": false,\n \"useMargins\": true\n}", + "panelsJSON": "[{\"version\":\"8.0.0\",\"type\":\"visualization\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"94a3dc1d-508a-4d42-a480-65b158925ba0\"},\"panelIndex\":\"94a3dc1d-508a-4d42-a480-65b158925ba0\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_94a3dc1d-508a-4d42-a480-65b158925ba0\"}]", + "refreshInterval": { + "pause": true, + "value": 0 + }, + "timeFrom": "now-10y", + "timeRestore": true, + "timeTo": "now", + "title": "dashboard with bad filters", + "version": 1 + }, + "migrationVersion": { + "dashboard": "7.14.0" + }, + "references": [ + { + "id": "a0f483a0-3dc9-11e8-8660-bad-index", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[1].meta.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[2].meta.index", + "type": "index-pattern" + }, + { + "id": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[3].meta.index", + "type": "index-pattern" + }, + { + "id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c", + "name": "kibanaSavedObjectMeta.searchSourceJSON.filter[4].meta.index", + "type": "index-pattern" + }, + { + "id": "50643b60-3dd3-11e8-b2b9-5d5dc1715159", + "name": "94a3dc1d-508a-4d42-a480-65b158925ba0:panel_94a3dc1d-508a-4d42-a480-65b158925ba0", + "type": "visualization" + } + ], + "type": "dashboard", + "updated_at": "2020-06-04T09:26:04.272Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "config:8.0.0", + "index": ".kibana", + "source": { + "config": { + "accessibility:disableAnimations": true, + "buildNum": null, + "dateFormat:tz": "UTC", + "defaultIndex": "0bf35f60-3dc9-11e8-8660-4d65aa086b3c" + }, + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "config": "7.13.0" + }, + "references": [ + ], + "type": "config", + "updated_at": "2020-06-04T09:22:54.572Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "ui-metric:DashboardPanelVersionInUrl:8.0.0", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "ui-metric", + "ui-metric": { + "count": 15 + }, + "updated_at": "2020-06-04T09:28:06.848Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "ui-metric:kibana-user_agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36", + "index": ".kibana", + "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "ui-metric", + "ui-metric": { + "count": 1 + }, + "updated_at": "2020-06-04T09:28:06.848Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "application_usage_daily:dashboards:2020-05-31", + "index": ".kibana", + "source": { + "application_usage_daily": { + "appId": "dashboards", + "minutesOnScreen": 13.956333333333333, + "numberOfClicks": 134, + "timestamp": "2020-05-31T00:00:00.000Z" + }, + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "application_usage_daily", + "updated_at": "2021-06-10T22:39:09.215Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "application_usage_daily:home:2020-05-31", + "index": ".kibana", + "source": { + "application_usage_daily": { + "appId": "home", + "minutesOnScreen": 0.5708666666666666, + "numberOfClicks": 1, + "timestamp": "2020-05-31T00:00:00.000Z" + }, + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "application_usage_daily", + "updated_at": "2021-06-10T22:39:09.215Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "application_usage_daily:management:2020-05-31", + "index": ".kibana", + "source": { + "application_usage_daily": { + "appId": "management", + "minutesOnScreen": 5.842616666666666, + "numberOfClicks": 107, + "timestamp": "2020-05-31T00:00:00.000Z" + }, + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "application_usage_daily", + "updated_at": "2021-06-10T22:39:09.215Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "application_usage_daily:management:2020-06-04", + "index": ".kibana", + "source": { + "application_usage_daily": { + "appId": "management", + "minutesOnScreen": 2.5120666666666667, + "numberOfClicks": 38, + "timestamp": "2020-06-04T00:00:00.000Z" + }, + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "application_usage_daily", + "updated_at": "2021-06-10T22:39:09.215Z" + }, + "type": "_doc" + } +} + +{ + "type": "doc", + "value": { + "id": "application_usage_daily:dashboards:2020-06-04", + "index": ".kibana", + "source": { + "application_usage_daily": { + "appId": "dashboards", + "minutesOnScreen": 9.065083333333334, + "numberOfClicks": 21, + "timestamp": "2020-06-04T00:00:00.000Z" + }, + "coreMigrationVersion": "7.14.0", + "references": [ + ], + "type": "application_usage_daily", + "updated_at": "2021-06-10T22:39:09.215Z" + }, + "type": "_doc" + } +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/dashboard/current/kibana/data.json.gz b/test/functional/fixtures/es_archiver/dashboard/current/kibana/data.json.gz deleted file mode 100644 index ae78761fef0d34..00000000000000 Binary files a/test/functional/fixtures/es_archiver/dashboard/current/kibana/data.json.gz and /dev/null differ diff --git a/test/functional/fixtures/es_archiver/dashboard/current/kibana/mappings.json b/test/functional/fixtures/es_archiver/dashboard/current/kibana/mappings.json index 9f5edaad0fe763..b6e225951c5454 100644 --- a/test/functional/fixtures/es_archiver/dashboard/current/kibana/mappings.json +++ b/test/functional/fixtures/es_archiver/dashboard/current/kibana/mappings.json @@ -2,155 +2,139 @@ "type": "index", "value": { "aliases": { - ".kibana": { - } + ".kibana_$KIBANA_PACKAGE_VERSION": {}, + ".kibana": {} }, - "index": ".kibana_1", + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { "_meta": { "migrationMappingPropertyHashes": { - "application_usage_totals": "c897e4310c5f24b07caaff3db53ae2c1", - "application_usage_transactional": "965839e75f809fefe04f92dc4d99722a", - "config": "ae24d22d5986d04124cc6568f771066f", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", "migrationVersion": "4a1746014a75ade3a714e1db5763276f", "namespace": "2f4316de49999235636386fe51dc06c1", "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", "references": "7997cf5a56cc02bdc9c93361bde732b0", "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", "telemetry": "36a616f7026dfa617d6655df850fe16d", "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "tsvb-validation-telemetry": "3a37ef6c8700ae6fc97d5c7da00e9215", "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "url": "b675c3be8d76ecf029294d51dc7ec65d", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" } }, "dynamic": "strict", "properties": { - "application_usage_totals": { + "application_usage_daily": { + "dynamic": "false", "properties": { - "appId": { - "type": "keyword" - }, - "minutesOnScreen": { - "type": "float" - }, - "numberOfClicks": { - "type": "long" - } - } - }, - "application_usage_transactional": { - "properties": { - "appId": { - "type": "keyword" - }, - "minutesOnScreen": { - "type": "float" - }, - "numberOfClicks": { - "type": "long" - }, "timestamp": { "type": "date" } } }, + "application_usage_totals": { + "dynamic": "false", + "type": "object" + }, + "application_usage_transactional": { + "dynamic": "false", + "type": "object" + }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { - "accessibility:disableAnimations": { - "type": "boolean" - }, "buildNum": { "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "notifications:lifetime:banner": { - "type": "long" - }, - "notifications:lifetime:error": { - "type": "long" - }, - "notifications:lifetime:info": { - "type": "long" - }, - "notifications:lifetime:warning": { - "type": "long" - }, - "xPackMonitoring:showBanner": { - "type": "boolean" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -162,33 +146,13 @@ } }, "index-pattern": { + "dynamic": "false", "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, "title": { "type": "text" }, "type": { "type": "keyword" - }, - "typeMeta": { - "type": "keyword" } } }, @@ -202,9 +166,32 @@ } } }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { + "type": "boolean" + }, + "sourceId": { + "type": "keyword" + }, + "targetType": { + "type": "keyword" + } + } + }, "migrationVersion": { "dynamic": "true", "properties": { + "config": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, "dashboard": { "fields": { "keyword": { @@ -249,6 +236,9 @@ "namespaces": { "type": "keyword" }, + "originId": { + "type": "keyword" + }, "query": { "properties": { "description": { @@ -305,22 +295,38 @@ "search": { "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -331,12 +337,13 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } + "dynamic": "false", + "type": "object" }, "telemetry": { "properties": { @@ -408,15 +415,19 @@ } }, "tsvb-validation-telemetry": { - "properties": { - "failedRequests": { - "type": "long" - } - } + "dynamic": "false", + "type": "object" }, "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, "ui-metric": { "properties": { "count": { @@ -441,6 +452,7 @@ "url": { "fields": { "keyword": { + "ignore_above": 2048, "type": "keyword" } }, @@ -448,6 +460,14 @@ } } }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" + } + } + }, "visualization": { "properties": { "description": { @@ -456,23 +476,28 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } @@ -483,7 +508,10 @@ "index": { "auto_expand_replicas": "0-1", "number_of_replicas": "0", - "number_of_shards": "1" + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" } } } diff --git a/test/functional/fixtures/es_archiver/deprecations_service/data.json b/test/functional/fixtures/es_archiver/deprecations_service/data.json index 31ce5af20b46c2..1c36f2e177fc55 100644 --- a/test/functional/fixtures/es_archiver/deprecations_service/data.json +++ b/test/functional/fixtures/es_archiver/deprecations_service/data.json @@ -1,14 +1,18 @@ { "type": "doc", "value": { - "index": ".kibana", "id": "test-deprecations-plugin:ff3733a0-9fty-11e7-ahb3-3dcb94193fab", + "index": ".kibana", "source": { - "type": "test-deprecations-plugin", - "updated_at": "2021-02-11T18:51:23.794Z", + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-deprecations-plugin": { "title": "Test saved object" - } - } + }, + "type": "test-deprecations-plugin", + "updated_at": "2021-02-11T18:51:23.794Z" + }, + "type": "_doc" } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/deprecations_service/mappings.json b/test/functional/fixtures/es_archiver/deprecations_service/mappings.json index 41cddecef0c419..5159b946e082f7 100644 --- a/test/functional/fixtures/es_archiver/deprecations_service/mappings.json +++ b/test/functional/fixtures/es_archiver/deprecations_service/mappings.json @@ -2,132 +2,285 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, + "dynamic": "strict", "properties": { + "application_usage_daily": { + "dynamic": "false", + "properties": { + "timestamp": { + "type": "date" + } + } + }, + "application_usage_totals": { + "dynamic": "false", + "type": "object" + }, + "application_usage_transactional": { + "dynamic": "false", + "type": "object" + }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { "buildNum": { "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { - "dynamic": "strict", "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, "index-pattern": { - "dynamic": "strict", + "dynamic": "false", "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { + "title": { "type": "text" }, - "intervalName": { + "type": { "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "notExpandable": { + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { "type": "boolean" }, - "sourceFilters": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "timeFieldName": { + "targetType": { "type": "keyword" + } + } + }, + "migrationVersion": { + "dynamic": "true", + "type": "object" + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { + "properties": { + "description": { + "type": "text" + }, + "filters": { + "enabled": false, + "type": "object" + }, + "query": { + "properties": { + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" + } + } + }, + "timefilter": { + "enabled": false, + "type": "object" }, "title": { "type": "text" } } }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "sample-data-telemetry": { + "properties": { + "installCount": { + "type": "long" + }, + "unInstallCount": { + "type": "long" + } + } + }, "search": { - "dynamic": "strict", "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -138,16 +291,47 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "dynamic": "strict", + "dynamic": "false", + "type": "object" + }, + "telemetry": { "properties": { - "uuid": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { "type": "keyword" + }, + "reportFailureCount": { + "type": "integer" + }, + "reportFailureVersion": { + "type": "keyword" + }, + "sendUsageFrom": { + "type": "keyword" + }, + "userHasSeenNotice": { + "type": "boolean" } } }, + "test-deprecations-plugin": { + "dynamic": "false", + "type": "object" + }, "timelion-sheet": { - "dynamic": "strict", "properties": { "description": { "type": "text" @@ -191,8 +375,24 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "updated_at": { + "type": "date" + }, "url": { - "dynamic": "strict", "properties": { "accessCount": { "type": "long" @@ -214,8 +414,15 @@ } } }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" + } + } + }, "visualization": { - "dynamic": "strict", "properties": { "description": { "type": "text" @@ -223,59 +430,28 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { - "type": "text" - } - } - }, - "query": { - "properties": { - "title": { - "type": "text" - }, - "description": { - "type": "text" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "type": "keyword", - "index": false - } - } - }, - "filters": { - "type": "object", - "enabled": false - }, - "timefilter": { - "type": "object", - "enabled": false - } - } - }, - "test-deprecations-plugin": { - "properties": { - "title": { + "index": false, "type": "text" } } @@ -284,9 +460,13 @@ }, "settings": { "index": { + "auto_expand_replicas": "0-1", "number_of_replicas": "0", - "number_of_shards": "1" + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" } } } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/discover/data.json b/test/functional/fixtures/es_archiver/discover/data.json index 0f2edc8c510c3f..14a9f0559c6f3a 100644 --- a/test/functional/fixtures/es_archiver/discover/data.json +++ b/test/functional/fixtures/es_archiver/discover/data.json @@ -4,14 +4,21 @@ "id": "index-pattern:logstash-*", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", "index-pattern": { + "fieldAttrs": "{\"referer\":{\"customLabel\":\"Referer custom\"}}", "fields": "[{\"name\":\"@message\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@message.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"@message\"}}},{\"name\":\"@tags\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"@tags.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"@tags\"}}},{\"name\":\"@timestamp\",\"type\":\"date\",\"esTypes\":[\"date\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"agent\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"agent\"}}},{\"name\":\"bytes\",\"type\":\"number\",\"esTypes\":[\"long\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"extension\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"extension.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"extension\"}}},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"headings\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"headings.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"headings\"}}},{\"name\":\"host\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"host\"}}},{\"name\":\"id\",\"type\":\"number\",\"esTypes\":[\"integer\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"index\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"index\"}}},{\"name\":\"ip\",\"type\":\"ip\",\"esTypes\":[\"ip\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"links\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"links\"}}},{\"name\":\"machine.os\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"machine.os\"}}},{\"name\":\"machine.ram\",\"type\":\"number\",\"esTypes\":[\"long\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"memory\",\"type\":\"number\",\"esTypes\":[\"double\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.char\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"esTypes\":[\"integer\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"nestedField.child\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"nested\":{\"path\":\"nestedField\"}}},{\"name\":\"phpmemory\",\"type\":\"number\",\"esTypes\":[\"long\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"referer\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"esTypes\":[\"date\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"esTypes\":[\"date\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.article:section\"}}},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.article:tag\"}}},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:description\"}}},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:image\"}}},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:image:height\"}}},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:image:width\"}}},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:site_name\"}}},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:title\"}}},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:type\"}}},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.og:url\"}}},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.twitter:card\"}}},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.twitter:description\"}}},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.twitter:image\"}}},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.twitter:site\"}}},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.twitter:title\"}}},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"relatedContent.url\"}}},{\"name\":\"request\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"request.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"request\"}}},{\"name\":\"response\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"response.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"response\"}}},{\"name\":\"spaces\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"spaces.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"spaces\"}}},{\"name\":\"type\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"url\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"url.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"url\"}}},{\"name\":\"utc_time\",\"type\":\"date\",\"esTypes\":[\"date\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"xss\",\"type\":\"string\",\"esTypes\":[\"text\"],\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"xss\"}}}]", "timeFieldName": "@timestamp", - "title": "logstash-*", - "fieldAttrs": "{\"referer\":{\"customLabel\":\"Referer custom\"}}" + "title": "logstash-*" }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], "type": "index-pattern" - } + }, + "type": "_doc" } } @@ -21,6 +28,17 @@ "id": "search:ab12e3c0-f231-11e6-9486-733b1ac9221a", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "search": "7.9.3" + }, + "references": [ + { + "id": "logstash-*", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], "search": { "columns": [ "_source" @@ -28,16 +46,19 @@ "description": "A Saved Search Description", "hits": 0, "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\n \"index\": \"logstash-*\",\n \"highlightAll\": true,\n \"filter\": [],\n \"query\": {\n \"query_string\": {\n \"query\": \"*\",\n \"analyze_wildcard\": true\n }\n }\n}" + "searchSourceJSON": "{\"highlightAll\":true,\"filter\":[],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" }, "sort": [ - "@timestamp", - "desc" + [ + "@timestamp", + "desc" + ] ], "title": "A Saved Search", "version": 1 }, "type": "search" - } + }, + "type": "_doc" } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/discover/mappings.json b/test/functional/fixtures/es_archiver/discover/mappings.json index 519af2dd75b9e1..93d724aa556039 100644 --- a/test/functional/fixtures/es_archiver/discover/mappings.json +++ b/test/functional/fixtures/es_archiver/discover/mappings.json @@ -2,126 +2,304 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, + "dynamic": "strict", "properties": { + "application_usage_daily": { + "dynamic": "false", + "properties": { + "timestamp": { + "type": "date" + } + } + }, + "application_usage_totals": { + "dynamic": "false", + "type": "object" + }, + "application_usage_transactional": { + "dynamic": "false", + "type": "object" + }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { "buildNum": { "type": "keyword" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { - "dynamic": "strict", "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, "index-pattern": { - "dynamic": "strict", + "dynamic": "false", "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { + "title": { "type": "text" }, - "intervalName": { + "type": { "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "notExpandable": { + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { "type": "boolean" }, - "sourceFilters": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "timeFieldName": { + "targetType": { "type": "keyword" + } + } + }, + "migrationVersion": { + "dynamic": "true", + "properties": { + "index-pattern": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" }, - "title": { + "search": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, "type": "text" + } + } + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { + "properties": { + "description": { + "type": "text" + }, + "filters": { + "enabled": false, + "type": "object" + }, + "query": { + "properties": { + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" + } + } + }, + "timefilter": { + "enabled": false, + "type": "object" }, - "fieldAttrs": { + "title": { "type": "text" } } }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "sample-data-telemetry": { + "properties": { + "installCount": { + "type": "long" + }, + "unInstallCount": { + "type": "long" + } + } + }, "search": { - "dynamic": "strict", "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -132,16 +310,43 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "dynamic": "strict", + "dynamic": "false", + "type": "object" + }, + "telemetry": { "properties": { - "uuid": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { + "type": "keyword" + }, + "reportFailureCount": { + "type": "integer" + }, + "reportFailureVersion": { + "type": "keyword" + }, + "sendUsageFrom": { "type": "keyword" + }, + "userHasSeenNotice": { + "type": "boolean" } } }, "timelion-sheet": { - "dynamic": "strict", "properties": { "description": { "type": "text" @@ -185,8 +390,24 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "updated_at": { + "type": "date" + }, "url": { - "dynamic": "strict", "properties": { "accessCount": { "type": "long" @@ -208,8 +429,15 @@ } } }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" + } + } + }, "visualization": { - "dynamic": "strict", "properties": { "description": { "type": "text" @@ -217,63 +445,43 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } - }, - "query": { - "properties": { - "title": { - "type": "text" - }, - "description": { - "type": "text" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "type": "keyword", - "index": false - } - } - }, - "filters": { - "type": "object", - "enabled": false - }, - "timefilter": { - "type": "object", - "enabled": false - } - } } } }, "settings": { "index": { - "number_of_replicas": "1", - "number_of_shards": "1" + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" } } } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/data.json b/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/data.json index 7f4043958bc89b..54feabcf54331d 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/data.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/data.json @@ -1,149 +1,161 @@ { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-transform:type_1-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-transform": { - "title": "test_1-obj_1", - "enabled": true + "enabled": true, + "title": "test_1-obj_1" }, "type": "test-export-transform", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-transform:type_1-obj_2", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-transform": { - "title": "test_1-obj_2", - "enabled": true + "enabled": true, + "title": "test_1-obj_2" }, "type": "test-export-transform", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-add:type_2-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-add": { "title": "test_2-obj_1" }, "type": "test-export-add", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-add:type_2-obj_2", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-add": { "title": "test_2-obj_2" }, "type": "test-export-add", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-add-dep:type_dep-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + { + "id": "type_2-obj_1", + "type": "test-export-add" + } + ], "test-export-add-dep": { "title": "type_dep-obj_1" }, "type": "test-export-add-dep", - "migrationVersion": {}, - "updated_at": "2018-12-21T00:43:07.096Z", - "references": [ - { - "type": "test-export-add", - "id": "type_2-obj_1" - } - ] - } + "updated_at": "2018-12-21T00:43:07.096Z" + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-add-dep:type_dep-obj_2", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + { + "id": "type_2-obj_2", + "type": "test-export-add" + } + ], "test-export-add-dep": { "title": "type_dep-obj_2" }, "type": "test-export-add-dep", - "migrationVersion": {}, - "updated_at": "2018-12-21T00:43:07.096Z", - "references": [ - { - "type": "test-export-add", - "id": "type_2-obj_2" - } - ] - } + "updated_at": "2018-12-21T00:43:07.096Z" + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-invalid-transform:type_3-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-invalid-transform": { "title": "test_2-obj_1" }, "type": "test-export-invalid-transform", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-transform-error:type_4-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-transform-error": { "title": "test_2-obj_1" }, "type": "test-export-transform-error", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json index 653e6399548135..b2385a281dd239 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/export_transform/mappings.json @@ -2,333 +2,301 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", - "settings": { - "index": { - "number_of_shards": "1", - "auto_expand_replicas": "0-1", - "number_of_replicas": "0" - } - }, + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, "dynamic": "strict", "properties": { - "test-export-transform": { - "properties": { - "title": { "type": "text" }, - "enabled": { "type": "boolean" } - } - }, - "test-export-add": { - "properties": { - "title": { "type": "text" } - } - }, - "test-export-add-dep": { - "properties": { - "title": { "type": "text" } - } + "apm-telemetry": { + "dynamic": "false", + "type": "object" }, - "test-export-transform-error": { + "application_usage_daily": { + "dynamic": "false", "properties": { - "title": { "type": "text" } + "timestamp": { + "type": "date" + } } }, - "test-export-invalid-transform": { - "properties": { - "title": { "type": "text" } - } + "application_usage_totals": { + "dynamic": "false", + "type": "object" }, - "apm-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "go": { - "type": "long", - "null_value": 0 - }, - "java": { - "type": "long", - "null_value": 0 - }, - "js-base": { - "type": "long", - "null_value": 0 - }, - "nodejs": { - "type": "long", - "null_value": 0 - }, - "python": { - "type": "long", - "null_value": 0 - }, - "ruby": { - "type": "long", - "null_value": 0 - } - } - } - } + "application_usage_transactional": { + "dynamic": "false", + "type": "object" }, "canvas-workpad": { "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "id": { - "type": "text", - "index": false - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - } - } + "type": "object" }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { - "accessibility:disableAnimations": { - "type": "boolean" - }, "buildNum": { "type": "keyword" - }, - "dateFormat:tz": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "defaultIndex": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "telemetry:optIn": { - "type": "boolean" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, - "map": { + "graph-workspace": { + "dynamic": "false", + "type": "object" + }, + "index-pattern": { + "dynamic": "false", "properties": { - "bounds": { - "dynamic": false, - "properties": {} - }, - "description": { - "type": "text" - }, - "layerListJSON": { + "title": { "type": "text" }, - "mapStateJSON": { - "type": "text" + "type": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "title": { - "type": "text" + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { + "type": "boolean" }, - "uiStateJSON": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "version": { - "type": "integer" + "targetType": { + "type": "keyword" } } }, - "graph-workspace": { + "map": { + "dynamic": "false", + "type": "object" + }, + "migrationVersion": { + "dynamic": "true", + "type": "object" + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { "properties": { "description": { "type": "text" }, - "kibanaSavedObjectMeta": { + "filters": { + "enabled": false, + "type": "object" + }, + "query": { "properties": { - "searchSourceJSON": { - "type": "text" + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" } } }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" + "timefilter": { + "enabled": false, + "type": "object" }, "title": { "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" } } }, - "index-pattern": { + "references": { "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { + "id": { "type": "keyword" }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { + "name": { "type": "keyword" }, - "title": { - "type": "text" - }, "type": { "type": "keyword" - }, - "typeMeta": { - "type": "keyword" } - } + }, + "type": "nested" }, - "kql-telemetry": { + "sample-data-telemetry": { "properties": { - "optInCount": { + "installCount": { "type": "long" }, - "optOutCount": { + "unInstallCount": { "type": "long" } } }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "space": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, "search": { "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -339,50 +307,68 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } + "dynamic": "false", + "type": "object" }, "space": { + "dynamic": "false", + "type": "object" + }, + "spaceId": { + "type": "keyword" + }, + "telemetry": { "properties": { - "_reserved": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { "type": "boolean" }, - "color": { + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { "type": "keyword" }, - "description": { - "type": "text" + "reportFailureCount": { + "type": "integer" }, - "disabledFeatures": { + "reportFailureVersion": { "type": "keyword" }, - "initials": { + "sendUsageFrom": { "type": "keyword" }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } + "userHasSeenNotice": { + "type": "boolean" } } }, - "spaceId": { - "type": "keyword" + "test-export-add": { + "dynamic": "false", + "type": "object" }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - } - } + "test-export-add-dep": { + "dynamic": "false", + "type": "object" + }, + "test-export-invalid-transform": { + "dynamic": "false", + "type": "object" + }, + "test-export-transform": { + "dynamic": "false", + "type": "object" + }, + "test-export-transform-error": { + "dynamic": "false", + "type": "object" }, "timelion-sheet": { "properties": { @@ -428,6 +414,20 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, "updated_at": { "type": "date" }, @@ -443,13 +443,21 @@ "type": "date" }, "url": { - "type": "text", "fields": { "keyword": { - "type": "keyword", - "ignore_above": 2048 + "ignore_above": 2048, + "type": "keyword" } - } + }, + "type": "text" + } + } + }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" } } }, @@ -461,42 +469,43 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" } } + }, + "settings": { + "index": { + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" + } } } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/data.json b/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/data.json index 6a272dc16e462f..4996c050adbf0d 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/data.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/data.json @@ -1,29 +1,37 @@ { "type": "doc", "value": { - "index": ".kibana", "id": "test-hidden-importable-exportable:ff3733a0-9fty-11e7-ahb3-3dcb94193fab", + "index": ".kibana", "source": { - "type": "test-hidden-importable-exportable", - "updated_at": "2021-02-11T18:51:23.794Z", + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-hidden-importable-exportable": { "title": "Hidden Saved object type that is importable/exportable." - } - } + }, + "type": "test-hidden-importable-exportable", + "updated_at": "2021-02-11T18:51:23.794Z" + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", "id": "test-hidden-non-importable-exportable:op3767a1-9rcg-53u7-jkb3-3dnb74193awc", + "index": ".kibana", "source": { - "type": "test-hidden-non-importable-exportable", - "updated_at": "2021-02-11T18:51:23.794Z", + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-hidden-non-importable-exportable": { "title": "Hidden Saved object type that is not importable/exportable." - } - } + }, + "type": "test-hidden-non-importable-exportable", + "updated_at": "2021-02-11T18:51:23.794Z" + }, + "type": "_doc" } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json index a158deb527cc83..d59f3b00d48182 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/hidden_saved_objects/mappings.json @@ -2,333 +2,301 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", - "settings": { - "index": { - "number_of_shards": "1", - "auto_expand_replicas": "0-1", - "number_of_replicas": "0" - } - }, + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, "dynamic": "strict", "properties": { - "test-export-transform": { - "properties": { - "title": { "type": "text" }, - "enabled": { "type": "boolean" } - } - }, - "test-export-add": { - "properties": { - "title": { "type": "text" } - } - }, - "test-export-add-dep": { - "properties": { - "title": { "type": "text" } - } + "apm-telemetry": { + "dynamic": "false", + "type": "object" }, - "test-export-transform-error": { + "application_usage_daily": { + "dynamic": "false", "properties": { - "title": { "type": "text" } + "timestamp": { + "type": "date" + } } }, - "test-export-invalid-transform": { - "properties": { - "title": { "type": "text" } - } + "application_usage_totals": { + "dynamic": "false", + "type": "object" }, - "apm-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "go": { - "type": "long", - "null_value": 0 - }, - "java": { - "type": "long", - "null_value": 0 - }, - "js-base": { - "type": "long", - "null_value": 0 - }, - "nodejs": { - "type": "long", - "null_value": 0 - }, - "python": { - "type": "long", - "null_value": 0 - }, - "ruby": { - "type": "long", - "null_value": 0 - } - } - } - } + "application_usage_transactional": { + "dynamic": "false", + "type": "object" }, "canvas-workpad": { "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "id": { - "type": "text", - "index": false - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - } - } + "type": "object" }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { - "accessibility:disableAnimations": { - "type": "boolean" - }, "buildNum": { "type": "keyword" - }, - "dateFormat:tz": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "defaultIndex": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "telemetry:optIn": { - "type": "boolean" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, - "map": { + "graph-workspace": { + "dynamic": "false", + "type": "object" + }, + "index-pattern": { + "dynamic": "false", "properties": { - "bounds": { - "dynamic": false, - "properties": {} - }, - "description": { - "type": "text" - }, - "layerListJSON": { + "title": { "type": "text" }, - "mapStateJSON": { - "type": "text" + "type": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "title": { - "type": "text" + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { + "type": "boolean" }, - "uiStateJSON": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "version": { - "type": "integer" + "targetType": { + "type": "keyword" } } }, - "graph-workspace": { + "map": { + "dynamic": "false", + "type": "object" + }, + "migrationVersion": { + "dynamic": "true", + "type": "object" + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { "properties": { "description": { "type": "text" }, - "kibanaSavedObjectMeta": { + "filters": { + "enabled": false, + "type": "object" + }, + "query": { "properties": { - "searchSourceJSON": { - "type": "text" + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" } } }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" + "timefilter": { + "enabled": false, + "type": "object" }, "title": { "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" } } }, - "index-pattern": { + "references": { "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { + "id": { "type": "keyword" }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { + "name": { "type": "keyword" }, - "title": { - "type": "text" - }, "type": { "type": "keyword" - }, - "typeMeta": { - "type": "keyword" } - } + }, + "type": "nested" }, - "kql-telemetry": { + "sample-data-telemetry": { "properties": { - "optInCount": { + "installCount": { "type": "long" }, - "optOutCount": { + "unInstallCount": { "type": "long" } } }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "space": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, "search": { "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -339,50 +307,76 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } + "dynamic": "false", + "type": "object" }, "space": { + "dynamic": "false", + "type": "object" + }, + "spaceId": { + "type": "keyword" + }, + "telemetry": { "properties": { - "_reserved": { + "allowChangingOptInStatus": { "type": "boolean" }, - "color": { + "enabled": { + "type": "boolean" + }, + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { "type": "keyword" }, - "description": { - "type": "text" + "reportFailureCount": { + "type": "integer" }, - "disabledFeatures": { + "reportFailureVersion": { "type": "keyword" }, - "initials": { + "sendUsageFrom": { "type": "keyword" }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } + "userHasSeenNotice": { + "type": "boolean" } } }, - "spaceId": { - "type": "keyword" + "test-export-add": { + "dynamic": "false", + "type": "object" }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - } - } + "test-export-add-dep": { + "dynamic": "false", + "type": "object" + }, + "test-export-invalid-transform": { + "dynamic": "false", + "type": "object" + }, + "test-export-transform": { + "dynamic": "false", + "type": "object" + }, + "test-export-transform-error": { + "dynamic": "false", + "type": "object" + }, + "test-hidden-importable-exportable": { + "dynamic": "false", + "type": "object" + }, + "test-hidden-non-importable-exportable": { + "dynamic": "false", + "type": "object" }, "timelion-sheet": { "properties": { @@ -428,6 +422,20 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, "updated_at": { "type": "date" }, @@ -443,13 +451,21 @@ "type": "date" }, "url": { - "type": "text", "fields": { "keyword": { - "type": "keyword", - "ignore_above": 2048 + "ignore_above": 2048, + "type": "keyword" } - } + }, + "type": "text" + } + } + }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" } } }, @@ -461,56 +477,43 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "test-hidden-non-importable-exportable": { - "properties": { - "title": { - "type": "text" - } - } - }, - "test-hidden-importable-exportable": { - "properties": { - "title": { + "index": false, "type": "text" } } } } + }, + "settings": { + "index": { + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" + } } } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/data.json b/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/data.json index caac89461b9ef0..3c311b0465193a 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/data.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/data.json @@ -1,87 +1,91 @@ { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-transform:type_1-obj_1", + "index": ".kibana", "source": { - "test-export-transform": { - "title": "test_1-obj_1", - "enabled": true - }, - "type": "test-export-transform", - "migrationVersion": {}, - "updated_at": "2018-12-21T00:43:07.096Z", + "coreMigrationVersion": "7.14.0", "references": [ { - "type": "test-export-transform", "id": "type_1-obj_2", - "name": "ref-1" + "name": "ref-1", + "type": "test-export-transform" }, { - "type": "test-export-add", "id": "type_2-obj_1", - "name": "ref-2" + "name": "ref-2", + "type": "test-export-add" } - ] - } + ], + "test-export-transform": { + "enabled": true, + "title": "test_1-obj_1" + }, + "type": "test-export-transform", + "updated_at": "2018-12-21T00:43:07.096Z" + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-transform:type_1-obj_2", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-transform": { - "title": "test_1-obj_2", - "enabled": true + "enabled": true, + "title": "test_1-obj_2" }, "type": "test-export-transform", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-add:type_2-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + ], "test-export-add": { "title": "test_2-obj_1" }, "type": "test-export-add", - "migrationVersion": {}, "updated_at": "2018-12-21T00:43:07.096Z" - } + }, + "type": "_doc" } } { "type": "doc", "value": { - "index": ".kibana", - "type": "doc", "id": "test-export-add-dep:type_dep-obj_1", + "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "references": [ + { + "id": "type_2-obj_1", + "type": "test-export-add" + } + ], "test-export-add-dep": { "title": "type_dep-obj_1" }, "type": "test-export-add-dep", - "migrationVersion": {}, - "updated_at": "2018-12-21T00:43:07.096Z", - "references": [ - { - "type": "test-export-add", - "id": "type_2-obj_1" - } - ] - } + "updated_at": "2018-12-21T00:43:07.096Z" + }, + "type": "_doc" } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json b/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json index 653e6399548135..b2385a281dd239 100644 --- a/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json +++ b/test/functional/fixtures/es_archiver/saved_objects_management/nested_export_transform/mappings.json @@ -2,333 +2,301 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", - "settings": { - "index": { - "number_of_shards": "1", - "auto_expand_replicas": "0-1", - "number_of_replicas": "0" - } - }, + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, "dynamic": "strict", "properties": { - "test-export-transform": { - "properties": { - "title": { "type": "text" }, - "enabled": { "type": "boolean" } - } - }, - "test-export-add": { - "properties": { - "title": { "type": "text" } - } - }, - "test-export-add-dep": { - "properties": { - "title": { "type": "text" } - } + "apm-telemetry": { + "dynamic": "false", + "type": "object" }, - "test-export-transform-error": { + "application_usage_daily": { + "dynamic": "false", "properties": { - "title": { "type": "text" } + "timestamp": { + "type": "date" + } } }, - "test-export-invalid-transform": { - "properties": { - "title": { "type": "text" } - } + "application_usage_totals": { + "dynamic": "false", + "type": "object" }, - "apm-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "go": { - "type": "long", - "null_value": 0 - }, - "java": { - "type": "long", - "null_value": 0 - }, - "js-base": { - "type": "long", - "null_value": 0 - }, - "nodejs": { - "type": "long", - "null_value": 0 - }, - "python": { - "type": "long", - "null_value": 0 - }, - "ruby": { - "type": "long", - "null_value": 0 - } - } - } - } + "application_usage_transactional": { + "dynamic": "false", + "type": "object" }, "canvas-workpad": { "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "id": { - "type": "text", - "index": false - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - } - } + "type": "object" }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { - "accessibility:disableAnimations": { - "type": "boolean" - }, "buildNum": { "type": "keyword" - }, - "dateFormat:tz": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "defaultIndex": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "telemetry:optIn": { - "type": "boolean" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, - "map": { + "graph-workspace": { + "dynamic": "false", + "type": "object" + }, + "index-pattern": { + "dynamic": "false", "properties": { - "bounds": { - "dynamic": false, - "properties": {} - }, - "description": { - "type": "text" - }, - "layerListJSON": { + "title": { "type": "text" }, - "mapStateJSON": { - "type": "text" + "type": { + "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "title": { - "type": "text" + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { + "type": "boolean" }, - "uiStateJSON": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "version": { - "type": "integer" + "targetType": { + "type": "keyword" } } }, - "graph-workspace": { + "map": { + "dynamic": "false", + "type": "object" + }, + "migrationVersion": { + "dynamic": "true", + "type": "object" + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { "properties": { "description": { "type": "text" }, - "kibanaSavedObjectMeta": { + "filters": { + "enabled": false, + "type": "object" + }, + "query": { "properties": { - "searchSourceJSON": { - "type": "text" + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" } } }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" + "timefilter": { + "enabled": false, + "type": "object" }, "title": { "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" } } }, - "index-pattern": { + "references": { "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { + "id": { "type": "keyword" }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { + "name": { "type": "keyword" }, - "title": { - "type": "text" - }, "type": { "type": "keyword" - }, - "typeMeta": { - "type": "keyword" } - } + }, + "type": "nested" }, - "kql-telemetry": { + "sample-data-telemetry": { "properties": { - "optInCount": { + "installCount": { "type": "long" }, - "optOutCount": { + "unInstallCount": { "type": "long" } } }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - }, - "space": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, "search": { "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -339,50 +307,68 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } + "dynamic": "false", + "type": "object" }, "space": { + "dynamic": "false", + "type": "object" + }, + "spaceId": { + "type": "keyword" + }, + "telemetry": { "properties": { - "_reserved": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { "type": "boolean" }, - "color": { + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { "type": "keyword" }, - "description": { - "type": "text" + "reportFailureCount": { + "type": "integer" }, - "disabledFeatures": { + "reportFailureVersion": { "type": "keyword" }, - "initials": { + "sendUsageFrom": { "type": "keyword" }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } + "userHasSeenNotice": { + "type": "boolean" } } }, - "spaceId": { - "type": "keyword" + "test-export-add": { + "dynamic": "false", + "type": "object" }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - } - } + "test-export-add-dep": { + "dynamic": "false", + "type": "object" + }, + "test-export-invalid-transform": { + "dynamic": "false", + "type": "object" + }, + "test-export-transform": { + "dynamic": "false", + "type": "object" + }, + "test-export-transform-error": { + "dynamic": "false", + "type": "object" }, "timelion-sheet": { "properties": { @@ -428,6 +414,20 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, "updated_at": { "type": "date" }, @@ -443,13 +443,21 @@ "type": "date" }, "url": { - "type": "text", "fields": { "keyword": { - "type": "keyword", - "ignore_above": 2048 + "ignore_above": 2048, + "type": "keyword" } - } + }, + "type": "text" + } + } + }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" } } }, @@ -461,42 +469,43 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" } } + }, + "settings": { + "index": { + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" + } } } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/visualize/data.json b/test/functional/fixtures/es_archiver/visualize/data.json index f337bffe80f2cd..d48aa3e98d18a8 100644 --- a/test/functional/fixtures/es_archiver/visualize/data.json +++ b/test/functional/fixtures/es_archiver/visualize/data.json @@ -4,15 +4,22 @@ "id": "index-pattern:logstash-*", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", "index-pattern": { + "fieldAttrs": "{\"utc_time\":{\"customLabel\":\"UTC time\"}}", "fieldFormatMap": "{\"bytes\":{\"id\":\"bytes\"}}", "fields": "[{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@message.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]", "timeFieldName": "@timestamp", - "title": "logstash-*", - "fieldAttrs": "{\"utc_time\":{\"customLabel\":\"UTC time\"}}" + "title": "logstash-*" }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], "type": "index-pattern" - } + }, + "type": "_doc" } } @@ -22,13 +29,20 @@ "id": "index-pattern:logstash*", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", "index-pattern": { "fieldFormatMap": "{\"bytes\":{\"id\":\"bytes\"}}", "fields": "[{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@message.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]", "title": "logstash*" }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], "type": "index-pattern" - } + }, + "type": "_doc" } } @@ -38,14 +52,21 @@ "id": "index-pattern:long-window-logstash-*", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", "index-pattern": { "fieldFormatMap": "{\"bytes\":{\"id\":\"bytes\"}}", "fields": "[{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@message.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]", "timeFieldName": "@timestamp", "title": "long-window-logstash-*" }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], "type": "index-pattern" - } + }, + "type": "_doc" } } @@ -55,18 +76,30 @@ "id": "visualization:Shared-Item-Visualization-AreaChart", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "logstash-*", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], "type": "visualization", "visualization": { "description": "AreaChart", "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"logstash-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + "searchSourceJSON": "{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" }, "title": "Shared-Item Visualization AreaChart", "uiStateJSON": "{}", "version": 1, - "visState": "{\"title\":\"New Visualization\",\"type\":\"area\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"smoothLines\":false,\"scale\":\"linear\",\"interpolate\":\"linear\",\"mode\":\"stacked\",\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}" + "visState": "{\"title\":\"New Visualization\",\"type\":\"area\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"smoothLines\":false,\"scale\":\"linear\",\"interpolate\":\"linear\",\"mode\":\"stacked\",\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}" } - } + }, + "type": "_doc" } } @@ -76,18 +109,30 @@ "id": "visualization:Visualization-AreaChart", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "logstash-*", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], "type": "visualization", "visualization": { "description": "AreaChart", "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"logstash-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + "searchSourceJSON": "{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" }, "title": "Visualization AreaChart", "uiStateJSON": "{}", "version": 1, - "visState": "{\"title\":\"Visualization AreaChart\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"filter\":true,\"truncate\":100},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":true,\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"lineWidth\":2,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"thresholdLine\":{\"show\":false,\"value\":10,\"width\":1,\"style\":\"full\",\"color\":\"#E7664C\"},\"labels\":{}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"timeRange\":{\"from\":\"now-15m\",\"to\":\"now\"},\"useNormalizedEsInterval\":true,\"scaleMetricValues\":false,\"interval\":\"auto\",\"drop_partials\":false,\"min_doc_count\":1,\"extended_bounds\":{}}}]}" + "visState": "{\"title\":\"Visualization AreaChart\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":false},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"filter\":true,\"truncate\":100},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":true,\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"lineWidth\":2,\"showCircles\":true,\"interpolate\":\"linear\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false,\"thresholdLine\":{\"show\":false,\"value\":10,\"width\":1,\"style\":\"full\",\"color\":\"#E7664C\"},\"labels\":{},\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"timeRange\":{\"from\":\"now-15m\",\"to\":\"now\"},\"useNormalizedEsInterval\":true,\"scaleMetricValues\":false,\"interval\":\"auto\",\"drop_partials\":false,\"min_doc_count\":1,\"extended_bounds\":{}}}]}" } - } + }, + "type": "_doc" } } @@ -97,34 +142,36 @@ "id": "visualization:68305470-87bc-11e9-a991-3b492a7c3e09", "index": ".kibana", "source": { - "visualization" : { - "title" : "chained input control", - "visState" : "{\"title\":\"chained input control\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1559757816862\",\"fieldName\":\"geo.src\",\"parent\":\"\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1559757836347\",\"fieldName\":\"clientip\",\"parent\":\"1559757816862\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_1_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}", - "uiStateJSON" : "{}", - "description" : "", - "version" : 1, - "kibanaSavedObjectMeta" : { - "searchSourceJSON" : "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" - } + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" }, - "type" : "visualization", - "references" : [ + "references": [ { - "name" : "control_0_index_pattern", - "type" : "index-pattern", - "id" : "logstash-*" + "id": "logstash-*", + "name": "control_0_index_pattern", + "type": "index-pattern" }, { - "name" : "control_1_index_pattern", - "type" : "index-pattern", - "id" : "logstash-*" + "id": "logstash-*", + "name": "control_1_index_pattern", + "type": "index-pattern" } ], - "migrationVersion" : { - "visualization" : "7.3.0" - }, - "updated_at" : "2019-06-05T18:04:48.310Z" - } + "type": "visualization", + "updated_at": "2019-06-05T18:04:48.310Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" + }, + "title": "chained input control", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"chained input control\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1559757816862\",\"fieldName\":\"geo.src\",\"parent\":\"\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1559757836347\",\"fieldName\":\"clientip\",\"parent\":\"1559757816862\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_1_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}" + } + }, + "type": "_doc" } } @@ -134,29 +181,31 @@ "id": "visualization:64983230-87bf-11e9-a991-3b492a7c3e09", "index": ".kibana", "source": { - "visualization" : { - "title" : "dynamic options input control", - "visState" : "{\"title\":\"dynamic options input control\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1559759127876\",\"fieldName\":\"geo.src\",\"parent\":\"\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}", - "uiStateJSON" : "{}", - "description" : "", - "version" : 1, - "kibanaSavedObjectMeta" : { - "searchSourceJSON" : "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" - } + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" }, - "type" : "visualization", - "references" : [ + "references": [ { - "name" : "control_0_index_pattern", - "type" : "index-pattern", - "id" : "logstash-*" + "id": "logstash-*", + "name": "control_0_index_pattern", + "type": "index-pattern" } ], - "migrationVersion" : { - "visualization" : "7.3.0" - }, - "updated_at" : "2019-06-05T18:26:10.771Z" - } + "type": "visualization", + "updated_at": "2019-06-05T18:26:10.771Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" + }, + "title": "dynamic options input control", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"dynamic options input control\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1559759127876\",\"fieldName\":\"geo.src\",\"parent\":\"\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}" + } + }, + "type": "_doc" } } @@ -166,34 +215,36 @@ "id": "visualization:5d2de430-87c0-11e9-a991-3b492a7c3e09", "index": ".kibana", "source": { - "visualization" : { - "title" : "chained input control with dynamic options", - "visState" : "{\"title\":\"chained input control with dynamic options\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1559759550755\",\"fieldName\":\"machine.os.raw\",\"parent\":\"\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1559759557302\",\"fieldName\":\"geo.src\",\"parent\":\"1559759550755\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_1_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}", - "uiStateJSON" : "{}", - "description" : "", - "version" : 1, - "kibanaSavedObjectMeta" : { - "searchSourceJSON" : "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" - } + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" }, - "type" : "visualization", - "references" : [ + "references": [ { - "name" : "control_0_index_pattern", - "type" : "index-pattern", - "id" : "logstash-*" + "id": "logstash-*", + "name": "control_0_index_pattern", + "type": "index-pattern" }, { - "name" : "control_1_index_pattern", - "type" : "index-pattern", - "id" : "logstash-*" + "id": "logstash-*", + "name": "control_1_index_pattern", + "type": "index-pattern" } ], - "migrationVersion" : { - "visualization" : "7.3.0" - }, - "updated_at" : "2019-06-05T18:33:07.827Z" - } + "type": "visualization", + "updated_at": "2019-06-05T18:33:07.827Z", + "visualization": { + "description": "", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" + }, + "title": "chained input control with dynamic options", + "uiStateJSON": "{}", + "version": 1, + "visState": "{\"title\":\"chained input control with dynamic options\",\"type\":\"input_control_vis\",\"params\":{\"controls\":[{\"id\":\"1559759550755\",\"fieldName\":\"machine.os.raw\",\"parent\":\"\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_0_index_pattern\"},{\"id\":\"1559759557302\",\"fieldName\":\"geo.src\",\"parent\":\"1559759550755\",\"label\":\"\",\"type\":\"list\",\"options\":{\"type\":\"terms\",\"multiselect\":true,\"dynamicOptions\":true,\"size\":5,\"order\":\"desc\"},\"indexPatternRefName\":\"control_1_index_pattern\"}],\"updateFiltersOnChange\":false,\"useTimeFilter\":false,\"pinFilters\":false},\"aggs\":[]}" + } + }, + "type": "_doc" } } @@ -203,12 +254,19 @@ "id": "index-pattern:test_index*", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", "index-pattern": { "fields": "[{\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"esTypes\":[\"_type\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"message\",\"type\":\"string\",\"esTypes\":[\"text\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"message.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"message\"}}},{\"name\":\"user\",\"type\":\"string\",\"esTypes\":[\"text\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"user.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"user\"}}}]", "title": "test_index*" }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], "type": "index-pattern" - } + }, + "type": "_doc" } } @@ -218,18 +276,30 @@ "id": "visualization:AreaChart-no-date-field", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "test_index*", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], "type": "visualization", "visualization": { "description": "AreaChart", "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"test_index*\",\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" }, "title": "AreaChart [no date field]", "uiStateJSON": "{}", "version": 1, - "visState": "{\"title\":\"AreaChart [no date field]\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"addTooltip\":true,\"addLegend\":true,\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" - } - } + "visState": "{\"title\":\"AreaChart [no date field]\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"addTooltip\":true,\"addLegend\":true,\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" + } + }, + "type": "_doc" } } @@ -239,13 +309,20 @@ "id": "index-pattern:log*", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", "index-pattern": { "fieldFormatMap": "{\"bytes\":{\"id\":\"bytes\"}}", "fields": "[{\"name\":\"referer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"xss.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.lastname\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.dest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"utc_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.char\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"clientip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"machine.ram\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"links\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"phpmemory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.twitter:card.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:modified_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:site_name.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"agent.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"headings\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.og:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"request\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"index.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"memory\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"relatedContent.twitter:site\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.coordinates\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"meta.related\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@message.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.article:section\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"xss\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"links.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"geo.srcdest\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"extension.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"machine.os.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"host.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:type.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"geo.src\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"spaces.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:image:height.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"url\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:site_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:title\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"@message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.twitter:image.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"bytes\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"meta.user.firstname\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"relatedContent.og:image:width.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.og:description.raw\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"relatedContent.article:published_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]", "title": "log*" }, + "migrationVersion": { + "index-pattern": "7.11.0" + }, + "references": [ + ], "type": "index-pattern" - } + }, + "type": "_doc" } } @@ -255,18 +332,30 @@ "id": "visualization:AreaChart-no-time-filter", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + { + "id": "log*", + "name": "kibanaSavedObjectMeta.searchSourceJSON.index", + "type": "index-pattern" + } + ], "type": "visualization", "visualization": { "description": "AreaChart", "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"log*\",\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}" + "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}" }, "title": "AreaChart [no time filter]", "uiStateJSON": "{}", "version": 1, - "visState": "{\"title\":\"AreaChart [no time filter]\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"addTooltip\":true,\"addLegend\":true,\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" - } - } + "visState": "{\"title\":\"AreaChart [no time filter]\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"addTooltip\":true,\"addLegend\":true,\"times\":[],\"addTimeMarker\":false,\"palette\":{\"type\":\"palette\",\"name\":\"kibana_palette\"},\"isVislibVis\":true,\"detailedTooltip\":true,\"fittingFunction\":\"zero\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}" + } + }, + "type": "_doc" } } @@ -276,6 +365,12 @@ "id": "visualization:VegaMap", "index": ".kibana", "source": { + "coreMigrationVersion": "7.14.0", + "migrationVersion": { + "visualization": "7.14.0" + }, + "references": [ + ], "type": "visualization", "visualization": { "description": "VegaMap", @@ -287,6 +382,7 @@ "version": 1, "visState": "{\"aggs\":[],\"params\":{\"spec\":\"{\\n $schema: https://vega.github.io/schema/vega/v5.json\\n config: {\\n kibana: {type: \\\"map\\\", latitude: 25, longitude: -70, zoom: 3}\\n }\\n data: [\\n {\\n name: table\\n url: {\\n index: kibana_sample_data_flights\\n %context%: true\\n // Uncomment to enable time filtering\\n // %timefield%: timestamp\\n body: {\\n size: 0\\n aggs: {\\n origins: {\\n terms: {field: \\\"OriginAirportID\\\", size: 10000}\\n aggs: {\\n originLocation: {\\n top_hits: {\\n size: 1\\n _source: {\\n includes: [\\\"OriginLocation\\\", \\\"Origin\\\"]\\n }\\n }\\n }\\n distinations: {\\n terms: {field: \\\"DestAirportID\\\", size: 10000}\\n aggs: {\\n destLocation: {\\n top_hits: {\\n size: 1\\n _source: {\\n includes: [\\\"DestLocation\\\"]\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n format: {property: \\\"aggregations.origins.buckets\\\"}\\n transform: [\\n {\\n type: geopoint\\n projection: projection\\n fields: [\\n originLocation.hits.hits[0]._source.OriginLocation.lon\\n originLocation.hits.hits[0]._source.OriginLocation.lat\\n ]\\n }\\n ]\\n }\\n {\\n name: selectedDatum\\n on: [\\n {trigger: \\\"!selected\\\", remove: true}\\n {trigger: \\\"selected\\\", insert: \\\"selected\\\"}\\n ]\\n }\\n ]\\n signals: [\\n {\\n name: selected\\n value: null\\n on: [\\n {events: \\\"@airport:mouseover\\\", update: \\\"datum\\\"}\\n {events: \\\"@airport:mouseout\\\", update: \\\"null\\\"}\\n ]\\n }\\n ]\\n scales: [\\n {\\n name: airportSize\\n type: linear\\n domain: {data: \\\"table\\\", field: \\\"doc_count\\\"}\\n range: [\\n {signal: \\\"zoom*zoom*0.2+1\\\"}\\n {signal: \\\"zoom*zoom*10+1\\\"}\\n ]\\n }\\n ]\\n marks: [\\n {\\n type: group\\n from: {\\n facet: {\\n name: facetedDatum\\n data: selectedDatum\\n field: distinations.buckets\\n }\\n }\\n data: [\\n {\\n name: facetDatumElems\\n source: facetedDatum\\n transform: [\\n {\\n type: geopoint\\n projection: projection\\n fields: [\\n destLocation.hits.hits[0]._source.DestLocation.lon\\n destLocation.hits.hits[0]._source.DestLocation.lat\\n ]\\n }\\n {type: \\\"formula\\\", expr: \\\"{x:parent.x, y:parent.y}\\\", as: \\\"source\\\"}\\n {type: \\\"formula\\\", expr: \\\"{x:datum.x, y:datum.y}\\\", as: \\\"target\\\"}\\n {type: \\\"linkpath\\\", shape: \\\"diagonal\\\"}\\n ]\\n }\\n ]\\n scales: [\\n {\\n name: lineThickness\\n type: log\\n clamp: true\\n range: [1, 8]\\n }\\n {\\n name: lineOpacity\\n type: log\\n clamp: true\\n range: [0.2, 0.8]\\n }\\n ]\\n marks: [\\n {\\n from: {data: \\\"facetDatumElems\\\"}\\n type: path\\n interactive: false\\n encode: {\\n update: {\\n path: {field: \\\"path\\\"}\\n stroke: {value: \\\"black\\\"}\\n strokeWidth: {scale: \\\"lineThickness\\\", field: \\\"doc_count\\\"}\\n strokeOpacity: {scale: \\\"lineOpacity\\\", field: \\\"doc_count\\\"}\\n }\\n }\\n }\\n ]\\n }\\n {\\n name: airport\\n type: symbol\\n from: {data: \\\"table\\\"}\\n encode: {\\n update: {\\n size: {scale: \\\"airportSize\\\", field: \\\"doc_count\\\"}\\n xc: {signal: \\\"datum.x\\\"}\\n yc: {signal: \\\"datum.y\\\"}\\n tooltip: {\\n signal: \\\"{title: datum.originLocation.hits.hits[0]._source.Origin + ' (' + datum.key + ')', connnections: length(datum.distinations.buckets), flights: datum.doc_count}\\\"\\n }\\n }\\n }\\n }\\n ]\\n}\"},\"title\":\"[Flights] Airport Connections (Hover Over Airport)\",\"type\":\"vega\"}" } - } + }, + "type": "_doc" } -} +} \ No newline at end of file diff --git a/test/functional/fixtures/es_archiver/visualize/mappings.json b/test/functional/fixtures/es_archiver/visualize/mappings.json index 59ec24853e2270..d032352d9a6886 100644 --- a/test/functional/fixtures/es_archiver/visualize/mappings.json +++ b/test/functional/fixtures/es_archiver/visualize/mappings.json @@ -2,126 +2,304 @@ "type": "index", "value": { "aliases": { + ".kibana_$KIBANA_PACKAGE_VERSION": {}, ".kibana": {} }, - "index": ".kibana_1", + "index": ".kibana_$KIBANA_PACKAGE_VERSION_001", "mappings": { + "_meta": { + "migrationMappingPropertyHashes": { + "application_usage_daily": "43b8830d5d0df85a6823d290885fc9fd", + "application_usage_totals": "3d1b76c39bfb2cc8296b024d73854724", + "application_usage_transactional": "3d1b76c39bfb2cc8296b024d73854724", + "config": "c63748b75f39d0c54de12d12c1ccbc20", + "core-usage-stats": "3d1b76c39bfb2cc8296b024d73854724", + "coreMigrationVersion": "2f4316de49999235636386fe51dc06c1", + "dashboard": "40554caf09725935e2c02e02563a2d07", + "index-pattern": "45915a1ad866812242df474eb0479052", + "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", + "legacy-url-alias": "6155300fd11a00e23d5cbaa39f0fce0a", + "migrationVersion": "4a1746014a75ade3a714e1db5763276f", + "namespace": "2f4316de49999235636386fe51dc06c1", + "namespaces": "2f4316de49999235636386fe51dc06c1", + "originId": "2f4316de49999235636386fe51dc06c1", + "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", + "references": "7997cf5a56cc02bdc9c93361bde732b0", + "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", + "search": "db2c00e39b36f40930a3b9fc71c823e1", + "search-telemetry": "3d1b76c39bfb2cc8296b024d73854724", + "telemetry": "36a616f7026dfa617d6655df850fe16d", + "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", + "type": "2f4316de49999235636386fe51dc06c1", + "ui-counter": "0d409297dc5ebe1e3a1da691c6ee32e3", + "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", + "updated_at": "00da57df13e94e9d98437d13ace4bfe0", + "url": "c7f66a0df8b1b52f17c28c4adb111105", + "usage-counters": "8cc260bdceffec4ffc3ad165c97dc1b4", + "visualization": "f819cf6636b75c9e76ba733a0c6ef355" + } + }, + "dynamic": "strict", "properties": { + "application_usage_daily": { + "dynamic": "false", + "properties": { + "timestamp": { + "type": "date" + } + } + }, + "application_usage_totals": { + "dynamic": "false", + "type": "object" + }, + "application_usage_transactional": { + "dynamic": "false", + "type": "object" + }, "config": { - "dynamic": "true", + "dynamic": "false", "properties": { "buildNum": { "type": "keyword" } } }, + "core-usage-stats": { + "dynamic": "false", + "type": "object" + }, + "coreMigrationVersion": { + "type": "keyword" + }, "dashboard": { - "dynamic": "strict", "properties": { "description": { "type": "text" }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "optionsJSON": { + "index": false, "type": "text" }, "panelsJSON": { + "index": false, "type": "text" }, "refreshInterval": { "properties": { "display": { + "doc_values": false, + "index": false, "type": "keyword" }, "pause": { + "doc_values": false, + "index": false, "type": "boolean" }, "section": { + "doc_values": false, + "index": false, "type": "integer" }, "value": { + "doc_values": false, + "index": false, "type": "integer" } } }, "timeFrom": { + "doc_values": false, + "index": false, "type": "keyword" }, "timeRestore": { + "doc_values": false, + "index": false, "type": "boolean" }, "timeTo": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, - "uiStateJSON": { - "type": "text" - }, "version": { "type": "integer" } } }, "index-pattern": { - "dynamic": "strict", + "dynamic": "false", "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { + "title": { "type": "text" }, - "intervalName": { + "type": { "type": "keyword" + } + } + }, + "kql-telemetry": { + "properties": { + "optInCount": { + "type": "long" }, - "notExpandable": { + "optOutCount": { + "type": "long" + } + } + }, + "legacy-url-alias": { + "dynamic": "false", + "properties": { + "disabled": { "type": "boolean" }, - "sourceFilters": { - "type": "text" + "sourceId": { + "type": "keyword" }, - "timeFieldName": { + "targetType": { "type": "keyword" + } + } + }, + "migrationVersion": { + "dynamic": "true", + "properties": { + "index-pattern": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" }, - "title": { + "visualization": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "namespace": { + "type": "keyword" + }, + "namespaces": { + "type": "keyword" + }, + "originId": { + "type": "keyword" + }, + "query": { + "properties": { + "description": { "type": "text" }, - "fieldAttrs": { + "filters": { + "enabled": false, + "type": "object" + }, + "query": { + "properties": { + "language": { + "type": "keyword" + }, + "query": { + "index": false, + "type": "keyword" + } + } + }, + "timefilter": { + "enabled": false, + "type": "object" + }, + "title": { "type": "text" } } }, + "references": { + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + }, + "type": "nested" + }, + "sample-data-telemetry": { + "properties": { + "installCount": { + "type": "long" + }, + "unInstallCount": { + "type": "long" + } + } + }, "search": { - "dynamic": "strict", "properties": { "columns": { + "doc_values": false, + "index": false, "type": "keyword" }, "description": { "type": "text" }, + "grid": { + "enabled": false, + "type": "object" + }, + "hideChart": { + "doc_values": false, + "index": false, + "type": "boolean" + }, "hits": { + "doc_values": false, + "index": false, "type": "integer" }, "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, "sort": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { @@ -132,16 +310,43 @@ } } }, + "search-telemetry": { + "dynamic": "false", + "type": "object" + }, "server": { - "dynamic": "strict", + "dynamic": "false", + "type": "object" + }, + "telemetry": { "properties": { - "uuid": { + "allowChangingOptInStatus": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "lastReported": { + "type": "date" + }, + "lastVersionChecked": { "type": "keyword" + }, + "reportFailureCount": { + "type": "integer" + }, + "reportFailureVersion": { + "type": "keyword" + }, + "sendUsageFrom": { + "type": "keyword" + }, + "userHasSeenNotice": { + "type": "boolean" } } }, "timelion-sheet": { - "dynamic": "strict", "properties": { "description": { "type": "text" @@ -185,8 +390,24 @@ "type": { "type": "keyword" }, + "ui-counter": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "ui-metric": { + "properties": { + "count": { + "type": "integer" + } + } + }, + "updated_at": { + "type": "date" + }, "url": { - "dynamic": "strict", "properties": { "accessCount": { "type": "long" @@ -208,8 +429,15 @@ } } }, + "usage-counters": { + "dynamic": "false", + "properties": { + "domainId": { + "type": "keyword" + } + } + }, "visualization": { - "dynamic": "strict", "properties": { "description": { "type": "text" @@ -217,23 +445,28 @@ "kibanaSavedObjectMeta": { "properties": { "searchSourceJSON": { + "index": false, "type": "text" } } }, - "savedSearchId": { + "savedSearchRefName": { + "doc_values": false, + "index": false, "type": "keyword" }, "title": { "type": "text" }, "uiStateJSON": { + "index": false, "type": "text" }, "version": { "type": "integer" }, "visState": { + "index": false, "type": "text" } } @@ -242,37 +475,13 @@ }, "settings": { "index": { - "number_of_replicas": "1", - "number_of_shards": "1" - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "references": { - "type": "nested", - "properties": { - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } + "auto_expand_replicas": "0-1", + "number_of_replicas": "0", + "number_of_shards": "1", + "priority": "10", + "refresh_interval": "1s", + "routing_partition_size": "1" } } } -} +} \ No newline at end of file diff --git a/test/functional/page_objects/visualize_page.ts b/test/functional/page_objects/visualize_page.ts index f77db553e015f9..a11a254509e7a8 100644 --- a/test/functional/page_objects/visualize_page.ts +++ b/test/functional/page_objects/visualize_page.ts @@ -49,7 +49,9 @@ export class VisualizePageObject extends FtrService { public async initTests(isNewLibrary = false) { await this.kibanaServer.savedObjects.clean({ types: ['visualization'] }); - await this.kibanaServer.importExport.load('visualize'); + await this.kibanaServer.importExport.load( + 'test/functional/fixtures/kbn_archiver/visualize.json' + ); await this.kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', diff --git a/x-pack/examples/reporting_example/public/components/app.tsx b/x-pack/examples/reporting_example/public/components/app.tsx index 0174ec2a17ad4d..5f6f5d17afafba 100644 --- a/x-pack/examples/reporting_example/public/components/app.tsx +++ b/x-pack/examples/reporting_example/public/components/app.tsx @@ -6,8 +6,9 @@ */ import { + EuiButton, EuiCard, - EuiCode, + EuiContextMenu, EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, @@ -17,7 +18,7 @@ import { EuiPageContent, EuiPageContentBody, EuiPageHeader, - EuiPanel, + EuiPopover, EuiText, EuiTitle, } from '@elastic/eui'; @@ -50,7 +51,19 @@ export const ReportingExampleApp = ({ reporting, screenshotMode, }: ReportingExampleAppDeps) => { - const { getDefaultLayoutSelectors, ReportingAPIClient } = reporting; + const { getDefaultLayoutSelectors } = reporting; + + // Context Menu + const [isPopoverOpen, setPopover] = useState(false); + const onButtonClick = () => { + setPopover(!isPopoverOpen); + }; + + const closePopover = () => { + setPopover(false); + }; + + // Async Logos const [logos, setLogos] = useState([]); useEffect(() => { @@ -61,7 +74,7 @@ export const ReportingExampleApp = ({ }); }); - const getPDFJobParams = (): JobParamsPDF => { + const getPDFJobParamsDefault = (): JobParamsPDF => { return { layout: { id: constants.LAYOUT_TYPES.PRESERVE_LAYOUT, @@ -73,7 +86,40 @@ export const ReportingExampleApp = ({ }; }; - // Render the application DOM. + const panels = [ + { id: 0, items: [{ name: 'PDF Reports', icon: 'document', panel: 1 }] }, + { + id: 1, + initialFocusedItemIndex: 1, + title: 'PDF Reports', + items: [ + { name: 'No Layout Option', icon: 'document', panel: 2 }, + { name: 'Canvas Layout Option', icon: 'canvasApp', panel: 3 }, + ], + }, + { + id: 2, + title: 'No Layout Option', + content: ( + + ), + }, + { + id: 3, + title: 'Canvas Layout Option', + content: ( + + ), + }, + ]; + return ( @@ -87,34 +133,21 @@ export const ReportingExampleApp = ({ -

- Use the ReportingStart.components.ScreenCapturePanel{' '} - component to add the Reporting panel to your page. -

- - +

Example of a Sharing menu using components from Reporting

- - - - - - - + Share} + isOpen={isPopoverOpen} + closePopover={closePopover} + panelPaddingSize="none" + anchorPosition="downLeft" + > + + -

- The logos below are in a data-shared-items-container element - for Reporting. -

-
{logos.map((item, index) => ( diff --git a/x-pack/plugins/alerting/README.md b/x-pack/plugins/alerting/README.md index cb43e534080905..9d314cc048b705 100644 --- a/x-pack/plugins/alerting/README.md +++ b/x-pack/plugins/alerting/README.md @@ -619,7 +619,7 @@ The _registerNavigation_ api allows you to register a handler for a specific ale alerting.registerNavigation( 'my-application-id', 'my-application-id.my-rule-type', - (alert: SanitizedAlert, alertType: AlertType) => `/my-unique-rule/${rule.id}` + (alert: SanitizedAlert) => `/my-unique-rule/${rule.id}` ); ``` @@ -635,7 +635,7 @@ The _registerDefaultNavigation_ API allows you to register a handler for any rul ``` alerting.registerDefaultNavigation( 'my-application-id', - (alert: SanitizedAlert, alertType: AlertType) => `/my-other-rules/${rule.id}` + (alert: SanitizedAlert) => `/my-other-rules/${rule.id}` ); ``` diff --git a/x-pack/plugins/alerting/public/alert_navigation_registry/alert_navigation_registry.test.ts b/x-pack/plugins/alerting/public/alert_navigation_registry/alert_navigation_registry.test.ts index 3364593705301d..7eb59963113865 100644 --- a/x-pack/plugins/alerting/public/alert_navigation_registry/alert_navigation_registry.test.ts +++ b/x-pack/plugins/alerting/public/alert_navigation_registry/alert_navigation_registry.test.ts @@ -23,7 +23,7 @@ const mockAlertType = (id: string): AlertType => ({ }); describe('AlertNavigationRegistry', () => { - function handler(alert: SanitizedAlert, alertType: AlertType) { + function handler(alert: SanitizedAlert) { return {}; } @@ -143,7 +143,7 @@ describe('AlertNavigationRegistry', () => { test('returns registered handlers by consumer & Alert Type', () => { const registry = new AlertNavigationRegistry(); - function indexThresholdHandler(alert: SanitizedAlert, alertType: AlertType) { + function indexThresholdHandler(alert: SanitizedAlert) { return {}; } @@ -155,7 +155,7 @@ describe('AlertNavigationRegistry', () => { test('returns default handlers by consumer when there is no handler for requested alert type', () => { const registry = new AlertNavigationRegistry(); - function defaultHandler(alert: SanitizedAlert, alertType: AlertType) { + function defaultHandler(alert: SanitizedAlert) { return {}; } @@ -168,7 +168,7 @@ describe('AlertNavigationRegistry', () => { registry.register('siem', mockAlertType('indexThreshold'), () => ({})); - function defaultHandler(alert: SanitizedAlert, alertType: AlertType) { + function defaultHandler(alert: SanitizedAlert) { return {}; } diff --git a/x-pack/plugins/alerting/public/alert_navigation_registry/types.ts b/x-pack/plugins/alerting/public/alert_navigation_registry/types.ts index bf00d2c1b6eaf9..53540facd9652e 100644 --- a/x-pack/plugins/alerting/public/alert_navigation_registry/types.ts +++ b/x-pack/plugins/alerting/public/alert_navigation_registry/types.ts @@ -6,9 +6,15 @@ */ import { JsonObject } from '../../../../../src/plugins/kibana_utils/common'; -import { AlertType, SanitizedAlert } from '../../common'; +import { SanitizedAlert } from '../../common'; -export type AlertNavigationHandler = ( - alert: SanitizedAlert, - alertType: AlertType -) => JsonObject | string; +/** + * Returns information that can be used to navigate to a specific page to view the given rule. + * + * @param rule The rule to view + * @returns A URL that is meant to be relative to your application id, or a state object that your application uses to render + * the rule. This information is intended to be used with cores NavigateToApp function, along with the application id that was + * originally registered to {@link PluginSetupContract.registerNavigation}. + * + */ +export type AlertNavigationHandler = (alert: SanitizedAlert) => JsonObject | string; diff --git a/x-pack/plugins/alerting/public/index.ts b/x-pack/plugins/alerting/public/index.ts index 5edca2f8c4c419..7c61ea1b6b1fd3 100644 --- a/x-pack/plugins/alerting/public/index.ts +++ b/x-pack/plugins/alerting/public/index.ts @@ -6,7 +6,8 @@ */ import { AlertingPublicPlugin } from './plugin'; -export { PluginSetupContract, PluginStartContract } from './plugin'; +export type { PluginSetupContract, PluginStartContract } from './plugin'; +export type { AlertNavigationHandler } from './alert_navigation_registry'; export function plugin() { return new AlertingPublicPlugin(); diff --git a/x-pack/plugins/alerting/public/plugin.ts b/x-pack/plugins/alerting/public/plugin.ts index 025467d92a6ace..be7080f5df6dac 100644 --- a/x-pack/plugins/alerting/public/plugin.ts +++ b/x-pack/plugins/alerting/public/plugin.ts @@ -12,12 +12,38 @@ import { loadAlert, loadAlertType } from './alert_api'; import { Alert, AlertNavigation } from '../common'; export interface PluginSetupContract { + /** + * Register a customized view of the particular rule type. Stack Management provides a generic overview, but a developer can register a + * custom navigation to provide the user an extra link to a more curated view. The alerting plugin doesn't actually do + * anything with this information, but it can be used by other plugins via the `getNavigation` functionality. Currently + * the trigger_actions_ui plugin uses it to expose the link from the generic rule details view in Stack Management. + * + * @param applicationId The application id that the user should be navigated to, to view a particular alert in a custom way. + * @param ruleType The rule type that has been registered with Alerting.Server.PluginSetupContract.registerType. If + * no such rule with that id exists, a warning is output to the console log. It used to throw an error, but that was temporarily moved + * because it was causing flaky test failures with https://github.com/elastic/kibana/issues/59229 and needs to be + * investigated more. + * @param handler The navigation handler should return either a relative URL, or a state object. This information can be used, + * in conjunction with the consumer id, to navigate the user to a custom URL to view a rule's details. + * @throws an error if the given applicationId and ruleType combination has already been registered. + */ registerNavigation: ( - consumer: string, - alertType: string, + applicationId: string, + ruleType: string, handler: AlertNavigationHandler ) => void; - registerDefaultNavigation: (consumer: string, handler: AlertNavigationHandler) => void; + + /** + * Register a customized view for all rule types with this application id. Stack Management provides a generic overview, but a developer can register a + * custom navigation to provide the user an extra link to a more curated view. The alerting plugin doesn't actually do + * anything with this information, but it can be used by other plugins via the `getNavigation` functionality. Currently + * the trigger_actions_ui plugin uses it to expose the link from the generic rule details view in Stack Management. + * + * @param applicationId The application id that the user should be navigated to, to view a particular alert in a custom way. + * @param handler The navigation handler should return either a relative URL, or a state object. This information can be used, + * in conjunction with the consumer id, to navigate the user to a custom URL to view a rule's details. + */ + registerDefaultNavigation: (applicationId: string, handler: AlertNavigationHandler) => void; } export interface PluginStartContract { getNavigation: (alertId: Alert['id']) => Promise; @@ -29,23 +55,25 @@ export class AlertingPublicPlugin implements Plugin { - const alertType = await loadAlertType({ http: core.http, id: alertTypeId }); + const alertType = await loadAlertType({ http: core.http, id: ruleTypeId }); if (!alertType) { // eslint-disable-next-line no-console console.log( - `Unable to register navigation for alert type "${alertTypeId}" because it is not registered on the server side.` + `Unable to register navigation for rule type "${ruleTypeId}" because it is not registered on the server side.` ); return; } - this.alertNavigationRegistry!.register(consumer, alertType, handler); + this.alertNavigationRegistry!.register(applicationId, alertType, handler); }; - const registerDefaultNavigation = async (consumer: string, handler: AlertNavigationHandler) => - this.alertNavigationRegistry!.registerDefault(consumer, handler); + const registerDefaultNavigation = async ( + applicationId: string, + handler: AlertNavigationHandler + ) => this.alertNavigationRegistry!.registerDefault(applicationId, handler); return { registerNavigation, @@ -69,7 +97,7 @@ export class AlertingPublicPlugin implements Plugin > = { actionsPlugin: mockActionsPlugin, - spaceId: 'default', + spaceId: 'test1', alertId: '1', alertName: 'name-of-alert', tags: ['tag-A', 'tag-B'], @@ -130,7 +130,7 @@ test('enqueues execution per selected action', async () => { "apiKey": "MTIzOmFiYw==", "id": "1", "params": Object { - "alertVal": "My 1 name-of-alert default tag-A,tag-B 2 goes here", + "alertVal": "My 1 name-of-alert test1 tag-A,tag-B 2 goes here", "contextVal": "My goes here", "foo": true, "stateVal": "My goes here", @@ -142,7 +142,7 @@ test('enqueues execution per selected action', async () => { }, "type": "SAVED_OBJECT", }, - "spaceId": "default", + "spaceId": "test1", }, ] `); @@ -154,6 +154,10 @@ test('enqueues execution per selected action', async () => { Object { "event": Object { "action": "execute-action", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -164,18 +168,28 @@ test('enqueues execution per selected action', async () => { "saved_objects": Array [ Object { "id": "1", + "namespace": "test1", "rel": "primary", "type": "alert", "type_id": "test", }, Object { "id": "1", + "namespace": "test1", "type": "action", "type_id": "test", }, ], }, "message": "alert: test:1: 'name-of-alert' instanceId: '2' scheduled actionGroup: 'default' action: test:1", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "name-of-alert", + "namespace": "test1", + "ruleset": "alerts", + }, }, ], ] @@ -183,10 +197,10 @@ test('enqueues execution per selected action', async () => { expect(jest.requireMock('./inject_action_params').injectActionParams).toHaveBeenCalledWith({ ruleId: '1', - spaceId: 'default', + spaceId: 'test1', actionTypeId: 'test', actionParams: { - alertVal: 'My 1 name-of-alert default tag-A,tag-B 2 goes here', + alertVal: 'My 1 name-of-alert test1 tag-A,tag-B 2 goes here', contextVal: 'My goes here', foo: true, stateVal: 'My goes here', @@ -233,7 +247,7 @@ test(`doesn't call actionsPlugin.execute for disabled actionTypes`, async () => id: '1', type: 'alert', }), - spaceId: 'default', + spaceId: 'test1', apiKey: createExecutionHandlerParams.apiKey, }); }); @@ -308,7 +322,7 @@ test('context attribute gets parameterized', async () => { "apiKey": "MTIzOmFiYw==", "id": "1", "params": Object { - "alertVal": "My 1 name-of-alert default tag-A,tag-B 2 goes here", + "alertVal": "My 1 name-of-alert test1 tag-A,tag-B 2 goes here", "contextVal": "My context-val goes here", "foo": true, "stateVal": "My goes here", @@ -320,7 +334,7 @@ test('context attribute gets parameterized', async () => { }, "type": "SAVED_OBJECT", }, - "spaceId": "default", + "spaceId": "test1", }, ] `); @@ -341,7 +355,7 @@ test('state attribute gets parameterized', async () => { "apiKey": "MTIzOmFiYw==", "id": "1", "params": Object { - "alertVal": "My 1 name-of-alert default tag-A,tag-B 2 goes here", + "alertVal": "My 1 name-of-alert test1 tag-A,tag-B 2 goes here", "contextVal": "My goes here", "foo": true, "stateVal": "My state-val goes here", @@ -353,7 +367,7 @@ test('state attribute gets parameterized', async () => { }, "type": "SAVED_OBJECT", }, - "spaceId": "default", + "spaceId": "test1", }, ] `); diff --git a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts index ef93179bdaba16..c3a36297c217ac 100644 --- a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts +++ b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts @@ -174,7 +174,11 @@ export function createExecutionHandler< const namespace = spaceId === 'default' ? {} : { namespace: spaceId }; const event: IEvent = { - event: { action: EVENT_LOG_ACTIONS.executeAction }, + event: { + action: EVENT_LOG_ACTIONS.executeAction, + kind: 'alert', + category: [alertType.producer], + }, kibana: { alerting: { instance_id: alertInstanceId, @@ -192,6 +196,14 @@ export function createExecutionHandler< { type: 'action', id: action.id, type_id: action.actionTypeId, ...namespace }, ], }, + rule: { + id: alertId, + license: alertType.minimumLicenseRequired, + category: alertType.id, + ruleset: alertType.producer, + ...namespace, + name: alertName, + }, }; event.message = `alert: ${alertLabel} instanceId: '${alertInstanceId}' scheduled ${ diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts index 7f31aead1e83c7..4893e509f6b6a6 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts @@ -266,6 +266,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -283,6 +287,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, } `); @@ -373,6 +385,8 @@ describe('Task Runner', () => { expect(eventLogger.logEvent).toHaveBeenNthCalledWith(1, { event: { action: 'new-instance', + category: ['alerts'], + kind: 'alert', duration: 0, start: '1970-01-01T00:00:00.000Z', }, @@ -393,35 +407,45 @@ describe('Task Runner', () => { ], }, message: "test:1: 'alert-name' created new instance: '1'", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); expect(eventLogger.logEvent).toHaveBeenNthCalledWith(2, { event: { action: 'active-instance', + category: ['alerts'], duration: 0, + kind: 'alert', start: '1970-01-01T00:00:00.000Z', }, kibana: { - alerting: { - instance_id: '1', - action_group_id: 'default', - action_subgroup: 'subDefault', - }, + alerting: { action_group_id: 'default', action_subgroup: 'subDefault', instance_id: '1' }, saved_objects: [ - { - id: '1', - namespace: undefined, - rel: 'primary', - type: 'alert', - type_id: 'test', - }, + { id: '1', namespace: undefined, rel: 'primary', type: 'alert', type_id: 'test' }, ], }, message: "test:1: 'alert-name' active instance: '1' in actionGroup(subgroup): 'default(subDefault)'", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); expect(eventLogger.logEvent).toHaveBeenNthCalledWith(3, { event: { action: 'execute-action', + category: ['alerts'], + kind: 'alert', }, kibana: { alerting: { @@ -447,13 +471,18 @@ describe('Task Runner', () => { }, message: "alert: test:1: 'alert-name' instanceId: '1' scheduled actionGroup(subgroup): 'default(subDefault)' action: action:1", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); expect(eventLogger.logEvent).toHaveBeenNthCalledWith(4, { '@timestamp': '1970-01-01T00:00:00.000Z', - event: { - action: 'execute', - outcome: 'success', - }, + event: { action: 'execute', category: ['alerts'], kind: 'alert', outcome: 'success' }, kibana: { alerting: { status: 'active', @@ -469,6 +498,14 @@ describe('Task Runner', () => { ], }, message: "alert executed: test:1: 'alert-name'", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); }); @@ -529,6 +566,8 @@ describe('Task Runner', () => { expect(eventLogger.logEvent).toHaveBeenNthCalledWith(1, { event: { action: 'new-instance', + category: ['alerts'], + kind: 'alert', duration: 0, start: '1970-01-01T00:00:00.000Z', }, @@ -548,10 +587,20 @@ describe('Task Runner', () => { ], }, message: "test:1: 'alert-name' created new instance: '1'", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); expect(eventLogger.logEvent).toHaveBeenNthCalledWith(2, { event: { action: 'active-instance', + category: ['alerts'], + kind: 'alert', duration: 0, start: '1970-01-01T00:00:00.000Z', }, @@ -571,11 +620,21 @@ describe('Task Runner', () => { ], }, message: "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); expect(eventLogger.logEvent).toHaveBeenNthCalledWith(3, { '@timestamp': '1970-01-01T00:00:00.000Z', event: { action: 'execute', + category: ['alerts'], + kind: 'alert', outcome: 'success', }, kibana: { @@ -593,6 +652,14 @@ describe('Task Runner', () => { ], }, message: "alert executed: test:1: 'alert-name'", + rule: { + category: 'test', + id: '1', + license: 'basic', + name: 'alert-name', + namespace: undefined, + ruleset: 'alerts', + }, }); }); @@ -711,7 +778,11 @@ describe('Task Runner', () => { Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 86400000000000, + "kind": "alert", "start": "1969-12-31T00:00:00.000Z", }, "kibana": Object { @@ -730,6 +801,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -737,6 +816,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -754,6 +837,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -944,7 +1035,11 @@ describe('Task Runner', () => { Object { "event": Object { "action": "new-instance", + "category": Array [ + "alerts", + ], "duration": 0, + "kind": "alert", "start": "1970-01-01T00:00:00.000Z", }, "kibana": Object { @@ -963,13 +1058,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' created new instance: '1'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 0, + "kind": "alert", "start": "1970-01-01T00:00:00.000Z", }, "kibana": Object { @@ -988,12 +1095,24 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "execute-action", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -1018,6 +1137,14 @@ describe('Task Runner', () => { ], }, "message": "alert: test:1: 'alert-name' instanceId: '1' scheduled actionGroup: 'default' action: action:1", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -1025,6 +1152,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -1042,6 +1173,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -1146,8 +1285,12 @@ describe('Task Runner', () => { Object { "event": Object { "action": "recovered-instance", + "category": Array [ + "alerts", + ], "duration": 64800000000000, "end": "1970-01-01T00:00:00.000Z", + "kind": "alert", "start": "1969-12-31T06:00:00.000Z", }, "kibana": Object { @@ -1165,13 +1308,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' instance '2' has recovered", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 86400000000000, + "kind": "alert", "start": "1969-12-31T00:00:00.000Z", }, "kibana": Object { @@ -1190,12 +1345,24 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "execute-action", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -1220,12 +1387,24 @@ describe('Task Runner', () => { ], }, "message": "alert: test:1: 'alert-name' instanceId: '2' scheduled actionGroup: 'recovered' action: action:2", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "execute-action", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -1250,6 +1429,14 @@ describe('Task Runner', () => { ], }, "message": "alert: test:1: 'alert-name' instanceId: '1' scheduled actionGroup: 'default' action: action:1", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -1257,6 +1444,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -1274,6 +1465,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -1573,8 +1772,12 @@ describe('Task Runner', () => { Object { "event": Object { "action": "recovered-instance", + "category": Array [ + "alerts", + ], "duration": 64800000000000, "end": "1970-01-01T00:00:00.000Z", + "kind": "alert", "start": "1969-12-31T06:00:00.000Z", }, "kibana": Object { @@ -1593,13 +1796,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' instance '2' has recovered", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 86400000000000, + "kind": "alert", "start": "1969-12-31T00:00:00.000Z", }, "kibana": Object { @@ -1618,6 +1833,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -1625,6 +1848,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -1642,6 +1869,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -1835,6 +2070,10 @@ describe('Task Runner', () => { }, "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "failure", "reason": "execute", }, @@ -1853,6 +2092,13 @@ describe('Task Runner', () => { ], }, "message": "alert execution failure: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -1895,6 +2141,10 @@ describe('Task Runner', () => { }, "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "failure", "reason": "decrypt", }, @@ -1913,6 +2163,13 @@ describe('Task Runner', () => { ], }, "message": "test:1: execution failed", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -1963,6 +2220,10 @@ describe('Task Runner', () => { }, "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "failure", "reason": "license", }, @@ -1981,6 +2242,13 @@ describe('Task Runner', () => { ], }, "message": "test:1: execution failed", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2031,6 +2299,10 @@ describe('Task Runner', () => { }, "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "failure", "reason": "unknown", }, @@ -2049,6 +2321,13 @@ describe('Task Runner', () => { ], }, "message": "test:1: execution failed", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2098,6 +2377,10 @@ describe('Task Runner', () => { }, "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "failure", "reason": "read", }, @@ -2116,6 +2399,13 @@ describe('Task Runner', () => { ], }, "message": "test:1: execution failed", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2223,12 +2513,61 @@ describe('Task Runner', () => { references: [], }); + const logger = taskRunnerFactoryInitializerParams.logger; return taskRunner.run().catch((ex) => { expect(ex).toMatchInlineSnapshot(`[Error: Saved object [alert/1] not found]`); + expect(logger.debug).toHaveBeenCalledWith( + `Executing Alert "1" has resulted in Error: Saved object [alert/1] not found` + ); + expect(logger.warn).toHaveBeenCalledTimes(1); + expect(logger.warn).nthCalledWith( + 1, + `Unable to execute rule "1" because Saved object [alert/1] not found - this rule will not be rescheduled. To restart rule execution, try disabling and re-enabling this rule.` + ); expect(isUnrecoverableError(ex)).toBeTruthy(); }); }); + test('correctly logs warning when Alert Task Runner throws due to failing to fetch the alert in a space', async () => { + alertsClient.get.mockImplementation(() => { + throw SavedObjectsErrorHelpers.createGenericNotFoundError('alert', '1'); + }); + + const taskRunner = new TaskRunner( + alertType, + { + ...mockedTaskInstance, + params: { + ...mockedTaskInstance.params, + spaceId: 'test space', + }, + }, + taskRunnerFactoryInitializerParams + ); + + encryptedSavedObjectsClient.getDecryptedAsInternalUser.mockResolvedValue({ + id: '1', + type: 'alert', + attributes: { + apiKey: Buffer.from('123:abc').toString('base64'), + }, + references: [], + }); + + const logger = taskRunnerFactoryInitializerParams.logger; + return taskRunner.run().catch((ex) => { + expect(ex).toMatchInlineSnapshot(`[Error: Saved object [alert/1] not found]`); + expect(logger.debug).toHaveBeenCalledWith( + `Executing Alert "1" has resulted in Error: Saved object [alert/1] not found` + ); + expect(logger.warn).toHaveBeenCalledTimes(1); + expect(logger.warn).nthCalledWith( + 1, + `Unable to execute rule "1" in the "test space" space because Saved object [alert/1] not found - this rule will not be rescheduled. To restart rule execution, try disabling and re-enabling this rule.` + ); + }); + }); + test('start time is logged for new alerts', async () => { taskRunnerFactoryInitializerParams.actionsPlugin.isActionTypeEnabled.mockReturnValue(true); taskRunnerFactoryInitializerParams.actionsPlugin.isActionExecutable.mockReturnValue(true); @@ -2280,7 +2619,11 @@ describe('Task Runner', () => { Object { "event": Object { "action": "new-instance", + "category": Array [ + "alerts", + ], "duration": 0, + "kind": "alert", "start": "1970-01-01T00:00:00.000Z", }, "kibana": Object { @@ -2299,13 +2642,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' created new instance: '1'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "new-instance", + "category": Array [ + "alerts", + ], "duration": 0, + "kind": "alert", "start": "1970-01-01T00:00:00.000Z", }, "kibana": Object { @@ -2324,13 +2679,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' created new instance: '2'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 0, + "kind": "alert", "start": "1970-01-01T00:00:00.000Z", }, "kibana": Object { @@ -2349,13 +2716,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 0, + "kind": "alert", "start": "1970-01-01T00:00:00.000Z", }, "kibana": Object { @@ -2374,6 +2753,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '2' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -2381,6 +2768,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -2398,6 +2789,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2472,7 +2871,11 @@ describe('Task Runner', () => { Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 86400000000000, + "kind": "alert", "start": "1969-12-31T00:00:00.000Z", }, "kibana": Object { @@ -2491,13 +2894,25 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], "duration": 64800000000000, + "kind": "alert", "start": "1969-12-31T06:00:00.000Z", }, "kibana": Object { @@ -2516,6 +2931,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '2' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -2523,6 +2946,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -2540,6 +2967,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2606,6 +3041,10 @@ describe('Task Runner', () => { Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -2623,12 +3062,24 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '1' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "active-instance", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -2646,6 +3097,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' active instance: '2' in actionGroup: 'default'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -2653,6 +3112,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -2670,6 +3133,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2731,8 +3202,12 @@ describe('Task Runner', () => { Object { "event": Object { "action": "recovered-instance", + "category": Array [ + "alerts", + ], "duration": 86400000000000, "end": "1970-01-01T00:00:00.000Z", + "kind": "alert", "start": "1969-12-31T00:00:00.000Z", }, "kibana": Object { @@ -2750,14 +3225,26 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' instance '1' has recovered", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "recovered-instance", + "category": Array [ + "alerts", + ], "duration": 64800000000000, "end": "1970-01-01T00:00:00.000Z", + "kind": "alert", "start": "1969-12-31T06:00:00.000Z", }, "kibana": Object { @@ -2775,6 +3262,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' instance '2' has recovered", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -2782,6 +3277,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -2799,6 +3298,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] @@ -2862,6 +3369,10 @@ describe('Task Runner', () => { Object { "event": Object { "action": "recovered-instance", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -2878,12 +3389,24 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' instance '1' has recovered", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ Object { "event": Object { "action": "recovered-instance", + "category": Array [ + "alerts", + ], + "kind": "alert", }, "kibana": Object { "alerting": Object { @@ -2900,6 +3423,14 @@ describe('Task Runner', () => { ], }, "message": "test:1: 'alert-name' instance '2' has recovered", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], Array [ @@ -2907,6 +3438,10 @@ describe('Task Runner', () => { "@timestamp": "1970-01-01T00:00:00.000Z", "event": Object { "action": "execute", + "category": Array [ + "alerts", + ], + "kind": "alert", "outcome": "success", }, "kibana": Object { @@ -2924,6 +3459,14 @@ describe('Task Runner', () => { ], }, "message": "alert executed: test:1: 'alert-name'", + "rule": Object { + "category": "test", + "id": "1", + "license": "basic", + "name": "alert-name", + "namespace": undefined, + "ruleset": "alerts", + }, }, ], ] diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts index f139617291a842..c9ca5d85e5116e 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts @@ -303,6 +303,10 @@ export class TaskRunner< event.message = `alert executed: ${alertLabel}`; event.event = event.event || {}; event.event.outcome = 'success'; + event.rule = { + ...event.rule, + name: alert.name, + }; // Cleanup alert instances that are no longer scheduling actions to avoid over populating the alertInstances object const instancesWithScheduledActions = pickBy( @@ -337,7 +341,8 @@ export class TaskRunner< alertId, alertLabel, namespace, - ruleTypeId: alert.alertTypeId, + ruleType: alertType, + rule: alert, }); if (!muteAll) { @@ -493,7 +498,11 @@ export class TaskRunner< // explicitly set execute timestamp so it will be before other events // generated here (new-instance, schedule-action, etc) '@timestamp': runDate, - event: { action: EVENT_LOG_ACTIONS.execute }, + event: { + action: EVENT_LOG_ACTIONS.execute, + kind: 'alert', + category: [this.alertType.producer], + }, kibana: { saved_objects: [ { @@ -505,6 +514,13 @@ export class TaskRunner< }, ], }, + rule: { + id: alertId, + license: this.alertType.minimumLicenseRequired, + category: this.alertType.id, + ruleset: this.alertType.producer, + namespace, + }, }; eventLogger.startTiming(event); @@ -587,6 +603,10 @@ export class TaskRunner< ), schedule: resolveErr(schedule, (error) => { if (isAlertSavedObjectNotFoundError(error, alertId)) { + const spaceMessage = spaceId ? `in the "${spaceId}" space ` : ''; + this.logger.warn( + `Unable to execute rule "${alertId}" ${spaceMessage}because ${error.message} - this rule will not be rescheduled. To restart rule execution, try disabling and re-enabling this rule.` + ); throwUnrecoverableError(error); } return { interval: taskSchedule?.interval ?? FALLBACK_RETRY_INTERVAL }; @@ -661,7 +681,19 @@ interface GenerateNewAndRecoveredInstanceEventsParams< alertId: string; alertLabel: string; namespace: string | undefined; - ruleTypeId: string; + ruleType: NormalizedAlertType< + AlertTypeParams, + AlertTypeState, + { + [x: string]: unknown; + }, + { + [x: string]: unknown; + }, + string, + string + >; + rule: SanitizedAlert; } function generateNewAndRecoveredInstanceEvents< @@ -675,7 +707,8 @@ function generateNewAndRecoveredInstanceEvents< currentAlertInstances, originalAlertInstances, recoveredAlertInstances, - ruleTypeId, + rule, + ruleType, } = params; const originalAlertInstanceIds = Object.keys(originalAlertInstances); const currentAlertInstanceIds = Object.keys(currentAlertInstances); @@ -742,6 +775,8 @@ function generateNewAndRecoveredInstanceEvents< const event: IEvent = { event: { action, + kind: 'alert', + category: [ruleType.producer], ...(state?.start ? { start: state.start as string } : {}), ...(state?.end ? { end: state.end as string } : {}), ...(state?.duration !== undefined ? { duration: state.duration as number } : {}), @@ -757,12 +792,20 @@ function generateNewAndRecoveredInstanceEvents< rel: SAVED_OBJECT_REL_PRIMARY, type: 'alert', id: alertId, - type_id: ruleTypeId, + type_id: ruleType.id, namespace, }, ], }, message, + rule: { + id: rule.id, + license: ruleType.minimumLicenseRequired, + category: ruleType.id, + ruleset: ruleType.producer, + namespace, + name: rule.name, + }, }; eventLogger.logEvent(event); } diff --git a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts index e4306b4c2ec988..35c7f0dfdfd73d 100644 --- a/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts +++ b/x-pack/plugins/apm/server/lib/fleet/register_fleet_policy_callbacks.ts @@ -115,6 +115,7 @@ export function getPackagePolicyWithAgentConfigurations( { ...firstInput, config: { + ...firstInput.config, [APM_SERVER]: { value: { ...apmServerValue, diff --git a/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts b/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts index 028c8c042c8dc3..611f9b18a0b1a2 100644 --- a/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts +++ b/x-pack/plugins/apm/server/lib/services/annotations/get_derived_service_annotations.ts @@ -92,7 +92,7 @@ export async function getDerivedServiceAnnotations({ }, }, sort: { - '@timestamp': 'desc', + '@timestamp': 'asc', }, }, }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js index fc5d03190d4f8d..adee8a56dea494 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.test.js @@ -6,11 +6,17 @@ */ import { of } from 'rxjs'; +import { TestScheduler } from 'rxjs/testing'; import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { caseFn } from './case'; describe('case', () => { const fn = functionWrapper(caseFn); + let testScheduler; + + beforeEach(() => { + testScheduler = new TestScheduler((actual, expected) => expect(actual).toStrictEqual(expected)); + }); describe('spec', () => { it('is a function', () => { @@ -19,29 +25,22 @@ describe('case', () => { }); describe('function', () => { - describe('no args', () => { - it('should return a case object that matches with the result as the context', () => { - const context = null; - const args = {}; - expect(fn(context, args)).resolves.toEqual({ - type: 'case', - matches: true, - result: context, - }); - }); - }); - describe('no if or value', () => { it('should return the result if provided', () => { const context = null; const args = { then: () => of('foo'), }; - expect(fn(context, args)).resolves.toEqual({ - type: 'case', - matches: true, - result: 'foo', - }); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', [ + { + type: 'case', + matches: true, + result: 'foo', + }, + ]) + ); }); }); @@ -49,11 +48,16 @@ describe('case', () => { it('should return as the matches prop', () => { const context = null; const args = { if: false }; - expect(fn(context, args)).resolves.toEqual({ - type: 'case', - matches: args.if, - result: context, - }); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', [ + { + type: 'case', + matches: args.if, + result: context, + }, + ]) + ); }); }); @@ -63,15 +67,23 @@ describe('case', () => { when: () => of('foo'), then: () => of('bar'), }; - expect(fn('foo', args)).resolves.toEqual({ - type: 'case', - matches: true, - result: 'bar', - }); - expect(fn('bar', args)).resolves.toEqual({ - type: 'case', - matches: false, - result: null, + + testScheduler.run(({ expectObservable }) => { + expectObservable(fn('foo', args)).toBe('(0|)', [ + { + type: 'case', + matches: true, + result: 'bar', + }, + ]); + + expectObservable(fn('bar', args)).toBe('(0|)', [ + { + type: 'case', + matches: false, + result: null, + }, + ]); }); }); }); @@ -81,13 +93,18 @@ describe('case', () => { const context = null; const args = { when: () => 'foo', - if: true, + if: false, }; - expect(fn(context, args)).resolves.toEqual({ - type: 'case', - matches: args.if, - result: context, - }); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', [ + { + type: 'case', + matches: args.if, + result: context, + }, + ]) + ); }); }); }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.ts index 7fba5b74e9b207..89329d69827160 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/case.ts @@ -5,15 +5,15 @@ * 2.0. */ -import { Observable } from 'rxjs'; -import { take } from 'rxjs/operators'; +import { Observable, defer, isObservable, of } from 'rxjs'; +import { map, concatMap } from 'rxjs/operators'; import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common'; import { getFunctionHelp } from '../../../i18n'; interface Arguments { when?(): Observable; if?: boolean; - then?(): Observable; + then(): Observable; } interface Case { @@ -22,7 +22,7 @@ interface Case { result: any; } -export function caseFn(): ExpressionFunctionDefinition<'case', any, Arguments, Promise> { +export function caseFn(): ExpressionFunctionDefinition<'case', any, Arguments, Observable> { const { help, args: argHelp } = getFunctionHelp().case; return { @@ -45,24 +45,24 @@ export function caseFn(): ExpressionFunctionDefinition<'case', any, Arguments, P help: argHelp.then!, }, }, - fn: async (input, args) => { - const matches = await doesMatch(input, args); - const result = matches ? await getResult(input, args) : null; - return { type: 'case', matches, result }; + fn(input, { if: condition, then, when }) { + return defer(() => { + const matches = condition ?? when?.().pipe(map((value) => value === input)) ?? true; + + return isObservable(matches) ? matches : of(matches); + }).pipe( + concatMap((matches) => + (matches ? then() : of(null)).pipe( + map( + (result): Case => ({ + matches, + result, + type: 'case', + }) + ) + ) + ) + ); }, }; } - -async function doesMatch(context: any, args: Arguments) { - if (typeof args.if !== 'undefined') { - return args.if; - } - if (typeof args.when !== 'undefined') { - return (await args.when().pipe(take(1)).toPromise()) === context; - } - return true; -} - -async function getResult(context: any, args: Arguments) { - return args.then?.().pipe(take(1)).toPromise() ?? context; -} diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js index fdea4faa4ece28..8c328e3d8adf6e 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.test.js @@ -6,6 +6,7 @@ */ import { of } from 'rxjs'; +import { TestScheduler } from 'rxjs/testing'; import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { testTable } from './__fixtures__/test_tables'; import { filterrows } from './filterrows'; @@ -15,31 +16,46 @@ const returnFalse = () => of(false); describe('filterrows', () => { const fn = functionWrapper(filterrows); + let testScheduler; + + beforeEach(() => { + testScheduler = new TestScheduler((actual, expected) => expect(actual).toStrictEqual(expected)); + }); it('returns a datable', () => { - expect(fn(testTable, { fn: inStock })).resolves.toHaveProperty('type', 'datatable'); + testScheduler.run(({ expectObservable }) => + expectObservable(fn(testTable, { fn: inStock })).toBe('(0|)', [ + expect.objectContaining({ type: 'datatable' }), + ]) + ); }); it('keeps rows that evaluate to true and removes rows that evaluate to false', () => { const inStockRows = testTable.rows.filter((row) => row.in_stock); - expect(fn(testTable, { fn: inStock })).resolves.toEqual( - expect.objectContaining({ - columns: testTable.columns, - rows: inStockRows, - }) + testScheduler.run(({ expectObservable }) => + expectObservable(fn(testTable, { fn: inStock })).toBe('(0|)', [ + expect.objectContaining({ + columns: testTable.columns, + rows: inStockRows, + }), + ]) ); }); it('returns datatable with no rows when no rows meet function condition', () => { - expect(fn(testTable, { fn: returnFalse })).resolves.toEqual( - expect.objectContaining({ - rows: [], - }) + testScheduler.run(({ expectObservable }) => + expectObservable(fn(testTable, { fn: returnFalse })).toBe('(0|)', [ + expect.objectContaining({ + rows: [], + }), + ]) ); }); it('throws when no function is provided', () => { - expect(() => fn(testTable)).toThrow('fn is not a function'); + testScheduler.run(({ expectObservable }) => + expectObservable(fn(testTable)).toBe('#', {}, new TypeError('fn is not a function')) + ); }); }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.ts index 082506f58e86fa..4923b835d2871e 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/filterrows.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { Observable } from 'rxjs'; -import { take } from 'rxjs/operators'; +import { Observable, combineLatest, defer } from 'rxjs'; +import { map } from 'rxjs/operators'; import { Datatable, ExpressionFunctionDefinition } from '../../../types'; import { getFunctionHelp } from '../../../i18n'; @@ -18,7 +18,7 @@ export function filterrows(): ExpressionFunctionDefinition< 'filterrows', Datatable, Arguments, - Promise + Observable > { const { help, args: argHelp } = getFunctionHelp().filterrows; @@ -38,24 +38,12 @@ export function filterrows(): ExpressionFunctionDefinition< }, }, fn(input, { fn }) { - const checks = input.rows.map((row) => - fn({ - ...input, - rows: [row], - }) - .pipe(take(1)) - .toPromise() + return defer(() => + combineLatest(input.rows.map((row) => fn({ ...input, rows: [row] }))) + ).pipe( + map((checks) => input.rows.filter((row, i) => checks[i])), + map((rows) => ({ ...input, rows })) ); - - return Promise.all(checks) - .then((results) => input.rows.filter((row, i) => results[i])) - .then( - (rows) => - ({ - ...input, - rows, - } as Datatable) - ); }, }; } diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js index 8e1106644105e4..cab331807e44c8 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.test.js @@ -6,11 +6,17 @@ */ import { of } from 'rxjs'; +import { TestScheduler } from 'rxjs/testing'; import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { ifFn } from './if'; describe('if', () => { const fn = functionWrapper(ifFn); + let testScheduler; + + beforeEach(() => { + testScheduler = new TestScheduler((actual, expected) => expect(actual).toStrictEqual(expected)); + }); describe('spec', () => { it('is a function', () => { @@ -21,66 +27,73 @@ describe('if', () => { describe('function', () => { describe('condition passed', () => { it('with then', () => { - expect(fn(null, { condition: true, then: () => of('foo') })).resolves.toBe('foo'); - expect( - fn(null, { condition: true, then: () => of('foo'), else: () => of('bar') }) - ).resolves.toBe('foo'); + testScheduler.run(({ expectObservable }) => { + expectObservable(fn(null, { condition: true, then: () => of('foo') })).toBe('(0|)', [ + 'foo', + ]); + + expectObservable( + fn(null, { condition: true, then: () => of('foo'), else: () => of('bar') }) + ).toBe('(0|)', ['foo']); + }); }); it('without then', () => { - expect(fn(null, { condition: true })).resolves.toBe(null); - expect(fn('some context', { condition: true })).resolves.toBe('some context'); + testScheduler.run(({ expectObservable }) => { + expectObservable(fn(null, { condition: true })).toBe('(0|)', [null]); + expectObservable(fn('some context', { condition: true })).toBe('(0|)', ['some context']); + }); }); }); describe('condition failed', () => { - it('with else', () => - expect( - fn('some context', { - condition: false, - then: () => of('foo'), - else: () => of('bar'), - }) - ).resolves.toBe('bar')); - - it('without else', () => - expect(fn('some context', { condition: false, then: () => of('foo') })).resolves.toBe( - 'some context' - )); - }); - - describe('falsy values', () => { - describe('for then', () => { - it('with null', () => { - expect(fn('some context', { condition: true, then: () => of(null) })).resolves.toBe(null); - }); - - it('with false', () => { - expect(fn('some context', { condition: true, then: () => of(false) })).resolves.toBe( - false - ); - }); - - it('with 0', () => { - expect(fn('some context', { condition: true, then: () => of(0) })).resolves.toBe(0); + it('with else', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + fn('some context', { + condition: false, + then: () => of('foo'), + else: () => of('bar'), + }) + ).toBe('(0|)', ['bar']); }); }); - describe('for else', () => { - it('with null', () => { - expect(fn('some context', { condition: false, else: () => of(null) })).resolves.toBe( - null - ); + it('without else', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + fn('some context', { condition: false, then: () => of('foo') }) + ).toBe('(0|)', ['some context']); }); + }); + }); - it('with false', () => { - expect(fn('some context', { condition: false, else: () => of(false) })).resolves.toBe( - false - ); + describe('falsy values', () => { + // eslint-disable-next-line no-unsanitized/method + it.each` + value + ${null} + ${false} + ${0} + `('for then with $value', ({ value }) => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + fn('some context', { condition: true, then: () => of(value) }) + ).toBe('(0|)', [value]); }); + }); - it('with 0', () => { - expect(fn('some context', { condition: false, else: () => of(0) })).resolves.toBe(0); + // eslint-disable-next-line no-unsanitized/method + it.each` + value + ${null} + ${false} + ${0} + `('for else with $value', ({ value }) => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + fn('some context', { condition: false, else: () => of(value) }) + ).toBe('(0|)', [value]); }); }); }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.ts index 6d7665db551e4b..82bfb87c173b0a 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/if.ts @@ -5,18 +5,22 @@ * 2.0. */ -import { Observable } from 'rxjs'; -import { take } from 'rxjs/operators'; +import { Observable, defer, of } from 'rxjs'; import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common'; import { getFunctionHelp } from '../../../i18n'; interface Arguments { - condition: boolean | null; + condition: boolean; then?(): Observable; else?(): Observable; } -export function ifFn(): ExpressionFunctionDefinition<'if', unknown, Arguments, unknown> { +export function ifFn(): ExpressionFunctionDefinition< + 'if', + unknown, + Arguments, + Observable +> { const { help, args: argHelp } = getFunctionHelp().if; return { @@ -38,12 +42,8 @@ export function ifFn(): ExpressionFunctionDefinition<'if', unknown, Arguments, u help: argHelp.else!, }, }, - fn: async (input, args) => { - if (args.condition) { - return args.then?.().pipe(take(1)).toPromise() ?? input; - } else { - return args.else?.().pipe(take(1)).toPromise() ?? input; - } + fn(input, args) { + return defer(() => (args.condition ? args.then?.() : args.else?.()) ?? of(input)); }, }; } diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js index 74eca79395a103..5bf100eb90f4ca 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.test.js @@ -6,6 +6,7 @@ */ import { of } from 'rxjs'; +import { TestScheduler } from 'rxjs/testing'; import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { getFunctionErrors } from '../../../i18n'; import { testTable } from './__fixtures__/test_tables'; @@ -46,36 +47,56 @@ const rowCount = (datatable) => describe('ply', () => { const fn = functionWrapper(ply); + let testScheduler; - it('maps a function over sub datatables grouped by specified columns and merges results into one datatable', async () => { - const arbitaryRowIndex = 0; - const result = await fn(testTable, { - by: ['name', 'in_stock'], - expression: [averagePrice, rowCount], - }); + beforeEach(() => { + testScheduler = new TestScheduler((actual, expected) => expect(actual).toStrictEqual(expected)); + }); - expect(result.type).toBe('datatable'); - expect(result.columns).toEqual([ - { id: 'name', name: 'name', meta: { type: 'string' } }, - { id: 'in_stock', name: 'in_stock', meta: { type: 'boolean' } }, - { id: 'average_price', name: 'average_price', meta: { type: 'number' } }, - { id: 'row_count', name: 'row_count', meta: { type: 'number' } }, - ]); - expect(result.rows[arbitaryRowIndex]).toHaveProperty('average_price'); - expect(result.rows[arbitaryRowIndex]).toHaveProperty('row_count'); + it('maps a function over sub datatables grouped by specified columns and merges results into one datatable', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable( + fn(testTable, { + by: ['name', 'in_stock'], + expression: [averagePrice, rowCount], + }) + ).toBe('(0|)', [ + expect.objectContaining({ + type: 'datatable', + columns: [ + { id: 'name', name: 'name', meta: { type: 'string' } }, + { id: 'in_stock', name: 'in_stock', meta: { type: 'boolean' } }, + { id: 'average_price', name: 'average_price', meta: { type: 'number' } }, + { id: 'row_count', name: 'row_count', meta: { type: 'number' } }, + ], + rows: expect.arrayContaining([ + expect.objectContaining({ + average_price: expect.anything(), + row_count: expect.anything(), + }), + ]), + }), + ]); + }); }); describe('missing args', () => { it('returns the original datatable if both args are missing', () => { - expect(fn(testTable)).resolves.toEqual(testTable); + testScheduler.run(({ expectObservable }) => { + expectObservable(fn(testTable)).toBe('(0|)', [testTable]); + }); }); describe('by', () => { it('passes the entire context into the expression when no columns are provided', () => { - expect(fn(testTable, { expression: [rowCount] })).resolves.toEqual({ - type: 'datatable', - rows: [{ row_count: testTable.rows.length }], - columns: [{ id: 'row_count', name: 'row_count', meta: { type: 'number' } }], + testScheduler.run(({ expectObservable }) => { + expectObservable(fn(testTable, { expression: [rowCount] })).toBe('(0|)', [ + { + type: 'datatable', + rows: [{ row_count: testTable.rows.length }], + columns: [{ id: 'row_count', name: 'row_count', meta: { type: 'number' } }], + }, + ]); }); }); @@ -91,24 +112,37 @@ describe('ply', () => { }); describe('expression', () => { - it('returns the original datatable grouped by the specified columns', async () => { - const arbitaryRowIndex = 6; - const result = await fn(testTable, { by: ['price', 'quantity'] }); - - expect(result.columns[0]).toHaveProperty('name', 'price'); - expect(result.columns[1]).toHaveProperty('name', 'quantity'); - expect(result.rows[arbitaryRowIndex]).toHaveProperty('price'); - expect(result.rows[arbitaryRowIndex]).toHaveProperty('quantity'); + it('returns the original datatable grouped by the specified columns', () => { + testScheduler.run(({ expectObservable }) => { + expectObservable(fn(testTable, { by: ['price', 'quantity'] })).toBe('(0|)', [ + expect.objectContaining({ + columns: expect.arrayContaining([ + expect.objectContaining({ name: 'price' }), + expect.objectContaining({ name: 'quantity' }), + ]), + rows: expect.arrayContaining([ + expect.objectContaining({ + price: expect.anything(), + quantity: expect.anything(), + }), + ]), + }), + ]); + }); }); it('throws when row counts do not match across resulting datatables', () => { - expect( - fn(testTable, { by: ['name'], expression: [doublePrice, rowCount] }) - ).rejects.toEqual( - expect.objectContaining({ - message: errors.rowCountMismatch().message, - }) - ); + testScheduler.run(({ expectObservable }) => { + expectObservable( + fn(testTable, { by: ['name'], expression: [doublePrice, rowCount] }) + ).toBe( + '#', + [], + expect.objectContaining({ + message: errors.rowCountMismatch().message, + }) + ); + }); }); }); }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.ts index 514d7f73d48e47..322bf7fee980cc 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/ply.ts @@ -5,18 +5,18 @@ * 2.0. */ -import { Observable } from 'rxjs'; -import { take } from 'rxjs/operators'; -import { groupBy, flatten, pick, map } from 'lodash'; +import { combineLatest, defer, of, Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { groupBy, flatten, pick, map as _map, uniqWith } from 'lodash'; import { Datatable, DatatableColumn, ExpressionFunctionDefinition } from '../../../types'; import { getFunctionHelp, getFunctionErrors } from '../../../i18n'; interface Arguments { - by: string[]; + by?: string[]; expression: Array<(datatable: Datatable) => Observable>; } -type Output = Datatable | Promise; +type Output = Datatable | Observable; export function ply(): ExpressionFunctionDefinition<'ply', Datatable, Arguments, Output> { const { help, args: argHelp } = getFunctionHelp().ply; @@ -30,7 +30,7 @@ export function ply(): ExpressionFunctionDefinition<'ply', Datatable, Arguments, args: { by: { types: ['string'], - help: argHelp.by, + help: argHelp.by!, multi: true, }, expression: { @@ -41,86 +41,62 @@ export function ply(): ExpressionFunctionDefinition<'ply', Datatable, Arguments, help: argHelp.expression, }, }, - fn: (input, args) => { + fn(input, args) { if (!args) { return input; } - let byColumns: DatatableColumn[]; - let originalDatatables: Datatable[]; - - if (args.by) { - byColumns = args.by.map((by) => { - const column = input.columns.find((col) => col.name === by); + const byColumns = + args.by?.map((by) => { + const column = input.columns.find(({ name }) => name === by); if (!column) { throw errors.columnNotFound(by); } return column; - }); - - const keyedDatatables = groupBy(input.rows, (row) => JSON.stringify(pick(row, args.by))); - - originalDatatables = Object.values(keyedDatatables).map((rows) => ({ - ...input, - rows, - })); - } else { - originalDatatables = [input]; - } - - const datatablePromises = originalDatatables.map((originalDatatable) => { - let expressionResultPromises = []; - - if (args.expression) { - expressionResultPromises = args.expression.map((expression) => - expression(originalDatatable).pipe(take(1)).toPromise() + }) ?? []; + + const originalDatatables = args.by + ? Object.values( + groupBy(input.rows, (row) => JSON.stringify(pick(row, args.by!))) + ).map((rows) => ({ ...input, rows })) + : [input]; + + const datatables$ = originalDatatables.map((originalDatatable) => + combineLatest( + args.expression?.map((expression) => defer(() => expression(originalDatatable))) ?? [ + of(originalDatatable), + ] + ).pipe(map(combineAcross)) + ); + + return (datatables$.length ? combineLatest(datatables$) : of([])).pipe( + map((newDatatables) => { + // Here we're just merging each for the by splits, so it doesn't actually matter if the rows are the same length + const columns = combineColumns([byColumns].concat(_map(newDatatables, 'columns'))); + const rows = flatten( + newDatatables.map((datatable, index) => + datatable.rows.map((row) => ({ + ...pick(originalDatatables[index].rows[0], args.by!), + ...row, + })) + ) ); - } else { - expressionResultPromises.push(Promise.resolve(originalDatatable)); - } - - return Promise.all(expressionResultPromises).then(combineAcross); - }); - - return Promise.all(datatablePromises).then((newDatatables) => { - // Here we're just merging each for the by splits, so it doesn't actually matter if the rows are the same length - const columns = combineColumns([byColumns].concat(map(newDatatables, 'columns'))); - const rows = flatten( - newDatatables.map((dt, i) => { - const byColumnValues = pick(originalDatatables[i].rows[0], args.by); - return dt.rows.map((row) => ({ - ...byColumnValues, - ...row, - })); - }) - ); - - return { - type: 'datatable', - rows, - columns, - } as Datatable; - }); + + return { + type: 'datatable', + rows, + columns, + } as Datatable; + }) + ); }, }; } function combineColumns(arrayOfColumnsArrays: DatatableColumn[][]) { - return arrayOfColumnsArrays.reduce((resultingColumns, columns) => { - if (columns) { - columns.forEach((column) => { - if (resultingColumns.find((resultingColumn) => resultingColumn.name === column.name)) { - return; - } else { - resultingColumns.push(column); - } - }); - } - - return resultingColumns; - }, []); + return uniqWith(arrayOfColumnsArrays.flat(), ({ name: a }, { name: b }) => a === b); } // This handles merging the tables produced by multiple expressions run on a single member of the `by` split. @@ -138,17 +114,17 @@ function combineAcross(datatableArray: Datatable[]) { }); // Merge columns and rows. - const arrayOfRowsArrays = map(datatableArray, 'rows'); + const arrayOfRowsArrays = _map(datatableArray, 'rows'); const rows = []; for (let i = 0; i < targetRowLength; i++) { - const rowsAcross = map(arrayOfRowsArrays, i); + const rowsAcross = _map(arrayOfRowsArrays, i); // The reason for the Object.assign is that rowsAcross is an array // and those rows need to be applied as arguments to Object.assign rows.push(Object.assign({}, ...rowsAcross)); } - const columns = combineColumns(map(datatableArray, 'columns')); + const columns = combineColumns(_map(datatableArray, 'columns')); return { type: 'datatable', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js index 6d9a20dfeb4873..7a6d483d6c72bc 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.test.js @@ -6,6 +6,7 @@ */ import { of } from 'rxjs'; +import { TestScheduler } from 'rxjs/testing'; import { functionWrapper } from '../../../test_helpers/function_wrapper'; import { switchFn } from './switch'; @@ -39,7 +40,13 @@ describe('switch', () => { result: 5, }, ]; - const nonMatchingCases = mockCases.filter((c) => !c.matches); + const nonMatchingCases = mockCases.filter(({ matches }) => !matches); + + let testScheduler; + + beforeEach(() => { + testScheduler = new TestScheduler((actual, expected) => expect(actual).toStrictEqual(expected)); + }); describe('spec', () => { it('is a function', () => { @@ -51,13 +58,19 @@ describe('switch', () => { describe('with no cases', () => { it('should return the context if no default is provided', () => { const context = 'foo'; - expect(fn(context, {})).resolves.toBe(context); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, {})).toBe('(0|)', [context]) + ); }); it('should return the default if provided', () => { const context = 'foo'; const args = { default: () => of('bar') }; - expect(fn(context, args)).resolves.toBe('bar'); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', ['bar']) + ); }); }); @@ -65,7 +78,10 @@ describe('switch', () => { it('should return the context if no default is provided', () => { const context = 'foo'; const args = { case: nonMatchingCases.map(getter) }; - expect(fn(context, args)).resolves.toBe(context); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', [context]) + ); }); it('should return the default if provided', () => { @@ -74,16 +90,22 @@ describe('switch', () => { case: nonMatchingCases.map(getter), default: () => of('bar'), }; - expect(fn(context, args)).resolves.toBe('bar'); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', ['bar']) + ); }); }); describe('with matching cases', () => { - it('should return the first match', async () => { + it('should return the first match', () => { const context = 'foo'; const args = { case: mockCases.map(getter) }; - const firstMatch = mockCases.find((c) => c.matches); - expect(fn(context, args)).resolves.toBe(firstMatch.result); + const { result } = mockCases.find(({ matches }) => matches); + + testScheduler.run(({ expectObservable }) => + expectObservable(fn(context, args)).toBe('(0|)', [result]) + ); }); }); }); diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.ts index 4258f56ec4cf5f..f4e6c92c91cb60 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/switch.ts @@ -5,18 +5,23 @@ * 2.0. */ -import { Observable } from 'rxjs'; -import { take } from 'rxjs/operators'; +import { Observable, defer, from, of } from 'rxjs'; +import { concatMap, filter, merge, pluck, take } from 'rxjs/operators'; import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common'; import { Case } from '../../../types'; import { getFunctionHelp } from '../../../i18n'; interface Arguments { - case: Array<() => Observable>; + case?: Array<() => Observable>; default?(): Observable; } -export function switchFn(): ExpressionFunctionDefinition<'switch', unknown, Arguments, unknown> { +export function switchFn(): ExpressionFunctionDefinition< + 'switch', + unknown, + Arguments, + Observable +> { const { help, args: argHelp } = getFunctionHelp().switch; return { @@ -29,7 +34,7 @@ export function switchFn(): ExpressionFunctionDefinition<'switch', unknown, Argu resolve: false, multi: true, required: true, - help: argHelp.case, + help: argHelp.case!, }, default: { aliases: ['finally'], @@ -37,18 +42,14 @@ export function switchFn(): ExpressionFunctionDefinition<'switch', unknown, Argu help: argHelp.default!, }, }, - fn: async (input, args) => { - const cases = args.case || []; - - for (let i = 0; i < cases.length; i++) { - const { matches, result } = await cases[i]().pipe(take(1)).toPromise(); - - if (matches) { - return result; - } - } - - return args.default?.().pipe(take(1)).toPromise() ?? input; + fn(input, args) { + return from(args.case ?? []).pipe( + concatMap((item) => item()), + filter(({ matches }) => matches), + pluck('result'), + merge(defer(() => args.default?.() ?? of(input))), + take(1) + ); }, }; } diff --git a/x-pack/plugins/canvas/i18n/components.ts b/x-pack/plugins/canvas/i18n/components.ts index a797a8bda061b6..7a23137e7ef60e 100644 --- a/x-pack/plugins/canvas/i18n/components.ts +++ b/x-pack/plugins/canvas/i18n/components.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { BOLD_MD_TOKEN, CANVAS, HTML, JSON, KIBANA, PDF, POST, URL, ZIP } from './constants'; +import { BOLD_MD_TOKEN, CANVAS, HTML, JSON, PDF, URL, ZIP } from './constants'; export const ComponentStrings = { AddEmbeddableFlyout: { @@ -1418,95 +1418,10 @@ export const ComponentStrings = { URL, }, }), - getCopyReportingConfigMessage: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.copyReportingConfigMessage', { - defaultMessage: 'Copied reporting configuration to clipboard', - }), getCopyShareConfigMessage: () => i18n.translate('xpack.canvas.workpadHeaderShareMenu.copyShareConfigMessage', { defaultMessage: 'Copied share markup to clipboard', }), - getExportPDFErrorTitle: (workpadName: string) => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.exportPDFErrorMessage', { - defaultMessage: "Failed to create {PDF} for '{workpadName}'", - values: { - PDF, - workpadName, - }, - }), - getExportPDFMessage: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.exportPDFMessage', { - defaultMessage: 'Exporting {PDF}. You can track the progress in Management.', - values: { - PDF, - }, - }), - getExportPDFTitle: (workpadName: string) => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.exportPDFTitle', { - defaultMessage: "{PDF} export of workpad '{workpadName}'", - values: { - PDF, - workpadName, - }, - }), - getPDFFullPageLayoutHelpText: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.FullPageLayoutHelpText', { - defaultMessage: 'Remove borders and footer logo', - }), - getPDFFullPageLayoutLabel: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.FullPageLayoutLabel', { - defaultMessage: 'Full page layout', - }), - getPDFPanelAdvancedOptionsLabel: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelAdvancedOptionsLabel', { - defaultMessage: 'Advanced options', - }), - getPDFPanelCopyAriaLabel: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyAriaLabel', { - defaultMessage: - 'Alternatively, you can generate a {PDF} from a script or with Watcher by using this {URL}. Press Enter to copy the {URL} to clipboard.', - values: { - PDF, - URL, - }, - }), - getPDFPanelCopyButtonLabel: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyButtonLabel', { - defaultMessage: 'Copy {POST} {URL}', - values: { - POST, - URL, - }, - }), - getPDFPanelCopyDescription: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyDescription', { - defaultMessage: - 'Alternatively, copy this {POST} {URL} to call generation from outside {KIBANA} or from Watcher.', - values: { - POST, - KIBANA, - URL, - }, - }), - getPDFPanelGenerateButtonLabel: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateButtonLabel', { - defaultMessage: 'Generate {PDF}', - values: { - PDF, - }, - }), - getPDFPanelGenerateDescription: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateDescription', { - defaultMessage: - '{PDF}s can take a minute or two to generate based on the size of your workpad.', - values: { - PDF, - }, - }), - getPDFPanelOptionsLabel: () => - i18n.translate('xpack.canvas.workpadHeaderShareMenu.pdfPanelOptionsLabel', { - defaultMessage: 'Options', - }), getShareableZipErrorTitle: (workpadName: string) => i18n.translate('xpack.canvas.workpadHeaderShareMenu.shareWebsiteErrorTitle', { defaultMessage: diff --git a/x-pack/plugins/canvas/kibana.json b/x-pack/plugins/canvas/kibana.json index 6213ecb58347c1..5faeaefc9e3922 100644 --- a/x-pack/plugins/canvas/kibana.json +++ b/x-pack/plugins/canvas/kibana.json @@ -29,7 +29,6 @@ "kibanaUtils", "lens", "maps", - "reporting", "savedObjects", "visualizations" ] diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/__snapshots__/share_menu.stories.storyshot b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/__snapshots__/share_menu.stories.storyshot index 302e015ea1d3a3..c78ff5bf781eca 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/__snapshots__/share_menu.stories.storyshot +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/__snapshots__/share_menu.stories.storyshot @@ -1,6 +1,37 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Storyshots components/WorkpadHeader/ShareMenu default 1`] = ` +exports[`Storyshots components/WorkpadHeader/ShareMenu minimal 1`] = ` +
+
+
+ +
+
+
+`; + +exports[`Storyshots components/WorkpadHeader/ShareMenu with Reporting 1`] = `
( -
- 'PDF URL String'} - onCopy={action('onCopy')} - onExport={action('onExport')} - /> -
- )); diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/share_menu.stories.tsx b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/share_menu.stories.tsx index bca96f3851e371..20e52b40bc702d 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/share_menu.stories.tsx +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/__stories__/share_menu.stories.tsx @@ -5,19 +5,34 @@ * 2.0. */ -import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; +import { storiesOf } from '@storybook/react'; import React from 'react'; +import { platformService } from '../../../../services/stubs/platform'; +import { reportingService } from '../../../../services/stubs/reporting'; import { ShareMenu } from '../share_menu.component'; -storiesOf('components/WorkpadHeader/ShareMenu', module).add('default', () => ( +storiesOf('components/WorkpadHeader/ShareMenu', module).add('minimal', () => ( { - action(`getExportUrl('${type}')`); - return type; + /> +)); + +storiesOf('components/WorkpadHeader/ShareMenu', module).add('with Reporting', () => ( + )); diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/pdf_panel.tsx b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/pdf_panel.tsx deleted file mode 100644 index b412bd5328a5bd..00000000000000 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/pdf_panel.tsx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { useState } from 'react'; -import { - EuiAccordion, - EuiButton, - EuiFormRow, - EuiHorizontalRule, - EuiSpacer, - EuiSwitch, - EuiText, - EuiTitle, -} from '@elastic/eui'; -import { Clipboard } from '../../clipboard'; -import { LayoutType } from './utils'; - -import { ComponentStrings } from '../../../../i18n/components'; -const { WorkpadHeaderShareMenu: strings } = ComponentStrings; - -interface Props { - /** Retrieve URL that will invoke PDF Report generation. */ - getPdfURL: (layout: LayoutType) => string; - /** Handler to invoke when the PDF is exported */ - onExport: (layout: LayoutType) => void; - /** Handler to invoke when the URL is copied to the clipboard. */ - onCopy: () => void; -} - -/** - * A panel displayed in the Export Menu with options in which to generate PDF Reports. - */ -export const PDFPanel = ({ getPdfURL, onExport, onCopy }: Props) => { - const [reportLayout, setReportLayout] = useState('preserve_layout'); - - return ( -
- -

{strings.getPDFPanelGenerateDescription()}

-
- - -
{strings.getPDFPanelOptionsLabel()}
-
- - - - reportLayout === 'canvas' - ? setReportLayout('preserve_layout') - : setReportLayout('canvas') - } - data-test-subj="reportModeToggle" - /> - - onExport(reportLayout)} - size="s" - style={{ width: '100%' }} - data-test-subj="generateReportButton" - > - {strings.getPDFPanelGenerateButtonLabel()} - - - - - -

{strings.getPDFPanelCopyDescription()}

-
- - - - {strings.getPDFPanelCopyButtonLabel()} - - -
-
- ); -}; diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.component.tsx b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.component.tsx index 0d2e877bebdfd3..d4cb4d0736bb14 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.component.tsx +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.component.tsx @@ -5,47 +5,47 @@ * 2.0. */ -import React, { FunctionComponent, useState } from 'react'; -import PropTypes from 'prop-types'; import { EuiButtonEmpty, EuiContextMenu, EuiIcon } from '@elastic/eui'; +import { IBasePath } from 'kibana/public'; +import PropTypes from 'prop-types'; +import React, { FunctionComponent, useState } from 'react'; +import { ReportingStart } from '../../../../../reporting/public'; import { ComponentStrings } from '../../../../i18n/components'; import { flattenPanelTree } from '../../../lib/flatten_panel_tree'; -import { Popover, ClosePopoverFn } from '../../popover'; -import { PDFPanel } from './pdf_panel'; +import { ClosePopoverFn, Popover } from '../../popover'; import { ShareWebsiteFlyout } from './flyout'; -import { LayoutType } from './utils'; +import { CanvasWorkpadSharingData, getPdfJobParams } from './utils'; const { WorkpadHeaderShareMenu: strings } = ComponentStrings; type CopyTypes = 'pdf' | 'reportingConfig'; type ExportTypes = 'pdf' | 'json'; -type ExportUrlTypes = 'pdf'; type CloseTypes = 'share'; export type OnCopyFn = (type: CopyTypes) => void; -export type OnExportFn = (type: ExportTypes, layout?: LayoutType) => void; +export type OnExportFn = (type: ExportTypes) => void; export type OnCloseFn = (type: CloseTypes) => void; -export type GetExportUrlFn = (type: ExportUrlTypes, layout: LayoutType) => string; export interface Props { - /** Flag to include the Reporting option only if Reporting is enabled */ - includeReporting: boolean; - /** Handler to invoke when an export URL is copied to the clipboard. */ - onCopy: OnCopyFn; + /** Canvas workpad to export as PDF **/ + sharingData: CanvasWorkpadSharingData; + sharingServices: { + /** BasePath dependency **/ + basePath: IBasePath; + /** Reporting dependency **/ + reporting?: ReportingStart; + }; /** Handler to invoke when an end product is exported. */ onExport: OnExportFn; - /** Handler to retrive an export URL based on the type of export requested. */ - getExportUrl: GetExportUrlFn; } /** * The Menu for Exporting a Workpad from Canvas. */ export const ShareMenu: FunctionComponent = ({ - includeReporting, - onCopy, + sharingData, + sharingServices: services, onExport, - getExportUrl, }) => { const [showFlyout, setShowFlyout] = useState(false); @@ -53,22 +53,6 @@ export const ShareMenu: FunctionComponent = ({ setShowFlyout(false); }; - const getPDFPanel = (closePopover: ClosePopoverFn) => { - return ( - getExportUrl('pdf', layoutType)} - onExport={(layoutType) => { - onExport('pdf', layoutType); - closePopover(); - }} - onCopy={() => { - onCopy('pdf'); - closePopover(); - }} - /> - ); - }; - const getPanelTree = (closePopover: ClosePopoverFn) => ({ id: 0, items: [ @@ -80,14 +64,20 @@ export const ShareMenu: FunctionComponent = ({ closePopover(); }, }, - includeReporting + services.reporting != null ? { name: strings.getShareDownloadPDFTitle(), icon: 'document', panel: { id: 1, title: strings.getShareDownloadPDFTitle(), - content: getPDFPanel(closePopover), + content: ( + getPdfJobParams(sharingData, services.basePath)} + layoutOption="canvas" + onClose={closePopover} + /> + ), }, 'data-test-subj': 'sharePanel-PDFReports', } @@ -132,8 +122,5 @@ export const ShareMenu: FunctionComponent = ({ }; ShareMenu.propTypes = { - includeReporting: PropTypes.bool.isRequired, - onCopy: PropTypes.func.isRequired, onExport: PropTypes.func.isRequired, - getExportUrl: PropTypes.func.isRequired, }; diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.ts b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.ts index 47b5e755d439cf..fc4906817cf6fc 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.ts +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/share_menu.ts @@ -7,16 +7,12 @@ import { connect } from 'react-redux'; import { compose, withProps } from 'recompose'; -import { jobCompletionNotifications } from '../../../../../../plugins/reporting/public'; -import { getWorkpad, getPages } from '../../../state/selectors/workpad'; -import { getWindow } from '../../../lib/get_window'; +import { ComponentStrings } from '../../../../i18n'; +import { CanvasWorkpad, State } from '../../../../types'; import { downloadWorkpad } from '../../../lib/download_workpad'; -import { ShareMenu as Component, Props as ComponentProps } from './share_menu.component'; -import { getPdfUrl, createPdf } from './utils'; -import { State, CanvasWorkpad } from '../../../../types'; import { withServices, WithServicesProps } from '../../../services'; - -import { ComponentStrings } from '../../../../i18n'; +import { getPages, getWorkpad } from '../../../state/selectors/workpad'; +import { Props as ComponentProps, ShareMenu as Component } from './share_menu.component'; const { WorkpadHeaderShareMenu: strings } = ComponentStrings; @@ -25,17 +21,6 @@ const mapStateToProps = (state: State) => ({ pageCount: getPages(state).length, }); -const getAbsoluteUrl = (path: string) => { - const { location } = getWindow(); - - if (!location) { - return path; - } // fallback for mocked window object - - const { protocol, hostname, port } = location; - return `${protocol}//${hostname}:${port}${path}`; -}; - interface Props { workpad: CanvasWorkpad; pageCount: number; @@ -45,63 +30,28 @@ export const ShareMenu = compose( connect(mapStateToProps), withServices, withProps( - ({ workpad, pageCount, services }: Props & WithServicesProps): ComponentProps => ({ - includeReporting: services.reporting.includeReporting(), - getExportUrl: (type, layout) => { - if (type === 'pdf') { - const pdfUrl = getPdfUrl( - workpad, - layout, - { pageCount }, - services.platform.getBasePathInterface() - ); - return getAbsoluteUrl(pdfUrl); - } - - throw new Error(strings.getUnknownExportErrorMessage(type)); - }, - onCopy: (type) => { - switch (type) { - case 'pdf': - services.notify.info(strings.getCopyPDFMessage()); - break; - case 'reportingConfig': - services.notify.info(strings.getCopyReportingConfigMessage()); - break; - default: - throw new Error(strings.getUnknownExportErrorMessage(type)); - } - }, - onExport: (type, layout) => { - switch (type) { - case 'pdf': - return createPdf( - workpad, - layout || 'preserve_layout', - { pageCount }, - services.platform.getBasePathInterface() - ) - .then(({ data }: { data: { job: { id: string } } }) => { - services.notify.info(strings.getExportPDFMessage(), { - title: strings.getExportPDFTitle(workpad.name), - }); - - // register the job so a completion notification shows up when it's ready - jobCompletionNotifications.add(data.job.id); - }) - .catch((err: Error) => { - services.notify.error(err, { - title: strings.getExportPDFErrorTitle(workpad.name), - 'data-test-subj': 'queueReportError', - }); - }); - case 'json': - downloadWorkpad(workpad.id); - return; - default: - throw new Error(strings.getUnknownExportErrorMessage(type)); - } - }, - }) + ({ workpad, pageCount, services }: Props & WithServicesProps): ComponentProps => { + const { + platform, + reporting: { start: reporting }, + } = services; + + return { + sharingServices: { basePath: platform.getBasePathInterface(), reporting }, + sharingData: { workpad, pageCount }, + onExport: (type) => { + switch (type) { + case 'pdf': + // notifications are automatically handled by the Reporting plugin + break; + case 'json': + downloadWorkpad(workpad.id); + return; + default: + throw new Error(strings.getUnknownExportErrorMessage(type)); + } + }, + }; + } ) )(Component); diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts index df82feb088379f..fd6f4bb894991c 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.test.ts @@ -7,9 +7,8 @@ jest.mock('../../../../common/lib/fetch'); -import { getPdfUrl, createPdf, LayoutType } from './utils'; +import { getPdfJobParams } from './utils'; import { workpads } from '../../../../__fixtures__/workpads'; -import { fetch } from '../../../../common/lib/fetch'; import { IBasePath } from 'kibana/public'; const basePath = ({ @@ -17,33 +16,36 @@ const basePath = ({ get: () => 'basepath/s/spacey', serverBasePath: `basepath`, } as unknown) as IBasePath; -const workpad = workpads[0]; - -test('getPdfUrl returns the correct url for canvas layout', () => { - ['canvas', 'preserve_layout'].forEach((layout) => { - const url = getPdfUrl(workpad, layout as LayoutType, { pageCount: 2 }, basePath); - - expect(url).toMatchInlineSnapshot( - `"basepath/s/spacey//api/reporting/generate/printablePdf?jobParams=(browserTimezone:America%2FNew_York,layout:(dimensions:(height:0,width:0),id:${layout}),objectType:'canvas%20workpad',relativeUrls:!(%2Fs%2Fspacey%2Fapp%2Fcanvas%23%2Fexport%2Fworkpad%2Fpdf%2Fbase-workpad%2Fpage%2F1,%2Fs%2Fspacey%2Fapp%2Fcanvas%23%2Fexport%2Fworkpad%2Fpdf%2Fbase-workpad%2Fpage%2F2),title:'base%20workpad')"` - ); - }); -}); - -test('createPdf posts to create the pdf with canvas layout', () => { - ['canvas', 'preserve_layout'].forEach((layout, index) => { - createPdf(workpad, layout as LayoutType, { pageCount: 2 }, basePath); - - expect(fetch.post).toBeCalled(); - - const args = (fetch.post as jest.MockedFunction).mock.calls[index]; - - expect(args[0]).toMatchInlineSnapshot( - `"basepath/s/spacey//api/reporting/generate/printablePdf"` - ); - expect(args[1]).toMatchInlineSnapshot(` - Object { - "jobParams": "(browserTimezone:America/New_York,layout:(dimensions:(height:0,width:0),id:${layout}),objectType:'canvas workpad',relativeUrls:!(/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/1,/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/2),title:'base workpad')", - } - `); - }); +const workpadSharingData = { workpad: workpads[0], pageCount: 12 }; + +test('getPdfJobParams returns the correct job params for canvas layout', () => { + const jobParams = getPdfJobParams(workpadSharingData, basePath); + expect(jobParams).toMatchInlineSnapshot(` + Object { + "browserTimezone": "America/New_York", + "layout": Object { + "dimensions": Object { + "height": 0, + "width": 0, + }, + "id": "canvas", + }, + "objectType": "canvas workpad", + "relativeUrls": Array [ + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/1", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/2", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/3", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/4", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/5", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/6", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/7", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/8", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/9", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/10", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/11", + "/s/spacey/app/canvas#/export/workpad/pdf/base-workpad/page/12", + ], + "title": "base workpad", + } + `); }); diff --git a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.ts b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.ts index 40797ef0977819..9586242bc7386f 100644 --- a/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.ts +++ b/x-pack/plugins/canvas/public/components/workpad_header/share_menu/utils.ts @@ -5,33 +5,24 @@ * 2.0. */ -import rison from 'rison-node'; import { IBasePath } from 'kibana/public'; import moment from 'moment-timezone'; -import { fetch } from '../../../../common/lib/fetch'; +import rison from 'rison-node'; +import { BaseParams } from '../../../../../reporting/common/types'; import { CanvasWorkpad } from '../../../../types'; -import { url } from '../../../../../../../src/plugins/kibana_utils/public'; -interface PageCount { +export interface CanvasWorkpadSharingData { + workpad: Pick; pageCount: number; } -export type LayoutType = 'canvas' | 'preserve_layout'; - -type Arguments = [CanvasWorkpad, LayoutType, PageCount, IBasePath]; - -interface PdfUrlData { - createPdfUri: string; - createPdfPayload: { jobParams: string }; -} +// TODO: get the correct type from Reporting plugin +type JobParamsPDF = BaseParams & { relativeUrls: string[] }; -function getPdfUrlParts( - { id, name: title, width, height }: CanvasWorkpad, - layoutType: LayoutType, - { pageCount }: PageCount, +export function getPdfJobParams( + { workpad: { id, name: title, width, height }, pageCount }: CanvasWorkpadSharingData, basePath: IBasePath -): PdfUrlData { - const reportingEntry = basePath.prepend('/api/reporting/generate'); +): JobParamsPDF { const urlPrefix = basePath.get().replace(basePath.serverBasePath, ''); // for Spaces prefix, which is included in basePath.get() const canvasEntry = `${urlPrefix}/app/canvas#`; @@ -51,34 +42,14 @@ function getPdfUrlParts( workpadUrls.push(rison.encode(`${canvasEntry}/export/workpad/pdf/${id}/page/${i}`)); } - const jobParams = { + return { browserTimezone: moment.tz.guess(), layout: { dimensions: { width, height }, - id: layoutType, + id: 'canvas', }, objectType: 'canvas workpad', relativeUrls: workpadUrls, title, }; - - return { - createPdfUri: `${reportingEntry}/printablePdf`, - createPdfPayload: { - jobParams: rison.encode(jobParams), - }, - }; -} - -export function getPdfUrl(...args: Arguments): string { - const urlParts = getPdfUrlParts(...args); - const param = (key: string, val: any) => - url.encodeUriQuery(key, true) + (val === true ? '' : '=' + url.encodeUriQuery(val, true)); - - return `${urlParts.createPdfUri}?${param('jobParams', urlParts.createPdfPayload.jobParams)}`; -} - -export function createPdf(...args: Arguments) { - const { createPdfUri, createPdfPayload } = getPdfUrlParts(...args); - return fetch.post(createPdfUri, createPdfPayload); } diff --git a/x-pack/plugins/canvas/public/services/reporting.ts b/x-pack/plugins/canvas/public/services/reporting.ts index 3299363cd5c7f1..4fa40401472c65 100644 --- a/x-pack/plugins/canvas/public/services/reporting.ts +++ b/x-pack/plugins/canvas/public/services/reporting.ts @@ -5,10 +5,11 @@ * 2.0. */ +import { ReportingStart } from '../../../reporting/public'; import { CanvasServiceFactory } from './'; export interface ReportingService { - includeReporting: () => boolean; + start?: ReportingStart; } export const reportingServiceFactory: CanvasServiceFactory = ( @@ -18,18 +19,24 @@ export const reportingServiceFactory: CanvasServiceFactory = ( startPlugins ): ReportingService => { const { reporting } = startPlugins; + + const reportingEnabled = () => ({ start: reporting }); + const reportingDisabled = () => ({ start: undefined }); + if (!reporting) { // Reporting is not enabled - return { includeReporting: () => false }; + return reportingDisabled(); } if (reporting.usesUiCapabilities()) { - // Canvas has declared Reporting as a subfeature with the `generatePdf` UI Capability - return { - includeReporting: () => coreStart.application.capabilities.canvas?.generatePdf === true, - }; + if (coreStart.application.capabilities.canvas?.generatePdf === true) { + // Canvas has declared Reporting as a subfeature with the `generatePdf` UI Capability + return reportingEnabled(); + } else { + return reportingDisabled(); + } } - // Reporting is enabled as an Elasticsearch feature (Legacy/Deprecated) - return { includeReporting: () => true }; + // Legacy/Deprecated: Reporting is enabled as an Elasticsearch feature + return reportingEnabled(); }; diff --git a/x-pack/plugins/canvas/public/services/stubs/reporting.ts b/x-pack/plugins/canvas/public/services/stubs/reporting.ts index f257dd14543ecd..b32dfc51cbfde8 100644 --- a/x-pack/plugins/canvas/public/services/stubs/reporting.ts +++ b/x-pack/plugins/canvas/public/services/stubs/reporting.ts @@ -8,5 +8,16 @@ import { ReportingService } from '../reporting'; export const reportingService: ReportingService = { - includeReporting: () => true, + start: { + usesUiCapabilities: () => true, + components: { + ReportingPanelPDF: () => (null as unknown) as JSX.Element, + }, + getDefaultLayoutSelectors: () => ({ + screenshot: 'stub', + renderComplete: 'stub', + itemsCountAttribute: 'stub', + timefilterDurationAttribute: 'stub', + }), + }, }; diff --git a/x-pack/plugins/canvas/shareable_runtime/webpack.config.js b/x-pack/plugins/canvas/shareable_runtime/webpack.config.js index e85840e8734308..d0bdc292619d89 100644 --- a/x-pack/plugins/canvas/shareable_runtime/webpack.config.js +++ b/x-pack/plugins/canvas/shareable_runtime/webpack.config.js @@ -38,7 +38,7 @@ module.exports = { 'src/plugins/data/public/expressions/interpreter' ), 'kbn/interpreter': path.resolve(KIBANA_ROOT, 'packages/kbn-interpreter/target/common'), - tinymath: path.resolve(KIBANA_ROOT, 'node_modules/tinymath/lib/tinymath.es5.js'), + tinymath: path.resolve(KIBANA_ROOT, 'node_modules/tinymath/lib/tinymath.min.js'), core_app_image_assets: path.resolve(KIBANA_ROOT, 'src/core/public/core_app/images'), }, extensions: ['.js', '.json', '.ts', '.tsx', '.scss'], diff --git a/x-pack/plugins/cases/common/api/connectors/index.ts b/x-pack/plugins/cases/common/api/connectors/index.ts index f9b7c8b12c2cd1..2a81396025d9af 100644 --- a/x-pack/plugins/cases/common/api/connectors/index.ts +++ b/x-pack/plugins/cases/common/api/connectors/index.ts @@ -38,6 +38,8 @@ export enum ConnectorTypes { none = '.none', } +export const connectorTypes = Object.values(ConnectorTypes); + const ConnectorJiraTypeFieldsRt = rt.type({ type: rt.literal(ConnectorTypes.jira), fields: rt.union([JiraFieldsRT, rt.null]), diff --git a/x-pack/plugins/cases/kibana.json b/x-pack/plugins/cases/kibana.json index c59800aaf9bcba..4a85a64c7e03a8 100644 --- a/x-pack/plugins/cases/kibana.json +++ b/x-pack/plugins/cases/kibana.json @@ -3,11 +3,15 @@ "id": "cases", "kibanaVersion": "kibana", "extraPublicDirs": ["common"], - "requiredPlugins": ["actions", "esUiShared", "features", "kibanaReact", "kibanaUtils", "triggersActionsUi"], - "optionalPlugins": [ - "spaces", - "security" + "requiredPlugins": [ + "actions", + "esUiShared", + "features", + "kibanaReact", + "kibanaUtils", + "triggersActionsUi" ], + "optionalPlugins": ["spaces", "security"], "server": true, "ui": true, "version": "8.0.0" diff --git a/x-pack/plugins/cases/public/components/all_cases/all_cases_generic.tsx b/x-pack/plugins/cases/public/components/all_cases/all_cases_generic.tsx index 41509d9c0d1358..a364f8bf2b068a 100644 --- a/x-pack/plugins/cases/public/components/all_cases/all_cases_generic.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/all_cases_generic.tsx @@ -62,9 +62,11 @@ interface AllCasesGenericProps { caseDetailsNavigation?: CasesNavigation; // if not passed, case name is not displayed as a link (Formerly dependant on isSelectorView) configureCasesNavigation?: CasesNavigation; // if not passed, header with nav is not displayed (Formerly dependant on isSelectorView) createCaseNavigation: CasesNavigation; + disableAlerts?: boolean; hiddenStatuses?: CaseStatusWithAllStatus[]; isSelectorView?: boolean; onRowClick?: (theCase?: Case | SubCase) => void; + showTitle?: boolean; updateCase?: (newCase: Case) => void; userCanCrud: boolean; } @@ -75,9 +77,11 @@ export const AllCasesGeneric = React.memo( caseDetailsNavigation, configureCasesNavigation, createCaseNavigation, + disableAlerts, hiddenStatuses = [], isSelectorView, onRowClick, + showTitle, updateCase, userCanCrud, }) => { @@ -190,6 +194,7 @@ export const AllCasesGeneric = React.memo( const columns = useCasesColumns({ caseDetailsNavigation, + disableAlerts, dispatchUpdateCaseProperty, filterStatus: filterOptions.status, handleIsLoading, @@ -271,6 +276,7 @@ export const AllCasesGeneric = React.memo( createCaseNavigation={createCaseNavigation} configureCasesNavigation={configureCasesNavigation} refresh={refresh} + showTitle={showTitle} userCanCrud={userCanCrud} /> )} diff --git a/x-pack/plugins/cases/public/components/all_cases/columns.tsx b/x-pack/plugins/cases/public/components/all_cases/columns.tsx index cf5da3928446e1..947d405d188cf0 100644 --- a/x-pack/plugins/cases/public/components/all_cases/columns.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/columns.tsx @@ -55,6 +55,7 @@ const renderStringField = (field: string, dataTestSubj: string) => export interface GetCasesColumn { caseDetailsNavigation?: CasesNavigation; + disableAlerts?: boolean; dispatchUpdateCaseProperty: (u: UpdateCase) => void; filterStatus: string; handleIsLoading: (a: boolean) => void; @@ -64,6 +65,7 @@ export interface GetCasesColumn { } export const useCasesColumns = ({ caseDetailsNavigation, + disableAlerts = false, dispatchUpdateCaseProperty, filterStatus, handleIsLoading, @@ -203,15 +205,19 @@ export const useCasesColumns = ({ }, truncateText: true, }, - { - align: RIGHT_ALIGNMENT, - field: 'totalAlerts', - name: ALERTS, - render: (totalAlerts: Case['totalAlerts']) => - totalAlerts != null - ? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`) - : getEmptyTagValue(), - }, + ...(!disableAlerts + ? [ + { + align: RIGHT_ALIGNMENT, + field: 'totalAlerts', + name: ALERTS, + render: (totalAlerts: Case['totalAlerts']) => + totalAlerts != null + ? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`) + : getEmptyTagValue(), + }, + ] + : []), { align: RIGHT_ALIGNMENT, field: 'totalComment', diff --git a/x-pack/plugins/cases/public/components/all_cases/header.tsx b/x-pack/plugins/cases/public/components/all_cases/header.tsx index a6737b987e2c42..7452fe7e44b3c4 100644 --- a/x-pack/plugins/cases/public/components/all_cases/header.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/header.tsx @@ -20,6 +20,7 @@ interface OwnProps { configureCasesNavigation: CasesNavigation; createCaseNavigation: CasesNavigation; refresh: number; + showTitle?: boolean; userCanCrud: boolean; } @@ -40,9 +41,10 @@ export const CasesTableHeader: FunctionComponent = ({ configureCasesNavigation, createCaseNavigation, refresh, + showTitle = true, userCanCrud, }) => ( - + ; // if not passed, case name is not displayed as a link (Formerly dependant on isSelector) configureCasesNavigation: CasesNavigation; // if not passed, header with nav is not displayed (Formerly dependant on isSelector) createCaseNavigation: CasesNavigation; + disableAlerts?: boolean; + showTitle?: boolean; userCanCrud: boolean; } diff --git a/x-pack/plugins/cases/public/components/callout/callout.test.tsx b/x-pack/plugins/cases/public/components/callout/callout.test.tsx index 926fe7b63fb5af..0a0caa40a8783e 100644 --- a/x-pack/plugins/cases/public/components/callout/callout.test.tsx +++ b/x-pack/plugins/cases/public/components/callout/callout.test.tsx @@ -80,7 +80,7 @@ describe('Callout', () => { }); it('dismiss the callout correctly', () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.find(`[data-test-subj="callout-dismiss-md5-hex"]`).exists()).toBeTruthy(); wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).simulate('click'); wrapper.update(); diff --git a/x-pack/plugins/cases/public/components/callout/callout.tsx b/x-pack/plugins/cases/public/components/callout/callout.tsx index 8e2f439f02c4bd..4cd7fad10fe70c 100644 --- a/x-pack/plugins/cases/public/components/callout/callout.tsx +++ b/x-pack/plugins/cases/public/components/callout/callout.tsx @@ -35,11 +35,9 @@ const CallOutComponent = ({ type, ]); - return showCallOut ? ( + return showCallOut && !isEmpty(messages) ? ( - {!isEmpty(messages) && ( - - )} + {i18n.READ_ONLY_FEATURE_MSG}, diff --git a/x-pack/plugins/cases/public/components/case_action_bar/actions.test.tsx b/x-pack/plugins/cases/public/components/case_action_bar/actions.test.tsx index 886e740d564470..ed8e238db75e75 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/actions.test.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/actions.test.tsx @@ -26,7 +26,14 @@ jest.mock('react-router-dom', () => { }), }; }); - +const defaultProps = { + allCasesNavigation: { + href: 'all-cases-href', + onClick: () => {}, + }, + caseData: basicCase, + currentExternalIncident: null, +}; describe('CaseView actions', () => { const handleOnDeleteConfirm = jest.fn(); const handleToggleModal = jest.fn(); @@ -49,7 +56,7 @@ describe('CaseView actions', () => { it('clicking trash toggles modal', () => { const wrapper = mount( - + ); @@ -67,7 +74,7 @@ describe('CaseView actions', () => { })); const wrapper = mount( - + ); @@ -82,7 +89,7 @@ describe('CaseView actions', () => { const wrapper = mount( = ({ + allCasesNavigation, caseData, currentExternalIncident, disabled = false, }) => { - const history = useHistory(); // Delete case const { handleToggleModal, @@ -57,7 +58,7 @@ const ActionsComponent: React.FC = ({ ); if (isDeleted) { - history.push('/'); + allCasesNavigation.onClick(null); return null; } return ( diff --git a/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx b/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx index 0d29335ea730e7..724d35b20df535 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx @@ -16,7 +16,12 @@ describe('CaseActionBar', () => { const onRefresh = jest.fn(); const onUpdateField = jest.fn(); const defaultProps = { + allCasesNavigation: { + href: 'all-cases-href', + onClick: () => {}, + }, caseData: basicCase, + disableAlerting: false, isLoading: false, onRefresh, onUpdateField, diff --git a/x-pack/plugins/cases/public/components/case_action_bar/index.tsx b/x-pack/plugins/cases/public/components/case_action_bar/index.tsx index a68ae4b3ca6a74..d8e012b0721065 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/index.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/index.tsx @@ -16,16 +16,16 @@ import { EuiFlexItem, EuiIconTip, } from '@elastic/eui'; -import { CaseStatuses, CaseType } from '../../../common'; +import { Case, CaseStatuses, CaseType } from '../../../common'; import * as i18n from '../case_view/translations'; import { FormattedRelativePreferenceDate } from '../formatted_date'; import { Actions } from './actions'; -import { Case } from '../../containers/types'; import { CaseService } from '../../containers/use_get_case_user_actions'; import { StatusContextMenu } from './status_context_menu'; import { getStatusDate, getStatusTitle } from './helpers'; import { SyncAlertsSwitch } from '../case_settings/sync_alerts_switch'; import { OnUpdateFields } from '../case_view'; +import { CasesNavigation } from '../links'; const MyDescriptionList = styled(EuiDescriptionList)` ${({ theme }) => css` @@ -37,17 +37,21 @@ const MyDescriptionList = styled(EuiDescriptionList)` `; interface CaseActionBarProps { + allCasesNavigation: CasesNavigation; caseData: Case; currentExternalIncident: CaseService | null; disabled?: boolean; + disableAlerting: boolean; isLoading: boolean; onRefresh: () => void; onUpdateField: (args: OnUpdateFields) => void; } const CaseActionBarComponent: React.FC = ({ + allCasesNavigation, caseData, currentExternalIncident, disabled = false, + disableAlerting, isLoading, onRefresh, onUpdateField, @@ -104,25 +108,27 @@ const CaseActionBarComponent: React.FC = ({ - - - - - {i18n.SYNC_ALERTS} - - - - - - - - - - + {!disableAlerting && ( + + + + + {i18n.SYNC_ALERTS} + + + + + + + + + + + )} {i18n.CASE_REFRESH} @@ -130,6 +136,7 @@ const CaseActionBarComponent: React.FC = ({ ( + {i18n.DOES_NOT_EXIST_TITLE}} + titleSize="xs" + body={

{i18n.DOES_NOT_EXIST_DESCRIPTION(caseId)}

} + actions={ + + {i18n.DOES_NOT_EXIST_BUTTON} + + } + /> +); diff --git a/x-pack/plugins/cases/public/components/case_view/index.tsx b/x-pack/plugins/cases/public/components/case_view/index.tsx index 86b13ae5a863c4..df57e49073a604 100644 --- a/x-pack/plugins/cases/public/components/case_view/index.tsx +++ b/x-pack/plugins/cases/public/components/case_view/index.tsx @@ -6,7 +6,6 @@ */ import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react'; -// import { useDispatch } from 'react-redux'; import styled from 'styled-components'; import { isEmpty } from 'lodash/fp'; import { @@ -17,7 +16,7 @@ import { EuiHorizontalRule, } from '@elastic/eui'; -import { CaseStatuses, CaseAttributes, CaseType, Case, CaseConnector } from '../../../common'; +import { CaseStatuses, CaseAttributes, CaseType, Case, CaseConnector, Ecs } from '../../../common'; import { HeaderPage } from '../header_page'; import { EditableTitle } from '../header_page/editable_title'; import { TagList } from '../tag_list'; @@ -39,11 +38,11 @@ import { } from '../configure_cases/utils'; import { StatusActionButton } from '../status/button'; import * as i18n from './translations'; -import { Ecs } from '../../../common'; import { CasesTimelineIntegration, CasesTimelineIntegrationProvider } from '../timeline_context'; import { useTimelineContext } from '../timeline_context/use_timeline_context'; import { CasesNavigation } from '../links'; import { OwnerProvider } from '../owner_context'; +import { DoesNotExist } from './does_not_exist'; const gutterTimeline = '70px'; // seems to be a timeline reference from the original file export interface CaseViewComponentProps { @@ -53,8 +52,8 @@ export interface CaseViewComponentProps { configureCasesNavigation: CasesNavigation; getCaseDetailHrefWithCommentId: (commentId: string) => string; onComponentInitialized?: () => void; - ruleDetailsNavigation: CasesNavigation; - showAlertDetails: (alertId: string, index: string) => void; + ruleDetailsNavigation?: CasesNavigation; + showAlertDetails?: (alertId: string, index: string) => void; subCaseId?: string; useFetchAlertData: (alertIds: string[]) => [boolean, Record]; userCanCrud: boolean; @@ -327,7 +326,9 @@ export const CaseComponent = React.memo( const onShowAlertDetails = useCallback( (alertId: string, index: string) => { - showAlertDetails(alertId, index); + if (showAlertDetails) { + showAlertDetails(alertId, index); + } }, [showAlertDetails] ); @@ -359,9 +360,11 @@ export const CaseComponent = React.memo( title={caseData.title} > ( <> { const { data, isLoading, isError, fetchCase, updateCase } = useGetCase(caseId, subCaseId); if (isError) { - return null; + return ; } if (isLoading) { return ( diff --git a/x-pack/plugins/cases/public/components/case_view/translations.ts b/x-pack/plugins/cases/public/components/case_view/translations.ts index 41ffbbd9342dad..3d4558ac3d4a00 100644 --- a/x-pack/plugins/cases/public/components/case_view/translations.ts +++ b/x-pack/plugins/cases/public/components/case_view/translations.ts @@ -128,3 +128,20 @@ export const CHANGED_CONNECTOR_FIELD = i18n.translate('xpack.cases.caseView.fiel export const SYNC_ALERTS = i18n.translate('xpack.cases.caseView.syncAlertsLabel', { defaultMessage: `Sync alerts`, }); + +export const DOES_NOT_EXIST_TITLE = i18n.translate('xpack.cases.caseView.doesNotExist.title', { + defaultMessage: 'This case does not exist', +}); + +export const DOES_NOT_EXIST_DESCRIPTION = (caseId: string) => + i18n.translate('xpack.cases.caseView.doesNotExist.description', { + values: { + caseId, + }, + defaultMessage: + 'A case with id {caseId} could not be found. This likely means the case has been deleted, or the id is incorrect.', + }); + +export const DOES_NOT_EXIST_BUTTON = i18n.translate('xpack.cases.caseView.doesNotExist.button', { + defaultMessage: 'Back to Cases', +}); diff --git a/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx b/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx index 0a1da1219342ed..3cf01be40eb4ae 100644 --- a/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx +++ b/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx @@ -50,7 +50,7 @@ describe('Mapping', () => { wrappingComponent: TestProviders, }); expect(wrapper.find('[data-test-subj="field-mapping-desc"]').first().text()).toBe( - 'Field mappings require an established connection to ServiceNow ITSM. Please check your connection credentials.' + 'Failed to retrieve mappings for ServiceNow ITSM.' ); }); }); diff --git a/x-pack/plugins/cases/public/components/configure_cases/translations.ts b/x-pack/plugins/cases/public/components/configure_cases/translations.ts index 2fb2133ba470c1..a379b03a4f675f 100644 --- a/x-pack/plugins/cases/public/components/configure_cases/translations.ts +++ b/x-pack/plugins/cases/public/components/configure_cases/translations.ts @@ -102,8 +102,7 @@ export const FIELD_MAPPING_DESC = (thirdPartyName: string): string => { export const FIELD_MAPPING_DESC_ERR = (thirdPartyName: string): string => { return i18n.translate('xpack.cases.configureCases.fieldMappingDescErr', { values: { thirdPartyName }, - defaultMessage: - 'Field mappings require an established connection to { thirdPartyName }. Please check your connection credentials.', + defaultMessage: 'Failed to retrieve mappings for { thirdPartyName }.', }); }; export const EDIT_FIELD_MAPPING_TITLE = (thirdPartyName: string): string => { diff --git a/x-pack/plugins/cases/public/components/create/form.tsx b/x-pack/plugins/cases/public/components/create/form.tsx index 83f759947ba65b..cbd4fd7654259d 100644 --- a/x-pack/plugins/cases/public/components/create/form.tsx +++ b/x-pack/plugins/cases/public/components/create/form.tsx @@ -38,6 +38,7 @@ const MySpinner = styled(EuiLoadingSpinner)` interface Props { connectors?: ActionConnector[]; + disableAlerts?: boolean; hideConnectorServiceNowSir?: boolean; isLoadingConnectors?: boolean; withSteps?: boolean; @@ -46,6 +47,7 @@ const empty: ActionConnector[] = []; export const CreateCaseForm: React.FC = React.memo( ({ connectors = empty, + disableAlerts = false, isLoadingConnectors = false, hideConnectorServiceNowSir = false, withSteps = true, @@ -99,11 +101,10 @@ export const CreateCaseForm: React.FC = React.memo( [connectors, hideConnectorServiceNowSir, isLoadingConnectors, isSubmitting] ); - const allSteps = useMemo(() => [firstStep, secondStep, thirdStep], [ - firstStep, - secondStep, - thirdStep, - ]); + const allSteps = useMemo( + () => [firstStep, ...(!disableAlerts ? [secondStep] : []), thirdStep], + [disableAlerts, firstStep, secondStep, thirdStep] + ); return ( <> @@ -117,7 +118,7 @@ export const CreateCaseForm: React.FC = React.memo( ) : ( <> {firstStep.children} - {secondStep.children} + {!disableAlerts && secondStep.children} {thirdStep.children} )} diff --git a/x-pack/plugins/cases/public/components/create/form_context.tsx b/x-pack/plugins/cases/public/components/create/form_context.tsx index 8584892e1286c0..30a60fb5c1e47f 100644 --- a/x-pack/plugins/cases/public/components/create/form_context.tsx +++ b/x-pack/plugins/cases/public/components/create/form_context.tsx @@ -73,7 +73,7 @@ export const FormContext: React.FC = ({ const submitCase = useCallback( async ( - { connectorId: dataConnectorId, fields, syncAlerts, ...dataWithoutConnectorId }, + { connectorId: dataConnectorId, fields, syncAlerts = true, ...dataWithoutConnectorId }, isValid ) => { if (isValid) { diff --git a/x-pack/plugins/cases/public/components/create/index.tsx b/x-pack/plugins/cases/public/components/create/index.tsx index 3362aa6af2078d..139a2103f6042b 100644 --- a/x-pack/plugins/cases/public/components/create/index.tsx +++ b/x-pack/plugins/cases/public/components/create/index.tsx @@ -34,6 +34,7 @@ const Container = styled.div` export interface CreateCaseProps extends Owner { afterCaseCreated?: (theCase: Case, postComment: UsePostComment['postComment']) => Promise; caseType?: CaseType; + disableAlerts?: boolean; hideConnectorServiceNowSir?: boolean; onCancel: () => void; onSuccess: (theCase: Case) => Promise; @@ -45,6 +46,7 @@ const CreateCaseComponent = ({ afterCaseCreated, caseType, hideConnectorServiceNowSir, + disableAlerts, onCancel, onSuccess, timelineIntegration, @@ -59,6 +61,7 @@ const CreateCaseComponent = ({ > diff --git a/x-pack/plugins/cases/public/components/links/index.tsx b/x-pack/plugins/cases/public/components/links/index.tsx index 310d700aa2a250..23eedc7c090bc6 100644 --- a/x-pack/plugins/cases/public/components/links/index.tsx +++ b/x-pack/plugins/cases/public/components/links/index.tsx @@ -16,7 +16,7 @@ import { import React, { useCallback } from 'react'; import * as i18n from './translations'; -export interface CasesNavigation { +export interface CasesNavigation { href: K extends 'configurable' ? (arg: T) => string : string; onClick: (arg: T) => void; } diff --git a/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx b/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx index a4ce8e3d925227..1b8e01b15db8dc 100644 --- a/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx +++ b/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx @@ -38,7 +38,7 @@ export interface ReturnUsePushToService { } export const usePushToService = ({ - configureCasesNavigation: { onClick, href }, + configureCasesNavigation: { href }, connector, caseId, caseServices, @@ -82,7 +82,7 @@ export const usePushToService = ({ id="xpack.cases.caseView.pushToServiceDisableByNoConnectors" values={{ link: ( - + {i18n.LINK_CONNECTOR_CONFIGURE} ), diff --git a/x-pack/plugins/cases/public/components/user_action_tree/index.tsx b/x-pack/plugins/cases/public/components/user_action_tree/index.tsx index 09b024fb2ca3d1..156e011a18d8d7 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/index.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/index.tsx @@ -21,7 +21,7 @@ import { isRight } from 'fp-ts/Either'; import * as i18n from './translations'; -import { Case, CaseUserActions } from '../../containers/types'; +import { Case, CaseUserActions } from '../../../common'; import { useUpdateComment } from '../../containers/use_update_comment'; import { useCurrentUser } from '../../common/lib/kibana'; import { AddComment, AddCommentRefObject } from '../add_comment'; @@ -56,7 +56,7 @@ export interface UserActionTreeProps { caseUserActions: CaseUserActions[]; connectors: ActionConnector[]; data: Case; - getRuleDetailsHref: (ruleId: string | null | undefined) => string; + getRuleDetailsHref?: (ruleId: string | null | undefined) => string; fetchUserActions: () => void; isLoadingDescription: boolean; isLoadingUserActions: boolean; @@ -397,18 +397,22 @@ export const UserActionTree = React.memo( return [ ...comments, - getAlertAttachment({ - action, - alertId, - getCaseDetailHrefWithCommentId, - getRuleDetailsHref, - index: alertIndex, - loadingAlertData, - onRuleDetailsClick, - ruleId, - ruleName, - onShowAlertDetails, - }), + ...(getRuleDetailsHref != null + ? [ + getAlertAttachment({ + action, + alertId, + getCaseDetailHrefWithCommentId, + getRuleDetailsHref, + index: alertIndex, + loadingAlertData, + onRuleDetailsClick, + ruleId, + ruleName, + onShowAlertDetails, + }), + ] + : []), ]; } else if (comment != null && comment.type === CommentType.generatedAlert) { // TODO: clean this up @@ -422,16 +426,20 @@ export const UserActionTree = React.memo( return [ ...comments, - getGeneratedAlertsAttachment({ - action, - alertIds, - getCaseDetailHrefWithCommentId, - getRuleDetailsHref, - onRuleDetailsClick, - renderInvestigateInTimelineActionComponent, - ruleId: comment.rule?.id ?? '', - ruleName: comment.rule?.name ?? i18n.UNKNOWN_RULE, - }), + ...(getRuleDetailsHref != null + ? [ + getGeneratedAlertsAttachment({ + action, + alertIds, + getCaseDetailHrefWithCommentId, + getRuleDetailsHref, + onRuleDetailsClick, + renderInvestigateInTimelineActionComponent, + ruleId: comment.rule?.id ?? '', + ruleName: comment.rule?.name ?? i18n.UNKNOWN_RULE, + }), + ] + : []), ]; } } diff --git a/x-pack/plugins/cases/public/containers/api.test.tsx b/x-pack/plugins/cases/public/containers/api.test.tsx index afd6b51b5f35d0..f9e128e7f713d7 100644 --- a/x-pack/plugins/cases/public/containers/api.test.tsx +++ b/x-pack/plugins/cases/public/containers/api.test.tsx @@ -161,7 +161,7 @@ describe('Case Configuration API', () => { query: { ...DEFAULT_QUERY_PARAMS, reporters, - tags: ['"coke"', '"pepsi"'], + tags: ['coke', 'pepsi'], search: 'hello', status: CaseStatuses.open, owner: [SECURITY_SOLUTION_OWNER], @@ -190,7 +190,7 @@ describe('Case Configuration API', () => { query: { ...DEFAULT_QUERY_PARAMS, reporters, - tags: ['"("', '"\\"double\\""'], + tags: ['(', '"double"'], search: 'hello', status: CaseStatuses.open, owner: [SECURITY_SOLUTION_OWNER], diff --git a/x-pack/plugins/cases/public/containers/api.ts b/x-pack/plugins/cases/public/containers/api.ts index 66a4d174b0ffb8..fc1dc34b4e1aca 100644 --- a/x-pack/plugins/cases/public/containers/api.ts +++ b/x-pack/plugins/cases/public/containers/api.ts @@ -189,7 +189,7 @@ export const getCases = async ({ }: FetchCasesProps): Promise => { const query = { reporters: filterOptions.reporters.map((r) => r.username ?? '').filter((r) => r !== ''), - tags: filterOptions.tags.map((t) => `"${t.replace(/"/g, '\\"')}"`), + tags: filterOptions.tags, status: filterOptions.status, ...(filterOptions.search.length > 0 ? { search: filterOptions.search } : {}), ...(filterOptions.onlyCollectionType ? { type: CaseType.collection } : {}), diff --git a/x-pack/plugins/cases/public/index.tsx b/x-pack/plugins/cases/public/index.tsx index e8589152b7ca8a..a33bb14cd78c1a 100644 --- a/x-pack/plugins/cases/public/index.tsx +++ b/x-pack/plugins/cases/public/index.tsx @@ -12,6 +12,11 @@ export function plugin(initializerContext: PluginInitializerContext) { return new CasesUiPlugin(initializerContext); } -export { CasesUiPlugin }; -export * from './plugin'; -export * from './types'; +export type { CasesUiPlugin }; +export type { CasesUiStart } from './types'; +export type { AllCasesProps } from './components/all_cases'; +export type { AllCasesSelectorModalProps } from './components/all_cases/selector_modal'; +export type { CaseViewProps } from './components/case_view'; +export type { ConfigureCasesProps } from './components/configure_cases'; +export type { CreateCaseProps } from './components/create'; +export type { RecentCasesProps } from './components/recent_cases'; diff --git a/x-pack/plugins/cases/public/types.ts b/x-pack/plugins/cases/public/types.ts index 2193832492aa22..2b31935c3ff970 100644 --- a/x-pack/plugins/cases/public/types.ts +++ b/x-pack/plugins/cases/public/types.ts @@ -44,12 +44,42 @@ export interface Owner { } export interface CasesUiStart { + /** + * Get the all cases table + * @param props AllCasesProps + * @returns A react component that displays all cases + */ getAllCases: (props: AllCasesProps) => ReactElement; + /** + * use Modal hook for all cases selector + * @param props UseAllCasesSelectorModalProps + * @returns A react component that is a modal for selecting a case + */ getAllCasesSelectorModal: ( props: AllCasesSelectorModalProps ) => ReactElement; + /** + * Get the case view component + * @param props CaseViewProps + * @returns A react component for viewing a specific case + */ getCaseView: (props: CaseViewProps) => ReactElement; + /** + * Get the configure case component + * @param props ConfigureCasesProps + * @returns A react component for configuring a specific case + */ getConfigureCases: (props: ConfigureCasesProps) => ReactElement; + /** + * Get the create case form + * @param props CreateCaseProps + * @returns A react component for creating a new case + */ getCreateCase: (props: CreateCaseProps) => ReactElement; + /** + * Get the recent cases component + * @param props RecentCasesProps + * @returns A react component for showing recent cases + */ getRecentCases: (props: RecentCasesProps) => ReactElement; } diff --git a/x-pack/plugins/cases/server/client/cases/push.ts b/x-pack/plugins/cases/server/client/cases/push.ts index dd527122d06168..c232f73c2a2351 100644 --- a/x-pack/plugins/cases/server/client/cases/push.ts +++ b/x-pack/plugins/cases/server/client/cases/push.ts @@ -25,6 +25,7 @@ import { createCaseError, flattenCaseSavedObject, getAlertInfoFromComments } fro import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; import { CasesClient, CasesClientArgs, CasesClientInternal } from '..'; import { Operations } from '../../authorization'; +import { casesConnectors } from '../../connectors'; /** * Returns true if the case should be closed based on the configuration settings and whether the case @@ -110,8 +111,7 @@ export const push = async ( }); const connectorMappings = await casesClientInternal.configuration.getMappings({ - connectorId: connector.id, - connectorType: connector.actionTypeId, + connector: theCase.connector, }); if (connectorMappings.length === 0) { @@ -125,6 +125,7 @@ export const push = async ( connector: connector as ActionConnector, mappings: connectorMappings[0].attributes.mappings, alerts, + casesConnectors, }); const pushRes = await actionsClient.execute({ diff --git a/x-pack/plugins/cases/server/client/cases/utils.test.ts b/x-pack/plugins/cases/server/client/cases/utils.test.ts index 9f18fa4931e62e..bfd5d1279420be 100644 --- a/x-pack/plugins/cases/server/client/cases/utils.test.ts +++ b/x-pack/plugins/cases/server/client/cases/utils.test.ts @@ -30,6 +30,7 @@ import { } from './utils'; import { flattenCaseSavedObject } from '../../common'; import { SECURITY_SOLUTION_OWNER } from '../../../common'; +import { casesConnectors } from '../../connectors'; const formatComment = { commentId: commentObj.id, @@ -443,6 +444,7 @@ describe('utils', () => { connector, mappings, alerts: [], + casesConnectors, }); expect(res).toEqual({ @@ -471,6 +473,7 @@ describe('utils', () => { connector, mappings, alerts: [], + casesConnectors, }); expect(res.comments).toEqual([ @@ -501,6 +504,7 @@ describe('utils', () => { }, ], alerts: [], + casesConnectors, }); expect(res.comments).toEqual([]); @@ -531,6 +535,7 @@ describe('utils', () => { }, ], alerts: [], + casesConnectors, }); expect(res.comments).toEqual([ @@ -561,6 +566,7 @@ describe('utils', () => { connector, mappings, alerts: [], + casesConnectors, }); expect(res.comments).toEqual([ @@ -595,6 +601,7 @@ describe('utils', () => { connector, mappings, alerts: [], + casesConnectors, }); expect(res).toEqual({ @@ -626,6 +633,7 @@ describe('utils', () => { connector, mappings, alerts: [], + casesConnectors, }).catch((e) => { expect(e).not.toBeNull(); expect(e).toEqual( @@ -645,6 +653,7 @@ describe('utils', () => { connector: { ...connector, actionTypeId: 'not-supported' }, mappings, alerts: [], + casesConnectors, }).catch((e) => { expect(e).not.toBeNull(); expect(e).toEqual(new Error('Invalid external service')); diff --git a/x-pack/plugins/cases/server/client/cases/utils.ts b/x-pack/plugins/cases/server/client/cases/utils.ts index ebcc5a07b4edde..d920c517a00044 100644 --- a/x-pack/plugins/cases/server/client/cases/utils.ts +++ b/x-pack/plugins/cases/server/client/cases/utils.ts @@ -12,17 +12,15 @@ import { CaseFullExternalService, CaseResponse, CaseUserActionsResponse, - CommentAttributes, - CommentRequestAlertType, - CommentRequestUserType, CommentResponse, CommentResponseAlertsType, CommentType, ConnectorMappingsAttributes, - ConnectorTypes, + CommentAttributes, + CommentRequestUserType, + CommentRequestAlertType, } from '../../../common'; import { ActionsClient } from '../../../../actions/server'; -import { externalServiceFormatters, FormatterConnectorTypes } from '../../connectors'; import { CasesClientGetAlertsResponse } from '../../client/alerts/types'; import { BasicParams, @@ -39,6 +37,7 @@ import { TransformFieldsArgs, } from './types'; import { getAlertIds } from '../utils'; +import { CasesConnectorsMap } from '../../connectors'; interface CreateIncidentArgs { actionsClient: ActionsClient; @@ -47,6 +46,7 @@ interface CreateIncidentArgs { connector: ActionConnector; mappings: ConnectorMappingsAttributes[]; alerts: CasesClientGetAlertsResponse; + casesConnectors: CasesConnectorsMap; } export const getLatestPushInfo = ( @@ -70,9 +70,6 @@ export const getLatestPushInfo = ( return null; }; -const isConnectorSupported = (connectorId: string): connectorId is FormatterConnectorTypes => - Object.values(ConnectorTypes).includes(connectorId as ConnectorTypes); - const getCommentContent = (comment: CommentResponse): string => { if (comment.type === CommentType.user) { return comment.comment; @@ -99,6 +96,7 @@ export const createIncident = async ({ connector, mappings, alerts, + casesConnectors, }: CreateIncidentArgs): Promise => { const { comments: caseComments, @@ -110,20 +108,15 @@ export const createIncident = async ({ updated_by: updatedBy, } = theCase; - if (!isConnectorSupported(connector.actionTypeId)) { - throw new Error('Invalid external service'); - } - const params = { title, description, createdAt, createdBy, updatedAt, updatedBy }; const latestPushInfo = getLatestPushInfo(connector.id, userActions); const externalId = latestPushInfo?.pushedInfo?.external_id ?? null; const defaultPipes = externalId ? ['informationUpdated'] : ['informationCreated']; let currentIncident: ExternalServiceParams | undefined; - const externalServiceFields = externalServiceFormatters[connector.actionTypeId].format( - theCase, - alerts - ); + const externalServiceFields = + casesConnectors.get(connector.actionTypeId)?.format(theCase, alerts) ?? {}; + let incident: Partial = { ...externalServiceFields }; if (externalId) { diff --git a/x-pack/plugins/cases/server/client/configure/client.ts b/x-pack/plugins/cases/server/client/configure/client.ts index d95667d5eee047..2f486556e4ae54 100644 --- a/x-pack/plugins/cases/server/client/configure/client.ts +++ b/x-pack/plugins/cases/server/client/configure/client.ts @@ -26,7 +26,6 @@ import { excess, GetConfigureFindRequest, GetConfigureFindRequestRt, - GetFieldsResponse, throwErrors, CasesConfigurationsResponse, CaseConfigurationsResponseRt, @@ -41,7 +40,6 @@ import { } from '../../common'; import { CasesClientInternal } from '../client_internal'; import { CasesClientArgs } from '../types'; -import { getFields } from './get_fields'; import { getMappings } from './get_mappings'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths @@ -49,12 +47,7 @@ import { FindActionResult } from '../../../../actions/server/types'; import { ActionType } from '../../../../actions/common'; import { Operations } from '../../authorization'; import { combineAuthorizedAndOwnerFilter } from '../utils'; -import { - ConfigurationGetFields, - MappingsArgs, - CreateMappingsArgs, - UpdateMappingsArgs, -} from './types'; +import { MappingsArgs, CreateMappingsArgs, UpdateMappingsArgs } from './types'; import { createMappings } from './create_mappings'; import { updateMappings } from './update_mappings'; import { @@ -69,7 +62,6 @@ import { * @ignore */ export interface InternalConfigureSubClient { - getFields(params: ConfigurationGetFields): Promise; getMappings( params: MappingsArgs ): Promise['saved_objects']>; @@ -116,12 +108,9 @@ export const createInternalConfigurationSubClient = ( casesClientInternal: CasesClientInternal ): InternalConfigureSubClient => { const configureSubClient: InternalConfigureSubClient = { - getFields: (params: ConfigurationGetFields) => getFields(params, clientArgs), getMappings: (params: MappingsArgs) => getMappings(params, clientArgs), - createMappings: (params: CreateMappingsArgs) => - createMappings(params, clientArgs, casesClientInternal), - updateMappings: (params: UpdateMappingsArgs) => - updateMappings(params, clientArgs, casesClientInternal), + createMappings: (params: CreateMappingsArgs) => createMappings(params, clientArgs), + updateMappings: (params: UpdateMappingsArgs) => updateMappings(params, clientArgs), }; return Object.freeze(configureSubClient); @@ -194,8 +183,7 @@ async function get( if (connector != null) { try { mappings = await casesClientInternal.configuration.getMappings({ - connectorId: connector.id, - connectorType: connector.type, + connector: transformESConnectorToCaseConnector(connector), }); } catch (e) { error = e.isBoom @@ -303,22 +291,22 @@ async function update( try { const resMappings = await casesClientInternal.configuration.getMappings({ - connectorId: connector != null ? connector.id : configuration.attributes.connector.id, - connectorType: connector != null ? connector.type : configuration.attributes.connector.type, + connector: + connector != null + ? connector + : transformESConnectorToCaseConnector(configuration.attributes.connector), }); mappings = resMappings.length > 0 ? resMappings[0].attributes.mappings : []; if (connector != null) { if (resMappings.length !== 0) { mappings = await casesClientInternal.configuration.updateMappings({ - connectorId: connector.id, - connectorType: connector.type, + connector, mappingId: resMappings[0].id, }); } else { mappings = await casesClientInternal.configuration.createMappings({ - connectorId: connector.id, - connectorType: connector.type, + connector, owner: configuration.attributes.owner, }); } @@ -326,9 +314,9 @@ async function update( } catch (e) { error = e.isBoom ? e.output.payload.message - : `Error connecting to ${ + : `Error creating mapping for ${ connector != null ? connector.name : configuration.attributes.connector.name - } instance`; + }`; } const patch = await caseConfigureService.patch({ @@ -429,14 +417,13 @@ async function create( try { mappings = await casesClientInternal.configuration.createMappings({ - connectorId: configuration.connector.id, - connectorType: configuration.connector.type, + connector: configuration.connector, owner: configuration.owner, }); } catch (e) { error = e.isBoom ? e.output.payload.message - : `Error connecting to ${configuration.connector.name} instance`; + : `Error creating mapping for ${configuration.connector.name}`; } const post = await caseConfigureService.post({ diff --git a/x-pack/plugins/cases/server/client/configure/create_mappings.ts b/x-pack/plugins/cases/server/client/configure/create_mappings.ts index b01f10d7a9e43b..bb4c32ae57071a 100644 --- a/x-pack/plugins/cases/server/client/configure/create_mappings.ts +++ b/x-pack/plugins/cases/server/client/configure/create_mappings.ts @@ -5,40 +5,33 @@ * 2.0. */ -import { ConnectorMappingsAttributes, ConnectorTypes } from '../../../common/api'; +import { ConnectorMappingsAttributes } from '../../../common/api'; import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server'; import { createCaseError } from '../../common/error'; -import { CasesClientArgs, CasesClientInternal } from '..'; +import { CasesClientArgs } from '..'; import { CreateMappingsArgs } from './types'; +import { casesConnectors } from '../../connectors'; export const createMappings = async ( - { connectorType, connectorId, owner }: CreateMappingsArgs, - clientArgs: CasesClientArgs, - casesClientInternal: CasesClientInternal + { connector, owner }: CreateMappingsArgs, + clientArgs: CasesClientArgs ): Promise => { const { unsecuredSavedObjectsClient, connectorMappingsService, logger } = clientArgs; try { - if (connectorType === ConnectorTypes.none) { - return []; - } - - const res = await casesClientInternal.configuration.getFields({ - connectorId, - connectorType, - }); + const mappings = casesConnectors.get(connector.type)?.getMapping() ?? []; const theMapping = await connectorMappingsService.post({ unsecuredSavedObjectsClient, attributes: { - mappings: res.defaultMappings, + mappings, owner, }, references: [ { type: ACTION_SAVED_OBJECT_TYPE, name: `associated-${ACTION_SAVED_OBJECT_TYPE}`, - id: connectorId, + id: connector.id, }, ], }); @@ -46,7 +39,7 @@ export const createMappings = async ( return theMapping.attributes.mappings; } catch (error) { throw createCaseError({ - message: `Failed to create mapping connector id: ${connectorId} type: ${connectorType}: ${error}`, + message: `Failed to create mapping connector id: ${connector.id} type: ${connector.type}: ${error}`, error, logger, }); diff --git a/x-pack/plugins/cases/server/client/configure/get_fields.ts b/x-pack/plugins/cases/server/client/configure/get_fields.ts deleted file mode 100644 index 78627cfaca6ed1..00000000000000 --- a/x-pack/plugins/cases/server/client/configure/get_fields.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import Boom from '@hapi/boom'; - -import { GetFieldsResponse } from '../../../common/api'; -import { createDefaultMapping, formatFields } from './utils'; -import { CasesClientArgs } from '..'; - -interface ConfigurationGetFields { - connectorId: string; - connectorType: string; -} - -export const getFields = async ( - { connectorType, connectorId }: ConfigurationGetFields, - clientArgs: CasesClientArgs -): Promise => { - const { actionsClient } = clientArgs; - const results = await actionsClient.execute({ - actionId: connectorId, - params: { - subAction: 'getFields', - subActionParams: {}, - }, - }); - if (results.status === 'error') { - throw Boom.failedDependency(results.serviceMessage); - } - const fields = formatFields(results.data, connectorType); - - return { fields, defaultMappings: createDefaultMapping(fields, connectorType) }; -}; diff --git a/x-pack/plugins/cases/server/client/configure/get_mappings.ts b/x-pack/plugins/cases/server/client/configure/get_mappings.ts index 3489c06b1da5ad..2fa0e8454bacfa 100644 --- a/x-pack/plugins/cases/server/client/configure/get_mappings.ts +++ b/x-pack/plugins/cases/server/client/configure/get_mappings.ts @@ -6,29 +6,25 @@ */ import { SavedObjectsFindResponse } from 'kibana/server'; -import { ConnectorMappings, ConnectorTypes } from '../../../common/api'; +import { ConnectorMappings } from '../../../common/api'; import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server'; import { createCaseError } from '../../common/error'; import { CasesClientArgs } from '..'; import { MappingsArgs } from './types'; export const getMappings = async ( - { connectorType, connectorId }: MappingsArgs, + { connector }: MappingsArgs, clientArgs: CasesClientArgs ): Promise['saved_objects']> => { const { unsecuredSavedObjectsClient, connectorMappingsService, logger } = clientArgs; try { - if (connectorType === ConnectorTypes.none) { - return []; - } - const myConnectorMappings = await connectorMappingsService.find({ unsecuredSavedObjectsClient, options: { hasReference: { type: ACTION_SAVED_OBJECT_TYPE, - id: connectorId, + id: connector.id, }, }, }); @@ -36,7 +32,7 @@ export const getMappings = async ( return myConnectorMappings.saved_objects; } catch (error) { throw createCaseError({ - message: `Failed to retrieve mapping connector id: ${connectorId} type: ${connectorType}: ${error}`, + message: `Failed to retrieve mapping connector id: ${connector.id} type: ${connector.type}: ${error}`, error, logger, }); diff --git a/x-pack/plugins/cases/server/client/configure/mock.ts b/x-pack/plugins/cases/server/client/configure/mock.ts deleted file mode 100644 index ad982a5cc12434..00000000000000 --- a/x-pack/plugins/cases/server/client/configure/mock.ts +++ /dev/null @@ -1,657 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ConnectorField, ConnectorMappingsAttributes, ConnectorTypes } from '../../../common'; -import { - JiraGetFieldsResponse, - ResilientGetFieldsResponse, - ServiceNowGetFieldsResponse, -} from './utils.test'; -interface TestMappings { - [key: string]: ConnectorMappingsAttributes[]; -} -export const mappings: TestMappings = { - [ConnectorTypes.jira]: [ - { - source: 'title', - target: 'summary', - action_type: 'overwrite', - }, - { - source: 'description', - target: 'description', - action_type: 'overwrite', - }, - { - source: 'comments', - target: 'comments', - action_type: 'append', - }, - ], - [`${ConnectorTypes.jira}-alt`]: [ - { - source: 'title', - target: 'title', - action_type: 'overwrite', - }, - { - source: 'description', - target: 'description', - action_type: 'overwrite', - }, - { - source: 'comments', - target: 'comments', - action_type: 'append', - }, - ], - [ConnectorTypes.resilient]: [ - { - source: 'title', - target: 'name', - action_type: 'overwrite', - }, - { - source: 'description', - target: 'description', - action_type: 'overwrite', - }, - { - source: 'comments', - target: 'comments', - action_type: 'append', - }, - ], - [ConnectorTypes.serviceNowITSM]: [ - { - source: 'title', - target: 'short_description', - action_type: 'overwrite', - }, - { - source: 'description', - target: 'description', - action_type: 'overwrite', - }, - { - source: 'comments', - target: 'work_notes', - action_type: 'append', - }, - ], - [ConnectorTypes.serviceNowSIR]: [ - { - source: 'title', - target: 'short_description', - action_type: 'overwrite', - }, - { - source: 'description', - target: 'description', - action_type: 'overwrite', - }, - { - source: 'comments', - target: 'work_notes', - action_type: 'append', - }, - ], -}; - -const jiraFields: JiraGetFieldsResponse = { - summary: { - required: true, - allowedValues: [], - defaultValue: {}, - schema: { - type: 'string', - }, - name: 'Summary', - }, - issuetype: { - required: true, - allowedValues: [ - { - self: 'https://siem-kibana.atlassian.net/rest/api/2/issuetype/10023', - id: '10023', - description: 'A problem or error.', - iconUrl: - 'https://siem-kibana.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype', - name: 'Bug', - subtask: false, - avatarId: 10303, - }, - ], - defaultValue: {}, - schema: { - type: 'issuetype', - }, - name: 'Issue Type', - }, - attachment: { - required: false, - allowedValues: [], - defaultValue: {}, - schema: { - type: 'array', - items: 'attachment', - }, - name: 'Attachment', - }, - duedate: { - required: false, - allowedValues: [], - defaultValue: {}, - schema: { - type: 'date', - }, - name: 'Due date', - }, - description: { - required: false, - allowedValues: [], - defaultValue: {}, - schema: { - type: 'string', - }, - name: 'Description', - }, - project: { - required: true, - allowedValues: [ - { - self: 'https://siem-kibana.atlassian.net/rest/api/2/project/10015', - id: '10015', - key: 'RJ2', - name: 'RJ2', - projectTypeKey: 'business', - simplified: false, - avatarUrls: { - '48x48': - 'https://siem-kibana.atlassian.net/secure/projectavatar?pid=10015&avatarId=10412', - '24x24': - 'https://siem-kibana.atlassian.net/secure/projectavatar?size=small&s=small&pid=10015&avatarId=10412', - '16x16': - 'https://siem-kibana.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10015&avatarId=10412', - '32x32': - 'https://siem-kibana.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10015&avatarId=10412', - }, - }, - ], - defaultValue: {}, - schema: { - type: 'project', - }, - name: 'Project', - }, - assignee: { - required: false, - allowedValues: [], - defaultValue: {}, - schema: { - type: 'user', - }, - name: 'Assignee', - }, - labels: { - required: false, - allowedValues: [], - defaultValue: {}, - schema: { - type: 'array', - items: 'string', - }, - name: 'Labels', - }, -}; -const resilientFields: ResilientGetFieldsResponse = [ - { input_type: 'text', name: 'addr', read_only: false, text: 'Address' }, - { - input_type: 'boolean', - name: 'alberta_health_risk_assessment', - read_only: false, - text: 'Alberta Health Risk Assessment', - }, - { input_type: 'number', name: 'hard_liability', read_only: true, text: 'Assessed Liability' }, - { input_type: 'text', name: 'city', read_only: false, text: 'City' }, - { input_type: 'select', name: 'country', read_only: false, text: 'Country/Region' }, - { input_type: 'select_owner', name: 'creator_id', read_only: true, text: 'Created By' }, - { input_type: 'select', name: 'crimestatus_id', read_only: false, text: 'Criminal Activity' }, - { input_type: 'boolean', name: 'data_encrypted', read_only: false, text: 'Data Encrypted' }, - { input_type: 'select', name: 'data_format', read_only: false, text: 'Data Format' }, - { input_type: 'datetimepicker', name: 'end_date', read_only: true, text: 'Date Closed' }, - { input_type: 'datetimepicker', name: 'create_date', read_only: true, text: 'Date Created' }, - { - input_type: 'datetimepicker', - name: 'determined_date', - read_only: false, - text: 'Date Determined', - }, - { - input_type: 'datetimepicker', - name: 'discovered_date', - read_only: false, - required: 'always', - text: 'Date Discovered', - }, - { input_type: 'datetimepicker', name: 'start_date', read_only: false, text: 'Date Occurred' }, - { input_type: 'select', name: 'exposure_dept_id', read_only: false, text: 'Department' }, - { input_type: 'textarea', name: 'description', read_only: false, text: 'Description' }, - { input_type: 'boolean', name: 'employee_involved', read_only: false, text: 'Employee Involved' }, - { input_type: 'boolean', name: 'data_contained', read_only: false, text: 'Exposure Resolved' }, - { input_type: 'select', name: 'exposure_type_id', read_only: false, text: 'Exposure Type' }, - { - input_type: 'multiselect', - name: 'gdpr_breach_circumstances', - read_only: false, - text: 'GDPR Breach Circumstances', - }, - { input_type: 'select', name: 'gdpr_breach_type', read_only: false, text: 'GDPR Breach Type' }, - { - input_type: 'textarea', - name: 'gdpr_breach_type_comment', - read_only: false, - text: 'GDPR Breach Type Comment', - }, - { input_type: 'select', name: 'gdpr_consequences', read_only: false, text: 'GDPR Consequences' }, - { - input_type: 'textarea', - name: 'gdpr_consequences_comment', - read_only: false, - text: 'GDPR Consequences Comment', - }, - { - input_type: 'select', - name: 'gdpr_final_assessment', - read_only: false, - text: 'GDPR Final Assessment', - }, - { - input_type: 'textarea', - name: 'gdpr_final_assessment_comment', - read_only: false, - text: 'GDPR Final Assessment Comment', - }, - { - input_type: 'select', - name: 'gdpr_identification', - read_only: false, - text: 'GDPR Identification', - }, - { - input_type: 'textarea', - name: 'gdpr_identification_comment', - read_only: false, - text: 'GDPR Identification Comment', - }, - { - input_type: 'select', - name: 'gdpr_personal_data', - read_only: false, - text: 'GDPR Personal Data', - }, - { - input_type: 'textarea', - name: 'gdpr_personal_data_comment', - read_only: false, - text: 'GDPR Personal Data Comment', - }, - { - input_type: 'boolean', - name: 'gdpr_subsequent_notification', - read_only: false, - text: 'GDPR Subsequent Notification', - }, - { input_type: 'number', name: 'id', read_only: true, text: 'ID' }, - { input_type: 'boolean', name: 'impact_likely', read_only: false, text: 'Impact Likely' }, - { - input_type: 'boolean', - name: 'ny_impact_likely', - read_only: false, - text: 'Impact Likely for New York', - }, - { - input_type: 'boolean', - name: 'or_impact_likely', - read_only: false, - text: 'Impact Likely for Oregon', - }, - { - input_type: 'boolean', - name: 'wa_impact_likely', - read_only: false, - text: 'Impact Likely for Washington', - }, - { input_type: 'boolean', name: 'confirmed', read_only: false, text: 'Incident Disposition' }, - { input_type: 'multiselect', name: 'incident_type_ids', read_only: false, text: 'Incident Type' }, - { - input_type: 'text', - name: 'exposure_individual_name', - read_only: false, - text: 'Individual Name', - }, - { - input_type: 'select', - name: 'harmstatus_id', - read_only: false, - text: 'Is harm/risk/misuse foreseeable?', - }, - { input_type: 'text', name: 'jurisdiction_name', read_only: false, text: 'Jurisdiction' }, - { - input_type: 'datetimepicker', - name: 'inc_last_modified_date', - read_only: true, - text: 'Last Modified', - }, - { - input_type: 'multiselect', - name: 'gdpr_lawful_data_processing_categories', - read_only: false, - text: 'Lawful Data Processing Categories', - }, - { input_type: 'multiselect_members', name: 'members', read_only: false, text: 'Members' }, - { input_type: 'text', name: 'name', read_only: false, required: 'always', text: 'Name' }, - { input_type: 'boolean', name: 'negative_pr_likely', read_only: false, text: 'Negative PR' }, - { input_type: 'datetimepicker', name: 'due_date', read_only: true, text: 'Next Due Date' }, - { - input_type: 'multiselect', - name: 'nist_attack_vectors', - read_only: false, - text: 'NIST Attack Vectors', - }, - { input_type: 'select', name: 'org_handle', read_only: true, text: 'Organization' }, - { input_type: 'select_owner', name: 'owner_id', read_only: false, text: 'Owner' }, - { input_type: 'select', name: 'phase_id', read_only: true, text: 'Phase' }, - { - input_type: 'select', - name: 'pipeda_other_factors', - read_only: false, - text: 'PIPEDA Other Factors', - }, - { - input_type: 'textarea', - name: 'pipeda_other_factors_comment', - read_only: false, - text: 'PIPEDA Other Factors Comment', - }, - { - input_type: 'select', - name: 'pipeda_overall_assessment', - read_only: false, - text: 'PIPEDA Overall Assessment', - }, - { - input_type: 'textarea', - name: 'pipeda_overall_assessment_comment', - read_only: false, - text: 'PIPEDA Overall Assessment Comment', - }, - { - input_type: 'select', - name: 'pipeda_probability_of_misuse', - read_only: false, - text: 'PIPEDA Probability of Misuse', - }, - { - input_type: 'textarea', - name: 'pipeda_probability_of_misuse_comment', - read_only: false, - text: 'PIPEDA Probability of Misuse Comment', - }, - { - input_type: 'select', - name: 'pipeda_sensitivity_of_pi', - read_only: false, - text: 'PIPEDA Sensitivity of PI', - }, - { - input_type: 'textarea', - name: 'pipeda_sensitivity_of_pi_comment', - read_only: false, - text: 'PIPEDA Sensitivity of PI Comment', - }, - { input_type: 'text', name: 'reporter', read_only: false, text: 'Reporting Individual' }, - { - input_type: 'select', - name: 'resolution_id', - read_only: false, - required: 'close', - text: 'Resolution', - }, - { - input_type: 'textarea', - name: 'resolution_summary', - read_only: false, - required: 'close', - text: 'Resolution Summary', - }, - { input_type: 'select', name: 'gdpr_harm_risk', read_only: false, text: 'Risk of Harm' }, - { input_type: 'select', name: 'severity_code', read_only: false, text: 'Severity' }, - { input_type: 'boolean', name: 'inc_training', read_only: true, text: 'Simulation' }, - { input_type: 'multiselect', name: 'data_source_ids', read_only: false, text: 'Source of Data' }, - { input_type: 'select', name: 'state', read_only: false, text: 'State' }, - { input_type: 'select', name: 'plan_status', read_only: false, text: 'Status' }, - { input_type: 'select', name: 'exposure_vendor_id', read_only: false, text: 'Vendor' }, - { - input_type: 'boolean', - name: 'data_compromised', - read_only: false, - text: 'Was personal information or personal data involved?', - }, - { - input_type: 'select', - name: 'workspace', - read_only: false, - required: 'always', - text: 'Workspace', - }, - { input_type: 'text', name: 'zip', read_only: false, text: 'Zip' }, -]; -const serviceNowFields: ServiceNowGetFieldsResponse = [ - { - column_label: 'Approval', - mandatory: 'false', - max_length: '40', - element: 'approval', - }, - { - column_label: 'Close notes', - mandatory: 'false', - max_length: '4000', - element: 'close_notes', - }, - { - column_label: 'Contact type', - mandatory: 'false', - max_length: '40', - element: 'contact_type', - }, - { - column_label: 'Correlation display', - mandatory: 'false', - max_length: '100', - element: 'correlation_display', - }, - { - column_label: 'Correlation ID', - mandatory: 'false', - max_length: '100', - element: 'correlation_id', - }, - { - column_label: 'Description', - mandatory: 'false', - max_length: '4000', - element: 'description', - }, - { - column_label: 'Number', - mandatory: 'false', - max_length: '40', - element: 'number', - }, - { - column_label: 'Short description', - mandatory: 'false', - max_length: '160', - element: 'short_description', - }, - { - column_label: 'Created by', - mandatory: 'false', - max_length: '40', - element: 'sys_created_by', - }, - { - column_label: 'Updated by', - mandatory: 'false', - max_length: '40', - element: 'sys_updated_by', - }, - { - column_label: 'Upon approval', - mandatory: 'false', - max_length: '40', - element: 'upon_approval', - }, - { - column_label: 'Upon reject', - mandatory: 'false', - max_length: '40', - element: 'upon_reject', - }, -]; -interface FormatFieldsTestData { - expected: ConnectorField[]; - fields: JiraGetFieldsResponse | ResilientGetFieldsResponse | ServiceNowGetFieldsResponse; - type: ConnectorTypes; -} -export const formatFieldsTestData: FormatFieldsTestData[] = [ - { - expected: [ - { id: 'summary', name: 'Summary', required: true, type: 'text' }, - { id: 'description', name: 'Description', required: false, type: 'text' }, - ], - fields: jiraFields, - type: ConnectorTypes.jira, - }, - { - expected: [ - { id: 'addr', name: 'Address', required: false, type: 'text' }, - { id: 'city', name: 'City', required: false, type: 'text' }, - { id: 'description', name: 'Description', required: false, type: 'textarea' }, - { - id: 'gdpr_breach_type_comment', - name: 'GDPR Breach Type Comment', - required: false, - type: 'textarea', - }, - { - id: 'gdpr_consequences_comment', - name: 'GDPR Consequences Comment', - required: false, - type: 'textarea', - }, - { - id: 'gdpr_final_assessment_comment', - name: 'GDPR Final Assessment Comment', - required: false, - type: 'textarea', - }, - { - id: 'gdpr_identification_comment', - name: 'GDPR Identification Comment', - required: false, - type: 'textarea', - }, - { - id: 'gdpr_personal_data_comment', - name: 'GDPR Personal Data Comment', - required: false, - type: 'textarea', - }, - { id: 'exposure_individual_name', name: 'Individual Name', required: false, type: 'text' }, - { id: 'jurisdiction_name', name: 'Jurisdiction', required: false, type: 'text' }, - { id: 'name', name: 'Name', required: true, type: 'text' }, - { - id: 'pipeda_other_factors_comment', - name: 'PIPEDA Other Factors Comment', - required: false, - type: 'textarea', - }, - { - id: 'pipeda_overall_assessment_comment', - name: 'PIPEDA Overall Assessment Comment', - required: false, - type: 'textarea', - }, - { - id: 'pipeda_probability_of_misuse_comment', - name: 'PIPEDA Probability of Misuse Comment', - required: false, - type: 'textarea', - }, - { - id: 'pipeda_sensitivity_of_pi_comment', - name: 'PIPEDA Sensitivity of PI Comment', - required: false, - type: 'textarea', - }, - { id: 'reporter', name: 'Reporting Individual', required: false, type: 'text' }, - { id: 'resolution_summary', name: 'Resolution Summary', required: false, type: 'textarea' }, - { id: 'zip', name: 'Zip', required: false, type: 'text' }, - ], - fields: resilientFields, - type: ConnectorTypes.resilient, - }, - { - expected: [ - { id: 'approval', name: 'Approval', required: false, type: 'text' }, - { id: 'close_notes', name: 'Close notes', required: false, type: 'textarea' }, - { id: 'contact_type', name: 'Contact type', required: false, type: 'text' }, - { id: 'correlation_display', name: 'Correlation display', required: false, type: 'text' }, - { id: 'correlation_id', name: 'Correlation ID', required: false, type: 'text' }, - { id: 'description', name: 'Description', required: false, type: 'textarea' }, - { id: 'number', name: 'Number', required: false, type: 'text' }, - { id: 'short_description', name: 'Short description', required: false, type: 'text' }, - { id: 'sys_created_by', name: 'Created by', required: false, type: 'text' }, - { id: 'sys_updated_by', name: 'Updated by', required: false, type: 'text' }, - { id: 'upon_approval', name: 'Upon approval', required: false, type: 'text' }, - { id: 'upon_reject', name: 'Upon reject', required: false, type: 'text' }, - ], - fields: serviceNowFields, - type: ConnectorTypes.serviceNowITSM, - }, - { - expected: [ - { id: 'approval', name: 'Approval', required: false, type: 'text' }, - { id: 'close_notes', name: 'Close notes', required: false, type: 'textarea' }, - { id: 'contact_type', name: 'Contact type', required: false, type: 'text' }, - { id: 'correlation_display', name: 'Correlation display', required: false, type: 'text' }, - { id: 'correlation_id', name: 'Correlation ID', required: false, type: 'text' }, - { id: 'description', name: 'Description', required: false, type: 'textarea' }, - { id: 'number', name: 'Number', required: false, type: 'text' }, - { id: 'short_description', name: 'Short description', required: false, type: 'text' }, - { id: 'sys_created_by', name: 'Created by', required: false, type: 'text' }, - { id: 'sys_updated_by', name: 'Updated by', required: false, type: 'text' }, - { id: 'upon_approval', name: 'Upon approval', required: false, type: 'text' }, - { id: 'upon_reject', name: 'Upon reject', required: false, type: 'text' }, - ], - fields: serviceNowFields, - type: ConnectorTypes.serviceNowSIR, - }, -]; -export const mockGetFieldsResponse = { - status: 'ok', - data: jiraFields, - actionId: '123', -}; - -export const actionsErrResponse = { - status: 'error', - serviceMessage: 'this is an actions error', -}; diff --git a/x-pack/plugins/cases/server/client/configure/types.ts b/x-pack/plugins/cases/server/client/configure/types.ts index a34251690db48d..aca3436c59082e 100644 --- a/x-pack/plugins/cases/server/client/configure/types.ts +++ b/x-pack/plugins/cases/server/client/configure/types.ts @@ -5,9 +5,10 @@ * 2.0. */ +import { CaseConnector } from '../../../common'; + export interface MappingsArgs { - connectorType: string; - connectorId: string; + connector: CaseConnector; } export interface CreateMappingsArgs extends MappingsArgs { @@ -17,8 +18,3 @@ export interface CreateMappingsArgs extends MappingsArgs { export interface UpdateMappingsArgs extends MappingsArgs { mappingId: string; } - -export interface ConfigurationGetFields { - connectorId: string; - connectorType: string; -} diff --git a/x-pack/plugins/cases/server/client/configure/update_mappings.ts b/x-pack/plugins/cases/server/client/configure/update_mappings.ts index 7eccf4cbbe5829..3d529e51e75614 100644 --- a/x-pack/plugins/cases/server/client/configure/update_mappings.ts +++ b/x-pack/plugins/cases/server/client/configure/update_mappings.ts @@ -5,40 +5,33 @@ * 2.0. */ -import { ConnectorMappingsAttributes, ConnectorTypes } from '../../../common/api'; +import { ConnectorMappingsAttributes } from '../../../common/api'; import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server'; import { createCaseError } from '../../common/error'; -import { CasesClientArgs, CasesClientInternal } from '..'; +import { CasesClientArgs } from '..'; import { UpdateMappingsArgs } from './types'; +import { casesConnectors } from '../../connectors'; export const updateMappings = async ( - { connectorType, connectorId, mappingId }: UpdateMappingsArgs, - clientArgs: CasesClientArgs, - casesClientInternal: CasesClientInternal + { connector, mappingId }: UpdateMappingsArgs, + clientArgs: CasesClientArgs ): Promise => { const { unsecuredSavedObjectsClient, connectorMappingsService, logger } = clientArgs; try { - if (connectorType === ConnectorTypes.none) { - return []; - } - - const res = await casesClientInternal.configuration.getFields({ - connectorId, - connectorType, - }); + const mappings = casesConnectors.get(connector.type)?.getMapping() ?? []; const theMapping = await connectorMappingsService.update({ unsecuredSavedObjectsClient, mappingId, attributes: { - mappings: res.defaultMappings, + mappings, }, references: [ { type: ACTION_SAVED_OBJECT_TYPE, name: `associated-${ACTION_SAVED_OBJECT_TYPE}`, - id: connectorId, + id: connector.id, }, ], }); @@ -46,7 +39,7 @@ export const updateMappings = async ( return theMapping.attributes.mappings ?? []; } catch (error) { throw createCaseError({ - message: `Failed to create mapping connector id: ${connectorId} type: ${connectorType}: ${error}`, + message: `Failed to create mapping connector id: ${connector.id} type: ${connector.type}: ${error}`, error, logger, }); diff --git a/x-pack/plugins/cases/server/client/configure/utils.test.ts b/x-pack/plugins/cases/server/client/configure/utils.test.ts deleted file mode 100644 index 41d62f5a9b91f9..00000000000000 --- a/x-pack/plugins/cases/server/client/configure/utils.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export { - JiraGetFieldsResponse, - ResilientGetFieldsResponse, - ServiceNowGetFieldsResponse, -} from '../../../../actions/server/types'; -import { createDefaultMapping, formatFields } from './utils'; -import { mappings, formatFieldsTestData } from './mock'; - -describe('client/configure/utils', () => { - describe('formatFields', () => { - formatFieldsTestData.forEach(({ expected, fields, type }) => { - it(`normalizes ${type} fields to common type ConnectorField`, () => { - const result = formatFields(fields, type); - expect(result).toEqual(expected); - }); - }); - }); - describe('createDefaultMapping', () => { - formatFieldsTestData.forEach(({ expected, fields, type }) => { - it(`normalizes ${type} fields to common type ConnectorField`, () => { - const result = createDefaultMapping(expected, type); - expect(result).toEqual(mappings[type]); - }); - }); - }); -}); diff --git a/x-pack/plugins/cases/server/client/configure/utils.ts b/x-pack/plugins/cases/server/client/configure/utils.ts deleted file mode 100644 index 24efb6ca54b3a3..00000000000000 --- a/x-pack/plugins/cases/server/client/configure/utils.ts +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ConnectorField, ConnectorMappingsAttributes, ConnectorTypes } from '../../../common'; -import { - JiraGetFieldsResponse, - ResilientGetFieldsResponse, - ServiceNowGetFieldsResponse, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../actions/server/types'; - -const normalizeJiraFields = (jiraFields: JiraGetFieldsResponse): ConnectorField[] => - Object.keys(jiraFields).reduce( - (acc, data) => - jiraFields[data].schema.type === 'string' - ? [ - ...acc, - { - id: data, - name: jiraFields[data].name, - required: jiraFields[data].required, - type: 'text', - }, - ] - : acc, - [] - ); - -const normalizeResilientFields = (resilientFields: ResilientGetFieldsResponse): ConnectorField[] => - resilientFields.reduce( - (acc: ConnectorField[], data) => - (data.input_type === 'textarea' || data.input_type === 'text') && !data.read_only - ? [ - ...acc, - { - id: data.name, - name: data.text, - required: data.required === 'always', - type: data.input_type, - }, - ] - : acc, - [] - ); -const normalizeServiceNowFields = (snFields: ServiceNowGetFieldsResponse): ConnectorField[] => - snFields.reduce( - (acc, data) => [ - ...acc, - { - id: data.element, - name: data.column_label, - required: data.mandatory === 'true', - type: parseFloat(data.max_length) > 160 ? 'textarea' : 'text', - }, - ], - [] - ); - -export const formatFields = (theData: unknown, theType: string): ConnectorField[] => { - switch (theType) { - case ConnectorTypes.jira: - return normalizeJiraFields(theData as JiraGetFieldsResponse); - case ConnectorTypes.resilient: - return normalizeResilientFields(theData as ResilientGetFieldsResponse); - case ConnectorTypes.serviceNowITSM: - return normalizeServiceNowFields(theData as ServiceNowGetFieldsResponse); - case ConnectorTypes.serviceNowSIR: - return normalizeServiceNowFields(theData as ServiceNowGetFieldsResponse); - default: - return []; - } -}; - -const getPreferredFields = (theType: string) => { - let title: string = ''; - let description: string = ''; - let comments: string = ''; - - if (theType === ConnectorTypes.jira) { - title = 'summary'; - description = 'description'; - comments = 'comments'; - } else if (theType === ConnectorTypes.resilient) { - title = 'name'; - description = 'description'; - comments = 'comments'; - } else if ( - theType === ConnectorTypes.serviceNowITSM || - theType === ConnectorTypes.serviceNowSIR - ) { - title = 'short_description'; - description = 'description'; - comments = 'work_notes'; - } - - return { title, description, comments }; -}; - -export const createDefaultMapping = ( - fields: ConnectorField[], - theType: string -): ConnectorMappingsAttributes[] => { - const { description, title, comments } = getPreferredFields(theType); - return [ - { - source: 'title', - target: title, - action_type: 'overwrite', - }, - { - source: 'description', - target: description, - action_type: 'overwrite', - }, - { - source: 'comments', - target: comments, - action_type: 'append', - }, - ]; -}; diff --git a/x-pack/plugins/cases/server/connectors/factory.ts b/x-pack/plugins/cases/server/connectors/factory.ts new file mode 100644 index 00000000000000..64e3e6f3eb225b --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/factory.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ConnectorTypes } from '../../common/api'; +import { getCaseConnector as getJiraCaseConnector } from './jira'; +import { getCaseConnector as getResilientCaseConnector } from './resilient'; +import { getServiceNowITSMCaseConnector, getServiceNowSIRCaseConnector } from './servicenow'; +import { ICasesConnector, CasesConnectorsMap } from './types'; + +const mapping: Record = { + [ConnectorTypes.jira]: getJiraCaseConnector(), + [ConnectorTypes.serviceNowITSM]: getServiceNowITSMCaseConnector(), + [ConnectorTypes.serviceNowSIR]: getServiceNowSIRCaseConnector(), + [ConnectorTypes.resilient]: getResilientCaseConnector(), + [ConnectorTypes.none]: null, +}; + +const isConnectorTypeSupported = (type: string): type is ConnectorTypes => + Object.values(ConnectorTypes).includes(type as ConnectorTypes); + +export const casesConnectors: CasesConnectorsMap = { + get: (type: string): ICasesConnector | undefined | null => + isConnectorTypeSupported(type) ? mapping[type] : undefined, +}; diff --git a/x-pack/plugins/cases/server/connectors/index.ts b/x-pack/plugins/cases/server/connectors/index.ts index 4b6f845a961f21..b5dc1cc4a8ff9e 100644 --- a/x-pack/plugins/cases/server/connectors/index.ts +++ b/x-pack/plugins/cases/server/connectors/index.ts @@ -7,20 +7,16 @@ import { RegisterConnectorsArgs, - ExternalServiceFormatterMapper, CommentSchemaType, ContextTypeGeneratedAlertType, ContextTypeAlertSchemaType, } from './types'; import { getActionType as getCaseConnector } from './case'; -import { serviceNowITSMExternalServiceFormatter } from './servicenow/itsm_formatter'; -import { serviceNowSIRExternalServiceFormatter } from './servicenow/sir_formatter'; -import { jiraExternalServiceFormatter } from './jira/external_service_formatter'; -import { resilientExternalServiceFormatter } from './resilient/external_service_formatter'; -import { CommentRequest, CommentType } from '../../common'; +import { CommentRequest, CommentType } from '../../common/api'; export * from './types'; export { transformConnectorComment } from './case'; +export { casesConnectors } from './factory'; /** * Separator used for creating a json parsable array from the mustache syntax that the alerting framework @@ -41,13 +37,6 @@ export const registerConnectors = ({ ); }; -export const externalServiceFormatters: ExternalServiceFormatterMapper = { - '.servicenow': serviceNowITSMExternalServiceFormatter, - '.servicenow-sir': serviceNowSIRExternalServiceFormatter, - '.jira': jiraExternalServiceFormatter, - '.resilient': resilientExternalServiceFormatter, -}; - export const isCommentGeneratedAlert = ( comment: CommentSchemaType | CommentRequest ): comment is ContextTypeGeneratedAlertType => { diff --git a/x-pack/plugins/cases/server/connectors/jira/external_service_formatter.test.ts b/x-pack/plugins/cases/server/connectors/jira/format.test.ts similarity index 71% rename from x-pack/plugins/cases/server/connectors/jira/external_service_formatter.test.ts rename to x-pack/plugins/cases/server/connectors/jira/format.test.ts index f5d76aeddf3130..edca4cf68250ce 100644 --- a/x-pack/plugins/cases/server/connectors/jira/external_service_formatter.test.ts +++ b/x-pack/plugins/cases/server/connectors/jira/format.test.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { CaseResponse } from '../../../common'; -import { jiraExternalServiceFormatter } from './external_service_formatter'; +import { CaseResponse } from '../../../common/api'; +import { format } from './format'; describe('Jira formatter', () => { const theCase = { @@ -15,21 +15,18 @@ describe('Jira formatter', () => { } as CaseResponse; it('it formats correctly', async () => { - const res = await jiraExternalServiceFormatter.format(theCase, []); + const res = await format(theCase, []); expect(res).toEqual({ ...theCase.connector.fields, labels: theCase.tags }); }); it('it formats correctly when fields do not exist ', async () => { const invalidFields = { tags: ['tag'], connector: { fields: null } } as CaseResponse; - const res = await jiraExternalServiceFormatter.format(invalidFields, []); + const res = await format(invalidFields, []); expect(res).toEqual({ priority: null, issueType: null, parent: null, labels: theCase.tags }); }); it('it replace white spaces with hyphens on tags', async () => { - const res = await jiraExternalServiceFormatter.format( - { ...theCase, tags: ['a tag with spaces'] }, - [] - ); + const res = await format({ ...theCase, tags: ['a tag with spaces'] }, []); expect(res).toEqual({ ...theCase.connector.fields, labels: ['a-tag-with-spaces'] }); }); }); diff --git a/x-pack/plugins/cases/server/connectors/jira/external_service_formatter.ts b/x-pack/plugins/cases/server/connectors/jira/format.ts similarity index 59% rename from x-pack/plugins/cases/server/connectors/jira/external_service_formatter.ts rename to x-pack/plugins/cases/server/connectors/jira/format.ts index 15ee2fd468ddaa..4caa23634d8875 100644 --- a/x-pack/plugins/cases/server/connectors/jira/external_service_formatter.ts +++ b/x-pack/plugins/cases/server/connectors/jira/format.ts @@ -5,14 +5,10 @@ * 2.0. */ -import { JiraFieldsType, ConnectorJiraTypeFields } from '../../../common'; -import { ExternalServiceFormatter } from '../types'; +import { ConnectorJiraTypeFields } from '../../../common/api'; +import { Format } from './types'; -interface ExternalServiceParams extends JiraFieldsType { - labels: string[]; -} - -const format: ExternalServiceFormatter['format'] = (theCase) => { +export const format: Format = (theCase, alerts) => { const { priority = null, issueType = null, parent = null } = (theCase.connector.fields as ConnectorJiraTypeFields['fields']) ?? {}; return { @@ -23,7 +19,3 @@ const format: ExternalServiceFormatter['format'] = (theCa parent, }; }; - -export const jiraExternalServiceFormatter: ExternalServiceFormatter = { - format, -}; diff --git a/x-pack/plugins/cases/server/connectors/jira/index.ts b/x-pack/plugins/cases/server/connectors/jira/index.ts new file mode 100644 index 00000000000000..9a2a00ac23b390 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/jira/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { getMapping } from './mapping'; +import { format } from './format'; +import { JiraCaseConnector } from './types'; + +export const getCaseConnector = (): JiraCaseConnector => ({ + getMapping, + format, +}); diff --git a/x-pack/plugins/cases/server/connectors/jira/mapping.ts b/x-pack/plugins/cases/server/connectors/jira/mapping.ts new file mode 100644 index 00000000000000..8f8a914b4e091a --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/jira/mapping.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { GetMapping } from './types'; + +export const getMapping: GetMapping = () => { + return [ + { + source: 'title', + target: 'summary', + action_type: 'overwrite', + }, + { + source: 'description', + target: 'description', + action_type: 'overwrite', + }, + { + source: 'comments', + target: 'comments', + action_type: 'append', + }, + ]; +}; diff --git a/x-pack/plugins/cases/server/connectors/jira/types.ts b/x-pack/plugins/cases/server/connectors/jira/types.ts new file mode 100644 index 00000000000000..59d5741d381b96 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/jira/types.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { JiraFieldsType } from '../../../common/api'; +import { ICasesConnector } from '../types'; + +interface ExternalServiceFormatterParams extends JiraFieldsType { + labels: string[]; +} + +export type JiraCaseConnector = ICasesConnector; +export type Format = ICasesConnector['format']; +export type GetMapping = ICasesConnector['getMapping']; diff --git a/x-pack/plugins/cases/server/connectors/resilient/external_service_formatter.test.ts b/x-pack/plugins/cases/server/connectors/resilient/format.test.ts similarity index 76% rename from x-pack/plugins/cases/server/connectors/resilient/external_service_formatter.test.ts rename to x-pack/plugins/cases/server/connectors/resilient/format.test.ts index b7096179b0fab6..20ba0bc3789343 100644 --- a/x-pack/plugins/cases/server/connectors/resilient/external_service_formatter.test.ts +++ b/x-pack/plugins/cases/server/connectors/resilient/format.test.ts @@ -6,7 +6,7 @@ */ import { CaseResponse } from '../../../common'; -import { resilientExternalServiceFormatter } from './external_service_formatter'; +import { format } from './format'; describe('IBM Resilient formatter', () => { const theCase = { @@ -14,13 +14,13 @@ describe('IBM Resilient formatter', () => { } as CaseResponse; it('it formats correctly', async () => { - const res = await resilientExternalServiceFormatter.format(theCase, []); + const res = await format(theCase, []); expect(res).toEqual({ ...theCase.connector.fields }); }); it('it formats correctly when fields do not exist ', async () => { const invalidFields = { tags: ['a tag'], connector: { fields: null } } as CaseResponse; - const res = await resilientExternalServiceFormatter.format(invalidFields, []); + const res = await format(invalidFields, []); expect(res).toEqual({ incidentTypes: null, severityCode: null }); }); }); diff --git a/x-pack/plugins/cases/server/connectors/resilient/external_service_formatter.ts b/x-pack/plugins/cases/server/connectors/resilient/format.ts similarity index 56% rename from x-pack/plugins/cases/server/connectors/resilient/external_service_formatter.ts rename to x-pack/plugins/cases/server/connectors/resilient/format.ts index 6dea452565d7c2..3e966d87686d20 100644 --- a/x-pack/plugins/cases/server/connectors/resilient/external_service_formatter.ts +++ b/x-pack/plugins/cases/server/connectors/resilient/format.ts @@ -5,15 +5,11 @@ * 2.0. */ -import { ResilientFieldsType, ConnectorResillientTypeFields } from '../../../common'; -import { ExternalServiceFormatter } from '../types'; +import { ConnectorResillientTypeFields } from '../../../common/api'; +import { Format } from './types'; -const format: ExternalServiceFormatter['format'] = (theCase) => { +export const format: Format = (theCase, alerts) => { const { incidentTypes = null, severityCode = null } = (theCase.connector.fields as ConnectorResillientTypeFields['fields']) ?? {}; return { incidentTypes, severityCode }; }; - -export const resilientExternalServiceFormatter: ExternalServiceFormatter = { - format, -}; diff --git a/x-pack/plugins/cases/server/connectors/resilient/index.ts b/x-pack/plugins/cases/server/connectors/resilient/index.ts new file mode 100644 index 00000000000000..a946d0d7fa1c58 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/resilient/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { getMapping } from './mapping'; +import { format } from './format'; +import { ResilientCaseConnector } from './types'; + +export const getCaseConnector = (): ResilientCaseConnector => ({ + getMapping, + format, +}); diff --git a/x-pack/plugins/cases/server/connectors/resilient/mapping.ts b/x-pack/plugins/cases/server/connectors/resilient/mapping.ts new file mode 100644 index 00000000000000..0226073711dfb9 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/resilient/mapping.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { GetMapping } from './types'; + +export const getMapping: GetMapping = () => { + return [ + { + source: 'title', + target: 'name', + action_type: 'overwrite', + }, + { + source: 'description', + target: 'description', + action_type: 'overwrite', + }, + { + source: 'comments', + target: 'comments', + action_type: 'append', + }, + ]; +}; diff --git a/x-pack/plugins/cases/server/connectors/resilient/types.ts b/x-pack/plugins/cases/server/connectors/resilient/types.ts new file mode 100644 index 00000000000000..f895dccf652145 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/resilient/types.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ResilientFieldsType } from '../../../common/api'; +import { ICasesConnector } from '../types'; + +export type ResilientCaseConnector = ICasesConnector; +export type Format = ICasesConnector['format']; +export type GetMapping = ICasesConnector['getMapping']; diff --git a/x-pack/plugins/cases/server/connectors/servicenow/index.ts b/x-pack/plugins/cases/server/connectors/servicenow/index.ts new file mode 100644 index 00000000000000..e16a76ff5f79fb --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/servicenow/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { getMapping as getServiceNowITSMMapping } from './itsm_mapping'; +import { format as formatServiceNowITSM } from './itsm_format'; +import { getMapping as getServiceNowSIRMapping } from './sir_mapping'; +import { format as formatServiceNowSIR } from './sir_format'; + +import { ServiceNowITSMCasesConnector, ServiceNowSIRCasesConnector } from './types'; + +export const getServiceNowITSMCaseConnector = (): ServiceNowITSMCasesConnector => ({ + getMapping: getServiceNowITSMMapping, + format: formatServiceNowITSM, +}); + +export const getServiceNowSIRCaseConnector = (): ServiceNowSIRCasesConnector => ({ + getMapping: getServiceNowSIRMapping, + format: formatServiceNowSIR, +}); diff --git a/x-pack/plugins/cases/server/connectors/servicenow/itsm_formmater.test.ts b/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.test.ts similarity index 74% rename from x-pack/plugins/cases/server/connectors/servicenow/itsm_formmater.test.ts rename to x-pack/plugins/cases/server/connectors/servicenow/itsm_format.test.ts index 78242e4c3848ab..2cc1816e7fa67e 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/itsm_formmater.test.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.test.ts @@ -5,8 +5,8 @@ * 2.0. */ -import { CaseResponse } from '../../../common'; -import { serviceNowITSMExternalServiceFormatter } from './itsm_formatter'; +import { CaseResponse } from '../../../common/api'; +import { format } from './itsm_format'; describe('ITSM formatter', () => { const theCase = { @@ -16,13 +16,13 @@ describe('ITSM formatter', () => { } as CaseResponse; it('it formats correctly', async () => { - const res = await serviceNowITSMExternalServiceFormatter.format(theCase, []); + const res = await format(theCase, []); expect(res).toEqual(theCase.connector.fields); }); it('it formats correctly when fields do not exist ', async () => { const invalidFields = { connector: { fields: null } } as CaseResponse; - const res = await serviceNowITSMExternalServiceFormatter.format(invalidFields, []); + const res = await format(invalidFields, []); expect(res).toEqual({ severity: null, urgency: null, diff --git a/x-pack/plugins/cases/server/connectors/servicenow/itsm_formatter.ts b/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts similarity index 58% rename from x-pack/plugins/cases/server/connectors/servicenow/itsm_formatter.ts rename to x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts index a4fa8a198fea77..9bf8c3e7e8b2e0 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/itsm_formatter.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts @@ -5,15 +5,11 @@ * 2.0. */ -import { ServiceNowITSMFieldsType, ConnectorServiceNowITSMTypeFields } from '../../../common'; -import { ExternalServiceFormatter } from '../types'; +import { ConnectorServiceNowITSMTypeFields } from '../../../common/api'; +import { ServiceNowITSMFormat } from './types'; -const format: ExternalServiceFormatter['format'] = (theCase) => { +export const format: ServiceNowITSMFormat = (theCase, alerts) => { const { severity = null, urgency = null, impact = null, category = null, subcategory = null } = (theCase.connector.fields as ConnectorServiceNowITSMTypeFields['fields']) ?? {}; return { severity, urgency, impact, category, subcategory }; }; - -export const serviceNowITSMExternalServiceFormatter: ExternalServiceFormatter = { - format, -}; diff --git a/x-pack/plugins/cases/server/connectors/servicenow/itsm_mapping.ts b/x-pack/plugins/cases/server/connectors/servicenow/itsm_mapping.ts new file mode 100644 index 00000000000000..a94d72576d6e38 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/servicenow/itsm_mapping.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ServiceNowITSMGetMapping } from './types'; + +export const getMapping: ServiceNowITSMGetMapping = () => { + return [ + { + source: 'title', + target: 'short_description', + action_type: 'overwrite', + }, + { + source: 'description', + target: 'description', + action_type: 'overwrite', + }, + { + source: 'comments', + target: 'work_notes', + action_type: 'append', + }, + ]; +}; diff --git a/x-pack/plugins/cases/server/connectors/servicenow/sir_formatter.test.ts b/x-pack/plugins/cases/server/connectors/servicenow/sir_format.test.ts similarity index 90% rename from x-pack/plugins/cases/server/connectors/servicenow/sir_formatter.test.ts rename to x-pack/plugins/cases/server/connectors/servicenow/sir_format.test.ts index 1f7716424cfa9b..fa103d4c1142d6 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/sir_formatter.test.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/sir_format.test.ts @@ -6,7 +6,7 @@ */ import { CaseResponse } from '../../../common'; -import { serviceNowSIRExternalServiceFormatter } from './sir_formatter'; +import { format } from './sir_format'; describe('ITSM formatter', () => { const theCase = { @@ -24,7 +24,7 @@ describe('ITSM formatter', () => { } as CaseResponse; it('it formats correctly without alerts', async () => { - const res = await serviceNowSIRExternalServiceFormatter.format(theCase, []); + const res = await format(theCase, []); expect(res).toEqual({ dest_ip: null, source_ip: null, @@ -38,7 +38,7 @@ describe('ITSM formatter', () => { it('it formats correctly when fields do not exist ', async () => { const invalidFields = { connector: { fields: null } } as CaseResponse; - const res = await serviceNowSIRExternalServiceFormatter.format(invalidFields, []); + const res = await format(invalidFields, []); expect(res).toEqual({ dest_ip: null, source_ip: null, @@ -73,7 +73,7 @@ describe('ITSM formatter', () => { url: { full: 'https://attack.com/api' }, }, ]; - const res = await serviceNowSIRExternalServiceFormatter.format(theCase, alerts); + const res = await format(theCase, alerts); expect(res).toEqual({ dest_ip: '192.168.1.1,192.168.1.4', source_ip: '192.168.1.2,192.168.1.3', @@ -109,7 +109,7 @@ describe('ITSM formatter', () => { url: { full: 'https://attack.com/api' }, }, ]; - const res = await serviceNowSIRExternalServiceFormatter.format(theCase, alerts); + const res = await format(theCase, alerts); expect(res).toEqual({ dest_ip: '192.168.1.1', source_ip: '192.168.1.2,192.168.1.3', @@ -150,7 +150,7 @@ describe('ITSM formatter', () => { connector: { fields: { ...theCase.connector.fields, destIp: false, malwareHash: false } }, } as CaseResponse; - const res = await serviceNowSIRExternalServiceFormatter.format(newCase, alerts); + const res = await format(newCase, alerts); expect(res).toEqual({ dest_ip: null, source_ip: '192.168.1.2,192.168.1.3', diff --git a/x-pack/plugins/cases/server/connectors/servicenow/sir_formatter.ts b/x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts similarity index 76% rename from x-pack/plugins/cases/server/connectors/servicenow/sir_formatter.ts rename to x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts index 1c528cd2b47bfb..1c6e993d395696 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/sir_formatter.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts @@ -5,23 +5,10 @@ * 2.0. */ import { get } from 'lodash/fp'; -import { ConnectorServiceNowSIRTypeFields } from '../../../common'; -import { ExternalServiceFormatter } from '../types'; -interface ExternalServiceParams { - dest_ip: string | null; - source_ip: string | null; - category: string | null; - subcategory: string | null; - malware_hash: string | null; - malware_url: string | null; - priority: string | null; -} -type SirFieldKey = 'dest_ip' | 'source_ip' | 'malware_hash' | 'malware_url'; -type AlertFieldMappingAndValues = Record< - string, - { alertPath: string; sirFieldKey: SirFieldKey; add: boolean } ->; -const format: ExternalServiceFormatter['format'] = (theCase, alerts) => { +import { ConnectorServiceNowSIRTypeFields } from '../../../common/api'; +import { ServiceNowSIRFormat, SirFieldKey, AlertFieldMappingAndValues } from './types'; + +export const format: ServiceNowSIRFormat = (theCase, alerts) => { const { destIp = null, sourceIp = null, @@ -83,6 +70,3 @@ const format: ExternalServiceFormatter['format'] = (theCa priority, }; }; -export const serviceNowSIRExternalServiceFormatter: ExternalServiceFormatter = { - format, -}; diff --git a/x-pack/plugins/cases/server/connectors/servicenow/sir_mapping.ts b/x-pack/plugins/cases/server/connectors/servicenow/sir_mapping.ts new file mode 100644 index 00000000000000..04d9809bc8b996 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/servicenow/sir_mapping.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ServiceNowSIRGetMapping } from './types'; + +export const getMapping: ServiceNowSIRGetMapping = () => { + return [ + { + source: 'title', + target: 'short_description', + action_type: 'overwrite', + }, + { + source: 'description', + target: 'description', + action_type: 'overwrite', + }, + { + source: 'comments', + target: 'work_notes', + action_type: 'append', + }, + ]; +}; diff --git a/x-pack/plugins/cases/server/connectors/servicenow/types.ts b/x-pack/plugins/cases/server/connectors/servicenow/types.ts new file mode 100644 index 00000000000000..500d1d22e3dcb8 --- /dev/null +++ b/x-pack/plugins/cases/server/connectors/servicenow/types.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ServiceNowITSMFieldsType } from '../../../common/api'; +import { ICasesConnector } from '../types'; + +export interface ServiceNowSIRFieldsType { + dest_ip: string | null; + source_ip: string | null; + category: string | null; + subcategory: string | null; + malware_hash: string | null; + malware_url: string | null; + priority: string | null; +} + +export type SirFieldKey = 'dest_ip' | 'source_ip' | 'malware_hash' | 'malware_url'; +export type AlertFieldMappingAndValues = Record< + string, + { alertPath: string; sirFieldKey: SirFieldKey; add: boolean } +>; + +// ServiceNow ITSM +export type ServiceNowITSMCasesConnector = ICasesConnector; +export type ServiceNowITSMFormat = ICasesConnector['format']; +export type ServiceNowITSMGetMapping = ICasesConnector['getMapping']; + +// ServiceNow SIR +export type ServiceNowSIRCasesConnector = ICasesConnector; +export type ServiceNowSIRFormat = ICasesConnector['format']; +export type ServiceNowSIRGetMapping = ICasesConnector['getMapping']; diff --git a/x-pack/plugins/cases/server/connectors/types.ts b/x-pack/plugins/cases/server/connectors/types.ts index 98cbe9683546b6..2fab59037b1bdd 100644 --- a/x-pack/plugins/cases/server/connectors/types.ts +++ b/x-pack/plugins/cases/server/connectors/types.ts @@ -6,7 +6,7 @@ */ import { Logger } from 'kibana/server'; -import { CaseResponse, ConnectorTypes } from '../../common/api'; +import { CaseResponse, ConnectorMappingsAttributes } from '../../common/api'; import { CasesClientGetAlertsResponse } from '../client/alerts/types'; import { CasesClientFactory } from '../client/factory'; import { RegisterActionType } from '../types'; @@ -26,12 +26,11 @@ export interface RegisterConnectorsArgs extends GetActionTypeParams { registerActionType: RegisterActionType; } -export type FormatterConnectorTypes = Exclude; - -export interface ExternalServiceFormatter { +export interface ICasesConnector { format: (theCase: CaseResponse, alerts: CasesClientGetAlertsResponse) => TExternalServiceParams; + getMapping: () => ConnectorMappingsAttributes[]; } -export type ExternalServiceFormatterMapper = { - [x in FormatterConnectorTypes]: ExternalServiceFormatter; -}; +export interface CasesConnectorsMap { + get: (type: string) => ICasesConnector | undefined | null; +} diff --git a/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts b/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts index bddceef8d782e6..ef5e0ebb5bbc10 100644 --- a/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts +++ b/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts @@ -10,20 +10,13 @@ import { AssociationType, CaseStatuses, CaseType, - CaseUserActionAttributes, CommentAttributes, CommentType, - ConnectorMappings, ConnectorTypes, ESCaseAttributes, ESCasesConfigureAttributes, } from '../../../../common'; -import { - CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT, - CASE_USER_ACTION_SAVED_OBJECT, - SECURITY_SOLUTION_OWNER, -} from '../../../../common/constants'; -import { mappings } from '../../../client/configure/mock'; +import { SECURITY_SOLUTION_OWNER } from '../../../../common/constants'; export const mockCases: Array> = [ { @@ -485,79 +478,3 @@ export const mockCaseConfigure: Array> = version: 'WzYsMV0=', }, ]; - -export const mockCaseMappings: Array> = [ - { - type: CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT, - id: 'mock-mappings-1', - attributes: { - mappings: mappings[ConnectorTypes.jira], - owner: SECURITY_SOLUTION_OWNER, - }, - references: [], - }, -]; - -export const mockCaseMappingsResilient: Array> = [ - { - type: CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT, - id: 'mock-mappings-1', - attributes: { - mappings: mappings[ConnectorTypes.resilient], - owner: SECURITY_SOLUTION_OWNER, - }, - references: [], - }, -]; - -export const mockCaseMappingsBad: Array>> = [ - { - type: CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT, - id: 'mock-mappings-bad', - attributes: {}, - references: [], - }, -]; - -export const mockUserActions: Array> = [ - { - type: CASE_USER_ACTION_SAVED_OBJECT, - id: 'mock-user-actions-1', - attributes: { - action_field: ['description', 'status', 'tags', 'title', 'connector', 'settings'], - action: 'create', - action_at: '2021-02-03T17:41:03.771Z', - action_by: { - email: 'elastic@elastic.co', - full_name: 'Elastic', - username: 'elastic', - }, - new_value: - '{"title":"A case","tags":["case"],"description":"Yeah!","connector":{"id":"connector-od","name":"My Connector","type":".servicenow-sir","fields":{"category":"Denial of Service","destIp":true,"malwareHash":true,"malwareUrl":true,"priority":"2","sourceIp":true,"subcategory":"45"}},"settings":{"syncAlerts":true}}', - old_value: null, - owner: SECURITY_SOLUTION_OWNER, - }, - version: 'WzYsMV0=', - references: [], - }, - { - type: CASE_USER_ACTION_SAVED_OBJECT, - id: 'mock-user-actions-2', - attributes: { - action_field: ['comment'], - action: 'create', - action_at: '2021-02-03T17:44:21.067Z', - action_by: { - email: 'elastic@elastic.co', - full_name: 'Elastic', - username: 'elastic', - }, - new_value: - '{"type":"alert","alertId":"cec3da90fb37a44407145adf1593f3b0d5ad94c4654201f773d63b5d4706128e","index":".siem-signals-default-000008"}', - old_value: null, - owner: SECURITY_SOLUTION_OWNER, - }, - version: 'WzYsMV0=', - references: [], - }, -]; diff --git a/x-pack/plugins/enterprise_search/kibana.json b/x-pack/plugins/enterprise_search/kibana.json index daae8cf57f63da..a7b29a1e6b457f 100644 --- a/x-pack/plugins/enterprise_search/kibana.json +++ b/x-pack/plugins/enterprise_search/kibana.json @@ -7,5 +7,10 @@ "optionalPlugins": ["usageCollection", "security", "home", "spaces", "cloud"], "server": true, "ui": true, - "requiredBundles": ["home"] + "requiredBundles": ["home"], + "owner": { + "name": "Enterprise Search", + "githubTeam": "enterprise-search-frontend" + }, + "description": "Adds dashboards for discovering and managing Enterprise Search products" } diff --git a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts index ebb6f8c4fe5aad..f2c6ccfacf2bbf 100644 --- a/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts +++ b/x-pack/plugins/enterprise_search/public/applications/__mocks__/kea_logic/kibana_logic.mock.ts @@ -7,6 +7,8 @@ import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks'; +import { securityMock } from '../../../../../security/public/mocks'; + import { mockHistory } from '../react_router/state.mock'; export const mockKibanaValues = { @@ -18,6 +20,7 @@ export const mockKibanaValues = { }, history: mockHistory, navigateToUrl: jest.fn(), + security: securityMock.createStart(), setBreadcrumbs: jest.fn(), setChromeIsVisible: jest.fn(), setDocTitle: jest.fn(), diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/engine_assignment_selector.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/engine_assignment_selector.test.tsx new file mode 100644 index 00000000000000..01c46e6423d706 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/engine_assignment_selector.test.tsx @@ -0,0 +1,101 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import '../../../__mocks__/react_router'; +import '../../../__mocks__/shallow_useeffect.mock'; +import { DEFAULT_INITIAL_APP_DATA } from '../../../../../common/__mocks__'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; +import { engines } from '../../__mocks__/engines.mock'; + +import React from 'react'; + +import { waitFor } from '@testing-library/dom'; +import { shallow } from 'enzyme'; + +import { EuiComboBox, EuiComboBoxOptionOption, EuiRadioGroup } from '@elastic/eui'; + +import { asRoleMapping } from '../../../shared/role_mapping/__mocks__/roles'; + +import { EngineAssignmentSelector } from './engine_assignment_selector'; + +describe('EngineAssignmentSelector', () => { + const mockRole = DEFAULT_INITIAL_APP_DATA.appSearch.role; + const actions = { + initializeRoleMappings: jest.fn(), + initializeRoleMapping: jest.fn(), + handleSaveMapping: jest.fn(), + handleEngineSelectionChange: jest.fn(), + handleAccessAllEnginesChange: jest.fn(), + handleAttributeValueChange: jest.fn(), + handleAttributeSelectorChange: jest.fn(), + handleDeleteMapping: jest.fn(), + handleRoleChange: jest.fn(), + handleAuthProviderChange: jest.fn(), + resetState: jest.fn(), + }; + + const mockValues = { + attributes: [], + elasticsearchRoles: [], + hasAdvancedRoles: true, + dataLoading: false, + roleType: 'admin', + roleMappings: [asRoleMapping], + attributeValue: '', + attributeName: 'username', + availableEngines: engines, + selectedEngines: new Set(), + accessAllEngines: false, + availableAuthProviders: [], + multipleAuthProvidersConfig: true, + selectedAuthProviders: [], + myRole: { + availableRoleTypes: mockRole.ability.availableRoleTypes, + }, + roleMappingErrors: [], + }; + + beforeEach(() => { + setMockActions(actions); + setMockValues(mockValues); + }); + + it('renders', () => { + setMockValues({ ...mockValues, roleMapping: asRoleMapping }); + const wrapper = shallow(); + + expect(wrapper.find(EuiRadioGroup)).toHaveLength(1); + expect(wrapper.find(EuiComboBox)).toHaveLength(1); + }); + + it('sets initial selected state when accessAllEngines is true', () => { + setMockValues({ ...mockValues, accessAllEngines: true }); + const wrapper = shallow(); + + expect(wrapper.find(EuiRadioGroup).prop('idSelected')).toBe('all'); + }); + + it('handles all/specific engines radio change', () => { + const wrapper = shallow(); + const radio = wrapper.find(EuiRadioGroup); + radio.simulate('change', { target: { checked: false } }); + + expect(actions.handleAccessAllEnginesChange).toHaveBeenCalledWith(false); + }); + + it('handles engine checkbox click', async () => { + const wrapper = shallow(); + await waitFor(() => + ((wrapper.find(EuiComboBox).props() as unknown) as { + onChange: (a: EuiComboBoxOptionOption[]) => void; + }).onChange([{ label: engines[0].name, value: engines[0].name }]) + ); + wrapper.update(); + + expect(actions.handleEngineSelectionChange).toHaveBeenCalledWith([engines[0].name]); + }); +}); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/engine_assignment_selector.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/engine_assignment_selector.tsx new file mode 100644 index 00000000000000..bb40a1a4fa279d --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/engine_assignment_selector.tsx @@ -0,0 +1,87 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { useActions, useValues } from 'kea'; + +import { EuiComboBox, EuiFormRow, EuiHorizontalRule, EuiRadioGroup } from '@elastic/eui'; + +import { RoleOptionLabel } from '../../../shared/role_mapping'; + +import { roleHasScopedEngines } from '../../utils/role/has_scoped_engines'; + +import { + ENGINE_REQUIRED_ERROR, + ALL_ENGINES_LABEL, + ALL_ENGINES_DESCRIPTION, + SPECIFIC_ENGINES_LABEL, + SPECIFIC_ENGINES_DESCRIPTION, + ENGINE_ASSIGNMENT_LABEL, +} from './constants'; +import { RoleMappingsLogic } from './role_mappings_logic'; + +export const EngineAssignmentSelector: React.FC = () => { + const { handleAccessAllEnginesChange, handleEngineSelectionChange } = useActions( + RoleMappingsLogic + ); + + const { + accessAllEngines, + availableEngines, + roleType, + selectedEngines, + selectedOptions, + } = useValues(RoleMappingsLogic); + + const hasEngineAssignment = selectedEngines.size > 0 || accessAllEngines; + + const engineOptions = [ + { + id: 'all', + label: , + }, + { + id: 'specific', + label: ( + + ), + }, + ]; + + return ( + <> + + + handleAccessAllEnginesChange(id === 'all')} + legend={{ + children: {ENGINE_ASSIGNMENT_LABEL}, + }} + /> + + + ({ label: name, value: name }))} + onChange={(options) => { + handleEngineSelectionChange(options.map(({ value }) => value as string)); + }} + fullWidth + isDisabled={accessAllEngines || !roleHasScopedEngines(roleType)} + /> + + + ); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx index 0b7d4255fc3236..8932c17367b2c1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.test.tsx @@ -13,16 +13,14 @@ import { engines } from '../../__mocks__/engines.mock'; import React from 'react'; -import { waitFor } from '@testing-library/dom'; import { shallow } from 'enzyme'; -import { EuiComboBox, EuiComboBoxOptionOption, EuiRadioGroup } from '@elastic/eui'; - import { AttributeSelector, RoleSelector, RoleMappingFlyout } from '../../../shared/role_mapping'; import { asRoleMapping } from '../../../shared/role_mapping/__mocks__/roles'; import { STANDARD_ROLE_TYPES } from './constants'; +import { EngineAssignmentSelector } from './engine_assignment_selector'; import { RoleMapping } from './role_mapping'; describe('RoleMapping', () => { @@ -73,6 +71,7 @@ describe('RoleMapping', () => { expect(wrapper.find(AttributeSelector)).toHaveLength(1); expect(wrapper.find(RoleSelector)).toHaveLength(1); + expect(wrapper.find(EngineAssignmentSelector)).toHaveLength(1); }); it('only passes standard role options for non-advanced roles', () => { @@ -82,33 +81,6 @@ describe('RoleMapping', () => { expect(wrapper.find(RoleSelector).prop('roleOptions')).toHaveLength(STANDARD_ROLE_TYPES.length); }); - it('sets initial selected state when accessAllEngines is true', () => { - setMockValues({ ...mockValues, accessAllEngines: true }); - const wrapper = shallow(); - - expect(wrapper.find(EuiRadioGroup).prop('idSelected')).toBe('all'); - }); - - it('handles all/specific engines radio change', () => { - const wrapper = shallow(); - const radio = wrapper.find(EuiRadioGroup); - radio.simulate('change', { target: { checked: false } }); - - expect(actions.handleAccessAllEnginesChange).toHaveBeenCalledWith(false); - }); - - it('handles engine checkbox click', async () => { - const wrapper = shallow(); - await waitFor(() => - ((wrapper.find(EuiComboBox).props() as unknown) as { - onChange: (a: EuiComboBoxOptionOption[]) => void; - }).onChange([{ label: engines[0].name, value: engines[0].name }]) - ); - wrapper.update(); - - expect(actions.handleEngineSelectionChange).toHaveBeenCalledWith([engines[0].name]); - }); - it('enables flyout when attribute value is valid', () => { setMockValues({ ...mockValues, diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.tsx index 7962734f86e2dd..b6a9dd72cfd05e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mapping.tsx @@ -9,47 +9,23 @@ import React from 'react'; import { useActions, useValues } from 'kea'; -import { - EuiComboBox, - EuiForm, - EuiFormRow, - EuiHorizontalRule, - EuiRadioGroup, - EuiSpacer, -} from '@elastic/eui'; +import { EuiForm, EuiSpacer } from '@elastic/eui'; -import { - AttributeSelector, - RoleSelector, - RoleOptionLabel, - RoleMappingFlyout, -} from '../../../shared/role_mapping'; +import { AttributeSelector, RoleSelector, RoleMappingFlyout } from '../../../shared/role_mapping'; import { AppLogic } from '../../app_logic'; import { AdvanceRoleType } from '../../types'; -import { roleHasScopedEngines } from '../../utils/role/has_scoped_engines'; - -import { - ADVANCED_ROLE_TYPES, - STANDARD_ROLE_TYPES, - ENGINE_REQUIRED_ERROR, - ALL_ENGINES_LABEL, - ALL_ENGINES_DESCRIPTION, - SPECIFIC_ENGINES_LABEL, - SPECIFIC_ENGINES_DESCRIPTION, - ENGINE_ASSIGNMENT_LABEL, -} from './constants'; +import { ADVANCED_ROLE_TYPES, STANDARD_ROLE_TYPES } from './constants'; +import { EngineAssignmentSelector } from './engine_assignment_selector'; import { RoleMappingsLogic } from './role_mappings_logic'; export const RoleMapping: React.FC = () => { const { myRole } = useValues(AppLogic); const { - handleAccessAllEnginesChange, handleAttributeSelectorChange, handleAttributeValueChange, handleAuthProviderChange, - handleEngineSelectionChange, handleRoleChange, handleSaveMapping, closeRoleMappingFlyout, @@ -61,7 +37,6 @@ export const RoleMapping: React.FC = () => { attributeValue, attributes, availableAuthProviders, - availableEngines, elasticsearchRoles, hasAdvancedRoles, multipleAuthProvidersConfig, @@ -69,7 +44,6 @@ export const RoleMapping: React.FC = () => { roleType, selectedEngines, selectedAuthProviders, - selectedOptions, roleMappingErrors, } = useValues(RoleMappingsLogic); @@ -90,22 +64,6 @@ export const RoleMapping: React.FC = () => { ? [...standardRoleOptions, ...advancedRoleOptions] : standardRoleOptions; - const engineOptions = [ - { - id: 'all', - label: , - }, - { - id: 'specific', - label: ( - - ), - }, - ]; - return ( { onChange={handleRoleChange} label="Role" /> - - {hasAdvancedRoles && ( - <> - - - handleAccessAllEnginesChange(id === 'all')} - legend={{ - children: {ENGINE_ASSIGNMENT_LABEL}, - }} - /> - - - ({ label: name, value: name }))} - onChange={(options) => { - handleEngineSelectionChange(options.map(({ value }) => value as string)); - }} - fullWidth - isDisabled={accessAllEngines || !roleHasScopedEngines(roleType)} - /> - - - )} + {hasAdvancedRoles && } ); diff --git a/x-pack/plugins/enterprise_search/public/applications/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/index.test.tsx index 2e0940b9c4af22..cb73686eb4c5ba 100644 --- a/x-pack/plugins/enterprise_search/public/applications/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/index.test.tsx @@ -12,6 +12,7 @@ import { getContext } from 'kea'; import { coreMock } from '../../../../../src/core/public/mocks'; import { chartPluginMock } from '../../../../../src/plugins/charts/public/mocks'; import { licensingMock } from '../../../licensing/public/mocks'; +import { securityMock } from '../../../security/public/mocks'; import { AppSearch } from './app_search'; import { EnterpriseSearch } from './enterprise_search'; @@ -27,6 +28,7 @@ describe('renderApp', () => { plugins: { licensing: licensingMock.createStart(), charts: chartPluginMock.createStartContract(), + security: securityMock.createStart(), }, } as any; const pluginData = { diff --git a/x-pack/plugins/enterprise_search/public/applications/index.tsx b/x-pack/plugins/enterprise_search/public/applications/index.tsx index c2bf77751528ae..ba2b28e64b9cf0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/index.tsx @@ -48,6 +48,7 @@ export const renderApp = ( cloud: plugins.cloud || {}, history: params.history, navigateToUrl: core.application.navigateToUrl, + security: plugins.security || {}, setBreadcrumbs: core.chrome.setBreadcrumbs, setChromeIsVisible: core.chrome.setIsVisible, setDocTitle: core.chrome.docTitle.change, diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts b/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts index 2bef7d373f1606..9c6db7d09f72c0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/kibana/kibana_logic.ts @@ -13,6 +13,7 @@ import { kea, MakeLogicType } from 'kea'; import { ApplicationStart, ChromeBreadcrumb } from '../../../../../../../src/core/public'; import { ChartsPluginStart } from '../../../../../../../src/plugins/charts/public'; import { CloudSetup } from '../../../../../cloud/public'; +import { SecurityPluginStart } from '../../../../../security/public'; import { HttpLogic } from '../http'; import { createHref, CreateHrefOptions } from '../react_router_helpers'; @@ -23,6 +24,7 @@ interface KibanaLogicProps { cloud: Partial; charts: ChartsPluginStart; navigateToUrl: ApplicationStart['navigateToUrl']; + security: Partial; setBreadcrumbs(crumbs: ChromeBreadcrumb[]): void; setChromeIsVisible(isVisible: boolean): void; setDocTitle(title: string): void; @@ -47,6 +49,7 @@ export const KibanaLogic = kea>({ }, {}, ], + security: [props.security || {}, {}], setBreadcrumbs: [props.setBreadcrumbs, {}], setChromeIsVisible: [props.setChromeIsVisible, {}], setDocTitle: [props.setDocTitle, {}], diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/constants.ts b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/constants.ts index be0c860627f799..47d481630510e2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/constants.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/constants.ts @@ -200,3 +200,8 @@ export const ROLE_MAPPINGS_HEADING_BUTTON = i18n.translate( 'xpack.enterpriseSearch.roleMapping.roleMappingsHeadingButton', { defaultMessage: 'Create a new role mapping' } ); + +export const ROLE_MAPPINGS_NO_RESULTS_MESSAGE = i18n.translate( + 'xpack.enterpriseSearch.roleMapping.noResults.message', + { defaultMessage: 'Create a new role mapping' } +); diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/index.ts b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/index.ts index 0f9362157f50ad..b0d10e9692714f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/index.ts @@ -11,3 +11,4 @@ export { RoleOptionLabel } from './role_option_label'; export { RoleSelector } from './role_selector'; export { RoleMappingFlyout } from './role_mapping_flyout'; export { RoleMappingsHeading } from './role_mappings_heading'; +export { UsersAndRolesRowActions } from './users_and_roles_row_actions'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/role_mappings_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/role_mappings_table.test.tsx index 5ec84db478bc3d..156b52a4016c32 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/role_mappings_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/role_mappings_table.test.tsx @@ -9,13 +9,14 @@ import { wsRoleMapping, asRoleMapping } from './__mocks__/roles'; import React from 'react'; -import { shallow } from 'enzyme'; +import { mount } from 'enzyme'; -import { EuiFieldSearch, EuiTableRow } from '@elastic/eui'; +import { EuiInMemoryTable, EuiTableHeaderCell } from '@elastic/eui'; import { ALL_LABEL, ANY_AUTH_PROVIDER_OPTION_LABEL } from './constants'; import { RoleMappingsTable } from './role_mappings_table'; +import { UsersAndRolesRowActions } from './users_and_roles_row_actions'; describe('RoleMappingsTable', () => { const initializeRoleMapping = jest.fn(); @@ -41,55 +42,44 @@ describe('RoleMappingsTable', () => { handleDeleteMapping, }; - it('renders', () => { - const wrapper = shallow(); + it('renders with "shouldShowAuthProvider" true', () => { + const wrapper = mount(); - expect(wrapper.find(EuiFieldSearch)).toHaveLength(1); - expect(wrapper.find(EuiTableRow)).toHaveLength(1); + expect(wrapper.find(EuiInMemoryTable)).toHaveLength(1); + expect(wrapper.find(EuiTableHeaderCell)).toHaveLength(6); }); - it('renders auth provider display names', () => { - const wrapper = shallow(); + it('renders with "shouldShowAuthProvider" false', () => { + const wrapper = mount(); - expect(wrapper.find('[data-test-subj="AuthProviderDisplay"]').prop('children')).toEqual( - `${ANY_AUTH_PROVIDER_OPTION_LABEL}, other_auth` - ); + expect(wrapper.find(EuiInMemoryTable)).toHaveLength(1); + expect(wrapper.find(EuiTableHeaderCell)).toHaveLength(5); }); - it('handles input change', () => { - const wrapper = shallow(); - const input = wrapper.find(EuiFieldSearch); - const value = 'Query'; - input.simulate('change', { target: { value } }); + it('renders auth provider display names', () => { + const wrapper = mount(); - expect(wrapper.find(EuiTableRow)).toHaveLength(0); + expect(wrapper.find('[data-test-subj="AuthProviderDisplayValue"]').prop('children')).toEqual( + `${ANY_AUTH_PROVIDER_OPTION_LABEL}, other_auth` + ); }); it('handles manage click', () => { - const wrapper = shallow(); - wrapper.find('[data-test-subj="ManageButton"]').simulate('click'); + const wrapper = mount(); + wrapper.find(UsersAndRolesRowActions).prop('onManageClick')(); expect(initializeRoleMapping).toHaveBeenCalled(); }); it('handles delete click', () => { - const wrapper = shallow(); - wrapper.find('[data-test-subj="DeleteButton"]').simulate('click'); + const wrapper = mount(); + wrapper.find(UsersAndRolesRowActions).prop('onDeleteClick')(); expect(handleDeleteMapping).toHaveBeenCalled(); }); - it('handles input change with special chars', () => { - const wrapper = shallow(); - const input = wrapper.find(EuiFieldSearch); - const value = '*//username'; - input.simulate('change', { target: { value } }); - - expect(wrapper.find(EuiTableRow)).toHaveLength(1); - }); - it('shows default message when "accessAllEngines" is true', () => { - const wrapper = shallow( + const wrapper = mount( ); @@ -100,7 +90,7 @@ describe('RoleMappingsTable', () => { const noItemsRoleMapping = { ...asRoleMapping, engines: [] }; noItemsRoleMapping.accessAllEngines = false; - const wrapper = shallow( + const wrapper = mount( —; const getAuthProviderDisplayValue = (authProvider: string) => @@ -73,114 +59,104 @@ export const RoleMappingsTable: React.FC = ({ initializeRoleMapping, handleDeleteMapping, }) => { - const [filterValue, updateValue] = useState(''); + const getFirstAttributeName = (rules: RoleRules): string => Object.entries(rules)[0][0]; + const getFirstAttributeValue = (rules: RoleRules): string => Object.entries(rules)[0][1]; // This is needed because App Search has `engines` and Workplace Search has `groups`. - const standardizeRoleMapping = (roleMappings as SharedRoleMapping[]).map((rm) => { + const standardizedRoleMappings = (roleMappings as SharedRoleMapping[]).map((rm) => { const _rm = { ...rm } as SharedRoleMapping; _rm.accessItems = rm[accessItemKey]; return _rm; - }); - - const filterResults = (result: SharedRoleMapping) => { - // Filter out non-alphanumeric characters, except for underscores, hyphens, and spaces - const sanitizedValue = filterValue.replace(/[^\w\s-]/g, ''); - const values = Object.values(result); - const regexp = new RegExp(sanitizedValue, 'i'); - return values.filter((x) => regexp.test(x)).length > 0; + }) as SharedRoleMapping[]; + + const attributeNameCol: EuiBasicTableColumn = { + field: 'attribute', + name: EXTERNAL_ATTRIBUTE_LABEL, + render: (_, { rules }: SharedRoleMapping) => getFirstAttributeName(rules), }; - const filteredResults = standardizeRoleMapping.filter(filterResults); - const getFirstAttributeName = (rules: RoleRules): string => Object.entries(rules)[0][0]; - const getFirstAttributeValue = (rules: RoleRules): string => Object.entries(rules)[0][1]; + const attributeValueCol: EuiBasicTableColumn = { + field: 'attributeValue', + name: ATTRIBUTE_VALUE_LABEL, + render: (_, { rules }: SharedRoleMapping) => getFirstAttributeValue(rules), + }; - const rowActions = (id: string) => ( - <> - initializeRoleMapping(id)} - iconType="pencil" - aria-label={MANAGE_BUTTON_LABEL} - data-test-subj="ManageButton" - />{' '} - handleDeleteMapping(id)} - iconType="trash" - aria-label={DELETE_BUTTON_LABEL} - data-test-subj="DeleteButton" + const roleCol: EuiBasicTableColumn = { + field: 'roleType', + name: ROLE_LABEL, + render: (_, { rules }: SharedRoleMapping) => getFirstAttributeValue(rules), + }; + + const accessItemsCol: EuiBasicTableColumn = { + field: 'accessItems', + name: accessHeader, + render: (_, { accessAllEngines, accessItems }: SharedRoleMapping) => ( + + {accessAllEngines ? ( + ALL_LABEL + ) : ( + <> + {accessItems.length === 0 + ? noItemsPlaceholder + : accessItems.map(({ name }) => ( + + {name} +
+
+ ))} + + )} +
+ ), + }; + + const authProviderCol: EuiBasicTableColumn = { + field: 'authProvider', + name: AUTH_PROVIDER_LABEL, + render: (_, { authProvider }: SharedRoleMapping) => ( + + {authProvider.map(getAuthProviderDisplayValue).join(', ')} + + ), + }; + + const actionsCol: EuiBasicTableColumn = { + field: 'id', + name: '', + align: 'right', + render: (_, { id }: SharedRoleMapping) => ( + initializeRoleMapping(id)} + onDeleteClick={() => handleDeleteMapping(id)} /> - - ); + ), + }; + const columns = shouldShowAuthProvider + ? [attributeNameCol, attributeValueCol, roleCol, accessItemsCol, authProviderCol, actionsCol] + : [attributeNameCol, attributeValueCol, roleCol, accessItemsCol, actionsCol]; + + const pagination = { + hidePerPageOptions: true, + }; + + const search = { + box: { + incremental: true, + fullWidth: false, + placeholder: FILTER_ROLE_MAPPINGS_PLACEHOLDER, + 'data-test-subj': 'RoleMappingsTableSearchInput', + }, + }; return ( - <> - updateValue(e.target.value)} - /> - - {filteredResults.length > 0 ? ( - - - {EXTERNAL_ATTRIBUTE_LABEL} - {ATTRIBUTE_VALUE_LABEL} - {ROLE_LABEL} - {accessHeader} - {shouldShowAuthProvider && ( - {AUTH_PROVIDER_LABEL} - )} - - - - {filteredResults.map( - ({ id, authProvider, rules, roleType, accessAllEngines, accessItems, toolTip }) => ( - - {getFirstAttributeName(rules)} - - {getFirstAttributeValue(rules)} - - {roleType} - - {accessAllEngines ? ( - ALL_LABEL - ) : ( - <> - {accessItems.length === 0 - ? noItemsPlaceholder - : accessItems.map(({ name }) => ( - - {name} -
-
- ))} - - )} -
- {shouldShowAuthProvider && ( - - {authProvider.map(getAuthProviderDisplayValue).join(', ')} - - )} - - {id && rowActions(id)} - {toolTip && } - -
- ) - )} -
-
- ) : ( -

- {i18n.translate('xpack.enterpriseSearch.roleMapping.moResults.message', { - defaultMessage: "No results found for '{filterValue}'", - values: { filterValue }, - })} -

- )} - + ); }; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/users_and_roles_row_actions.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/users_and_roles_row_actions.test.tsx new file mode 100644 index 00000000000000..dbb47b50d40669 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/users_and_roles_row_actions.test.tsx @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { shallow } from 'enzyme'; + +import { EuiButtonIcon } from '@elastic/eui'; + +import { UsersAndRolesRowActions } from './users_and_roles_row_actions'; + +describe('UsersAndRolesRowActions', () => { + const onManageClick = jest.fn(); + const onDeleteClick = jest.fn(); + + const props = { + onManageClick, + onDeleteClick, + }; + + it('renders', () => { + const wrapper = shallow(); + + expect(wrapper.find(EuiButtonIcon)).toHaveLength(2); + }); + + it('handles manage click', () => { + const wrapper = shallow(); + const button = wrapper.find(EuiButtonIcon).first(); + button.simulate('click'); + + expect(onManageClick).toHaveBeenCalled(); + }); + + it('handles delete click', () => { + const wrapper = shallow(); + const button = wrapper.find(EuiButtonIcon).last(); + button.simulate('click'); + + expect(onDeleteClick).toHaveBeenCalled(); + }); +}); diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/users_and_roles_row_actions.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/users_and_roles_row_actions.tsx new file mode 100644 index 00000000000000..3d956c0aabd688 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/users_and_roles_row_actions.tsx @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { EuiButtonIcon } from '@elastic/eui'; + +import { MANAGE_BUTTON_LABEL, DELETE_BUTTON_LABEL } from '../constants'; + +interface Props { + onManageClick(): void; + onDeleteClick(): void; +} + +export const UsersAndRolesRowActions: React.FC = ({ onManageClick, onDeleteClick }) => ( + <> + {' '} + + +); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.tsx index 92a936fcdbefe7..b1e190edade2b1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/account_header/account_header.tsx @@ -27,7 +27,7 @@ import { getWorkplaceSearchUrl } from '../../../../shared/enterprise_search_url' import { EuiButtonEmptyTo } from '../../../../shared/react_router_helpers'; import { AppLogic } from '../../../app_logic'; import { WORKPLACE_SEARCH_TITLE, ACCOUNT_NAV } from '../../../constants'; -import { PERSONAL_SOURCES_PATH, LOGOUT_ROUTE, KIBANA_ACCOUNT_ROUTE } from '../../../routes'; +import { PERSONAL_SOURCES_PATH, LOGOUT_ROUTE, PERSONAL_SETTINGS_PATH } from '../../../routes'; export const AccountHeader: React.FC = () => { const [isPopoverOpen, setPopover] = useState(false); @@ -44,8 +44,7 @@ export const AccountHeader: React.FC = () => { const accountNavItems = [ - {/* TODO: Once auth is completed, we need to have non-admins redirect to the self-hosted form */} - {ACCOUNT_NAV.SETTINGS} + {ACCOUNT_NAV.SETTINGS} , {ACCOUNT_NAV.LOGOUT} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx index ba5fb7c9d377d4..0fc8a6e7c7c0d0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx @@ -28,7 +28,9 @@ import { ORG_SETTINGS_PATH, ROLE_MAPPINGS_PATH, SECURITY_PATH, + PERSONAL_SETTINGS_PATH, } from './routes'; +import { AccountSettings } from './views/account_settings'; import { SourcesRouter } from './views/content_sources'; import { SourceAdded } from './views/content_sources/components/source_added'; import { SourceSubNav } from './views/content_sources/components/source_sub_nav'; @@ -103,6 +105,11 @@ export const WorkplaceSearchConfigured: React.FC = (props) => { + + + + + } />} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/routes.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/routes.ts index 5e5d6e2c82b310..1fe8019c4b3646 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/routes.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/routes.ts @@ -13,7 +13,6 @@ export const SETUP_GUIDE_PATH = '/setup_guide'; export const NOT_FOUND_PATH = '/404'; export const LOGOUT_ROUTE = '/logout'; -export const KIBANA_ACCOUNT_ROUTE = '/security/account'; export const LEAVE_FEEDBACK_EMAIL = 'support@elastic.co'; export const LEAVE_FEEDBACK_URL = `mailto:${LEAVE_FEEDBACK_EMAIL}?Subject=Elastic%20Workplace%20Search%20Feedback`; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/account_settings/account_settings.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/account_settings/account_settings.tsx new file mode 100644 index 00000000000000..e28faaeec8993a --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/account_settings/account_settings.tsx @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useState, useEffect, useMemo } from 'react'; + +import { useValues } from 'kea'; + +import type { AuthenticatedUser } from '../../../../../../security/public'; +import { KibanaLogic } from '../../../shared/kibana/kibana_logic'; + +export const AccountSettings: React.FC = () => { + const { security } = useValues(KibanaLogic); + + const [currentUser, setCurrentUser] = useState(null); + + useEffect(() => { + security!.authc!.getCurrentUser().then(setCurrentUser); + }, [security.authc]); + + const PersonalInfo = useMemo(() => security!.uiApi!.components.getPersonalInfo, [security.uiApi]); + const ChangePassword = useMemo(() => security!.uiApi!.components.getChangePassword, [ + security.uiApi, + ]); + + if (!currentUser) { + return null; + } + + return ( + <> + + + + ); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/account_settings/index.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/account_settings/index.ts new file mode 100644 index 00000000000000..016b8f721aea4c --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/account_settings/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { AccountSettings } from './account_settings'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/group_assignment_selector.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/group_assignment_selector.test.tsx new file mode 100644 index 00000000000000..94c21f3b5524f6 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/group_assignment_selector.test.tsx @@ -0,0 +1,113 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import '../../../__mocks__/react_router'; +import '../../../__mocks__/shallow_useeffect.mock'; +import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; + +import React from 'react'; + +import { waitFor } from '@testing-library/dom'; +import { shallow } from 'enzyme'; + +import { EuiComboBox, EuiComboBoxOptionOption, EuiRadioGroup } from '@elastic/eui'; + +import { wsRoleMapping } from '../../../shared/role_mapping/__mocks__/roles'; + +import { GroupAssignmentSelector } from './group_assignment_selector'; + +describe('GroupAssignmentSelector', () => { + const initializeRoleMappings = jest.fn(); + const initializeRoleMapping = jest.fn(); + const handleSaveMapping = jest.fn(); + const handleGroupSelectionChange = jest.fn(); + const handleAllGroupsSelectionChange = jest.fn(); + const handleAttributeValueChange = jest.fn(); + const handleAttributeSelectorChange = jest.fn(); + const handleDeleteMapping = jest.fn(); + const handleRoleChange = jest.fn(); + const handleAuthProviderChange = jest.fn(); + const resetState = jest.fn(); + const groups = [ + { + name: 'Group 1', + id: 'g1', + }, + { + name: 'Group 2', + id: 'g2', + }, + ]; + const mockValues = { + attributes: [], + elasticsearchRoles: [], + dataLoading: false, + roleType: 'admin', + roleMappings: [wsRoleMapping], + attributeValue: '', + attributeName: 'username', + availableGroups: groups, + selectedGroups: new Set(), + includeInAllGroups: false, + availableAuthProviders: [], + multipleAuthProvidersConfig: true, + selectedAuthProviders: [], + roleMappingErrors: [], + }; + + beforeEach(() => { + setMockActions({ + initializeRoleMappings, + initializeRoleMapping, + handleSaveMapping, + handleGroupSelectionChange, + handleAllGroupsSelectionChange, + handleAttributeValueChange, + handleAttributeSelectorChange, + handleDeleteMapping, + handleRoleChange, + handleAuthProviderChange, + resetState, + }); + setMockValues(mockValues); + }); + + it('renders', () => { + setMockValues({ ...mockValues, GroupAssignmentSelector: wsRoleMapping }); + const wrapper = shallow(); + + expect(wrapper.find(EuiRadioGroup)).toHaveLength(1); + expect(wrapper.find(EuiComboBox)).toHaveLength(1); + }); + + it('sets initial selected state when includeInAllGroups is true', () => { + setMockValues({ ...mockValues, includeInAllGroups: true }); + const wrapper = shallow(); + + expect(wrapper.find(EuiRadioGroup).prop('idSelected')).toBe('all'); + }); + + it('handles all/specific groups radio change', () => { + const wrapper = shallow(); + const radio = wrapper.find(EuiRadioGroup); + radio.simulate('change', { target: { checked: false } }); + + expect(handleAllGroupsSelectionChange).toHaveBeenCalledWith(false); + }); + + it('handles group checkbox click', async () => { + const wrapper = shallow(); + await waitFor(() => + ((wrapper.find(EuiComboBox).props() as unknown) as { + onChange: (a: EuiComboBoxOptionOption[]) => void; + }).onChange([{ label: groups[0].name, value: groups[0].name }]) + ); + wrapper.update(); + + expect(handleGroupSelectionChange).toHaveBeenCalledWith([groups[0].name]); + }); +}); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/group_assignment_selector.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/group_assignment_selector.tsx new file mode 100644 index 00000000000000..b53b092eced2db --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/group_assignment_selector.tsx @@ -0,0 +1,78 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { useActions, useValues } from 'kea'; + +import { EuiComboBox, EuiFormRow, EuiHorizontalRule, EuiRadioGroup } from '@elastic/eui'; + +import { RoleOptionLabel } from '../../../shared/role_mapping'; + +import { + GROUP_ASSIGNMENT_INVALID_ERROR, + GROUP_ASSIGNMENT_LABEL, + ALL_GROUPS_LABEL, + ALL_GROUPS_DESCRIPTION, + SPECIFIC_GROUPS_LABEL, + SPECIFIC_GROUPS_DESCRIPTION, +} from './constants'; + +import { RoleMappingsLogic } from './role_mappings_logic'; + +export const GroupAssignmentSelector: React.FC = () => { + const { handleAllGroupsSelectionChange, handleGroupSelectionChange } = useActions( + RoleMappingsLogic + ); + + const { includeInAllGroups, availableGroups, selectedGroups, selectedOptions } = useValues( + RoleMappingsLogic + ); + + const hasGroupAssignment = selectedGroups.size > 0 || includeInAllGroups; + + const groupOptions = [ + { + id: 'all', + label: , + }, + { + id: 'specific', + label: ( + + ), + }, + ]; + + return ( + <> + + + handleAllGroupsSelectionChange(id === 'all')} + legend={{ + children: {GROUP_ASSIGNMENT_LABEL}, + }} + /> + + + ({ label: name, value: id }))} + onChange={(options) => { + handleGroupSelectionChange(options.map(({ value }) => value as string)); + }} + fullWidth + isDisabled={includeInAllGroups} + /> + + + ); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx index 619a931864500a..d0f88984bd8c7b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.test.tsx @@ -11,14 +11,12 @@ import { setMockActions, setMockValues } from '../../../__mocks__/kea_logic'; import React from 'react'; -import { waitFor } from '@testing-library/dom'; import { shallow } from 'enzyme'; -import { EuiComboBox, EuiComboBoxOptionOption, EuiRadioGroup } from '@elastic/eui'; - import { AttributeSelector, RoleSelector, RoleMappingFlyout } from '../../../shared/role_mapping'; import { wsRoleMapping } from '../../../shared/role_mapping/__mocks__/roles'; +import { GroupAssignmentSelector } from './group_assignment_selector'; import { RoleMapping } from './role_mapping'; describe('RoleMapping', () => { @@ -83,33 +81,7 @@ describe('RoleMapping', () => { expect(wrapper.find(AttributeSelector)).toHaveLength(1); expect(wrapper.find(RoleSelector)).toHaveLength(1); - }); - - it('sets initial selected state when includeInAllGroups is true', () => { - setMockValues({ ...mockValues, includeInAllGroups: true }); - const wrapper = shallow(); - - expect(wrapper.find(EuiRadioGroup).prop('idSelected')).toBe('all'); - }); - - it('handles all/specific groups radio change', () => { - const wrapper = shallow(); - const radio = wrapper.find(EuiRadioGroup); - radio.simulate('change', { target: { checked: false } }); - - expect(handleAllGroupsSelectionChange).toHaveBeenCalledWith(false); - }); - - it('handles group checkbox click', async () => { - const wrapper = shallow(); - await waitFor(() => - ((wrapper.find(EuiComboBox).props() as unknown) as { - onChange: (a: EuiComboBoxOptionOption[]) => void; - }).onChange([{ label: groups[0].name, value: groups[0].name }]) - ); - wrapper.update(); - - expect(handleGroupSelectionChange).toHaveBeenCalledWith([groups[0].name]); + expect(wrapper.find(GroupAssignmentSelector)).toHaveLength(1); }); it('enables flyout when attribute value is valid', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.tsx index e2f24ce392c397..cc773895bff1c4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mapping.tsx @@ -9,35 +9,15 @@ import React from 'react'; import { useActions, useValues } from 'kea'; -import { - EuiComboBox, - EuiForm, - EuiFormRow, - EuiHorizontalRule, - EuiRadioGroup, - EuiSpacer, -} from '@elastic/eui'; +import { EuiForm, EuiSpacer } from '@elastic/eui'; -import { - AttributeSelector, - RoleSelector, - RoleOptionLabel, - RoleMappingFlyout, -} from '../../../shared/role_mapping'; +import { AttributeSelector, RoleSelector, RoleMappingFlyout } from '../../../shared/role_mapping'; import { Role } from '../../types'; -import { - ADMIN_ROLE_TYPE_DESCRIPTION, - USER_ROLE_TYPE_DESCRIPTION, - GROUP_ASSIGNMENT_INVALID_ERROR, - GROUP_ASSIGNMENT_LABEL, - ALL_GROUPS_LABEL, - ALL_GROUPS_DESCRIPTION, - SPECIFIC_GROUPS_LABEL, - SPECIFIC_GROUPS_DESCRIPTION, -} from './constants'; +import { ADMIN_ROLE_TYPE_DESCRIPTION, USER_ROLE_TYPE_DESCRIPTION } from './constants'; +import { GroupAssignmentSelector } from './group_assignment_selector'; import { RoleMappingsLogic } from './role_mappings_logic'; interface RoleType { @@ -56,24 +36,9 @@ const roleOptions = [ }, ] as RoleType[]; -const groupOptions = [ - { - id: 'all', - label: , - }, - { - id: 'specific', - label: ( - - ), - }, -]; - export const RoleMapping: React.FC = () => { const { handleSaveMapping, - handleGroupSelectionChange, - handleAllGroupsSelectionChange, handleAttributeValueChange, handleAttributeSelectorChange, handleRoleChange, @@ -87,13 +52,11 @@ export const RoleMapping: React.FC = () => { roleType, attributeValue, attributeName, - availableGroups, selectedGroups, includeInAllGroups, availableAuthProviders, multipleAuthProvidersConfig, selectedAuthProviders, - selectedOptions, roleMapping, roleMappingErrors, } = useValues(RoleMappingsLogic); @@ -132,29 +95,7 @@ export const RoleMapping: React.FC = () => { onChange={handleRoleChange} label="Role" /> - - - handleAllGroupsSelectionChange(id === 'all')} - legend={{ - children: {GROUP_ASSIGNMENT_LABEL}, - }} - /> - - - ({ label: name, value: id }))} - onChange={(options) => { - handleGroupSelectionChange(options.map(({ value }) => value as string)); - }} - fullWidth - isDisabled={includeInAllGroups} - /> - + ); diff --git a/x-pack/plugins/enterprise_search/public/plugin.ts b/x-pack/plugins/enterprise_search/public/plugin.ts index e402d233da58db..6e521efc369df1 100644 --- a/x-pack/plugins/enterprise_search/public/plugin.ts +++ b/x-pack/plugins/enterprise_search/public/plugin.ts @@ -21,6 +21,7 @@ import { } from '../../../../src/plugins/home/public'; import { CloudSetup } from '../../cloud/public'; import { LicensingPluginStart } from '../../licensing/public'; +import { SecurityPluginSetup, SecurityPluginStart } from '../../security/public'; import { APP_SEARCH_PLUGIN, @@ -42,11 +43,13 @@ export interface ClientData extends InitialAppData { interface PluginsSetup { cloud?: CloudSetup; home?: HomePublicPluginSetup; + security?: SecurityPluginSetup; } export interface PluginsStart { cloud?: CloudSetup; licensing: LicensingPluginStart; charts: ChartsPluginStart; + security?: SecurityPluginStart; } export class EnterpriseSearchPlugin implements Plugin { diff --git a/x-pack/plugins/event_log/README.md b/x-pack/plugins/event_log/README.md index 2272341c65f5e9..032f77543acb97 100644 --- a/x-pack/plugins/event_log/README.md +++ b/x-pack/plugins/event_log/README.md @@ -101,11 +101,20 @@ Below is a document in the expected structure, with descriptions of the fields: logger: "name of the logger", }, - // Rule fields. All of them are supported. + // Rule fields. // https://www.elastic.co/guide/en/ecs/current/ecs-rule.html rule: { + // Fields currently are populated: + id: "a823fd56-5467-4727-acb1-66809737d943", // rule id + category: "test", // rule type id + license: "basic", // rule type minimumLicenseRequired + name: "rule-name", // + ruleset: "alerts", // rule type producer + // Fields currently are not populated: author: ["Elastic"], - id: "a823fd56-5467-4727-acb1-66809737d943", + description: "Some rule description", + version: '1', + uuid: "uuid" // etc }, diff --git a/x-pack/plugins/event_log/generated/mappings.json b/x-pack/plugins/event_log/generated/mappings.json index da04db1086aa89..3eadcc21257b08 100644 --- a/x-pack/plugins/event_log/generated/mappings.json +++ b/x-pack/plugins/event_log/generated/mappings.json @@ -214,6 +214,10 @@ "version": { "ignore_above": 1024, "type": "keyword" + }, + "namespace": { + "ignore_above": 1024, + "type": "keyword" } } }, diff --git a/x-pack/plugins/event_log/generated/schemas.ts b/x-pack/plugins/event_log/generated/schemas.ts index a13b304e8adab0..2a066ca0bd15bc 100644 --- a/x-pack/plugins/event_log/generated/schemas.ts +++ b/x-pack/plugins/event_log/generated/schemas.ts @@ -91,6 +91,7 @@ export const EventSchema = schema.maybe( ruleset: ecsString(), uuid: ecsString(), version: ecsString(), + namespace: ecsString(), }) ), user: schema.maybe( diff --git a/x-pack/plugins/fleet/common/services/__snapshots__/package_to_package_policy.test.ts.snap b/x-pack/plugins/fleet/common/services/__snapshots__/package_to_package_policy.test.ts.snap new file mode 100644 index 00000000000000..d49743fa487f49 --- /dev/null +++ b/x-pack/plugins/fleet/common/services/__snapshots__/package_to_package_policy.test.ts.snap @@ -0,0 +1,804 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Fleet - packageToPackagePolicy packageToPackagePolicy returns package policy with multiple policy templates (aka has integrations 1`] = ` +Object { + "description": undefined, + "enabled": true, + "inputs": Array [ + Object { + "enabled": true, + "policy_template": "billing", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.billing", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "cost_explorer_config.group_by_dimension_keys": Object { + "type": "text", + "value": Array [ + "AZ", + "INSTANCE_TYPE", + "SERVICE", + ], + }, + "cost_explorer_config.group_by_tag_keys": Object { + "type": "text", + "value": Array [ + "aws:createdBy", + ], + }, + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "12h", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "cloudtrail", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.cloudtrail", + "type": "logs", + }, + "enabled": true, + "vars": Object { + "api_timeout": Object { + "type": "text", + "value": undefined, + }, + "fips_enabled": Object { + "type": "bool", + "value": false, + }, + "queue_url": Object { + "type": "text", + "value": undefined, + }, + "visibility_timeout": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "s3", + }, + Object { + "enabled": false, + "policy_template": "cloudtrail", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.cloudtrail", + "type": "logs", + }, + "enabled": false, + "vars": Object { + "interval": Object { + "type": "text", + "value": "10s", + }, + "password": Object { + "type": "password", + "value": undefined, + }, + "search": Object { + "type": "text", + "value": "search sourcetype=aws:cloudtrail", + }, + "ssl": Object { + "type": "yaml", + "value": undefined, + }, + "tags": Object { + "type": "text", + "value": Array [ + "forwarded", + ], + }, + "url": Object { + "type": "text", + "value": "https://server.example.com:8089", + }, + "username": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "httpjson", + }, + Object { + "enabled": true, + "policy_template": "cloudwatch", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.cloudwatch_logs", + "type": "logs", + }, + "enabled": true, + "vars": Object { + "api_timeout": Object { + "type": "text", + "value": undefined, + }, + "fips_enabled": Object { + "type": "bool", + "value": false, + }, + "queue_url": Object { + "type": "text", + "value": undefined, + }, + "visibility_timeout": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "s3", + }, + Object { + "enabled": true, + "policy_template": "cloudwatch", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.cloudwatch_metrics", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "metrics": Object { + "type": "yaml", + "value": "- namespace: AWS/EC2 + resource_type: ec2:instance + name: + - CPUUtilization + - DiskWriteOps + statistic: + - Average + - Maximum + # dimensions: + # - name: InstanceId + # value: i-123456 + # tags: + # - key: created-by + # value: foo +", + }, + "period": Object { + "type": "text", + "value": "300s", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "dynamodb", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.dynamodb", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "5m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "ebs", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.ebs", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "5m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "ec2", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.ec2_logs", + "type": "logs", + }, + "enabled": true, + "vars": Object { + "api_timeout": Object { + "type": "text", + "value": undefined, + }, + "fips_enabled": Object { + "type": "bool", + "value": false, + }, + "queue_url": Object { + "type": "text", + "value": undefined, + }, + "visibility_timeout": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "s3", + }, + Object { + "enabled": true, + "policy_template": "ec2", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.ec2_metrics", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "5m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "elb", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.elb_logs", + "type": "logs", + }, + "enabled": true, + "vars": Object { + "api_timeout": Object { + "type": "text", + "value": undefined, + }, + "fips_enabled": Object { + "type": "bool", + "value": false, + }, + "queue_url": Object { + "type": "text", + "value": undefined, + }, + "visibility_timeout": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "s3", + }, + Object { + "enabled": true, + "policy_template": "elb", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.elb_metrics", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "lambda", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.lambda", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "5m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "natgateway", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.natgateway", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "rds", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.rds", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "s3", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.s3access", + "type": "logs", + }, + "enabled": true, + "vars": Object { + "api_timeout": Object { + "type": "text", + "value": undefined, + }, + "fips_enabled": Object { + "type": "bool", + "value": false, + }, + "queue_url": Object { + "type": "text", + "value": undefined, + }, + "visibility_timeout": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "s3", + }, + Object { + "enabled": true, + "policy_template": "s3", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.s3_daily_storage", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "24h", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + Object { + "data_stream": Object { + "dataset": "aws.s3_request", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "sns", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.sns", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "5m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "sqs", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.sqs", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "5m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "transitgateway", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.transitgateway", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "usage", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.usage", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + }, + }, + ], + "type": "aws/metrics", + }, + Object { + "enabled": true, + "policy_template": "vpcflow", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.vpcflow", + "type": "logs", + }, + "enabled": true, + "vars": Object { + "api_timeout": Object { + "type": "text", + "value": undefined, + }, + "fips_enabled": Object { + "type": "bool", + "value": false, + }, + "queue_url": Object { + "type": "text", + "value": undefined, + }, + "visibility_timeout": Object { + "type": "text", + "value": undefined, + }, + }, + }, + ], + "type": "s3", + }, + Object { + "enabled": true, + "policy_template": "vpn", + "streams": Array [ + Object { + "data_stream": Object { + "dataset": "aws.vpn", + "type": "metrics", + }, + "enabled": true, + "vars": Object { + "latency": Object { + "type": "text", + "value": undefined, + }, + "period": Object { + "type": "text", + "value": "1m", + }, + "regions": Object { + "type": "text", + "value": Array [], + }, + "tags_filter": Object { + "type": "yaml", + "value": "# - key: \\"created-by\\" + # value: \\"foo\\" +", + }, + }, + }, + ], + "type": "aws/metrics", + }, + ], + "name": "aws-1", + "namespace": "default", + "output_id": "some-output-id", + "package": Object { + "name": "aws", + "title": "AWS", + "version": "0.5.3", + }, + "policy_id": "some-agent-policy-id", + "vars": Object { + "access_key_id": Object { + "type": "text", + "value": undefined, + }, + "credential_profile_name": Object { + "type": "text", + "value": undefined, + }, + "endpoint": Object { + "type": "text", + "value": "amazonaws.com", + }, + "role_arn": Object { + "type": "text", + "value": undefined, + }, + "secret_access_key": Object { + "type": "text", + "value": undefined, + }, + "session_token": Object { + "type": "text", + "value": undefined, + }, + "shared_credential_file": Object { + "type": "text", + "value": undefined, + }, + }, +} +`; diff --git a/x-pack/plugins/fleet/common/services/__snapshots__/validate_package_policy.test.ts.snap b/x-pack/plugins/fleet/common/services/__snapshots__/validate_package_policy.test.ts.snap new file mode 100644 index 00000000000000..72f4182d87629f --- /dev/null +++ b/x-pack/plugins/fleet/common/services/__snapshots__/validate_package_policy.test.ts.snap @@ -0,0 +1,301 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Fleet - validatePackagePolicy() works for packages with multiple policy templates (aka integrations) returns errors for invalid package policy 1`] = ` +Object { + "description": null, + "inputs": Object { + "billing-aws/metrics": Object { + "streams": Object { + "aws.billing": Object { + "vars": Object { + "cost_explorer_config.group_by_dimension_keys": null, + "cost_explorer_config.group_by_tag_keys": null, + "latency": null, + "period": null, + }, + }, + }, + }, + "cloudtrail-httpjson": Object { + "streams": Object { + "aws.cloudtrail": Object { + "vars": Object { + "interval": null, + "password": null, + "search": null, + "ssl": null, + "tags": null, + "url": null, + "username": null, + }, + }, + }, + }, + "cloudtrail-s3": Object { + "streams": Object { + "aws.cloudtrail": Object { + "vars": Object { + "api_timeout": null, + "fips_enabled": null, + "queue_url": Array [ + "Queue URL is required", + ], + "visibility_timeout": null, + }, + }, + }, + }, + "cloudwatch-aws/metrics": Object { + "streams": Object { + "aws.cloudwatch_metrics": Object { + "vars": Object { + "latency": null, + "metrics": null, + "period": null, + "regions": null, + }, + }, + }, + }, + "cloudwatch-s3": Object { + "streams": Object { + "aws.cloudwatch_logs": Object { + "vars": Object { + "api_timeout": null, + "fips_enabled": null, + "queue_url": Array [ + "Queue URL is required", + ], + "visibility_timeout": null, + }, + }, + }, + }, + "dynamodb-aws/metrics": Object { + "streams": Object { + "aws.dynamodb": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "ebs-aws/metrics": Object { + "streams": Object { + "aws.ebs": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "ec2-aws/metrics": Object { + "streams": Object { + "aws.ec2_metrics": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "ec2-s3": Object { + "streams": Object { + "aws.ec2_logs": Object { + "vars": Object { + "api_timeout": null, + "fips_enabled": null, + "queue_url": Array [ + "Queue URL is required", + ], + "visibility_timeout": null, + }, + }, + }, + }, + "elb-aws/metrics": Object { + "streams": Object { + "aws.elb_metrics": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "elb-s3": Object { + "streams": Object { + "aws.elb_logs": Object { + "vars": Object { + "api_timeout": null, + "fips_enabled": null, + "queue_url": Array [ + "Queue URL is required", + ], + "visibility_timeout": null, + }, + }, + }, + }, + "lambda-aws/metrics": Object { + "streams": Object { + "aws.lambda": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "natgateway-aws/metrics": Object { + "streams": Object { + "aws.natgateway": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + }, + }, + }, + }, + "rds-aws/metrics": Object { + "streams": Object { + "aws.rds": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "s3-aws/metrics": Object { + "streams": Object { + "aws.s3_daily_storage": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + }, + }, + "aws.s3_request": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + }, + }, + }, + }, + "s3-s3": Object { + "streams": Object { + "aws.s3access": Object { + "vars": Object { + "api_timeout": null, + "fips_enabled": null, + "queue_url": Array [ + "Queue URL is required", + ], + "visibility_timeout": null, + }, + }, + }, + }, + "sns-aws/metrics": Object { + "streams": Object { + "aws.sns": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + "sqs-aws/metrics": Object { + "streams": Object { + "aws.sqs": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + }, + }, + }, + }, + "transitgateway-aws/metrics": Object { + "streams": Object { + "aws.transitgateway": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + }, + }, + }, + }, + "usage-aws/metrics": Object { + "streams": Object { + "aws.usage": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + }, + }, + }, + }, + "vpcflow-s3": Object { + "streams": Object { + "aws.vpcflow": Object { + "vars": Object { + "api_timeout": null, + "fips_enabled": null, + "queue_url": Array [ + "Queue URL is required", + ], + "visibility_timeout": null, + }, + }, + }, + }, + "vpn-aws/metrics": Object { + "streams": Object { + "aws.vpn": Object { + "vars": Object { + "latency": null, + "period": null, + "regions": null, + "tags_filter": null, + }, + }, + }, + }, + }, + "name": null, + "namespace": null, + "vars": Object { + "access_key_id": null, + "credential_profile_name": null, + "endpoint": null, + "role_arn": null, + "secret_access_key": null, + "session_token": null, + "shared_credential_file": null, + }, +} +`; diff --git a/x-pack/plugins/fleet/common/services/fixtures/aws_package.ts b/x-pack/plugins/fleet/common/services/fixtures/aws_package.ts new file mode 100644 index 00000000000000..2b93cca3d4e4d2 --- /dev/null +++ b/x-pack/plugins/fleet/common/services/fixtures/aws_package.ts @@ -0,0 +1,2742 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export const AWS_PACKAGE = { + name: 'aws', + title: 'AWS', + version: '0.5.3', + release: 'beta', + description: 'AWS Integration', + type: 'integration', + download: '/epr/aws/aws-0.5.3.zip', + path: '/package/aws/0.5.3', + icons: [ + { + src: '/img/logo_aws.svg', + path: '/package/aws/0.5.3/img/logo_aws.svg', + title: 'logo aws', + size: '32x32', + type: 'image/svg+xml', + }, + ], + format_version: '1.0.0', + readme: '/package/aws/0.5.3/docs/README.md', + license: 'basic', + categories: ['aws', 'cloud', 'network', 'security'], + conditions: { + 'kibana.version': '^7.12.0', + }, + screenshots: [ + { + src: '/img/metricbeat-aws-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-overview.png', + title: 'metricbeat aws overview', + size: '3848x2440', + type: 'image/png', + }, + ], + assets: { + kibana: { + dashboard: [], + map: [], + search: [], + visualization: [], + }, + elasticsearch: { + ingest_pipeline: [], + }, + }, + policy_templates: [ + { + name: 'billing', + title: 'AWS Billing', + description: 'Collect AWS billing metrics', + data_streams: ['billing'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect billing metrics', + description: 'Collect billing metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_billing.svg', + path: '/package/aws/0.5.3/img/logo_billing.svg', + title: 'AWS Billing logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/metricbeat-aws-billing-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-billing-overview.png', + title: 'metricbeat aws billing overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/billing.md', + }, + { + name: 'cloudtrail', + title: 'AWS Cloudtrail', + description: 'Collect logs from AWS Cloudtrail', + data_streams: ['cloudtrail'], + inputs: [ + { + type: 's3', + title: 'Collect logs from Cloudtrail service', + description: 'Collecting Cloudtrail logs using S3 input', + input_group: 'logs', + }, + { + type: 'httpjson', + title: 'Collect logs from third-party REST API (experimental)', + description: 'Collect logs from third-party REST API (experimental)', + input_group: 'logs', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_cloudtrail.svg', + path: '/package/aws/0.5.3/img/logo_cloudtrail.svg', + title: 'AWS Cloudtrail logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/filebeat-aws-cloudtrail.png', + path: '/package/aws/0.5.3/img/filebeat-aws-cloudtrail.png', + title: 'filebeat aws cloudtrail', + size: '1702x1063', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/cloudtrail.md', + }, + { + name: 'cloudwatch', + title: 'AWS CloudWatch', + description: 'Collect logs and metrics from CloudWatch', + data_streams: ['cloudwatch_logs', 'cloudwatch_metrics'], + inputs: [ + { + type: 's3', + title: 'Collect logs from CloudWatch', + description: 'Collecting logs from CloudWatch using S3 input', + input_group: 'logs', + }, + { + type: 'aws/metrics', + title: 'Collect metrics from CloudWatch', + description: 'Collecting metrics from AWS CloudWatch', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_cloudwatch.svg', + path: '/package/aws/0.5.3/img/logo_cloudwatch.svg', + title: 'AWS CloudWatch logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + readme: '/package/aws/0.5.3/docs/cloudwatch.md', + }, + { + name: 'dynamodb', + title: 'AWS DynamoDB', + description: 'Collect AWS DynamoDB metrics', + data_streams: ['dynamodb'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect dynamodb metrics', + description: 'Collect dynamodb metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_dynamodb.svg', + path: '/package/aws/0.5.3/img/logo_dynamodb.svg', + title: 'AWS DynamoDB logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + categories: ['datastore'], + screenshots: [ + { + src: '/img/metricbeat-aws-dynamodb-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-dynamodb-overview.png', + title: 'metricbeat aws dynamodb overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/dynamodb.md', + }, + { + name: 'ebs', + title: 'AWS EBS', + description: 'Collect AWS EBS metrics', + data_streams: ['ebs'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect EBS metrics', + description: 'Collect EBS metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_ebs.svg', + path: '/package/aws/0.5.3/img/logo_ebs.svg', + title: 'AWS EBS logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + categories: ['datastore'], + screenshots: [ + { + src: '/img/metricbeat-aws-ebs-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-ebs-overview.png', + title: 'metricbeat aws ebs overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/ebs.md', + }, + { + name: 'ec2', + title: 'AWS EC2', + description: 'Collect logs and metrics from EC2 service', + data_streams: ['ec2_logs', 'ec2_metrics'], + inputs: [ + { + type: 's3', + title: 'Collect logs from EC2 service', + description: 'Collecting EC2 logs using S3 input', + input_group: 'logs', + }, + { + type: 'aws/metrics', + title: 'Collect metrics from EC2 service', + description: 'Collecting EC2 metrics using AWS CloudWatch', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_ec2.svg', + path: '/package/aws/0.5.3/img/logo_ec2.svg', + title: 'AWS EC2 logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/metricbeat-aws-ec2-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-ec2-overview.png', + title: 'metricbeat aws ec2 overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/ec2.md', + }, + { + name: 'elb', + title: 'AWS ELB', + description: 'Collect logs and metrics from ELB service', + data_streams: ['elb_logs', 'elb_metrics'], + inputs: [ + { + type: 's3', + title: 'Collect logs from ELB service', + description: 'Collecting ELB logs using S3 input', + input_group: 'logs', + }, + { + type: 'aws/metrics', + title: 'Collect metrics from ELB service', + description: 'Collecting ELB metrics using AWS CloudWatch', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_elb.svg', + path: '/package/aws/0.5.3/img/logo_elb.svg', + title: 'AWS ELB logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/metricbeat-aws-elb-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-elb-overview.png', + title: 'metricbeat aws elb overview', + size: '2640x2240', + type: 'image/png', + }, + { + src: '/img/filebeat-aws-elb-overview.png', + path: '/package/aws/0.5.3/img/filebeat-aws-elb-overview.png', + title: 'filebeat aws elb overview', + size: '1684x897', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/elb.md', + }, + { + name: 'lambda', + title: 'AWS Lambda', + description: 'Collect AWS Lambda metrics', + data_streams: ['lambda'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect Lambda metrics', + description: 'Collect Lambda metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_lambda.svg', + path: '/package/aws/0.5.3/img/logo_lambda.svg', + title: 'AWS Lambda logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/metricbeat-aws-lambda-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-lambda-overview.png', + title: 'metricbeat aws lambda overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/lambda.md', + }, + { + name: 'natgateway', + title: 'AWS NATGateway', + description: 'Collect AWS NATGateway metrics', + data_streams: ['natgateway'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect NATGateway metrics', + description: 'Collect NATGateway metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_natgateway.svg', + path: '/package/aws/0.5.3/img/logo_natgateway.svg', + title: 'AWS NATGateway logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + readme: '/package/aws/0.5.3/docs/natgateway.md', + }, + { + name: 'rds', + title: 'AWS RDS', + description: 'Collect AWS RDS metrics', + data_streams: ['rds'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect RDS metrics', + description: 'Collect RDS metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_rds.svg', + path: '/package/aws/0.5.3/img/logo_rds.svg', + title: 'AWS RDS logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + categories: ['datastore'], + screenshots: [ + { + src: '/img/metricbeat-aws-rds-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-rds-overview.png', + title: 'metricbeat aws rds overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/rds.md', + }, + { + name: 's3', + title: 'AWS S3', + description: 'Collect AWS S3 metrics', + data_streams: ['s3_daily_storage', 's3_request', 's3access'], + inputs: [ + { + type: 's3', + title: 'Collect S3 access logs', + description: 'Collecting S3 access logs using S3 input', + input_group: 'logs', + }, + { + type: 'aws/metrics', + title: 'Collect metrics from S3', + description: 'Collecting S3 metrics using AWS CloudWatch', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_s3.svg', + path: '/package/aws/0.5.3/img/logo_s3.svg', + title: 'AWS S3 logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + categories: ['datastore'], + screenshots: [ + { + src: '/img/metricbeat-aws-s3-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-s3-overview.png', + title: 'metricbeat aws s3 overview', + size: '2640x2240', + type: 'image/png', + }, + { + src: '/img/filebeat-aws-s3access-overview.png', + path: '/package/aws/0.5.3/img/filebeat-aws-s3access-overview.png', + title: 'filebeat aws s3access overview', + size: '1684x897', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/s3.md', + }, + { + name: 'sns', + title: 'AWS SNS', + description: 'Collect AWS SNS metrics', + data_streams: ['sns'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect SNS metrics', + description: 'Collect SNS metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_sns.svg', + path: '/package/aws/0.5.3/img/logo_sns.svg', + title: 'AWS SNS logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/metricbeat-aws-sns-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-sns-overview.png', + title: 'metricbeat aws sns overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/sns.md', + }, + { + name: 'sqs', + title: 'AWS SQS', + description: 'Collect AWS SQS metrics', + data_streams: ['sqs'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect SQS metrics', + description: 'Collect SQS metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_sqs.svg', + path: '/package/aws/0.5.3/img/logo_sqs.svg', + title: 'AWS SQS logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + screenshots: [ + { + src: '/img/metricbeat-aws-sqs-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-sqs-overview.png', + title: 'metricbeat aws sqs overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/sqs.md', + }, + { + name: 'transitgateway', + title: 'AWS Transit Gateway', + description: 'Collect AWS Transit Gateway metrics', + data_streams: ['transitgateway'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect Transit Gateway metrics', + description: 'Collect Transit Gateway metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_transitgateway.svg', + path: '/package/aws/0.5.3/img/logo_transitgateway.svg', + title: 'AWS Transit Gateway logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + readme: '/package/aws/0.5.3/docs/transitgateway.md', + }, + { + name: 'usage', + title: 'AWS Usage', + description: 'Collect AWS Usage metrics', + data_streams: ['usage'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect Usage metrics', + description: 'Collect Usage metrics', + input_group: 'metrics', + }, + ], + multiple: true, + screenshots: [ + { + src: '/img/metricbeat-aws-usage-overview.png', + path: '/package/aws/0.5.3/img/metricbeat-aws-usage-overview.png', + title: 'metricbeat aws sns overview', + size: '2640x2240', + type: 'image/png', + }, + ], + readme: '/package/aws/0.5.3/docs/usage.md', + }, + { + name: 'vpcflow', + title: 'AWS VPC Flow', + description: 'Collect AWS vpcflow logs', + data_streams: ['vpcflow'], + inputs: [ + { + type: 's3', + title: 'Collect VPC Flow logs', + description: 'Collecting VPC Flow logs using S3 input', + input_group: 'logs', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_vpcflow.svg', + path: '/package/aws/0.5.3/img/logo_vpcflow.svg', + title: 'AWS VPC logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + readme: '/package/aws/0.5.3/docs/vpcflow.md', + }, + { + name: 'vpn', + title: 'AWS VPN', + description: 'Collect AWS VPN metrics', + data_streams: ['vpn'], + inputs: [ + { + type: 'aws/metrics', + title: 'Collect VPN metrics', + description: 'Collect VPN metrics', + input_group: 'metrics', + }, + ], + multiple: true, + icons: [ + { + src: '/img/logo_vpn.svg', + path: '/package/aws/0.5.3/img/logo_vpn.svg', + title: 'AWS VPN logo', + size: '32x32', + type: 'image/svg+xml', + }, + ], + categories: ['network'], + readme: '/package/aws/0.5.3/docs/vpn.md', + }, + ], + data_streams: [ + { + type: 'metrics', + dataset: 'aws.billing', + title: 'AWS billing metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '12h', + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'cost_explorer_config.group_by_dimension_keys', + type: 'text', + title: 'Cost Explorer Group By Dimension Keys', + multi: true, + required: false, + show_user: true, + default: ['AZ', 'INSTANCE_TYPE', 'SERVICE'], + }, + { + name: 'cost_explorer_config.group_by_tag_keys', + type: 'text', + title: 'Cost Explorer Group By Tag Keys', + multi: true, + required: false, + show_user: true, + default: ['aws:createdBy'], + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS Billing metrics', + description: 'Collect AWS billing metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'billing', + }, + { + type: 'logs', + dataset: 'aws.cloudtrail', + title: 'AWS CloudTrail logs', + release: 'beta', + ingest_pipeline: 'default', + streams: [ + { + input: 's3', + vars: [ + { + name: 'visibility_timeout', + type: 'text', + title: 'Visibility Timeout', + description: + 'The duration that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. The maximum is 12 hours.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'api_timeout', + type: 'text', + title: 'API Timeout', + description: + 'The maximum duration of AWS API can take. The maximum is half of the visibility timeout value.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'queue_url', + type: 'text', + title: 'Queue URL', + description: 'URL of the AWS SQS queue that messages will be received from.', + multi: false, + required: true, + show_user: true, + }, + { + name: 'fips_enabled', + type: 'bool', + title: 'Enable S3 FIPS', + description: + 'Enabling this option changes the service name from `s3` to `s3-fips` for connecting to the correct service endpoint.', + multi: false, + required: false, + show_user: false, + default: false, + }, + ], + template_path: 's3.yml.hbs', + title: 'AWS CloudTrail logs', + description: 'Collect AWS CloudTrail logs using s3 input', + enabled: true, + }, + { + input: 'httpjson', + vars: [ + { + name: 'url', + type: 'text', + title: 'URL of Splunk Enterprise Server', + description: 'i.e. scheme://host:port, path is automatic', + multi: false, + required: true, + show_user: true, + default: 'https://server.example.com:8089', + }, + { + name: 'username', + type: 'text', + title: 'Splunk REST API Username', + multi: false, + required: true, + show_user: true, + }, + { + name: 'password', + type: 'password', + title: 'Splunk REST API Password', + multi: false, + required: true, + show_user: true, + }, + { + name: 'ssl', + type: 'yaml', + title: 'SSL Configuration', + description: + 'i.e. certificate_authorities, supported_protocols, verification_mode etc.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'interval', + type: 'text', + title: 'Interval to query Splunk Enterprise REST API', + description: 'Go Duration syntax (eg. 10s)', + multi: false, + required: true, + show_user: true, + default: '10s', + }, + { + name: 'search', + type: 'text', + title: 'Splunk search string', + multi: false, + required: true, + show_user: true, + default: 'search sourcetype=aws:cloudtrail', + }, + { + name: 'tags', + type: 'text', + title: 'Tags', + multi: true, + required: false, + show_user: false, + default: ['forwarded'], + }, + ], + template_path: 'httpjson.yml.hbs', + title: 'AWS CloudTrail logs via Splunk Enterprise REST API', + description: 'Collect AWS CloudTrail logs via Splunk Enterprise REST API', + enabled: false, + }, + ], + package: 'aws', + path: 'cloudtrail', + }, + { + type: 'logs', + dataset: 'aws.cloudwatch_logs', + title: 'AWS CloudWatch logs', + release: 'beta', + ingest_pipeline: 'default', + streams: [ + { + input: 's3', + vars: [ + { + name: 'visibility_timeout', + type: 'text', + title: 'Visibility Timeout', + description: + 'The duration that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. The maximum is 12 hours.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'api_timeout', + type: 'text', + title: 'API Timeout', + description: + 'The maximum duration of AWS API can take. The maximum is half of the visibility timeout value.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'queue_url', + type: 'text', + title: 'Queue URL', + description: 'URL of the AWS SQS queue that messages will be received from.', + multi: false, + required: true, + show_user: true, + }, + { + name: 'fips_enabled', + type: 'bool', + title: 'Enable S3 FIPS', + description: + 'Enabling this option changes the service name from `s3` to `s3-fips` for connecting to the correct service endpoint.', + multi: false, + required: false, + show_user: false, + default: false, + }, + ], + template_path: 's3.yml.hbs', + title: 'AWS CloudWatch logs', + description: 'Collect AWS CloudWatch logs using s3 input', + enabled: true, + }, + ], + package: 'aws', + path: 'cloudwatch_logs', + }, + { + type: 'metrics', + dataset: 'aws.cloudwatch_metrics', + title: 'AWS CloudWatch metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '300s', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'metrics', + type: 'yaml', + title: 'Metrics', + multi: false, + required: true, + show_user: true, + default: + '- namespace: AWS/EC2\n resource_type: ec2:instance\n name:\n - CPUUtilization\n - DiskWriteOps\n statistic:\n - Average\n - Maximum\n # dimensions:\n # - name: InstanceId\n # value: i-123456\n # tags:\n # - key: created-by\n # value: foo\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS CloudWatch metrics', + description: 'Collect AWS CloudWatch metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'cloudwatch_metrics', + }, + { + type: 'metrics', + dataset: 'aws.dynamodb', + title: 'AWS DynamoDB metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '5m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS DynamoDB metrics', + description: 'Collect AWS DynamoDB metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'dynamodb', + }, + { + type: 'metrics', + dataset: 'aws.ebs', + title: 'AWS EBS metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '5m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS EBS metrics', + description: 'Collect AWS EBS metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'ebs', + }, + { + type: 'logs', + dataset: 'aws.ec2_logs', + title: 'AWS EC2 logs', + release: 'beta', + ingest_pipeline: 'default', + streams: [ + { + input: 's3', + vars: [ + { + name: 'visibility_timeout', + type: 'text', + title: 'Visibility Timeout', + description: + 'The duration that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. The maximum is 12 hours.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'api_timeout', + type: 'text', + title: 'API Timeout', + description: + 'The maximum duration of AWS API can take. The maximum is half of the visibility timeout value.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'queue_url', + type: 'text', + title: 'Queue URL', + description: 'URL of the AWS SQS queue that messages will be received from.', + multi: false, + required: true, + show_user: true, + }, + { + name: 'fips_enabled', + type: 'bool', + title: 'Enable S3 FIPS', + description: + 'Enabling this option changes the service name from `s3` to `s3-fips` for connecting to the correct service endpoint.', + multi: false, + required: false, + show_user: false, + default: false, + }, + ], + template_path: 's3.yml.hbs', + title: 'AWS EC2 logs', + description: 'Collect AWS EC2 logs using s3 input', + enabled: true, + }, + ], + package: 'aws', + path: 'ec2_logs', + }, + { + type: 'metrics', + dataset: 'aws.ec2_metrics', + title: 'AWS EC2 metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '5m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS EC2 metrics', + description: 'Collect AWS EC2 metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'ec2_metrics', + }, + { + type: 'logs', + dataset: 'aws.elb_logs', + title: 'AWS ELB logs', + release: 'beta', + ingest_pipeline: 'default', + streams: [ + { + input: 's3', + vars: [ + { + name: 'visibility_timeout', + type: 'text', + title: 'Visibility Timeout', + description: + 'The duration that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. The maximum is 12 hours.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'api_timeout', + type: 'text', + title: 'API Timeout', + description: + 'The maximum duration of AWS API can take. The maximum is half of the visibility timeout value.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'queue_url', + type: 'text', + title: 'Queue URL', + description: 'URL of the AWS SQS queue that messages will be received from.', + multi: false, + required: true, + show_user: true, + }, + { + name: 'fips_enabled', + type: 'bool', + title: 'Enable S3 FIPS', + description: + 'Enabling this option changes the service name from `s3` to `s3-fips` for connecting to the correct service endpoint.', + multi: false, + required: false, + show_user: false, + default: false, + }, + ], + template_path: 's3.yml.hbs', + title: 'AWS ELB logs', + description: 'Collect AWS ELB logs using s3 input', + enabled: true, + }, + ], + package: 'aws', + path: 'elb_logs', + }, + { + type: 'metrics', + dataset: 'aws.elb_metrics', + title: 'AWS ELB metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS ELB metrics', + description: 'Collect AWS ELB metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'elb_metrics', + }, + { + type: 'metrics', + dataset: 'aws.lambda', + title: 'AWS Lambda metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '5m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS Lambda metrics', + description: 'Collect AWS Lambda metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'lambda', + }, + { + type: 'metrics', + dataset: 'aws.natgateway', + title: 'AWS NAT gateway metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS NAT gateway metrics', + description: 'Collect AWS NAT gateway metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'natgateway', + }, + { + type: 'metrics', + dataset: 'aws.rds', + title: 'AWS RDS metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS RDS metrics', + description: 'Collect AWS RDS metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'rds', + }, + { + type: 'metrics', + dataset: 'aws.s3_daily_storage', + title: 'AWS S3 daily storage metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '24h', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS S3 daily storage metrics', + description: 'Collect AWS S3 daily storage metrics', + enabled: true, + }, + ], + package: 'aws', + path: 's3_daily_storage', + }, + { + type: 'metrics', + dataset: 'aws.s3_request', + title: 'AWS S3 request metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS S3 request metrics', + description: 'Collect AWS S3 request metrics', + enabled: true, + }, + ], + package: 'aws', + path: 's3_request', + }, + { + type: 'logs', + dataset: 'aws.s3access', + title: 'AWS s3access logs', + release: 'beta', + ingest_pipeline: 'default', + streams: [ + { + input: 's3', + vars: [ + { + name: 'visibility_timeout', + type: 'text', + title: 'Visibility Timeout', + description: + 'The duration that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. The maximum is 12 hours.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'api_timeout', + type: 'text', + title: 'API Timeout', + description: + 'The maximum duration of AWS API can take. The maximum is half of the visibility timeout value.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'queue_url', + type: 'text', + title: 'Queue URL', + description: 'URL of the AWS SQS queue that messages will be received from.', + multi: false, + required: true, + show_user: true, + }, + { + name: 'fips_enabled', + type: 'bool', + title: 'Enable S3 FIPS', + description: + 'Enabling this option changes the service name from `s3` to `s3-fips` for connecting to the correct service endpoint.', + multi: false, + required: false, + show_user: false, + default: false, + }, + ], + template_path: 's3.yml.hbs', + title: 'AWS s3access logs', + description: 'Collect AWS s3access logs using s3 input', + enabled: true, + }, + ], + package: 'aws', + path: 's3access', + }, + { + type: 'metrics', + dataset: 'aws.sns', + title: 'AWS SNS metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '5m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS SNS metrics', + description: 'Collect AWS SNS metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'sns', + }, + { + type: 'metrics', + dataset: 'aws.sqs', + title: 'AWS SQS metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '5m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS SQS metrics', + description: 'Collect AWS SQS metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'sqs', + }, + { + type: 'metrics', + dataset: 'aws.transitgateway', + title: 'AWS Transit Gateway metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS Transit Gateway metrics', + description: 'Collect AWS Transit Gateway metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'transitgateway', + }, + { + type: 'metrics', + dataset: 'aws.usage', + title: 'AWS usage metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS usage metrics', + description: 'Collect AWS usage metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'usage', + }, + { + type: 'logs', + dataset: 'aws.vpcflow', + title: 'AWS vpcflow logs', + release: 'beta', + ingest_pipeline: 'default', + streams: [ + { + input: 's3', + vars: [ + { + name: 'visibility_timeout', + type: 'text', + title: 'Visibility Timeout', + description: + 'The duration that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. The maximum is 12 hours.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'api_timeout', + type: 'text', + title: 'API Timeout', + description: + 'The maximum duration of AWS API can take. The maximum is half of the visibility timeout value.', + multi: false, + required: false, + show_user: false, + }, + { + name: 'queue_url', + type: 'text', + title: 'Queue URL', + description: 'URL of the AWS SQS queue that messages will be received from.', + multi: false, + required: true, + show_user: true, + }, + { + name: 'fips_enabled', + type: 'bool', + title: 'Enable S3 FIPS', + description: + 'Enabling this option changes the service name from `s3` to `s3-fips` for connecting to the correct service endpoint.', + multi: false, + required: false, + show_user: false, + default: false, + }, + ], + template_path: 's3.yml.hbs', + title: 'AWS vpcflow logs', + description: 'Collect AWS vpcflow logs using s3 input', + enabled: true, + }, + ], + package: 'aws', + path: 'vpcflow', + }, + { + type: 'metrics', + dataset: 'aws.vpn', + title: 'AWS VPN metrics', + release: 'beta', + streams: [ + { + input: 'aws/metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '1m', + }, + { + name: 'regions', + type: 'text', + title: 'Regions', + multi: true, + required: false, + show_user: true, + }, + { + name: 'latency', + type: 'text', + title: 'Latency', + multi: false, + required: false, + show_user: false, + }, + { + name: 'tags_filter', + type: 'yaml', + title: 'Tags Filter', + multi: false, + required: false, + show_user: false, + default: '# - key: "created-by"\n # value: "foo"\n', + }, + ], + template_path: 'stream.yml.hbs', + title: 'AWS VPN metrics', + description: 'Collect AWS VPN metrics', + enabled: true, + }, + ], + package: 'aws', + path: 'vpn', + }, + ], + owner: { + github: 'elastic/integrations', + }, + vars: [ + { + name: 'shared_credential_file', + type: 'text', + title: 'Shared Credential File', + description: 'Directory of the shared credentials file', + multi: false, + required: false, + show_user: false, + }, + { + name: 'credential_profile_name', + type: 'text', + title: 'Credential Profile Name', + multi: false, + required: false, + show_user: true, + }, + { + name: 'access_key_id', + type: 'text', + title: 'Access Key ID', + multi: false, + required: false, + show_user: false, + }, + { + name: 'secret_access_key', + type: 'text', + title: 'Secret Access Key', + multi: false, + required: false, + show_user: false, + }, + { + name: 'session_token', + type: 'text', + title: 'Session Token', + multi: false, + required: false, + show_user: false, + }, + { + name: 'role_arn', + type: 'text', + title: 'Role ARN', + multi: false, + required: false, + show_user: false, + }, + { + name: 'endpoint', + type: 'text', + title: 'Endpoint', + description: 'URL of the entry point for an AWS web service', + multi: false, + required: false, + show_user: false, + default: 'amazonaws.com', + }, + ], + latestVersion: '0.5.3', + removable: true, + status: 'not_installed', +}; + +export const INVALID_AWS_POLICY = { + name: 'aws-1', + namespace: 'default', + package: { name: 'aws', title: 'AWS', version: '0.5.3' }, + enabled: true, + policy_id: 'some-agent-policy-id', + output_id: 'some-output-id', + inputs: [ + { + type: 'aws/metrics', + policy_template: 'billing', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.billing' }, + vars: { + period: { value: '12h', type: 'text' }, + latency: { type: 'text' }, + 'cost_explorer_config.group_by_dimension_keys': { + value: ['AZ', 'INSTANCE_TYPE', 'SERVICE'], + type: 'text', + }, + 'cost_explorer_config.group_by_tag_keys': { value: ['aws:createdBy'], type: 'text' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'cloudtrail', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.cloudtrail' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'httpjson', + policy_template: 'cloudtrail', + enabled: false, + streams: [ + { + enabled: false, + data_stream: { type: 'logs', dataset: 'aws.cloudtrail' }, + vars: { + url: { value: 'https://server.example.com:8089', type: 'text' }, + username: { type: 'text' }, + password: { type: 'password' }, + ssl: { type: 'yaml' }, + interval: { value: '10s', type: 'text' }, + search: { value: 'search sourcetype=aws:cloudtrail', type: 'text' }, + tags: { value: ['forwarded'], type: 'text' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'cloudwatch', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.cloudwatch_logs' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'cloudwatch', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.cloudwatch_metrics' }, + vars: { + period: { value: '300s', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + metrics: { + value: + '- namespace: AWS/EC2\n resource_type: ec2:instance\n name:\n - CPUUtilization\n - DiskWriteOps\n statistic:\n - Average\n - Maximum\n # dimensions:\n # - name: InstanceId\n # value: i-123456\n # tags:\n # - key: created-by\n # value: foo\n', + type: 'yaml', + }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'dynamodb', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.dynamodb' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'ebs', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.ebs' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'ec2', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.ec2_logs' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'ec2', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.ec2_metrics' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'elb', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.elb_logs' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'elb', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.elb_metrics' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'lambda', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.lambda' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'natgateway', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.natgateway' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'rds', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.rds' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 's3', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.s3access' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 's3', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.s3_daily_storage' }, + vars: { + period: { value: '24h', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.s3_request' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'sns', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.sns' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'sqs', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.sqs' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'transitgateway', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.transitgateway' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'usage', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.usage' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'vpcflow', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.vpcflow' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'vpn', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.vpn' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + ], + vars: { + shared_credential_file: { type: 'text' }, + credential_profile_name: { type: 'text' }, + access_key_id: { type: 'text' }, + secret_access_key: { type: 'text' }, + session_token: { type: 'text' }, + role_arn: { type: 'text' }, + endpoint: { value: 'amazonaws.com', type: 'text' }, + }, +}; + +export const VALID_AWS_POLICY = { + name: 'aws-1', + namespace: 'default', + package: { name: 'aws', title: 'AWS', version: '0.5.3' }, + enabled: true, + policy_id: 'some-agent-policy-id', + output_id: 'some-output-id', + inputs: [ + { + type: 'aws/metrics', + policy_template: 'billing', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.billing' }, + vars: { + period: { value: '12h', type: 'text' }, + latency: { type: 'text' }, + 'cost_explorer_config.group_by_dimension_keys': { + value: ['AZ', 'INSTANCE_TYPE', 'SERVICE'], + type: 'text', + }, + 'cost_explorer_config.group_by_tag_keys': { value: ['aws:createdBy'], type: 'text' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'cloudtrail', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.cloudtrail' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text', value: 'http://localhost' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'httpjson', + policy_template: 'cloudtrail', + enabled: false, + streams: [ + { + enabled: false, + data_stream: { type: 'logs', dataset: 'aws.cloudtrail' }, + vars: { + url: { value: 'https://server.example.com:8089', type: 'text' }, + username: { type: 'text' }, + password: { type: 'password' }, + ssl: { type: 'yaml' }, + interval: { value: '10s', type: 'text' }, + search: { value: 'search sourcetype=aws:cloudtrail', type: 'text' }, + tags: { value: ['forwarded'], type: 'text' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'cloudwatch', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.cloudwatch_logs' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text', value: 'http://localhost' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'cloudwatch', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.cloudwatch_metrics' }, + vars: { + period: { value: '300s', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + metrics: { + value: + '- namespace: AWS/EC2\n resource_type: ec2:instance\n name:\n - CPUUtilization\n - DiskWriteOps\n statistic:\n - Average\n - Maximum\n # dimensions:\n # - name: InstanceId\n # value: i-123456\n # tags:\n # - key: created-by\n # value: foo\n', + type: 'yaml', + }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'dynamodb', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.dynamodb' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'ebs', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.ebs' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'ec2', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.ec2_logs' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text', value: 'http://localhost' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'ec2', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.ec2_metrics' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'elb', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.elb_logs' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text', value: 'http://localhost' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'elb', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.elb_metrics' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'lambda', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.lambda' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'natgateway', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.natgateway' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'rds', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.rds' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 's3', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.s3access' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text', value: 'http://localhost' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 's3', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.s3_daily_storage' }, + vars: { + period: { value: '24h', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.s3_request' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'sns', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.sns' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'sqs', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.sqs' }, + vars: { + period: { value: '5m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'transitgateway', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.transitgateway' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'usage', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.usage' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + }, + }, + ], + }, + { + type: 's3', + policy_template: 'vpcflow', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'logs', dataset: 'aws.vpcflow' }, + vars: { + visibility_timeout: { type: 'text' }, + api_timeout: { type: 'text' }, + queue_url: { type: 'text', value: 'http://localhost' }, + fips_enabled: { value: false, type: 'bool' }, + }, + }, + ], + }, + { + type: 'aws/metrics', + policy_template: 'vpn', + enabled: true, + streams: [ + { + enabled: true, + data_stream: { type: 'metrics', dataset: 'aws.vpn' }, + vars: { + period: { value: '1m', type: 'text' }, + regions: { value: [], type: 'text' }, + latency: { type: 'text' }, + tags_filter: { value: '# - key: "created-by"\n # value: "foo"\n', type: 'yaml' }, + }, + }, + ], + }, + ], + vars: { + shared_credential_file: { type: 'text' }, + credential_profile_name: { type: 'text' }, + access_key_id: { type: 'text' }, + secret_access_key: { type: 'text' }, + session_token: { type: 'text' }, + role_arn: { type: 'text' }, + endpoint: { value: 'amazonaws.com', type: 'text' }, + }, +}; diff --git a/x-pack/plugins/fleet/common/services/index.ts b/x-pack/plugins/fleet/common/services/index.ts index 1fea5033e645c0..86361ae1633995 100644 --- a/x-pack/plugins/fleet/common/services/index.ts +++ b/x-pack/plugins/fleet/common/services/index.ts @@ -7,7 +7,11 @@ export * from './routes'; export * as AgentStatusKueryHelper from './agent_status'; -export { packageToPackagePolicyInputs, packageToPackagePolicy } from './package_to_package_policy'; +export { + packageToPackagePolicyInputs, + packageToPackagePolicy, + getStreamsForInputType, +} from './package_to_package_policy'; export { storedPackagePoliciesToAgentInputs } from './package_policies_to_agent_inputs'; export { fullAgentPolicyToYaml } from './full_agent_policy_to_yaml'; export { isPackageLimited, doesAgentPolicyAlreadyIncludePackage } from './limited_package'; @@ -17,3 +21,12 @@ export { isDiffPathProtocol } from './is_diff_path_protocol'; export { LicenseService } from './license'; export { isAgentUpgradeable } from './is_agent_upgradeable'; export { doesPackageHaveIntegrations } from './packages_with_integrations'; +export { + PackagePolicyValidationResults, + PackagePolicyConfigValidationResults, + PackagePolicyInputValidationResults, + validatePackagePolicy, + validatePackagePolicyConfig, + validationHasErrors, + countValidationErrors, +} from './validate_package_policy'; diff --git a/x-pack/plugins/fleet/common/services/limited_package.ts b/x-pack/plugins/fleet/common/services/limited_package.ts index e247b61869de12..601f680c8bf039 100644 --- a/x-pack/plugins/fleet/common/services/limited_package.ts +++ b/x-pack/plugins/fleet/common/services/limited_package.ts @@ -7,9 +7,10 @@ import type { PackageInfo, AgentPolicy, PackagePolicy } from '../types'; -// Assume packages only ever include 1 config template for now export const isPackageLimited = (packageInfo: PackageInfo): boolean => { - return packageInfo.policy_templates?.[0]?.multiple === false; + return (packageInfo.policy_templates || []).some( + (policyTemplate) => policyTemplate.multiple === false + ); }; export const doesAgentPolicyAlreadyIncludePackage = ( diff --git a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts index 31c47bf9dc69de..a5acd823c20fd3 100644 --- a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts +++ b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.test.ts @@ -218,4 +218,81 @@ describe('Fleet - storedPackagePoliciesToAgentInputs', () => { }, ]); }); + + it('returns agent inputs with deeply merged config values', () => { + expect( + storedPackagePoliciesToAgentInputs([ + { + ...mockPackagePolicy, + inputs: [ + { + ...mockInput, + compiled_input: { + agent_input_template_group1_vars: { + inputVar: 'input-value', + }, + agent_input_template_group2_vars: { + inputVar3: { + testFieldGroup: { + subField1: 'subfield1', + }, + testField: 'test', + }, + }, + }, + config: { + agent_input_template_group1_vars: { + value: { + inputVar2: {}, + }, + }, + agent_input_template_group2_vars: { + value: { + inputVar3: { + testFieldGroup: { + subField2: 'subfield2', + }, + }, + inputVar4: '', + }, + }, + }, + }, + ], + }, + ]) + ).toEqual([ + { + id: 'some-uuid', + revision: 1, + name: 'mock-package-policy', + type: 'test-logs', + data_stream: { namespace: 'default' }, + use_output: 'default', + agent_input_template_group1_vars: { + inputVar: 'input-value', + inputVar2: {}, + }, + agent_input_template_group2_vars: { + inputVar3: { + testField: 'test', + testFieldGroup: { + subField1: 'subfield1', + subField2: 'subfield2', + }, + }, + inputVar4: '', + }, + streams: [ + { + id: 'test-logs-foo', + data_stream: { dataset: 'foo', type: 'logs' }, + fooKey: 'fooValue1', + fooKey2: ['fooValue2'], + }, + { id: 'test-logs-bar', data_stream: { dataset: 'bar', type: 'logs' } }, + ], + }, + ]); + }); }); diff --git a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts index 61d7764a832b16..f262521461b983 100644 --- a/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts +++ b/x-pack/plugins/fleet/common/services/package_policies_to_agent_inputs.ts @@ -5,6 +5,8 @@ * 2.0. */ +import { merge } from 'lodash'; + import type { PackagePolicy, FullAgentPolicyInput, FullAgentPolicyInputStream } from '../types'; import { DEFAULT_OUTPUT } from '../constants'; @@ -31,10 +33,6 @@ export const storedPackagePoliciesToAgentInputs = ( namespace: packagePolicy.namespace || 'default', }, use_output: DEFAULT_OUTPUT.name, - ...Object.entries(input.config || {}).reduce((acc, [key, { value }]) => { - acc[key] = value; - return acc; - }, {} as { [k: string]: any }), ...(input.compiled_input || {}), ...(input.streams.length ? { @@ -56,6 +54,15 @@ export const storedPackagePoliciesToAgentInputs = ( : {}), }; + // deeply merge the input.config values with the full policy input + merge( + fullInput, + Object.entries(input.config || {}).reduce( + (acc, [key, { value }]) => ({ ...acc, [key]: value }), + {} + ) + ); + if (packagePolicy.package) { fullInput.meta = { package: { diff --git a/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts b/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts index 65b853ed5b38ff..0e5cab08edfb79 100644 --- a/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts +++ b/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts @@ -8,6 +8,7 @@ import type { PackageInfo } from '../types'; import { packageToPackagePolicy, packageToPackagePolicyInputs } from './package_to_package_policy'; +import { AWS_PACKAGE } from './fixtures/aws_package'; describe('Fleet - packageToPackagePolicy', () => { const mockPackage: PackageInfo = { @@ -59,7 +60,7 @@ describe('Fleet - packageToPackagePolicy', () => { expect( packageToPackagePolicyInputs(({ ...mockPackage, - policy_templates: [{ inputs: [] }], + policy_templates: [{ name: 'test_template', inputs: [] }], } as unknown) as PackageInfo) ).toEqual([]); }); @@ -68,17 +69,17 @@ describe('Fleet - packageToPackagePolicy', () => { expect( packageToPackagePolicyInputs(({ ...mockPackage, - policy_templates: [{ inputs: [{ type: 'foo' }] }], + policy_templates: [{ name: 'test_template', inputs: [{ type: 'foo' }] }], } as unknown) as PackageInfo) - ).toEqual([{ type: 'foo', enabled: true, streams: [] }]); + ).toEqual([{ type: 'foo', enabled: true, policy_template: 'test_template', streams: [] }]); expect( packageToPackagePolicyInputs(({ ...mockPackage, - policy_templates: [{ inputs: [{ type: 'foo' }, { type: 'bar' }] }], + policy_templates: [{ name: 'test_template', inputs: [{ type: 'foo' }, { type: 'bar' }] }], } as unknown) as PackageInfo) ).toEqual([ - { type: 'foo', enabled: true, streams: [] }, - { type: 'bar', enabled: true, streams: [] }, + { type: 'foo', enabled: true, policy_template: 'test_template', streams: [] }, + { type: 'bar', enabled: true, policy_template: 'test_template', streams: [] }, ]); }); @@ -91,24 +92,34 @@ describe('Fleet - packageToPackagePolicy', () => { { type: 'logs', dataset: 'bar', streams: [{ input: 'bar' }] }, { type: 'logs', dataset: 'bar2', streams: [{ input: 'bar' }] }, ], - policy_templates: [ - { - inputs: [{ type: 'foo' }, { type: 'bar' }], - }, - ], + policy_templates: [{ name: 'test_template', inputs: [{ type: 'foo' }, { type: 'bar' }] }], } as unknown) as PackageInfo) ).toEqual([ { type: 'foo', + policy_template: 'test_template', enabled: true, - streams: [{ enabled: true, data_stream: { dataset: 'foo', type: 'logs' } }], + streams: [ + { + enabled: true, + data_stream: { dataset: 'foo', type: 'logs' }, + }, + ], }, { type: 'bar', + policy_template: 'test_template', + enabled: true, streams: [ - { enabled: true, data_stream: { dataset: 'bar', type: 'logs' } }, - { enabled: true, data_stream: { dataset: 'bar2', type: 'logs' } }, + { + enabled: true, + data_stream: { dataset: 'bar', type: 'logs' }, + }, + { + enabled: true, + data_stream: { dataset: 'bar2', type: 'logs' }, + }, ], }, ]); @@ -145,15 +156,12 @@ describe('Fleet - packageToPackagePolicy', () => { ], }, ], - policy_templates: [ - { - inputs: [{ type: 'foo' }, { type: 'bar' }], - }, - ], + policy_templates: [{ name: 'test_template', inputs: [{ type: 'foo' }, { type: 'bar' }] }], } as unknown) as PackageInfo) ).toEqual([ { type: 'foo', + policy_template: 'test_template', enabled: true, streams: [ { @@ -165,6 +173,7 @@ describe('Fleet - packageToPackagePolicy', () => { }, { type: 'bar', + policy_template: 'test_template', enabled: true, streams: [ { @@ -236,6 +245,7 @@ describe('Fleet - packageToPackagePolicy', () => { ], policy_templates: [ { + name: 'test_template', inputs: [ { type: 'foo', @@ -262,6 +272,8 @@ describe('Fleet - packageToPackagePolicy', () => { ).toEqual([ { type: 'foo', + policy_template: 'test_template', + enabled: true, vars: { 'foo-input-var-name': { value: 'foo-input-var-value' }, @@ -280,6 +292,8 @@ describe('Fleet - packageToPackagePolicy', () => { }, { type: 'bar', + policy_template: 'test_template', + enabled: true, vars: { 'bar-input-var-name': { value: ['value1', 'value2'] }, @@ -304,6 +318,8 @@ describe('Fleet - packageToPackagePolicy', () => { }, { type: 'with-disabled-streams', + policy_template: 'test_template', + enabled: false, streams: [ { @@ -339,6 +355,7 @@ describe('Fleet - packageToPackagePolicy', () => { }, }); }); + it('returns package policy with custom name', () => { expect(packageToPackagePolicy(mockPackage, '1', '2', 'default', 'pkgPolicy-1')).toEqual({ policy_id: '1', @@ -354,6 +371,7 @@ describe('Fleet - packageToPackagePolicy', () => { }, }); }); + it('returns package policy with namespace and description', () => { expect( packageToPackagePolicy( @@ -379,6 +397,7 @@ describe('Fleet - packageToPackagePolicy', () => { }, }); }); + it('returns package policy with inputs', () => { const mockPackageWithPolicyTemplates = ({ ...mockPackage, @@ -401,5 +420,17 @@ describe('Fleet - packageToPackagePolicy', () => { }, }); }); + + it('returns package policy with multiple policy templates (aka has integrations', () => { + expect( + packageToPackagePolicy( + (AWS_PACKAGE as unknown) as PackageInfo, + 'some-agent-policy-id', + 'some-output-id', + 'default', + 'aws-1' + ) + ).toMatchSnapshot(); + }); }); }); diff --git a/x-pack/plugins/fleet/common/services/package_to_package_policy.ts b/x-pack/plugins/fleet/common/services/package_to_package_policy.ts index 8f79e633eed0c2..0d40adb4bf7dc3 100644 --- a/x-pack/plugins/fleet/common/services/package_to_package_policy.ts +++ b/x-pack/plugins/fleet/common/services/package_to_package_policy.ts @@ -7,8 +7,8 @@ import type { PackageInfo, - RegistryPolicyTemplate, RegistryVarsEntry, + RegistryInput, RegistryStream, PackagePolicyConfigRecord, NewPackagePolicyInput, @@ -17,13 +17,20 @@ import type { PackagePolicyConfigRecordEntry, } from '../types'; -const getStreamsForInputType = ( +import { doesPackageHaveIntegrations } from './'; + +export const getStreamsForInputType = ( inputType: string, - packageInfo: PackageInfo + packageInfo: PackageInfo, + dataStreamPaths: string[] = [] ): Array => { const streams: Array = []; + const dataStreams = packageInfo.data_streams || []; + const dataStreamsToSearch = dataStreamPaths.length + ? dataStreams.filter((dataStream) => dataStreamPaths.includes(dataStream.path)) + : dataStreams; - (packageInfo.data_streams || []).forEach((dataStream) => { + dataStreamsToSearch.forEach((dataStream) => { (dataStream.streams || []).forEach((stream) => { if (stream.input === inputType) { streams.push({ @@ -59,48 +66,87 @@ const varsReducer = ( * This service creates a package policy inputs definition from defaults provided in package info */ export const packageToPackagePolicyInputs = ( - packageInfo: PackageInfo -): NewPackagePolicy['inputs'] => { - const inputs: NewPackagePolicy['inputs'] = []; - - // Assume package will only ever ship one package policy template for now - const packagePolicyTemplate: RegistryPolicyTemplate | null = - packageInfo.policy_templates && packageInfo.policy_templates[0] - ? packageInfo.policy_templates[0] - : null; - - // Create package policy input property - if (packagePolicyTemplate?.inputs?.length) { - // Map each package package policy input to agent policy package policy input - packagePolicyTemplate.inputs.forEach((packageInput) => { - // Map each package input stream into package policy input stream - const streams: NewPackagePolicyInputStream[] = getStreamsForInputType( - packageInput.type, - packageInfo - ).map((packageStream) => { - const stream: NewPackagePolicyInputStream = { - enabled: packageStream.enabled === false ? false : true, - data_stream: packageStream.data_stream, - }; - if (packageStream.vars && packageStream.vars.length) { - stream.vars = packageStream.vars.reduce(varsReducer, {}); - } - return stream; - }); - - const input: NewPackagePolicyInput = { - type: packageInput.type, - enabled: streams.length ? !!streams.find((stream) => stream.enabled) : true, - streams, + packageInfo: PackageInfo, + integrationToEnable?: string +): NewPackagePolicyInput[] => { + const hasIntegrations = doesPackageHaveIntegrations(packageInfo); + const inputs: NewPackagePolicyInput[] = []; + const packageInputsByPolicyTemplateAndType: { + [key: string]: RegistryInput & { data_streams?: string[]; policy_template: string }; + } = {}; + + packageInfo.policy_templates?.forEach((packagePolicyTemplate) => { + packagePolicyTemplate.inputs?.forEach((packageInput) => { + const inputKey = `${packagePolicyTemplate.name}-${packageInput.type}`; + const input = { + ...packageInput, + ...(packagePolicyTemplate.data_streams + ? { data_streams: packagePolicyTemplate.data_streams } + : {}), + policy_template: packagePolicyTemplate.name, }; + packageInputsByPolicyTemplateAndType[inputKey] = input; + }); + }); - if (packageInput.vars && packageInput.vars.length) { - input.vars = packageInput.vars.reduce(varsReducer, {}); - } + Object.values(packageInputsByPolicyTemplateAndType).forEach((packageInput) => { + const streamsForInput: NewPackagePolicyInputStream[] = []; + let varsForInput: PackagePolicyConfigRecord = {}; - inputs.push(input); + // Map each package input stream into package policy input stream + const streams = getStreamsForInputType( + packageInput.type, + packageInfo, + packageInput.data_streams + ).map((packageStream) => { + const stream: NewPackagePolicyInputStream = { + enabled: packageStream.enabled === false ? false : true, + data_stream: packageStream.data_stream, + }; + if (packageStream.vars && packageStream.vars.length) { + stream.vars = packageStream.vars.reduce(varsReducer, {}); + } + return stream; }); - } + + // If non-integration package, collect input-level vars, otherwise skip them, + // we do not support input-level vars for packages with integrations yet) + if (packageInput.vars?.length && !hasIntegrations) { + varsForInput = packageInput.vars.reduce(varsReducer, {}); + } + + streamsForInput.push(...streams); + + // Check if we should enable this input by the streams below it + // Enable it if at least one of its streams is enabled + let enableInput = streamsForInput.length + ? !!streamsForInput.find((stream) => stream.enabled) + : true; + + // If we are wanting to enabling this input, check if we only want + // to enable specific integrations (aka `policy_template`s) + if ( + enableInput && + hasIntegrations && + integrationToEnable && + integrationToEnable !== packageInput.policy_template + ) { + enableInput = false; + } + + const input: NewPackagePolicyInput = { + type: packageInput.type, + policy_template: packageInput.policy_template, + enabled: enableInput, + streams: streamsForInput, + }; + + if (Object.keys(varsForInput).length) { + input.vars = varsForInput; + } + + inputs.push(input); + }); return inputs; }; @@ -119,7 +165,8 @@ export const packageToPackagePolicy = ( outputId: string, namespace: string = '', packagePolicyName?: string, - description?: string + description?: string, + integrationToEnable?: string ): NewPackagePolicy => { const packagePolicy: NewPackagePolicy = { name: packagePolicyName || `${packageInfo.name}-1`, @@ -133,7 +180,8 @@ export const packageToPackagePolicy = ( enabled: true, policy_id: agentPolicyId, output_id: outputId, - inputs: packageToPackagePolicyInputs(packageInfo), + inputs: packageToPackagePolicyInputs(packageInfo, integrationToEnable), + vars: undefined, }; if (packageInfo.vars?.length) { diff --git a/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts b/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts new file mode 100644 index 00000000000000..95dbf156040a17 --- /dev/null +++ b/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts @@ -0,0 +1,635 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { installationStatuses } from '../constants'; +import type { PackageInfo, NewPackagePolicy, RegistryPolicyTemplate } from '../types'; + +import { validatePackagePolicy, validationHasErrors } from './validate_package_policy'; +import { AWS_PACKAGE, INVALID_AWS_POLICY, VALID_AWS_POLICY } from './fixtures/aws_package'; + +describe('Fleet - validatePackagePolicy()', () => { + describe('works for packages with single policy template (aka no integrations)', () => { + const mockPackage = ({ + name: 'mock-package', + title: 'Mock package', + version: '0.0.0', + description: 'description', + type: 'mock', + categories: [], + requirement: { kibana: { versions: '' }, elasticsearch: { versions: '' } }, + format_version: '', + download: '', + path: '', + assets: { + kibana: { + dashboard: [], + visualization: [], + search: [], + 'index-pattern': [], + }, + }, + status: installationStatuses.NotInstalled, + data_streams: [ + { + dataset: 'foo', + streams: [ + { + input: 'foo', + title: 'Foo', + vars: [{ name: 'var-name', type: 'yaml' }], + }, + ], + }, + { + dataset: 'bar', + streams: [ + { + input: 'bar', + title: 'Bar', + vars: [{ name: 'var-name', type: 'yaml', required: true }], + }, + { + input: 'with-no-stream-vars', + title: 'Bar stream no vars', + enabled: true, + }, + ], + }, + { + dataset: 'bar2', + streams: [ + { + input: 'bar', + title: 'Bar 2', + vars: [{ default: 'bar2-var-value', name: 'var-name', type: 'text' }], + }, + ], + }, + { + dataset: 'disabled', + streams: [ + { + input: 'with-disabled-streams', + title: 'Disabled', + enabled: false, + vars: [{ multi: true, required: true, name: 'var-name', type: 'text' }], + }, + ], + }, + { + dataset: 'disabled2', + streams: [ + { + input: 'with-disabled-streams', + title: 'Disabled 2', + enabled: false, + }, + ], + }, + ], + policy_templates: [ + { + name: 'pkgPolicy1', + title: 'Package policy 1', + description: 'test package policy', + inputs: [ + { + type: 'foo', + title: 'Foo', + vars: [ + { default: 'foo-input-var-value', name: 'foo-input-var-name', type: 'text' }, + { + default: 'foo-input2-var-value', + name: 'foo-input2-var-name', + required: true, + type: 'text', + }, + { name: 'foo-input3-var-name', type: 'text', required: true, multi: true }, + ], + }, + { + type: 'bar', + title: 'Bar', + vars: [ + { + default: ['value1', 'value2'], + name: 'bar-input-var-name', + type: 'text', + multi: true, + }, + { name: 'bar-input2-var-name', required: true, type: 'text' }, + ], + }, + { + type: 'with-no-config-or-streams', + title: 'With no config or streams', + }, + { + type: 'with-disabled-streams', + title: 'With disabled streams', + }, + { + type: 'with-no-stream-vars', + enabled: true, + vars: [{ required: true, name: 'var-name', type: 'text' }], + }, + ], + }, + ], + } as unknown) as PackageInfo; + + const validPackagePolicy: NewPackagePolicy = { + name: 'pkgPolicy1-1', + namespace: 'default', + policy_id: 'test-policy', + enabled: true, + output_id: 'test-output', + inputs: [ + { + type: 'foo', + policy_template: 'pkgPolicy1', + enabled: true, + vars: { + 'foo-input-var-name': { value: 'foo-input-var-value', type: 'text' }, + 'foo-input2-var-name': { value: 'foo-input2-var-value', type: 'text' }, + 'foo-input3-var-name': { value: ['test'], type: 'text' }, + }, + streams: [ + { + data_stream: { dataset: 'foo', type: 'logs' }, + enabled: true, + vars: { 'var-name': { value: 'test_yaml: value', type: 'yaml' } }, + }, + ], + }, + { + type: 'bar', + policy_template: 'pkgPolicy1', + enabled: true, + vars: { + 'bar-input-var-name': { value: ['value1', 'value2'], type: 'text' }, + 'bar-input2-var-name': { value: 'test', type: 'text' }, + }, + streams: [ + { + data_stream: { dataset: 'bar', type: 'logs' }, + enabled: true, + vars: { 'var-name': { value: 'test_yaml: value', type: 'yaml' } }, + }, + { + data_stream: { dataset: 'bar2', type: 'logs' }, + enabled: true, + vars: { 'var-name': { value: undefined, type: 'text' } }, + }, + ], + }, + { + type: 'with-no-config-or-streams', + policy_template: 'pkgPolicy1', + enabled: true, + streams: [], + }, + { + type: 'with-disabled-streams', + policy_template: 'pkgPolicy1', + enabled: true, + streams: [ + { + data_stream: { dataset: 'disabled', type: 'logs' }, + enabled: false, + vars: { 'var-name': { value: undefined, type: 'text' } }, + }, + { + data_stream: { dataset: 'disabled2', type: 'logs' }, + enabled: false, + }, + ], + }, + { + type: 'with-no-stream-vars', + policy_template: 'pkgPolicy1', + enabled: true, + vars: { + 'var-name': { value: 'test', type: 'text' }, + }, + streams: [ + { + data_stream: { dataset: 'with-no-stream-vars-bar', type: 'logs' }, + enabled: true, + }, + ], + }, + ], + }; + + const invalidPackagePolicy: NewPackagePolicy = { + ...validPackagePolicy, + name: '', + inputs: [ + { + type: 'foo', + policy_template: 'pkgPolicy1', + enabled: true, + vars: { + 'foo-input-var-name': { value: undefined, type: 'text' }, + 'foo-input2-var-name': { value: '', type: 'text' }, + 'foo-input3-var-name': { value: [], type: 'text' }, + }, + streams: [ + { + data_stream: { dataset: 'foo', type: 'logs' }, + enabled: true, + vars: { 'var-name': { value: 'invalidyaml: test\n foo bar:', type: 'yaml' } }, + }, + ], + }, + { + type: 'bar', + policy_template: 'pkgPolicy1', + enabled: true, + vars: { + 'bar-input-var-name': { value: 'invalid value for multi', type: 'text' }, + 'bar-input2-var-name': { value: undefined, type: 'text' }, + }, + streams: [ + { + data_stream: { dataset: 'bar', type: 'logs' }, + enabled: true, + vars: { 'var-name': { value: ' \n\n', type: 'yaml' } }, + }, + { + data_stream: { dataset: 'bar2', type: 'logs' }, + enabled: true, + vars: { 'var-name': { value: undefined, type: 'text' } }, + }, + ], + }, + { + type: 'with-no-config-or-streams', + policy_template: 'pkgPolicy1', + enabled: true, + streams: [], + }, + { + type: 'with-disabled-streams', + policy_template: 'pkgPolicy1', + enabled: true, + streams: [ + { + data_stream: { dataset: 'disabled', type: 'logs' }, + enabled: false, + vars: { + 'var-name': { + value: 'invalid value but not checked due to not enabled', + type: 'text', + }, + }, + }, + { + data_stream: { dataset: 'disabled2', type: 'logs' }, + enabled: false, + }, + ], + }, + { + type: 'with-no-stream-vars', + policy_template: 'pkgPolicy1', + enabled: true, + vars: { + 'var-name': { value: undefined, type: 'text' }, + }, + streams: [ + { + data_stream: { dataset: 'with-no-stream-vars-bar', type: 'logs' }, + enabled: true, + }, + ], + }, + ], + }; + + const noErrorsValidationResults = { + name: null, + description: null, + namespace: null, + inputs: { + foo: { + vars: { + 'foo-input-var-name': null, + 'foo-input2-var-name': null, + 'foo-input3-var-name': null, + }, + streams: { foo: { vars: { 'var-name': null } } }, + }, + bar: { + vars: { 'bar-input-var-name': null, 'bar-input2-var-name': null }, + streams: { + bar: { vars: { 'var-name': null } }, + bar2: { vars: { 'var-name': null } }, + }, + }, + 'with-disabled-streams': { + streams: { + disabled: { + vars: { 'var-name': null }, + }, + disabled2: {}, + }, + }, + 'with-no-stream-vars': { + streams: { + 'with-no-stream-vars-bar': {}, + }, + vars: { 'var-name': null }, + }, + }, + }; + + it('returns no errors for valid package policy', () => { + expect(validatePackagePolicy(validPackagePolicy, mockPackage)).toEqual( + noErrorsValidationResults + ); + }); + + it('returns errors for invalid package policy', () => { + expect(validatePackagePolicy(invalidPackagePolicy, mockPackage)).toEqual({ + name: ['Name is required'], + description: null, + namespace: null, + inputs: { + foo: { + vars: { + 'foo-input-var-name': null, + 'foo-input2-var-name': ['foo-input2-var-name is required'], + 'foo-input3-var-name': ['foo-input3-var-name is required'], + }, + streams: { foo: { vars: { 'var-name': ['Invalid YAML format'] } } }, + }, + bar: { + vars: { + 'bar-input-var-name': ['Invalid format'], + 'bar-input2-var-name': ['bar-input2-var-name is required'], + }, + streams: { + bar: { vars: { 'var-name': ['var-name is required'] } }, + bar2: { vars: { 'var-name': null } }, + }, + }, + 'with-disabled-streams': { + streams: { + disabled: { vars: { 'var-name': null } }, + disabled2: {}, + }, + }, + 'with-no-stream-vars': { + vars: { + 'var-name': ['var-name is required'], + }, + streams: { 'with-no-stream-vars-bar': {} }, + }, + }, + }); + }); + + it('returns no errors for disabled inputs', () => { + const disabledInputs = invalidPackagePolicy.inputs.map((input) => ({ + ...input, + enabled: false, + })); + expect( + validatePackagePolicy({ ...validPackagePolicy, inputs: disabledInputs }, mockPackage) + ).toEqual(noErrorsValidationResults); + }); + + it('returns only package policy and input-level errors for disabled streams', () => { + const inputsWithDisabledStreams = invalidPackagePolicy.inputs.map((input) => + input.streams + ? { + ...input, + streams: input.streams.map((stream) => ({ ...stream, enabled: false })), + } + : input + ); + expect( + validatePackagePolicy( + { ...invalidPackagePolicy, inputs: inputsWithDisabledStreams }, + mockPackage + ) + ).toEqual({ + name: ['Name is required'], + description: null, + namespace: null, + inputs: { + foo: { + vars: { + 'foo-input-var-name': null, + 'foo-input2-var-name': ['foo-input2-var-name is required'], + 'foo-input3-var-name': ['foo-input3-var-name is required'], + }, + streams: { foo: { vars: { 'var-name': null } } }, + }, + bar: { + vars: { + 'bar-input-var-name': ['Invalid format'], + 'bar-input2-var-name': ['bar-input2-var-name is required'], + }, + streams: { + bar: { vars: { 'var-name': null } }, + bar2: { vars: { 'var-name': null } }, + }, + }, + 'with-disabled-streams': { + streams: { + disabled: { + vars: { 'var-name': null }, + }, + disabled2: {}, + }, + }, + 'with-no-stream-vars': { + vars: { + 'var-name': ['var-name is required'], + }, + streams: { 'with-no-stream-vars-bar': {} }, + }, + }, + }); + }); + + it('returns no errors for packages with no package policies', () => { + expect( + validatePackagePolicy(validPackagePolicy, { + ...mockPackage, + policy_templates: undefined, + }) + ).toEqual({ + name: null, + description: null, + namespace: null, + inputs: null, + }); + expect( + validatePackagePolicy(validPackagePolicy, { + ...mockPackage, + policy_templates: [], + }) + ).toEqual({ + name: null, + description: null, + namespace: null, + inputs: null, + }); + }); + + it('returns no errors for packages with no inputs', () => { + expect( + validatePackagePolicy(validPackagePolicy, { + ...mockPackage, + policy_templates: [{} as RegistryPolicyTemplate], + }) + ).toEqual({ + name: null, + description: null, + namespace: null, + inputs: null, + }); + expect( + validatePackagePolicy(validPackagePolicy, { + ...mockPackage, + policy_templates: [({ inputs: [] } as unknown) as RegistryPolicyTemplate], + }) + ).toEqual({ + name: null, + description: null, + namespace: null, + inputs: null, + }); + }); + }); + + describe('works for packages with multiple policy templates (aka integrations)', () => { + it('returns errors for invalid package policy', () => { + expect( + validatePackagePolicy( + INVALID_AWS_POLICY as NewPackagePolicy, + (AWS_PACKAGE as unknown) as PackageInfo + ) + ).toMatchSnapshot(); + }); + + it('returns no errors for valid package policy', () => { + expect( + validationHasErrors( + validatePackagePolicy( + VALID_AWS_POLICY as NewPackagePolicy, + (AWS_PACKAGE as unknown) as PackageInfo + ) + ) + ).toBe(false); + }); + }); +}); + +describe('Fleet - validationHasErrors()', () => { + it('returns true for stream validation results with errors', () => { + expect( + validationHasErrors({ + vars: { foo: ['foo error'], bar: null }, + }) + ).toBe(true); + }); + + it('returns false for stream validation results with no errors', () => { + expect( + validationHasErrors({ + vars: { foo: null, bar: null }, + }) + ).toBe(false); + }); + + it('returns true for input validation results with errors', () => { + expect( + validationHasErrors({ + vars: { foo: ['foo error'], bar: null }, + streams: { stream1: { vars: { foo: null, bar: null } } }, + }) + ).toBe(true); + expect( + validationHasErrors({ + vars: { foo: null, bar: null }, + streams: { stream1: { vars: { foo: ['foo error'], bar: null } } }, + }) + ).toBe(true); + }); + + it('returns false for input validation results with no errors', () => { + expect( + validationHasErrors({ + vars: { foo: null, bar: null }, + streams: { stream1: { vars: { foo: null, bar: null } } }, + }) + ).toBe(false); + }); + + it('returns true for package policy validation results with errors', () => { + expect( + validationHasErrors({ + name: ['name error'], + description: null, + namespace: null, + inputs: { + input1: { + vars: { foo: null, bar: null }, + streams: { stream1: { vars: { foo: null, bar: null } } }, + }, + }, + }) + ).toBe(true); + expect( + validationHasErrors({ + name: null, + description: null, + namespace: null, + inputs: { + input1: { + vars: { foo: ['foo error'], bar: null }, + streams: { stream1: { vars: { foo: null, bar: null } } }, + }, + }, + }) + ).toBe(true); + expect( + validationHasErrors({ + name: null, + description: null, + namespace: null, + inputs: { + input1: { + vars: { foo: null, bar: null }, + streams: { stream1: { vars: { foo: ['foo error'], bar: null } } }, + }, + }, + }) + ).toBe(true); + }); + + it('returns false for package policy validation results with no errors', () => { + expect( + validationHasErrors({ + name: null, + description: null, + namespace: null, + inputs: { + input1: { + vars: { foo: null, bar: null }, + streams: { stream1: { vars: { foo: null, bar: null } } }, + }, + }, + }) + ).toBe(false); + }); +}); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts b/x-pack/plugins/fleet/common/services/validate_package_policy.ts similarity index 76% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts rename to x-pack/plugins/fleet/common/services/validate_package_policy.ts index de1b8df9f95974..b8673aa8b2301d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts +++ b/x-pack/plugins/fleet/common/services/validate_package_policy.ts @@ -5,21 +5,22 @@ * 2.0. */ +import { getFlattenedObject } from '@kbn/std'; import { i18n } from '@kbn/i18n'; import { safeLoad } from 'js-yaml'; import { keyBy } from 'lodash'; -import { getFlattenedObject, isValidNamespace } from '../../../../services'; import type { NewPackagePolicy, PackagePolicyInput, PackagePolicyInputStream, PackagePolicyConfigRecordEntry, PackageInfo, - RegistryInput, RegistryStream, RegistryVarsEntry, -} from '../../../../types'; +} from '../types'; + +import { isValidNamespace, doesPackageHaveIntegrations } from './'; type Errors = string[] | null; @@ -48,6 +49,7 @@ export const validatePackagePolicy = ( packagePolicy: NewPackagePolicy, packageInfo: PackageInfo ): PackagePolicyValidationResults => { + const hasIntegrations = doesPackageHaveIntegrations(packageInfo); const validationResults: PackagePolicyValidationResults = { name: null, description: null, @@ -81,54 +83,61 @@ export const validatePackagePolicy = ( if ( !packageInfo.policy_templates || packageInfo.policy_templates.length === 0 || - !packageInfo.policy_templates[0] || - !packageInfo.policy_templates[0].inputs || - packageInfo.policy_templates[0].inputs.length === 0 + !packageInfo.policy_templates.find( + (policyTemplate) => policyTemplate.inputs && policyTemplate.inputs.length > 0 + ) ) { validationResults.inputs = null; return validationResults; } - const registryInputsByType: Record< - string, - RegistryInput - > = packageInfo.policy_templates[0].inputs.reduce((inputs, registryInput) => { - inputs[registryInput.type] = registryInput; - return inputs; - }, {} as Record); - - const registryStreamsByDataset: Record = ( - packageInfo.data_streams || [] - ).reduce((dataStreams, registryDataStream) => { - dataStreams[registryDataStream.dataset] = registryDataStream.streams || []; - return dataStreams; - }, {} as Record); - - // Validate each package policy input with either its own config fields or streams + // Build cache for fast var definition lookup + const inputVarDefsByPolicyTemplateAndType = packageInfo.policy_templates.reduce< + Record> + >((varDefs, policyTemplate) => { + (policyTemplate.inputs || []).forEach((input) => { + const varDefKey = hasIntegrations ? `${policyTemplate.name}-${input.type}` : input.type; + if ((input.vars || []).length) { + varDefs[varDefKey] = keyBy(input.vars || [], 'name'); + } + }); + return varDefs; + }, {}); + const streamsByDatasetAndInput = (packageInfo.data_streams || []).reduce< + Record + >((streams, dataStream) => { + dataStream.streams?.forEach((stream) => { + streams[`${dataStream.dataset}-${stream.input}`] = stream; + }); + return streams; + }, {}); + const streamVarDefsByDatasetAndInput = Object.entries(streamsByDatasetAndInput).reduce< + Record> + >((varDefs, [path, stream]) => { + varDefs[path] = keyBy(stream.vars || [], 'name'); + return varDefs; + }, {}); + + // Validate each package policy input with either its own var fields and stream vars packagePolicy.inputs.forEach((input) => { if (!input.vars && !input.streams) { return; } - + const inputKey = hasIntegrations ? `${input.policy_template}-${input.type}` : input.type; const inputValidationResults: PackagePolicyInputValidationResults = { vars: undefined, streams: {}, }; - const inputVarsByName = (registryInputsByType[input.type].vars || []).reduce( - (vars, registryVar) => { - vars[registryVar.name] = registryVar; - return vars; - }, - {} as Record - ); - - // Validate input-level config fields - const inputConfigs = Object.entries(input.vars || {}); - if (inputConfigs.length) { - inputValidationResults.vars = inputConfigs.reduce((results, [name, configEntry]) => { + // Validate input-level var fields + const inputVars = Object.entries(input.vars || {}); + if (inputVars.length) { + inputValidationResults.vars = inputVars.reduce((results, [name, configEntry]) => { results[name] = input.enabled - ? validatePackagePolicyConfig(configEntry, inputVarsByName[name]) + ? validatePackagePolicyConfig( + configEntry, + inputVarDefsByPolicyTemplateAndType[inputKey][name] + ) : null; return results; }, {} as ValidationEntry); @@ -136,28 +145,20 @@ export const validatePackagePolicy = ( delete inputValidationResults.vars; } - // Validate each input stream with config fields + // Validate each input stream with var definitions if (input.streams.length) { input.streams.forEach((stream) => { const streamValidationResults: PackagePolicyConfigValidationResults = {}; + const streamVarDefs = + streamVarDefsByDatasetAndInput[`${stream.data_stream.dataset}-${input.type}`]; // Validate stream-level config fields if (stream.vars) { - const streamVarsByName = ( - ( - registryStreamsByDataset[stream.data_stream.dataset].find( - (registryStream) => registryStream.input === input.type - ) || {} - ).vars || [] - ).reduce((vars, registryVar) => { - vars[registryVar.name] = registryVar; - return vars; - }, {} as Record); streamValidationResults.vars = Object.entries(stream.vars).reduce( (results, [name, configEntry]) => { results[name] = - input.enabled && stream.enabled - ? validatePackagePolicyConfig(configEntry, streamVarsByName[name]) + streamVarDefs[name] && input.enabled && stream.enabled + ? validatePackagePolicyConfig(configEntry, streamVarDefs[name]) : null; return results; }, @@ -172,7 +173,7 @@ export const validatePackagePolicy = ( } if (inputValidationResults.vars || inputValidationResults.streams) { - validationResults.inputs![input.type] = inputValidationResults; + validationResults.inputs![inputKey] = inputValidationResults; } }); diff --git a/x-pack/plugins/fleet/common/types/models/package_policy.ts b/x-pack/plugins/fleet/common/types/models/package_policy.ts index c0b74c2a7b025f..40c3a0c66f15cf 100644 --- a/x-pack/plugins/fleet/common/types/models/package_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/package_policy.ts @@ -37,6 +37,7 @@ export interface PackagePolicyInputStream extends NewPackagePolicyInputStream { export interface NewPackagePolicyInput { type: string; + policy_template?: string; enabled: boolean; keep_enabled?: boolean; vars?: PackagePolicyConfigRecord; diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/index.ts b/x-pack/plugins/fleet/public/applications/fleet/components/index.ts index ac5a78a4ea7095..5e927c5b0e3d6f 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/components/index.ts @@ -7,5 +7,4 @@ export * from '../../../components'; -export * from './enrollment_instructions'; export * from './search_bar'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx index eeb8f18d17d4f6..fd980475dc9194 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/hooks/use_breadcrumbs.tsx @@ -91,10 +91,10 @@ const breadcrumbGetters: { }), }, ], - add_integration_to_policy: ({ pkgTitle, pkgkey }) => [ + add_integration_to_policy: ({ pkgTitle, pkgkey, integration }) => [ INTEGRATIONS_BASE_BREADCRUMB, { - href: pagePathGetters.integration_details_overview({ pkgkey })[1], + href: pagePathGetters.integration_details_overview({ pkgkey, integration })[1], text: pkgTitle, useIntegrationsBasePath: true, }, diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx index bdf49f44f4397a..ecc538bd95e2a6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/actions_menu.tsx @@ -11,8 +11,7 @@ import { EuiContextMenuItem, EuiPortal } from '@elastic/eui'; import type { AgentPolicy } from '../../../types'; import { useCapabilities } from '../../../hooks'; -import { ContextMenuActions } from '../../../components'; -import { AgentEnrollmentFlyout } from '../../agents/components'; +import { AgentEnrollmentFlyout, ContextMenuActions } from '../../../components'; import { AgentPolicyYamlFlyout } from './agent_policy_yaml_flyout'; import { AgentPolicyCopyProvider } from './agent_policy_copy_provider'; @@ -102,7 +101,7 @@ export const AgentPolicyActionMenu = memo<{ ) : null} {isEnrollmentFlyoutOpen && ( - + )} = memo( ({ @@ -37,6 +38,7 @@ export const CreatePackagePolicyPageLayout: React.FunctionComponent<{ onCancel, agentPolicy, packageInfo, + integrationInfo, children, 'data-test-subj': dataTestSubj, }) => { @@ -47,8 +49,9 @@ export const CreatePackagePolicyPageLayout: React.FunctionComponent<{ @@ -68,7 +71,7 @@ export const CreatePackagePolicyPageLayout: React.FunctionComponent<{ id="xpack.fleet.createPackagePolicy.pageTitleWithPackageName" defaultMessage="Add {packageName} integration" values={{ - packageName: packageInfo.title, + packageName: integrationInfo?.title || packageInfo.title, }} /> )} @@ -98,7 +101,14 @@ export const CreatePackagePolicyPageLayout: React.FunctionComponent<{ ); - }, [dataTestSubj, from, packageInfo]); + }, [ + dataTestSubj, + from, + integrationInfo?.icons, + integrationInfo?.name, + integrationInfo?.title, + packageInfo, + ]); const pageDescription = useMemo(() => { return from === 'edit' || from === 'package-edit' ? ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx index 6563918a5efb2c..3e4b120a28f8e7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx @@ -60,19 +60,26 @@ const StepsWithLessPadding = styled(EuiSteps)` } `; +interface AddToPolicyParams { + pkgkey: string; + integration?: string; +} + +interface AddFromPolicyParams { + policyId: string; +} + export const CreatePackagePolicyPage: React.FunctionComponent = () => { const { notifications } = useStartServices(); const { agents: { enabled: isFleetEnabled }, } = useConfig(); - const { - params: { policyId, pkgkey }, - } = useRouteMatch<{ policyId: string; pkgkey: string }>(); + const { params } = useRouteMatch(); const { getHref, getPath } = useLink(); const history = useHistory(); const handleNavigateTo = useNavigateToCallback(); const routeState = useIntraAppState(); - const from: CreatePackagePolicyFrom = policyId ? 'policy' : 'package'; + const from: CreatePackagePolicyFrom = 'policyId' in params ? 'policy' : 'package'; // Agent policy and package info states const [agentPolicy, setAgentPolicy] = useState(); @@ -215,9 +222,11 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { return routeState.onCancelUrl; } return from === 'policy' - ? getHref('policy_details', { policyId: agentPolicyId || policyId }) - : getHref('integration_details_overview', { pkgkey }); - }, [agentPolicyId, policyId, from, getHref, pkgkey, routeState]); + ? getHref('policy_details', { + policyId: agentPolicyId || (params as AddFromPolicyParams).policyId, + }) + : getHref('integration_details_overview', { pkgkey: (params as AddToPolicyParams).pkgkey }); + }, [agentPolicyId, params, from, getHref, routeState]); const cancelClickHandler: ReactEventHandler = useCallback( (ev) => { @@ -230,14 +239,14 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { ); // Save package policy - const savePackagePolicy = async () => { + const savePackagePolicy = useCallback(async () => { setFormState('LOADING'); const result = await sendCreatePackagePolicy(packagePolicy); setFormState('SUBMITTED'); return result; - }; + }, [packagePolicy]); - const onSubmit = async () => { + const onSubmit = useCallback(async () => { if (formState === 'VALID' && hasErrors) { setFormState('INVALID'); return; @@ -255,7 +264,11 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { : routeState.onSaveNavigateTo ); } else { - history.push(getPath('policy_details', { policyId: agentPolicy?.id || policyId })); + history.push( + getPath('policy_details', { + policyId: agentPolicy?.id || (params as AddFromPolicyParams).policyId, + }) + ); } notifications.toasts.addSuccess({ @@ -282,27 +295,54 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { }); setFormState('VALID'); } - }; - - const layoutProps = { - from, - cancelUrl, - onCancel: cancelClickHandler, + }, [ + agentCount, agentPolicy, - packageInfo, - }; + formState, + getPath, + handleNavigateTo, + hasErrors, + history, + notifications.toasts, + packagePolicy.name, + params, + routeState, + savePackagePolicy, + ]); + + const integrationInfo = useMemo( + () => + (params as AddToPolicyParams).integration + ? packageInfo?.policy_templates?.find( + (policyTemplate) => policyTemplate.name === (params as AddToPolicyParams).integration + ) + : undefined, + [packageInfo?.policy_templates, params] + ); + + const layoutProps = useMemo( + () => ({ + from, + cancelUrl, + onCancel: cancelClickHandler, + agentPolicy, + packageInfo, + integrationInfo, + }), + [agentPolicy, cancelClickHandler, cancelUrl, from, integrationInfo, packageInfo] + ); const stepSelectAgentPolicy = useMemo( () => ( ), - [pkgkey, updatePackageInfo, agentPolicy, updateAgentPolicy] + [params, updatePackageInfo, agentPolicy, updateAgentPolicy] ); const ExtensionView = useUIExtension(packagePolicy.package?.name ?? '', 'package-policy-create'); @@ -310,14 +350,14 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { const stepSelectPackage = useMemo( () => ( ), - [policyId, updateAgentPolicy, packageInfo, updatePackageInfo] + [params, updateAgentPolicy, packageInfo, updatePackageInfo] ); const stepConfigurePackagePolicy = useMemo( @@ -333,12 +373,14 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { updatePackagePolicy={updatePackagePolicy} validationResults={validationResults!} submitAttempted={formState === 'INVALID'} + integrationToEnable={integrationInfo?.name} /> {/* Only show the out-of-box configuration step if a UI extension is NOT registered */} {!ExtensionView && ( { updatePackagePolicy, validationResults, formState, + integrationInfo?.name, ExtensionView, handleExtensionViewOnChange, ] @@ -406,8 +449,9 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { {from === 'package' ? packageInfo && ( ) : agentPolicy && ( @@ -476,8 +520,13 @@ const PolicyBreadcrumb: React.FunctionComponent<{ const IntegrationBreadcrumb: React.FunctionComponent<{ pkgTitle: string; pkgkey: string; -}> = ({ pkgTitle, pkgkey }) => { - useBreadcrumbs('add_integration_to_policy', { pkgTitle, pkgkey }); + integration?: string; +}> = ({ pkgTitle, pkgkey, integration }) => { + useBreadcrumbs('add_integration_to_policy', { + pkgTitle, + pkgkey, + ...(integration ? { integration } : {}), + }); return null; }; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/index.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/index.ts index 0c2dc6c1c64912..0e1953316fd53c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/index.ts @@ -15,4 +15,4 @@ export { validatePackagePolicyConfig, validationHasErrors, countValidationErrors, -} from './validate_package_policy'; +} from '../../../../services'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts deleted file mode 100644 index 180a585a4305ac..00000000000000 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.test.ts +++ /dev/null @@ -1,600 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { installationStatuses } from '../../../../../../../common/constants'; -import type { PackageInfo, NewPackagePolicy, RegistryPolicyTemplate } from '../../../../types'; - -import { validatePackagePolicy, validationHasErrors } from './validate_package_policy'; - -describe('Fleet - validatePackagePolicy()', () => { - const mockPackage = ({ - name: 'mock-package', - title: 'Mock package', - version: '0.0.0', - description: 'description', - type: 'mock', - categories: [], - requirement: { kibana: { versions: '' }, elasticsearch: { versions: '' } }, - format_version: '', - download: '', - path: '', - assets: { - kibana: { - dashboard: [], - visualization: [], - search: [], - 'index-pattern': [], - }, - }, - status: installationStatuses.NotInstalled, - data_streams: [ - { - dataset: 'foo', - streams: [ - { - input: 'foo', - title: 'Foo', - vars: [{ name: 'var-name', type: 'yaml' }], - }, - ], - }, - { - dataset: 'bar', - streams: [ - { - input: 'bar', - title: 'Bar', - vars: [{ name: 'var-name', type: 'yaml', required: true }], - }, - { - input: 'with-no-stream-vars', - title: 'Bar stream no vars', - enabled: true, - }, - ], - }, - { - dataset: 'bar2', - streams: [ - { - input: 'bar', - title: 'Bar 2', - vars: [{ default: 'bar2-var-value', name: 'var-name', type: 'text' }], - }, - ], - }, - { - dataset: 'disabled', - streams: [ - { - input: 'with-disabled-streams', - title: 'Disabled', - enabled: false, - vars: [{ multi: true, required: true, name: 'var-name', type: 'text' }], - }, - ], - }, - { - dataset: 'disabled2', - streams: [ - { - input: 'with-disabled-streams', - title: 'Disabled 2', - enabled: false, - }, - ], - }, - ], - policy_templates: [ - { - name: 'pkgPolicy1', - title: 'Package policy 1', - description: 'test package policy', - inputs: [ - { - type: 'foo', - title: 'Foo', - vars: [ - { default: 'foo-input-var-value', name: 'foo-input-var-name', type: 'text' }, - { - default: 'foo-input2-var-value', - name: 'foo-input2-var-name', - required: true, - type: 'text', - }, - { name: 'foo-input3-var-name', type: 'text', required: true, multi: true }, - ], - }, - { - type: 'bar', - title: 'Bar', - vars: [ - { - default: ['value1', 'value2'], - name: 'bar-input-var-name', - type: 'text', - multi: true, - }, - { name: 'bar-input2-var-name', required: true, type: 'text' }, - ], - }, - { - type: 'with-no-config-or-streams', - title: 'With no config or streams', - }, - { - type: 'with-disabled-streams', - title: 'With disabled streams', - }, - { - type: 'with-no-stream-vars', - enabled: true, - vars: [{ required: true, name: 'var-name', type: 'text' }], - }, - ], - }, - ], - } as unknown) as PackageInfo; - - const validPackagePolicy: NewPackagePolicy = { - name: 'pkgPolicy1-1', - namespace: 'default', - policy_id: 'test-policy', - enabled: true, - output_id: 'test-output', - inputs: [ - { - type: 'foo', - enabled: true, - vars: { - 'foo-input-var-name': { value: 'foo-input-var-value', type: 'text' }, - 'foo-input2-var-name': { value: 'foo-input2-var-value', type: 'text' }, - 'foo-input3-var-name': { value: ['test'], type: 'text' }, - }, - streams: [ - { - data_stream: { dataset: 'foo', type: 'logs' }, - enabled: true, - vars: { 'var-name': { value: 'test_yaml: value', type: 'yaml' } }, - }, - ], - }, - { - type: 'bar', - enabled: true, - vars: { - 'bar-input-var-name': { value: ['value1', 'value2'], type: 'text' }, - 'bar-input2-var-name': { value: 'test', type: 'text' }, - }, - streams: [ - { - data_stream: { dataset: 'bar', type: 'logs' }, - enabled: true, - vars: { 'var-name': { value: 'test_yaml: value', type: 'yaml' } }, - }, - { - data_stream: { dataset: 'bar2', type: 'logs' }, - enabled: true, - vars: { 'var-name': { value: undefined, type: 'text' } }, - }, - ], - }, - { - type: 'with-no-config-or-streams', - enabled: true, - streams: [], - }, - { - type: 'with-disabled-streams', - enabled: true, - streams: [ - { - data_stream: { dataset: 'disabled', type: 'logs' }, - enabled: false, - vars: { 'var-name': { value: undefined, type: 'text' } }, - }, - { - data_stream: { dataset: 'disabled2', type: 'logs' }, - enabled: false, - }, - ], - }, - { - type: 'with-no-stream-vars', - enabled: true, - vars: { - 'var-name': { value: 'test', type: 'text' }, - }, - streams: [ - { - data_stream: { dataset: 'with-no-stream-vars-bar', type: 'logs' }, - enabled: true, - }, - ], - }, - ], - }; - - const invalidPackagePolicy: NewPackagePolicy = { - ...validPackagePolicy, - name: '', - inputs: [ - { - type: 'foo', - enabled: true, - vars: { - 'foo-input-var-name': { value: undefined, type: 'text' }, - 'foo-input2-var-name': { value: '', type: 'text' }, - 'foo-input3-var-name': { value: [], type: 'text' }, - }, - streams: [ - { - data_stream: { dataset: 'foo', type: 'logs' }, - enabled: true, - vars: { 'var-name': { value: 'invalidyaml: test\n foo bar:', type: 'yaml' } }, - }, - ], - }, - { - type: 'bar', - enabled: true, - vars: { - 'bar-input-var-name': { value: 'invalid value for multi', type: 'text' }, - 'bar-input2-var-name': { value: undefined, type: 'text' }, - }, - streams: [ - { - data_stream: { dataset: 'bar', type: 'logs' }, - enabled: true, - vars: { 'var-name': { value: ' \n\n', type: 'yaml' } }, - }, - { - data_stream: { dataset: 'bar2', type: 'logs' }, - enabled: true, - vars: { 'var-name': { value: undefined, type: 'text' } }, - }, - ], - }, - { - type: 'with-no-config-or-streams', - enabled: true, - streams: [], - }, - { - type: 'with-disabled-streams', - enabled: true, - streams: [ - { - data_stream: { dataset: 'disabled', type: 'logs' }, - enabled: false, - vars: { - 'var-name': { - value: 'invalid value but not checked due to not enabled', - type: 'text', - }, - }, - }, - { - data_stream: { dataset: 'disabled2', type: 'logs' }, - enabled: false, - }, - ], - }, - { - type: 'with-no-stream-vars', - enabled: true, - vars: { - 'var-name': { value: undefined, type: 'text' }, - }, - streams: [ - { - data_stream: { dataset: 'with-no-stream-vars-bar', type: 'logs' }, - enabled: true, - }, - ], - }, - ], - }; - - const noErrorsValidationResults = { - name: null, - description: null, - namespace: null, - inputs: { - foo: { - vars: { - 'foo-input-var-name': null, - 'foo-input2-var-name': null, - 'foo-input3-var-name': null, - }, - streams: { foo: { vars: { 'var-name': null } } }, - }, - bar: { - vars: { 'bar-input-var-name': null, 'bar-input2-var-name': null }, - streams: { - bar: { vars: { 'var-name': null } }, - bar2: { vars: { 'var-name': null } }, - }, - }, - 'with-disabled-streams': { - streams: { - disabled: { - vars: { 'var-name': null }, - }, - disabled2: {}, - }, - }, - 'with-no-stream-vars': { - streams: { - 'with-no-stream-vars-bar': {}, - }, - vars: { 'var-name': null }, - }, - }, - }; - - it('returns no errors for valid package policy', () => { - expect(validatePackagePolicy(validPackagePolicy, mockPackage)).toEqual( - noErrorsValidationResults - ); - }); - - it('returns errors for invalid package policy', () => { - expect(validatePackagePolicy(invalidPackagePolicy, mockPackage)).toEqual({ - name: ['Name is required'], - description: null, - namespace: null, - inputs: { - foo: { - vars: { - 'foo-input-var-name': null, - 'foo-input2-var-name': ['foo-input2-var-name is required'], - 'foo-input3-var-name': ['foo-input3-var-name is required'], - }, - streams: { foo: { vars: { 'var-name': ['Invalid YAML format'] } } }, - }, - bar: { - vars: { - 'bar-input-var-name': ['Invalid format'], - 'bar-input2-var-name': ['bar-input2-var-name is required'], - }, - streams: { - bar: { vars: { 'var-name': ['var-name is required'] } }, - bar2: { vars: { 'var-name': null } }, - }, - }, - 'with-disabled-streams': { - streams: { - disabled: { vars: { 'var-name': null } }, - disabled2: {}, - }, - }, - 'with-no-stream-vars': { - vars: { - 'var-name': ['var-name is required'], - }, - streams: { 'with-no-stream-vars-bar': {} }, - }, - }, - }); - }); - - it('returns no errors for disabled inputs', () => { - const disabledInputs = invalidPackagePolicy.inputs.map((input) => ({ - ...input, - enabled: false, - })); - expect( - validatePackagePolicy({ ...validPackagePolicy, inputs: disabledInputs }, mockPackage) - ).toEqual(noErrorsValidationResults); - }); - - it('returns only package policy and input-level errors for disabled streams', () => { - const inputsWithDisabledStreams = invalidPackagePolicy.inputs.map((input) => - input.streams - ? { - ...input, - streams: input.streams.map((stream) => ({ ...stream, enabled: false })), - } - : input - ); - expect( - validatePackagePolicy( - { ...invalidPackagePolicy, inputs: inputsWithDisabledStreams }, - mockPackage - ) - ).toEqual({ - name: ['Name is required'], - description: null, - namespace: null, - inputs: { - foo: { - vars: { - 'foo-input-var-name': null, - 'foo-input2-var-name': ['foo-input2-var-name is required'], - 'foo-input3-var-name': ['foo-input3-var-name is required'], - }, - streams: { foo: { vars: { 'var-name': null } } }, - }, - bar: { - vars: { - 'bar-input-var-name': ['Invalid format'], - 'bar-input2-var-name': ['bar-input2-var-name is required'], - }, - streams: { - bar: { vars: { 'var-name': null } }, - bar2: { vars: { 'var-name': null } }, - }, - }, - 'with-disabled-streams': { - streams: { - disabled: { - vars: { 'var-name': null }, - }, - disabled2: {}, - }, - }, - 'with-no-stream-vars': { - vars: { - 'var-name': ['var-name is required'], - }, - streams: { 'with-no-stream-vars-bar': {} }, - }, - }, - }); - }); - - it('returns no errors for packages with no package policies', () => { - expect( - validatePackagePolicy(validPackagePolicy, { - ...mockPackage, - policy_templates: undefined, - }) - ).toEqual({ - name: null, - description: null, - namespace: null, - inputs: null, - }); - expect( - validatePackagePolicy(validPackagePolicy, { - ...mockPackage, - policy_templates: [], - }) - ).toEqual({ - name: null, - description: null, - namespace: null, - inputs: null, - }); - }); - - it('returns no errors for packages with no inputs', () => { - expect( - validatePackagePolicy(validPackagePolicy, { - ...mockPackage, - policy_templates: [{} as RegistryPolicyTemplate], - }) - ).toEqual({ - name: null, - description: null, - namespace: null, - inputs: null, - }); - expect( - validatePackagePolicy(validPackagePolicy, { - ...mockPackage, - policy_templates: [({ inputs: [] } as unknown) as RegistryPolicyTemplate], - }) - ).toEqual({ - name: null, - description: null, - namespace: null, - inputs: null, - }); - }); -}); - -describe('Fleet - validationHasErrors()', () => { - it('returns true for stream validation results with errors', () => { - expect( - validationHasErrors({ - vars: { foo: ['foo error'], bar: null }, - }) - ).toBe(true); - }); - - it('returns false for stream validation results with no errors', () => { - expect( - validationHasErrors({ - vars: { foo: null, bar: null }, - }) - ).toBe(false); - }); - - it('returns true for input validation results with errors', () => { - expect( - validationHasErrors({ - vars: { foo: ['foo error'], bar: null }, - streams: { stream1: { vars: { foo: null, bar: null } } }, - }) - ).toBe(true); - expect( - validationHasErrors({ - vars: { foo: null, bar: null }, - streams: { stream1: { vars: { foo: ['foo error'], bar: null } } }, - }) - ).toBe(true); - }); - - it('returns false for input validation results with no errors', () => { - expect( - validationHasErrors({ - vars: { foo: null, bar: null }, - streams: { stream1: { vars: { foo: null, bar: null } } }, - }) - ).toBe(false); - }); - - it('returns true for package policy validation results with errors', () => { - expect( - validationHasErrors({ - name: ['name error'], - description: null, - namespace: null, - inputs: { - input1: { - vars: { foo: null, bar: null }, - streams: { stream1: { vars: { foo: null, bar: null } } }, - }, - }, - }) - ).toBe(true); - expect( - validationHasErrors({ - name: null, - description: null, - namespace: null, - inputs: { - input1: { - vars: { foo: ['foo error'], bar: null }, - streams: { stream1: { vars: { foo: null, bar: null } } }, - }, - }, - }) - ).toBe(true); - expect( - validationHasErrors({ - name: null, - description: null, - namespace: null, - inputs: { - input1: { - vars: { foo: null, bar: null }, - streams: { stream1: { vars: { foo: ['foo error'], bar: null } } }, - }, - }, - }) - ).toBe(true); - }); - - it('returns false for package policy validation results with no errors', () => { - expect( - validationHasErrors({ - name: null, - description: null, - namespace: null, - inputs: { - input1: { - vars: { foo: null, bar: null }, - streams: { stream1: { vars: { foo: null, bar: null } } }, - }, - }, - }) - ).toBe(false); - }); -}); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx index e64598e583d353..1ff5d20baec068 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_configure_package.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { useMemo } from 'react'; import { EuiHorizontalRule, EuiFlexGroup, @@ -15,86 +15,92 @@ import { } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { - PackageInfo, - RegistryStream, - NewPackagePolicy, - NewPackagePolicyInput, -} from '../../../types'; +import type { PackageInfo, NewPackagePolicy, NewPackagePolicyInput } from '../../../types'; import { Loading } from '../../../components'; +import { getStreamsForInputType, doesPackageHaveIntegrations } from '../../../services'; import type { PackagePolicyValidationResults } from './services'; import { PackagePolicyInputPanel } from './components'; -const findStreamsForInputType = ( - inputType: string, - packageInfo: PackageInfo -): Array => { - const streams: Array = []; - - (packageInfo.data_streams || []).forEach((dataStream) => { - (dataStream.streams || []).forEach((stream) => { - if (stream.input === inputType) { - streams.push({ - ...stream, - data_stream: { - dataset: dataStream.dataset, - }, - }); - } - }); - }); - - return streams; -}; - export const StepConfigurePackagePolicy: React.FunctionComponent<{ packageInfo: PackageInfo; + showOnlyIntegration?: string; packagePolicy: NewPackagePolicy; updatePackagePolicy: (fields: Partial) => void; validationResults: PackagePolicyValidationResults; submitAttempted: boolean; -}> = ({ packageInfo, packagePolicy, updatePackagePolicy, validationResults, submitAttempted }) => { +}> = ({ + packageInfo, + showOnlyIntegration, + packagePolicy, + updatePackagePolicy, + validationResults, + submitAttempted, +}) => { + const hasIntegrations = useMemo(() => doesPackageHaveIntegrations(packageInfo), [packageInfo]); + const packagePolicyTemplates = useMemo( + () => + showOnlyIntegration + ? (packageInfo.policy_templates || []).filter( + (policyTemplate) => policyTemplate.name === showOnlyIntegration + ) + : packageInfo.policy_templates || [], + [packageInfo.policy_templates, showOnlyIntegration] + ); + // Configure inputs (and their streams) // Assume packages only export one config template for now const renderConfigureInputs = () => - packageInfo.policy_templates && - packageInfo.policy_templates[0] && - packageInfo.policy_templates[0].inputs && - packageInfo.policy_templates[0].inputs.length ? ( + packagePolicyTemplates.length ? ( <> - {packageInfo.policy_templates[0].inputs.map((packageInput) => { - const packagePolicyInput = packagePolicy.inputs.find( - (input) => input.type === packageInput.type - ); - const packageInputStreams = findStreamsForInputType(packageInput.type, packageInfo); - return packagePolicyInput ? ( - - ) => { - const indexOfUpdatedInput = packagePolicy.inputs.findIndex( - (input) => input.type === packageInput.type - ); - const newInputs = [...packagePolicy.inputs]; - newInputs[indexOfUpdatedInput] = { - ...newInputs[indexOfUpdatedInput], - ...updatedInput, - }; - updatePackagePolicy({ - inputs: newInputs, - }); - }} - inputValidationResults={validationResults!.inputs![packagePolicyInput.type]} - forceShowErrors={submitAttempted} - /> - - - ) : null; + {packagePolicyTemplates.map((policyTemplate) => { + return (policyTemplate.inputs || []).map((packageInput) => { + const packagePolicyInput = packagePolicy.inputs.find( + (input) => + input.type === packageInput.type && + (hasIntegrations ? input.policy_template === policyTemplate.name : true) + ); + const packageInputStreams = getStreamsForInputType( + packageInput.type, + packageInfo, + hasIntegrations ? policyTemplate.data_streams : [] + ); + return packagePolicyInput ? ( + + ) => { + const indexOfUpdatedInput = packagePolicy.inputs.findIndex( + (input) => + input.type === packageInput.type && + (hasIntegrations ? input.policy_template === policyTemplate.name : true) + ); + const newInputs = [...packagePolicy.inputs]; + newInputs[indexOfUpdatedInput] = { + ...newInputs[indexOfUpdatedInput], + ...updatedInput, + }; + updatePackagePolicy({ + inputs: newInputs, + }); + }} + inputValidationResults={ + validationResults!.inputs![ + hasIntegrations + ? `${policyTemplate.name}-${packagePolicyInput.type}` + : packagePolicyInput.type + ] + } + forceShowErrors={submitAttempted} + /> + + + ) : null; + }); })} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx index 380e49a1d8dd97..7444bed6ed3fdb 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx @@ -38,7 +38,7 @@ export const StepDefinePackagePolicy: React.FunctionComponent<{ agentPolicy: AgentPolicy; packageInfo: PackageInfo; packagePolicy: NewPackagePolicy; - integration?: string; + integrationToEnable?: string; updatePackagePolicy: (fields: Partial) => void; validationResults: PackagePolicyValidationResults; submitAttempted: boolean; @@ -47,7 +47,7 @@ export const StepDefinePackagePolicy: React.FunctionComponent<{ agentPolicy, packageInfo, packagePolicy, - integration, + integrationToEnable, updatePackagePolicy, validationResults, submitAttempted, @@ -95,7 +95,8 @@ export const StepDefinePackagePolicy: React.FunctionComponent<{ ? pkgPoliciesWithMatchingNames[pkgPoliciesWithMatchingNames.length - 1] + 1 : 1 }`, - packagePolicy.description + packagePolicy.description, + integrationToEnable ) ); } @@ -107,7 +108,7 @@ export const StepDefinePackagePolicy: React.FunctionComponent<{ namespace: agentPolicy.namespace, }); } - }, [packagePolicy, agentPolicy, packageInfo, updatePackagePolicy, integration]); + }, [packagePolicy, agentPolicy, packageInfo, updatePackagePolicy, integrationToEnable]); return validationResults ? ( = ({ }) => { const { getHref } = useLink(); const hasWriteCapabilities = useCapabilities().write; - const refreshAgentPolicy = useAgentPolicyRefresh(); // With the package policies provided on input, generate the list of package policies // used in the InMemoryTable (flattens some values for search) as well as @@ -168,71 +164,15 @@ export const PackagePoliciesTable: React.FunctionComponent = ({ actions: [ { render: (packagePolicy: InMemoryPackagePolicy) => { - const menuItems = [ - // FIXME: implement View package policy action - // {}} - // key="packagePolicyView" - // > - // - // , - - - , - // FIXME: implement Copy package policy action - // {}} key="packagePolicyCopy"> - // - // , - ]; - - if (!agentPolicy.is_managed) { - menuItems.push( - - {(deletePackagePoliciesPrompt) => { - return ( - { - deletePackagePoliciesPrompt([packagePolicy.id], refreshAgentPolicy); - }} - > - - - ); - }} - - ); - } - return ; + return ( + + ); }, }, ], }, ], - [agentPolicy, getHref, hasWriteCapabilities, refreshAgentPolicy] + [agentPolicy] ); return ( diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx index e91d32a78ec963..1ea1a7de53b959 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx @@ -20,13 +20,13 @@ import { sendUpdateAgentPolicy, useConfig, sendGetAgentStatus, + useAgentPolicyRefresh, } from '../../../../../hooks'; import { AgentPolicyForm, agentPolicyFormValidation, ConfirmDeployAgentPolicyModal, } from '../../../components'; -import { useAgentPolicyRefresh } from '../../hooks'; const FormWrapper = styled.div` max-width: 800px; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/index.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/index.ts index 07daef8bb2ced8..fb269f95213d9b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/index.ts @@ -6,4 +6,3 @@ */ export { useGetAgentStatus, AgentStatusRefreshContext } from './use_agent_status'; -export { AgentPolicyRefreshContext, useAgentPolicyRefresh } from './use_config'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx index 7138abb081a77f..9d3fe64b6639d3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/index.tsx @@ -28,6 +28,7 @@ import styled from 'styled-components'; import type { AgentPolicy, AgentPolicyDetailsDeployAgentAction } from '../../../types'; import { FLEET_ROUTING_PATHS } from '../../../constants'; import { + AgentPolicyRefreshContext, useGetOneAgentPolicy, useLink, useBreadcrumbs, @@ -39,7 +40,7 @@ import { Loading, Error } from '../../../components'; import { WithHeaderLayout } from '../../../layouts'; import { LinkedAgentCount, AgentPolicyActionMenu } from '../components'; -import { AgentPolicyRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; +import { useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; import { PackagePoliciesView, SettingsView } from './components'; const Divider = styled.div` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx index 540b06d7a9786b..fb80611e5295c8 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx @@ -23,8 +23,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import type { Agent, AgentPolicy } from '../../../../../types'; import { useKibanaVersion } from '../../../../../hooks'; import { isAgentUpgradeable } from '../../../../../services'; -import { AgentPolicyPackageBadges } from '../../../components/agent_policy_package_badges'; -import { AgentPolicySummaryLine } from '../../../../../components'; +import { AgentPolicyPackageBadges, AgentPolicySummaryLine } from '../../../../../components'; // Allows child text to be truncated const FlexItemWithMinWidth = styled(EuiFlexItem)` diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx index 70cb6cddad5fad..672b8718c9cbe7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx @@ -22,7 +22,6 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage, FormattedRelative } from '@kbn/i18n/react'; -import { AgentEnrollmentFlyout } from '../components'; import type { Agent, AgentPolicy, SimplifiedAgentStatus } from '../../../types'; import { usePagination, @@ -37,7 +36,11 @@ import { useKibanaVersion, useStartServices, } from '../../../hooks'; -import { AgentPolicySummaryLine, ContextMenuActions } from '../../../components'; +import { + AgentEnrollmentFlyout, + AgentPolicySummaryLine, + ContextMenuActions, +} from '../../../components'; import { AgentStatusKueryHelper, isAgentUpgradeable } from '../../../services'; import { AGENT_SAVED_OBJECT_TYPE } from '../../../constants'; import { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_requirements_page/fleet_server_requirement_page.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_requirements_page/fleet_server_requirement_page.tsx index 83f09789a94148..20d366b01af2bb 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_requirements_page/fleet_server_requirement_page.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_requirements_page/fleet_server_requirement_page.tsx @@ -26,10 +26,15 @@ import styled from 'styled-components'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { DownloadStep } from '../components/agent_enrollment_flyout/steps'; -import { useStartServices, useGetOutputs, sendGenerateServiceToken } from '../../../hooks'; -import { PLATFORM_OPTIONS, usePlatform } from '../hooks/use_platform'; -import type { PLATFORM_TYPE } from '../hooks/use_platform'; +import { DownloadStep } from '../../../components'; +import { + useStartServices, + useGetOutputs, + sendGenerateServiceToken, + usePlatform, + PLATFORM_OPTIONS, +} from '../../../hooks'; +import type { PLATFORM_TYPE } from '../../../hooks'; const FlexItemWithMinWidth = styled(EuiFlexItem)` min-width: 0px; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx deleted file mode 100644 index 4edc1121b1091a..00000000000000 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/agent_policy_selection.tsx +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { useState, useEffect } from 'react'; -import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiButtonEmpty, EuiButton, EuiCallOut, EuiSelect, EuiSpacer, EuiText } from '@elastic/eui'; - -import { SO_SEARCH_LIMIT } from '../../../../constants'; -import type { AgentPolicy, GetEnrollmentAPIKeysResponse } from '../../../../types'; -import { - sendGetEnrollmentAPIKeys, - useStartServices, - sendCreateEnrollmentAPIKey, -} from '../../../../hooks'; -import { AgentPolicyPackageBadges } from '../agent_policy_package_badges'; - -type Props = { - agentPolicies?: AgentPolicy[]; - onAgentPolicyChange?: (key?: string) => void; - excludeFleetServer?: boolean; -} & ( - | { - withKeySelection: true; - onKeyChange?: (key?: string) => void; - } - | { - withKeySelection: false; - } -); - -export const EnrollmentStepAgentPolicy: React.FC = (props) => { - const { notifications } = useStartServices(); - const { withKeySelection, agentPolicies, onAgentPolicyChange, excludeFleetServer } = props; - const onKeyChange = props.withKeySelection && props.onKeyChange; - - const [isAuthenticationSettingsOpen, setIsAuthenticationSettingsOpen] = useState(false); - const [enrollmentAPIKeys, setEnrollmentAPIKeys] = useState( - [] - ); - const [isLoadingEnrollmentKey, setIsLoadingEnrollmentKey] = useState(false); - - const [selectedState, setSelectedState] = useState<{ - agentPolicyId?: string; - enrollmentAPIKeyId?: string; - }>({}); - - useEffect( - function triggerOnAgentPolicyChangeEffect() { - if (onAgentPolicyChange) { - onAgentPolicyChange(selectedState.agentPolicyId); - } - }, - [selectedState.agentPolicyId, onAgentPolicyChange] - ); - - useEffect( - function triggerOnKeyChangeEffect() { - if (!withKeySelection || !onKeyChange) { - return; - } - - if (onKeyChange) { - onKeyChange(selectedState.enrollmentAPIKeyId); - } - }, - [withKeySelection, onKeyChange, selectedState.enrollmentAPIKeyId] - ); - - useEffect( - function useDefaultAgentPolicyEffect() { - if (agentPolicies && agentPolicies.length && !selectedState.agentPolicyId) { - if (agentPolicies.length === 1) { - setSelectedState({ - ...selectedState, - agentPolicyId: agentPolicies[0].id, - }); - return; - } - - const defaultAgentPolicy = agentPolicies.find((agentPolicy) => agentPolicy.is_default); - if (defaultAgentPolicy) { - setSelectedState({ - ...selectedState, - agentPolicyId: defaultAgentPolicy.id, - }); - } - } - }, - [agentPolicies, selectedState] - ); - - useEffect( - function useEnrollmentKeysForAgentPolicyEffect() { - if (!withKeySelection) { - return; - } - if (!selectedState.agentPolicyId) { - setIsAuthenticationSettingsOpen(true); - setEnrollmentAPIKeys([]); - return; - } - - async function fetchEnrollmentAPIKeys() { - try { - const res = await sendGetEnrollmentAPIKeys({ - page: 1, - perPage: SO_SEARCH_LIMIT, - }); - if (res.error) { - throw res.error; - } - - if (!res.data) { - throw new Error('No data while fetching enrollment API keys'); - } - - setEnrollmentAPIKeys( - res.data.list.filter( - (key) => key.policy_id === selectedState.agentPolicyId && key.active === true - ) - ); - } catch (error) { - notifications.toasts.addError(error, { - title: 'Error', - }); - } - } - fetchEnrollmentAPIKeys(); - }, - [withKeySelection, selectedState.agentPolicyId, notifications.toasts] - ); - - useEffect( - function useDefaultEnrollmentKeyForAgentPolicyEffect() { - if (!withKeySelection) { - return; - } - if ( - !selectedState.enrollmentAPIKeyId && - enrollmentAPIKeys.length > 0 && - enrollmentAPIKeys[0].policy_id === selectedState.agentPolicyId - ) { - const enrollmentAPIKeyId = enrollmentAPIKeys[0].id; - setSelectedState({ - agentPolicyId: selectedState.agentPolicyId, - enrollmentAPIKeyId, - }); - } - }, - [ - withKeySelection, - enrollmentAPIKeys, - selectedState.enrollmentAPIKeyId, - selectedState.agentPolicyId, - ] - ); - - return ( - <> - - - - } - isLoading={!agentPolicies} - options={(agentPolicies || []).map((agentPolicy) => ({ - value: agentPolicy.id, - text: agentPolicy.name, - }))} - value={selectedState.agentPolicyId || undefined} - onChange={(e) => - setSelectedState({ - agentPolicyId: e.target.value, - enrollmentAPIKeyId: undefined, - }) - } - aria-label={i18n.translate('xpack.fleet.enrollmentStepAgentPolicy.policySelectAriaLabel', { - defaultMessage: 'Agent policy', - })} - /> - - {selectedState.agentPolicyId && ( - - )} - {withKeySelection && onKeyChange && ( - <> - - setIsAuthenticationSettingsOpen(!isAuthenticationSettingsOpen)} - > - - - {isAuthenticationSettingsOpen && ( - <> - - {enrollmentAPIKeys.length && selectedState.enrollmentAPIKeyId ? ( - ({ - value: key.id, - text: key.name, - }))} - value={selectedState.enrollmentAPIKeyId || undefined} - prepend={ - - - - } - onChange={(e) => { - setSelectedState({ - ...selectedState, - enrollmentAPIKeyId: e.target.value, - }); - }} - /> - ) : ( - -
- -
- - { - setIsLoadingEnrollmentKey(true); - if (selectedState.agentPolicyId) { - sendCreateEnrollmentAPIKey({ policy_id: selectedState.agentPolicyId }) - .then((res) => { - if (res.error) { - throw res.error; - } - setIsLoadingEnrollmentKey(false); - if (res.data?.item) { - setEnrollmentAPIKeys([res.data.item]); - setSelectedState({ - ...selectedState, - enrollmentAPIKeyId: res.data.item.id, - }); - notifications.toasts.addSuccess( - i18n.translate('xpack.fleet.newEnrollmentKey.keyCreatedToasts', { - defaultMessage: 'Enrollment token created', - }) - ); - } - }) - .catch((error) => { - setIsLoadingEnrollmentKey(false); - notifications.toasts.addError(error, { - title: 'Error', - }); - }); - } - }} - > - - -
- )} - - )} - - )} - - ); -}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_modal/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_modal/index.tsx index 8ee401d3c4ddf7..f15b58200ea889 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_modal/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_reassign_policy_modal/index.tsx @@ -24,7 +24,7 @@ import { useStartServices, useGetAgentPolicies, } from '../../../../hooks'; -import { AgentPolicyPackageBadges } from '../agent_policy_package_badges'; +import { AgentPolicyPackageBadges } from '../../../../components'; interface Props { onClose: () => void; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/index.tsx index 45f09c79d55337..966a7779413735 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/index.tsx @@ -7,7 +7,6 @@ export * from './loading'; export * from './agent_reassign_policy_modal'; -export * from './agent_enrollment_flyout'; export * from './agent_health'; export * from './agent_unenroll_modal'; export * from './agent_upgrade_modal'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx index 40642587c1a38f..67758282521b79 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/list_layout.tsx @@ -14,7 +14,7 @@ import { useRouteMatch } from 'react-router-dom'; import { FLEET_ROUTING_PATHS } from '../../../constants'; import { WithHeaderLayout } from '../../../layouts'; import { useCapabilities, useLink, useGetAgentPolicies } from '../../../hooks'; -import { AgentEnrollmentFlyout } from '../components'; +import { AgentEnrollmentFlyout } from '../../../components'; export const ListLayout: React.FunctionComponent<{}> = ({ children }) => { const { getHref } = useLink(); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx index 66e0c338dbbbcd..8dc9ad33962e0d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/index.tsx @@ -22,6 +22,7 @@ import { import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; import { ENROLLMENT_API_KEYS_INDEX } from '../../../constants'; +import { NewEnrollmentTokenModal } from '../../../components'; import { useBreadcrumbs, usePagination, @@ -34,7 +35,6 @@ import { import type { EnrollmentAPIKey, GetAgentPoliciesResponseItem } from '../../../types'; import { SearchBar } from '../../../components/search_bar'; -import { NewEnrollmentTokenModal } from './components/new_enrollment_key_modal'; import { ConfirmEnrollmentTokenDelete } from './components/confirm_delete_modal'; const ApiKeyField: React.FunctionComponent<{ apiKeyId: string }> = ({ apiKeyId }) => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx index 9da10c1de2be06..f905fd1c89da27 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/overview/index.tsx @@ -20,7 +20,7 @@ import { i18n } from '@kbn/i18n'; import { WithHeaderLayout } from '../../layouts'; import { useGetAgentPolicies, useBreadcrumbs } from '../../hooks'; -import { AgentEnrollmentFlyout } from '../agents/components'; +import { AgentEnrollmentFlyout } from '../../components'; import { OverviewAgentSection } from './components/agent_section'; import { OverviewPolicySection } from './components/agent_policy_section'; diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx index 3477335321a2ca..04253994d3875e 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx @@ -202,12 +202,30 @@ describe('when on integration detail', () => { expect(firstRowAgentCount.tagName).not.toEqual('A'); }); + it('should show add agent button if agent count is zero', async () => { + await mockedApi.waitForApi(); + const firstRowAgentCount = renderResult.getAllByTestId('rowAgentCount')[0]; + expect(firstRowAgentCount.textContent).toEqual('0'); + + const addAgentButton = renderResult.getAllByTestId('addAgentButton')[0]; + expect(addAgentButton).not.toBeNull(); + }); + it('should show link for agent count if greater than zero', async () => { await mockedApi.waitForApi(); const secondRowAgentCount = renderResult.getAllByTestId('rowAgentCount')[1]; expect(secondRowAgentCount.textContent).toEqual('100'); expect(secondRowAgentCount.tagName).toEqual('A'); }); + + it('should NOT show add agent button if agent count is greater than zero', async () => { + await mockedApi.waitForApi(); + const secondRowAgentCount = renderResult.getAllByTestId('rowAgentCount')[1]; + expect(secondRowAgentCount.textContent).toEqual('100'); + + const addAgentButton = renderResult.getAllByTestId('addAgentButton')[1]; + expect(addAgentButton).toBeUndefined(); + }); }); }); diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx index d5dce6334762c0..7da7328fdebbca 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/package_policies.tsx @@ -5,23 +5,44 @@ * 2.0. */ -import React, { memo, useCallback, useMemo } from 'react'; +import React, { memo, useCallback, useMemo, useState } from 'react'; import { Redirect } from 'react-router-dom'; import type { CriteriaWithPagination, EuiTableFieldDataColumnType } from '@elastic/eui'; -import { EuiBasicTable, EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { + EuiButtonIcon, + EuiBasicTable, + EuiLink, + EuiFlexGroup, + EuiFlexItem, + EuiToolTip, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedRelative, FormattedMessage } from '@kbn/i18n/react'; +import styled from 'styled-components'; import { InstallStatus } from '../../../../../types'; -import { useLink, useUrlPagination, useGetPackageInstallStatus } from '../../../../../hooks'; +import { + useLink, + useUrlPagination, + useGetPackageInstallStatus, + AgentPolicyRefreshContext, +} from '../../../../../hooks'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '../../../../../constants'; -import { AgentPolicySummaryLine } from '../../../../../components'; -import { LinkedAgentCount } from '../../../../../components'; +import { + AgentEnrollmentFlyout, + AgentPolicySummaryLine, + LinkedAgentCount, + PackagePolicyActionsMenu, +} from '../../../../../components'; import type { PackagePolicyAndAgentPolicy } from './use_package_policies_with_agent_policy'; import { usePackagePoliciesWithAgentPolicy } from './use_package_policies_with_agent_policy'; import { Persona } from './persona'; +const AddAgentButton = styled(EuiButtonIcon)` + margin-left: ${(props) => props.theme.eui.euiSizeS}; +`; + const IntegrationDetailsLink = memo<{ packagePolicy: PackagePolicyAndAgentPolicy['packagePolicy']; }>(({ packagePolicy }) => { @@ -39,16 +60,18 @@ const IntegrationDetailsLink = memo<{ ); }); + interface PackagePoliciesPanelProps { name: string; version: string; } export const PackagePoliciesPage = ({ name, version }: PackagePoliciesPanelProps) => { + const [flyoutOpenForPolicyId, setFlyoutOpenForPolicyId] = useState(null); const { getPath } = useLink(); const getPackageInstallStatus = useGetPackageInstallStatus(); const packageInstallStatus = getPackageInstallStatus(name); const { pagination, pageSizeOptions, setPagination } = useUrlPagination(); - const { data, isLoading } = usePackagePoliciesWithAgentPolicy({ + const { data, isLoading, resendRequest: refreshPolicies } = usePackagePoliciesWithAgentPolicy({ page: pagination.currentPage, perPage: pagination.pageSize, kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.package.name: ${name}`, @@ -97,16 +120,36 @@ export const PackagePoliciesPage = ({ name, version }: PackagePoliciesPanelProps defaultMessage: 'Agents', }), truncateText: true, - align: 'right', + align: 'left', width: '8ch', render({ packagePolicy, agentPolicy }: PackagePolicyAndAgentPolicy) { + const count = agentPolicy?.agents ?? 0; + return ( - + <> + + {count === 0 && ( + + setFlyoutOpenForPolicyId(agentPolicy.id)} + data-test-subj="addAgentButton" + /> + + )} + ); }, }, @@ -134,6 +177,19 @@ export const PackagePoliciesPage = ({ name, version }: PackagePoliciesPanelProps ); }, }, + { + field: '', + name: i18n.translate('xpack.fleet.epm.packageDetails.integrationList.actions', { + defaultMessage: 'Actions', + }), + width: '8ch', + align: 'right', + render({ agentPolicy, packagePolicy }) { + return ( + + ); + }, + }, ], [] ); @@ -165,19 +221,31 @@ export const PackagePoliciesPage = ({ name, version }: PackagePoliciesPanelProps } return ( - - - - + + + + + + + {flyoutOpenForPolicyId && ( + setFlyoutOpenForPolicyId(null)} + agentPolicies={ + data?.items + .filter(({ agentPolicy }) => agentPolicy.id === flyoutOpenForPolicyId) + .map(({ agentPolicy }) => agentPolicy) ?? [] + } /> - - + )} + ); }; diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts index aae43a1acd5689..33c1d3ff773023 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/policies/use_package_policies_with_agent_policy.ts @@ -43,11 +43,13 @@ export const usePackagePoliciesWithAgentPolicy = ( isLoading: boolean; error: Error | null; data?: GetPackagePoliciesWithAgentPolicy; + resendRequest: () => void; } => { const { data: packagePoliciesData, error, isLoading: isLoadingPackagePolicies, + resendRequest, } = useGetPackagePolicies(query); const agentPoliciesFilter = useMemo(() => { @@ -124,5 +126,6 @@ export const usePackagePoliciesWithAgentPolicy = ( data: enrichedData, error, isLoading: isLoadingPackagePolicies || isLoadingAgentPolicies, + resendRequest, }; }; diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/advanced_agent_authentication_settings.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/advanced_agent_authentication_settings.tsx new file mode 100644 index 00000000000000..25602b7e108fdd --- /dev/null +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/advanced_agent_authentication_settings.tsx @@ -0,0 +1,196 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { FunctionComponent } from 'react'; +import React, { useEffect, useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiButtonEmpty, EuiButton, EuiCallOut, EuiSelect, EuiSpacer, EuiText } from '@elastic/eui'; + +import { SO_SEARCH_LIMIT } from '../../applications/fleet/constants'; +import type { GetEnrollmentAPIKeysResponse } from '../../applications/fleet/types'; +import { + sendGetEnrollmentAPIKeys, + useStartServices, + sendCreateEnrollmentAPIKey, +} from '../../applications/fleet/hooks'; + +interface Props { + agentPolicyId?: string; + onKeyChange: (key?: string) => void; +} + +export const AdvancedAgentAuthenticationSettings: FunctionComponent = ({ + agentPolicyId, + onKeyChange, +}) => { + const { notifications } = useStartServices(); + const [enrollmentAPIKeys, setEnrollmentAPIKeys] = useState( + [] + ); + // TODO: Remove this piece of state since we don't need it here. The currently selected enrollment API key only + // needs to live on the form + const [selectedEnrollmentApiKey, setSelectedEnrollmentApiKey] = useState(); + const [isLoadingEnrollmentKey, setIsLoadingEnrollmentKey] = useState(false); + const [isAuthenticationSettingsOpen, setIsAuthenticationSettingsOpen] = useState(false); + + const onCreateEnrollmentTokenClick = async () => { + setIsLoadingEnrollmentKey(true); + if (agentPolicyId) { + try { + const res = await sendCreateEnrollmentAPIKey({ policy_id: agentPolicyId }); + if (res.error) { + throw res.error; + } + setIsLoadingEnrollmentKey(false); + if (!res.data?.item) { + return; + } + setEnrollmentAPIKeys([res.data.item]); + setSelectedEnrollmentApiKey(res.data.item.id); + notifications.toasts.addSuccess( + i18n.translate('xpack.fleet.newEnrollmentKey.keyCreatedToasts', { + defaultMessage: 'Enrollment token created', + }) + ); + } catch (error) { + setIsLoadingEnrollmentKey(false); + notifications.toasts.addError(error, { + title: 'Error', + }); + } + } + }; + + useEffect( + function triggerOnKeyChangeEffect() { + if (onKeyChange) { + onKeyChange(selectedEnrollmentApiKey); + } + }, + [onKeyChange, selectedEnrollmentApiKey] + ); + + useEffect( + function useEnrollmentKeysForAgentPolicyEffect() { + if (!agentPolicyId) { + setIsAuthenticationSettingsOpen(true); + setEnrollmentAPIKeys([]); + return; + } + + async function fetchEnrollmentAPIKeys() { + try { + const res = await sendGetEnrollmentAPIKeys({ + page: 1, + perPage: SO_SEARCH_LIMIT, + }); + if (res.error) { + throw res.error; + } + + if (!res.data) { + throw new Error('No data while fetching enrollment API keys'); + } + + setEnrollmentAPIKeys( + res.data.list.filter((key) => key.policy_id === agentPolicyId && key.active === true) + ); + } catch (error) { + notifications.toasts.addError(error, { + title: 'Error', + }); + } + } + fetchEnrollmentAPIKeys(); + }, + [agentPolicyId, notifications.toasts] + ); + + useEffect( + function useDefaultEnrollmentKeyForAgentPolicyEffect() { + if ( + !selectedEnrollmentApiKey && + enrollmentAPIKeys.length > 0 && + enrollmentAPIKeys[0].policy_id === agentPolicyId + ) { + const enrollmentAPIKeyId = enrollmentAPIKeys[0].id; + setSelectedEnrollmentApiKey(enrollmentAPIKeyId); + } + }, + [enrollmentAPIKeys, selectedEnrollmentApiKey, agentPolicyId] + ); + return ( + <> + setIsAuthenticationSettingsOpen(!isAuthenticationSettingsOpen)} + > + + + {isAuthenticationSettingsOpen && ( + <> + + {enrollmentAPIKeys.length && selectedEnrollmentApiKey ? ( + ({ + value: key.id, + text: key.name, + }))} + value={selectedEnrollmentApiKey || undefined} + prepend={ + + + + } + onChange={(e) => { + setSelectedEnrollmentApiKey(e.target.value); + }} + /> + ) : ( + +
+ +
+ + + + +
+ )} + + )} + + ); +}; diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.mocks.ts b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.mocks.ts new file mode 100644 index 00000000000000..f1055e7e2583ee --- /dev/null +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.mocks.ts @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +jest.mock('../../hooks/use_request', () => { + const module = jest.requireActual('../../hooks/use_request'); + return { + ...module, + useGetSettings: jest.fn(), + sendGetFleetStatus: jest.fn(), + }; +}); + +jest.mock( + '../../applications/fleet/sections/agents/agent_requirements_page/fleet_server_requirement_page', + () => { + const module = jest.requireActual( + '../../applications/fleet/sections/agents/agent_requirements_page/fleet_server_requirement_page' + ); + return { + ...module, + FleetServerRequirementPage: jest.fn(), + useFleetServerInstructions: jest.fn(), + }; + } +); + +/** + * These steps functions use hooks inside useMemo which is not compatible with jest currently + */ +jest.mock('./steps', () => { + const module = jest.requireActual('./steps'); + return { + ...module, + AgentPolicySelectionStep: jest.fn(), + AgentEnrollmentKeySelectionStep: jest.fn(), + }; +}); + +jest.mock('@elastic/eui', () => { + const module = jest.requireActual('@elastic/eui'); + return { + ...module, + EuiSteps: 'eui-steps', + }; +}); diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx new file mode 100644 index 00000000000000..db9245b11b0f99 --- /dev/null +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx @@ -0,0 +1,164 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import './agent_enrollment_flyout.test.mocks'; + +import React from 'react'; +import { registerTestBed } from '@kbn/test/jest'; +import { act } from '@testing-library/react'; + +import { coreMock } from 'src/core/public/mocks'; + +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; + +import type { AgentPolicy } from '../../../common'; +import { useGetSettings, sendGetFleetStatus } from '../../hooks/use_request'; +import { FleetStatusProvider, ConfigContext } from '../../hooks'; + +import { useFleetServerInstructions } from '../../applications/fleet/sections/agents/agent_requirements_page'; + +import { AgentEnrollmentKeySelectionStep, AgentPolicySelectionStep } from './steps'; + +import type { Props } from '.'; +import { AgentEnrollmentFlyout } from '.'; + +const TestComponent = (props: Props) => ( + + + + + + + +); + +const setup = async (props?: Props) => { + const testBed = await registerTestBed(TestComponent)(props); + const { find, component } = testBed; + + return { + ...testBed, + actions: { + goToStandaloneTab: () => + act(() => { + find('agentEnrollmentFlyout.standaloneTab').simulate('click'); + component.update(); + }), + }, + }; +}; + +type SetupReturn = ReturnType; +type TestBed = SetupReturn extends Promise ? U : SetupReturn; + +const testAgentPolicy: AgentPolicy = { + id: 'test', + is_managed: false, + namespace: 'test', + package_policies: [], + revision: 1, + status: 'active', + updated_at: 'test', + updated_by: 'test', + name: 'test', +}; + +describe('', () => { + let testBed: TestBed; + + beforeEach(async () => { + (useGetSettings as jest.Mock).mockReturnValue({ + data: { item: { fleet_server_hosts: ['test'] } }, + }); + + (sendGetFleetStatus as jest.Mock).mockResolvedValue({ + data: { isReady: true }, + }); + + (useFleetServerInstructions as jest.Mock).mockReturnValue({ + serviceToken: 'test', + getServiceToken: jest.fn(), + isLoadingServiceToken: false, + installCommand: jest.fn(), + platform: 'test', + setPlatform: jest.fn(), + }); + + await act(async () => { + testBed = await setup({ + agentPolicies: [], + onClose: jest.fn(), + }); + testBed.component.update(); + }); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + describe('managed instructions', () => { + it('uses the agent policy selection step', async () => { + const { exists } = testBed; + expect(exists('agentEnrollmentFlyout')).toBe(true); + expect(AgentPolicySelectionStep).toHaveBeenCalled(); + expect(AgentEnrollmentKeySelectionStep).not.toHaveBeenCalled(); + }); + + describe('with a specific policy', () => { + beforeEach(async () => { + jest.clearAllMocks(); + await act(async () => { + testBed = await setup({ + agentPolicy: testAgentPolicy, + onClose: jest.fn(), + }); + testBed.component.update(); + }); + }); + + it('uses the configure enrollment step, not the agent policy selection step', () => { + const { exists } = testBed; + expect(exists('agentEnrollmentFlyout')).toBe(true); + expect(AgentPolicySelectionStep).not.toHaveBeenCalled(); + expect(AgentEnrollmentKeySelectionStep).toHaveBeenCalled(); + }); + }); + }); + + describe('standalone instructions', () => { + it('uses the agent policy selection step', async () => { + const { exists, actions } = testBed; + actions.goToStandaloneTab(); + expect(exists('agentEnrollmentFlyout')).toBe(true); + expect(AgentPolicySelectionStep).toHaveBeenCalled(); + expect(AgentEnrollmentKeySelectionStep).not.toHaveBeenCalled(); + }); + + describe('with a specific policy', () => { + beforeEach(async () => { + jest.clearAllMocks(); + await act(async () => { + testBed = await setup({ + agentPolicy: testAgentPolicy, + onClose: jest.fn(), + }); + testBed.component.update(); + }); + }); + + it('does not use either of the agent policy selection or enrollment key steps', () => { + const { exists, actions } = testBed; + jest.clearAllMocks(); + expect(exists('agentEnrollmentFlyout')).toBe(true); + actions.goToStandaloneTab(); + expect(AgentPolicySelectionStep).not.toHaveBeenCalled(); + expect(AgentEnrollmentKeySelectionStep).not.toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_selection.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_selection.tsx new file mode 100644 index 00000000000000..f92b2d48259351 --- /dev/null +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_policy_selection.tsx @@ -0,0 +1,117 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useState, useEffect } from 'react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiSelect, EuiSpacer, EuiText } from '@elastic/eui'; + +import type { AgentPolicy } from '../../types'; +import { AgentPolicyPackageBadges } from '../agent_policy_package_badges'; + +import { AdvancedAgentAuthenticationSettings } from './advanced_agent_authentication_settings'; + +type Props = { + agentPolicies?: AgentPolicy[]; + onAgentPolicyChange?: (key?: string) => void; + excludeFleetServer?: boolean; +} & ( + | { + withKeySelection: true; + onKeyChange?: (key?: string) => void; + } + | { + withKeySelection: false; + } +); + +const resolveAgentId = ( + agentPolicies?: AgentPolicy[], + selectedAgentId?: string +): undefined | string => { + if (agentPolicies && agentPolicies.length && !selectedAgentId) { + if (agentPolicies.length === 1) { + return agentPolicies[0].id; + } + + const defaultAgentPolicy = agentPolicies.find((agentPolicy) => agentPolicy.is_default); + if (defaultAgentPolicy) { + return defaultAgentPolicy.id; + } + } + + return selectedAgentId; +}; + +export const EnrollmentStepAgentPolicy: React.FC = (props) => { + const { withKeySelection, agentPolicies, onAgentPolicyChange, excludeFleetServer } = props; + const onKeyChange = props.withKeySelection && props.onKeyChange; + const [selectedAgentId, setSelectedAgentId] = useState( + () => resolveAgentId(agentPolicies, undefined) // no agent id selected yet + ); + + useEffect( + function triggerOnAgentPolicyChangeEffect() { + if (onAgentPolicyChange) { + onAgentPolicyChange(selectedAgentId); + } + }, + [selectedAgentId, onAgentPolicyChange] + ); + + useEffect( + function useDefaultAgentPolicyEffect() { + const resolvedId = resolveAgentId(agentPolicies, selectedAgentId); + if (resolvedId !== selectedAgentId) { + setSelectedAgentId(resolvedId); + } + }, + [agentPolicies, selectedAgentId] + ); + + return ( + <> + + + + } + isLoading={!agentPolicies} + options={(agentPolicies || []).map((agentPolicy) => ({ + value: agentPolicy.id, + text: agentPolicy.name, + }))} + value={selectedAgentId || undefined} + onChange={(e) => setSelectedAgentId(e.target.value)} + aria-label={i18n.translate('xpack.fleet.enrollmentStepAgentPolicy.policySelectAriaLabel', { + defaultMessage: 'Agent policy', + })} + /> + + {selectedAgentId && ( + + )} + {withKeySelection && onKeyChange && ( + <> + + + + )} + + ); +}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/index.tsx similarity index 55% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx rename to x-pack/plugins/fleet/public/components/agent_enrollment_flyout/index.tsx index 1aa88dcef4adc1..b91af80691033e 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/index.tsx +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/index.tsx @@ -16,72 +16,31 @@ import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, - EuiButton, EuiFlyoutFooter, EuiTab, EuiTabs, - EuiCallOut, - EuiLink, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; -import { useGetSettings, useUrlModal } from '../../../../hooks'; -import type { AgentPolicy } from '../../../../types'; +import { useGetSettings, useUrlModal } from '../../hooks'; import { ManagedInstructions } from './managed_instructions'; import { StandaloneInstructions } from './standalone_instructions'; +import { MissingFleetServerHostCallout } from './missing_fleet_server_host_callout'; +import type { BaseProps } from './types'; -interface Props { +export interface Props extends BaseProps { onClose: () => void; - agentPolicies?: AgentPolicy[]; } -const MissingFleetServerHostCallout: React.FunctionComponent = () => { - const { setModal } = useUrlModal(); - return ( - - - - - ), - }} - /> - - { - setModal('settings'); - }} - > - - - - ); -}; +export * from './agent_policy_selection'; +export * from './managed_instructions'; +export * from './standalone_instructions'; +export * from './steps'; export const AgentEnrollmentFlyout: React.FunctionComponent = ({ onClose, + agentPolicy, agentPolicies, }) => { const [mode, setMode] = useState<'managed' | 'standalone'>('managed'); @@ -100,7 +59,7 @@ export const AgentEnrollmentFlyout: React.FunctionComponent = ({ }, [modal, lastModal, settings]); return ( - +

@@ -119,13 +78,21 @@ export const AgentEnrollmentFlyout: React.FunctionComponent = ({ - setMode('managed')}> + setMode('managed')} + > - setMode('standalone')}> + setMode('standalone')} + > = ({ } > {fleetServerHosts.length === 0 && mode === 'managed' ? null : mode === 'managed' ? ( - + ) : ( - + )} - + - + - - - - - diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/managed_instructions.tsx similarity index 80% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx rename to x-pack/plugins/fleet/public/components/agent_enrollment_flyout/managed_instructions.tsx index df1630abfab476..2bb8586a11503d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/managed_instructions.tsx +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/managed_instructions.tsx @@ -11,28 +11,20 @@ import type { EuiContainedStepProps } from '@elastic/eui/src/components/steps/st import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { AgentPolicy } from '../../../../types'; -import { - useGetOneEnrollmentAPIKey, - useGetSettings, - useLink, - useFleetStatus, -} from '../../../../hooks'; -import { NewEnrollmentTokenModal } from '../../enrollment_token_list_page/components/new_enrollment_key_modal'; +import { useGetOneEnrollmentAPIKey, useGetSettings, useLink, useFleetStatus } from '../../hooks'; -import { ManualInstructions } from '../../../../components/enrollment_instructions'; +import { ManualInstructions } from '../../components/enrollment_instructions'; import { FleetServerRequirementPage, ServiceTokenStep, FleetServerCommandStep, useFleetServerInstructions, -} from '../../agent_requirements_page'; +} from '../../applications/fleet/sections/agents/agent_requirements_page'; -import { DownloadStep, AgentPolicySelectionStep } from './steps'; +import { DownloadStep, AgentPolicySelectionStep, AgentEnrollmentKeySelectionStep } from './steps'; +import type { BaseProps } from './types'; -interface Props { - agentPolicies?: AgentPolicy[]; -} +type Props = BaseProps; const DefaultMissingRequirements = () => { const { getHref } = useLink(); @@ -61,7 +53,7 @@ const FleetServerMissingRequirements = () => { return ; }; -export const ManagedInstructions = React.memo(({ agentPolicies }) => { +export const ManagedInstructions = React.memo(({ agentPolicy, agentPolicies }) => { const fleetStatus = useFleetStatus(); const [selectedAPIKeyId, setSelectedAPIKeyId] = useState(); @@ -83,11 +75,13 @@ export const ManagedInstructions = React.memo(({ agentPolicies }) => { const fleetServerHosts = settings.data?.item?.fleet_server_hosts || []; const baseSteps: EuiContainedStepProps[] = [ DownloadStep(), - AgentPolicySelectionStep({ - agentPolicies, - setSelectedAPIKeyId, - setIsFleetServerPolicySelected, - }), + !agentPolicy + ? AgentPolicySelectionStep({ + agentPolicies, + setSelectedAPIKeyId, + setIsFleetServerPolicySelected, + }) + : AgentEnrollmentKeySelectionStep({ agentPolicy, setSelectedAPIKeyId }), ]; if (isFleetServerPolicySelected) { baseSteps.push( @@ -108,6 +102,7 @@ export const ManagedInstructions = React.memo(({ agentPolicies }) => { } return baseSteps; }, [ + agentPolicy, agentPolicies, selectedAPIKeyId, apiKey.data, @@ -116,11 +111,6 @@ export const ManagedInstructions = React.memo(({ agentPolicies }) => { fleetServerInstructions, ]); - const [isModalOpen, setModalOpen] = useState(false); - const closeModal = () => { - setModalOpen(false); - }; - return ( <> {fleetStatus.isReady ? ( @@ -133,10 +123,6 @@ export const ManagedInstructions = React.memo(({ agentPolicies }) => { - - {isModalOpen && ( - - )} ) : fleetStatus.missingRequirements?.length === 1 && fleetStatus.missingRequirements[0] === 'fleet_server' ? ( diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/missing_fleet_server_host_callout.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/missing_fleet_server_host_callout.tsx new file mode 100644 index 00000000000000..636032552a1ae8 --- /dev/null +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/missing_fleet_server_host_callout.tsx @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiCallOut, EuiLink, EuiButton, EuiSpacer } from '@elastic/eui'; + +import { useUrlModal } from '../../hooks'; + +export const MissingFleetServerHostCallout: React.FunctionComponent = () => { + const { setModal } = useUrlModal(); + return ( + + + + + ), + }} + /> + + { + setModal('settings'); + }} + > + + + + ); +}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/standalone_instructions.tsx similarity index 94% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx rename to x-pack/plugins/fleet/public/components/agent_enrollment_flyout/standalone_instructions.tsx index 1d830b2c578b10..59898b9190c00d 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/standalone_instructions.tsx +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/standalone_instructions.tsx @@ -22,24 +22,22 @@ import type { EuiContainedStepProps } from '@elastic/eui/src/components/steps/st import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import type { AgentPolicy } from '../../../../types'; -import { useStartServices, useLink, sendGetOneAgentPolicyFull } from '../../../../hooks'; -import { fullAgentPolicyToYaml, agentPolicyRouteService } from '../../../../services'; +import { useStartServices, useLink, sendGetOneAgentPolicyFull } from '../../hooks'; +import { fullAgentPolicyToYaml, agentPolicyRouteService } from '../../services'; import { DownloadStep, AgentPolicySelectionStep } from './steps'; +import type { BaseProps } from './types'; -interface Props { - agentPolicies?: AgentPolicy[]; -} +type Props = BaseProps; const RUN_INSTRUCTIONS = './elastic-agent install'; -export const StandaloneInstructions = React.memo(({ agentPolicies }) => { +export const StandaloneInstructions = React.memo(({ agentPolicy, agentPolicies }) => { const { getHref } = useLink(); const core = useStartServices(); const { notifications } = core; - const [selectedPolicyId, setSelectedPolicyId] = useState(); + const [selectedPolicyId, setSelectedPolicyId] = useState(agentPolicy?.id); const [fullAgentPolicy, setFullAgentPolicy] = useState(); const downloadLink = selectedPolicyId @@ -74,9 +72,11 @@ export const StandaloneInstructions = React.memo(({ agentPolicies }) => { }, [selectedPolicyId, notifications.toasts]); const yaml = useMemo(() => fullAgentPolicyToYaml(fullAgentPolicy), [fullAgentPolicy]); - const steps: EuiContainedStepProps[] = [ + const steps = [ DownloadStep(), - AgentPolicySelectionStep({ agentPolicies, setSelectedPolicyId, excludeFleetServer: true }), + !agentPolicy + ? AgentPolicySelectionStep({ agentPolicies, setSelectedPolicyId, excludeFleetServer: true }) + : undefined, { title: i18n.translate('xpack.fleet.agentEnrollment.stepConfigureAgentTitle', { defaultMessage: 'Configure the agent', @@ -178,7 +178,7 @@ export const StandaloneInstructions = React.memo(({ agentPolicies }) => { ), }, - ]; + ].filter(Boolean) as EuiContainedStepProps[]; return ( <> diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps.tsx similarity index 65% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx rename to x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps.tsx index 8ba0098b3d2778..ea4fa626afbb6a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_enrollment_flyout/steps.tsx +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/steps.tsx @@ -5,16 +5,17 @@ * 2.0. */ -import React, { useCallback } from 'react'; +import React, { useCallback, useMemo } from 'react'; import { EuiText, EuiButton, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import type { AgentPolicy, PackagePolicy } from '../../../../types'; -import { sendGetOneAgentPolicy } from '../../../../hooks'; -import { FLEET_SERVER_PACKAGE } from '../../../../constants'; +import type { AgentPolicy, PackagePolicy } from '../../types'; +import { sendGetOneAgentPolicy } from '../../hooks'; +import { FLEET_SERVER_PACKAGE } from '../../constants'; import { EnrollmentStepAgentPolicy } from './agent_policy_selection'; +import { AdvancedAgentAuthenticationSettings } from './advanced_agent_authentication_settings'; export const DownloadStep = () => { return { @@ -59,12 +60,14 @@ export const AgentPolicySelectionStep = ({ setIsFleetServerPolicySelected?: (selected: boolean) => void; excludeFleetServer?: boolean; }) => { - const regularAgentPolicies = Array.isArray(agentPolicies) - ? agentPolicies.filter( - (policy) => - policy && !policy.is_managed && (!excludeFleetServer || !policy.is_default_fleet_server) - ) - : []; + const regularAgentPolicies = useMemo(() => { + return Array.isArray(agentPolicies) + ? agentPolicies.filter( + (policy) => + policy && !policy.is_managed && (!excludeFleetServer || !policy.is_default_fleet_server) + ) + : []; + }, [agentPolicies, excludeFleetServer]); const onAgentPolicyChange = useCallback( async (policyId?: string) => { @@ -103,3 +106,35 @@ export const AgentPolicySelectionStep = ({ ), }; }; + +export const AgentEnrollmentKeySelectionStep = ({ + agentPolicy, + setSelectedAPIKeyId, +}: { + agentPolicy: AgentPolicy; + setSelectedAPIKeyId: (key?: string) => void; +}) => { + return { + title: i18n.translate('xpack.fleet.agentEnrollment.stepConfigurePolicyAuthenticationTitle', { + defaultMessage: 'Configure agent authentication', + }), + children: ( + <> + + {agentPolicy.name}, + }} + /> + + + + + ), + }; +}; diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/types.ts b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/types.ts new file mode 100644 index 00000000000000..b9bcf8fb3e4b27 --- /dev/null +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/types.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { AgentPolicy } from '../../types'; + +export interface BaseProps { + /** + * The user selected policy to be used + */ + agentPolicy?: AgentPolicy; + + /** + * A selection of policies for the user to choose from, will be ignored if `agentPolicy` has been provided + */ + agentPolicies?: AgentPolicy[]; +} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx b/x-pack/plugins/fleet/public/components/agent_policy_package_badges.tsx similarity index 94% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx rename to x-pack/plugins/fleet/public/components/agent_policy_package_badges.tsx index 605888349ab4ec..418e274022461b 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_policy_package_badges.tsx +++ b/x-pack/plugins/fleet/public/components/agent_policy_package_badges.tsx @@ -10,11 +10,11 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSpacer, EuiText, EuiFlexGroup, EuiFlexItem, EuiBadge, EuiCallOut } from '@elastic/eui'; -import { FLEET_SERVER_PACKAGE } from '../../../../../../common/constants'; +import { FLEET_SERVER_PACKAGE } from '../../common/constants'; -import type { PackagePolicy, PackagePolicyPackage } from '../../../types'; -import { useGetOneAgentPolicy } from '../../../hooks'; -import { PackageIcon } from '../../../components'; +import type { PackagePolicy, PackagePolicyPackage } from '../types'; +import { useGetOneAgentPolicy } from '../hooks'; +import { PackageIcon } from '../components'; interface Props { agentPolicyId: string; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/danger_eui_context_menu_item.tsx b/x-pack/plugins/fleet/public/components/danger_eui_context_menu_item.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/danger_eui_context_menu_item.tsx rename to x-pack/plugins/fleet/public/components/danger_eui_context_menu_item.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/index.tsx b/x-pack/plugins/fleet/public/components/enrollment_instructions/index.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/index.tsx rename to x-pack/plugins/fleet/public/components/enrollment_instructions/index.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx b/x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx similarity index 95% rename from x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx rename to x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx index c9f011c59504be..f746a1c9144607 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/enrollment_instructions/manual/index.tsx +++ b/x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx @@ -12,8 +12,8 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import type { EnrollmentAPIKey } from '../../../types'; -import { PLATFORM_OPTIONS, usePlatform } from '../../../sections/agents/hooks/use_platform'; -import type { PLATFORM_TYPE } from '../../../sections/agents/hooks/use_platform'; +import { PLATFORM_OPTIONS, usePlatform } from '../../../hooks'; +import type { PLATFORM_TYPE } from '../../../hooks'; interface Props { fleetServerHosts: string[]; diff --git a/x-pack/plugins/fleet/public/components/index.ts b/x-pack/plugins/fleet/public/components/index.ts index 6db18c0e73a141..d054b96ccb4c62 100644 --- a/x-pack/plugins/fleet/public/components/index.ts +++ b/x-pack/plugins/fleet/public/components/index.ts @@ -13,5 +13,11 @@ export { ExtensionWrapper } from './extension_wrapper'; export { AlphaMessaging } from './alpha_messaging'; export { AlphaFlyout } from './alpha_flyout'; export { HeaderProps, Header } from './header'; +export { NewEnrollmentTokenModal } from './new_enrollment_key_modal'; +export { AgentPolicyPackageBadges } from './agent_policy_package_badges'; +export { DangerEuiContextMenuItem } from './danger_eui_context_menu_item'; +export { PackagePolicyDeleteProvider } from './package_policy_delete_provider'; +export { PackagePolicyActionsMenu } from './package_policy_actions_menu'; export * from './link_and_revision'; export * from './settings_flyout'; +export * from './agent_enrollment_flyout'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_modal.tsx b/x-pack/plugins/fleet/public/components/new_enrollment_key_modal.tsx similarity index 97% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_modal.tsx rename to x-pack/plugins/fleet/public/components/new_enrollment_key_modal.tsx index 29e130f5583ab5..0752c1ab348893 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/enrollment_token_list_page/components/new_enrollment_key_modal.tsx +++ b/x-pack/plugins/fleet/public/components/new_enrollment_key_modal.tsx @@ -9,8 +9,8 @@ import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiConfirmModal, EuiForm, EuiFormRow, EuiFieldText, EuiSelect } from '@elastic/eui'; -import type { AgentPolicy, EnrollmentAPIKey } from '../../../../types'; -import { useInput, useStartServices, sendCreateEnrollmentAPIKey } from '../../../../hooks'; +import type { AgentPolicy, EnrollmentAPIKey } from '../types'; +import { useInput, useStartServices, sendCreateEnrollmentAPIKey } from '../hooks'; function useCreateApiKeyForm( policyIdDefaultValue: string | undefined, diff --git a/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx b/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx new file mode 100644 index 00000000000000..03bf2095f7f3e0 --- /dev/null +++ b/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx @@ -0,0 +1,112 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useMemo, useState } from 'react'; +import { EuiContextMenuItem, EuiPortal } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; + +import type { AgentPolicy, PackagePolicy } from '../types'; + +import { useAgentPolicyRefresh, useCapabilities, useLink } from '../hooks'; + +import { AgentEnrollmentFlyout } from './agent_enrollment_flyout'; +import { ContextMenuActions } from './context_menu_actions'; +import { DangerEuiContextMenuItem } from './danger_eui_context_menu_item'; +import { PackagePolicyDeleteProvider } from './package_policy_delete_provider'; + +export const PackagePolicyActionsMenu: React.FunctionComponent<{ + agentPolicy: AgentPolicy; + packagePolicy: PackagePolicy; +}> = ({ agentPolicy, packagePolicy }) => { + const [isEnrollmentFlyoutOpen, setIsEnrollmentFlyoutOpen] = useState(false); + const { getHref } = useLink(); + const hasWriteCapabilities = useCapabilities().write; + const refreshAgentPolicy = useAgentPolicyRefresh(); + + const onEnrollmentFlyoutClose = useMemo(() => { + return () => setIsEnrollmentFlyoutOpen(false); + }, []); + + const menuItems = [ + // FIXME: implement View package policy action + // {}} + // key="packagePolicyView" + // > + // + // , + setIsEnrollmentFlyoutOpen(true)} + key="addAgent" + > + + , + + + , + // FIXME: implement Copy package policy action + // {}} key="packagePolicyCopy"> + // + // , + ]; + + if (!agentPolicy.is_managed) { + menuItems.push( + + {(deletePackagePoliciesPrompt) => { + return ( + { + deletePackagePoliciesPrompt([packagePolicy.id], refreshAgentPolicy); + }} + > + + + ); + }} + + ); + } + return ( + <> + {isEnrollmentFlyoutOpen && ( + + + + )} + + + ); +}; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx b/x-pack/plugins/fleet/public/components/package_policy_delete_provider.tsx similarity index 98% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx rename to x-pack/plugins/fleet/public/components/package_policy_delete_provider.tsx index 198886e9b9c7ff..86f064405497b7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/package_policy_delete_provider.tsx +++ b/x-pack/plugins/fleet/public/components/package_policy_delete_provider.tsx @@ -10,9 +10,9 @@ import { EuiCallOut, EuiConfirmModal, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { useStartServices, sendRequest, sendDeletePackagePolicy, useConfig } from '../../../hooks'; -import { AGENT_API_ROUTES, AGENT_SAVED_OBJECT_TYPE } from '../../../constants'; -import type { AgentPolicy } from '../../../types'; +import { useStartServices, sendRequest, sendDeletePackagePolicy, useConfig } from '../hooks'; +import { AGENT_API_ROUTES, AGENT_SAVED_OBJECT_TYPE } from '../../common/constants'; +import type { AgentPolicy } from '../types'; interface Props { agentPolicy: AgentPolicy; diff --git a/x-pack/plugins/fleet/public/hooks/index.ts b/x-pack/plugins/fleet/public/hooks/index.ts index 0b413f72094d9d..9f41e5c7cc92b5 100644 --- a/x-pack/plugins/fleet/public/hooks/index.ts +++ b/x-pack/plugins/fleet/public/hooks/index.ts @@ -24,3 +24,5 @@ export * from './use_url_params'; export * from './use_fleet_status'; export * from './use_ui_extension'; export * from './use_intra_app_state'; +export * from './use_platform'; +export * from './use_agent_policy_refresh'; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/use_config.tsx b/x-pack/plugins/fleet/public/hooks/use_agent_policy_refresh.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/hooks/use_config.tsx rename to x-pack/plugins/fleet/public/hooks/use_agent_policy_refresh.tsx diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/hooks/use_platform.tsx b/x-pack/plugins/fleet/public/hooks/use_platform.tsx similarity index 100% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/hooks/use_platform.tsx rename to x-pack/plugins/fleet/public/hooks/use_platform.tsx diff --git a/x-pack/plugins/fleet/public/services/index.ts b/x-pack/plugins/fleet/public/services/index.ts index 4575efe9637056..fbd3bddde744b8 100644 --- a/x-pack/plugins/fleet/public/services/index.ts +++ b/x-pack/plugins/fleet/public/services/index.ts @@ -30,6 +30,14 @@ export { LicenseService, isAgentUpgradeable, doesPackageHaveIntegrations, + PackagePolicyValidationResults, + PackagePolicyConfigValidationResults, + PackagePolicyInputValidationResults, + validatePackagePolicy, + validatePackagePolicyConfig, + validationHasErrors, + countValidationErrors, + getStreamsForInputType, } from '../../common'; export * from './pkg_key_from_package_info'; diff --git a/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts b/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts index d861b211b88484..9616ba11545e0d 100644 --- a/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts +++ b/x-pack/plugins/fleet/server/collectors/fleet_server_collector.ts @@ -4,6 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ + +import { isBoom } from '@hapi/boom'; import type { SavedObjectsClient, ElasticsearchClient } from 'kibana/server'; import { packagePolicyService, settingsService } from '../services'; @@ -38,11 +40,18 @@ export const getFleetServerUsage = async ( return DEFAULT_USAGE; } - const numHostsUrls = - (await settingsService.getSettings(soClient)).fleet_server_hosts?.length ?? 0; + const numHostsUrls = await settingsService + .getSettings(soClient) + .then((settings) => settings.fleet_server_hosts?.length ?? 0) + .catch((err) => { + if (isBoom(error) && error.output.statusCode === 404) { + return 0; + } - // Find all policies with Fleet server than query agent status + throw err; + }); + // Find all policies with Fleet server than query agent status let hasMore = true; const policyIds = new Set(); let page = 1; diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index 10e5a6ac57f576..bd7bb98eb7c07c 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -235,6 +235,7 @@ const getSavedObjectTypes = ( enabled: false, properties: { type: { type: 'keyword' }, + policy_template: { type: 'keyword' }, enabled: { type: 'boolean' }, vars: { type: 'flattened' }, config: { type: 'flattened' }, diff --git a/x-pack/plugins/fleet/server/services/package_policy.test.ts b/x-pack/plugins/fleet/server/services/package_policy.test.ts index 46e5db3a958646..a6958ba88449a0 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.test.ts @@ -408,6 +408,11 @@ describe('Package policy service', () => { ], policy_templates: [ { + name: 'template_1', + inputs: [{ type: 'log', template_path: 'some_template_path.yml' }], + }, + { + name: 'template_2', inputs: [{ type: 'log', template_path: 'some_template_path.yml' }], }, ], @@ -416,6 +421,7 @@ describe('Package policy service', () => { [ { type: 'log', + policy_template: 'template_1', enabled: true, vars: { hosts: { @@ -433,12 +439,24 @@ describe('Package policy service', () => { }, ], }, + { + type: 'log', + policy_template: 'template_2', + enabled: true, + vars: { + hosts: { + value: ['localhost'], + }, + }, + streams: [], + }, ] ); expect(inputs).toEqual([ { type: 'log', + policy_template: 'template_1', enabled: true, vars: { hosts: { @@ -465,6 +483,20 @@ describe('Package policy service', () => { }, ], }, + { + type: 'log', + policy_template: 'template_2', + enabled: true, + vars: { + hosts: { + value: ['localhost'], + }, + }, + compiled_input: { + hosts: ['localhost'], + }, + streams: [], + }, ]); }); diff --git a/x-pack/plugins/fleet/server/services/package_policy.ts b/x-pack/plugins/fleet/server/services/package_policy.ts index 02f9731421ba04..93bcef458279c0 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.ts @@ -511,11 +511,17 @@ async function _compilePackagePolicyInput( vars: PackagePolicy['vars'], input: PackagePolicyInput ) { - if ((!input.enabled || !pkgInfo.policy_templates?.[0]?.inputs?.length) ?? 0 > 0) { + const packagePolicyTemplate = input.policy_template + ? pkgInfo.policy_templates?.find( + (policyTemplate) => policyTemplate.name === input.policy_template + ) + : pkgInfo.policy_templates?.[0]; + + if (!input.enabled || !packagePolicyTemplate || !packagePolicyTemplate.inputs?.length) { return undefined; } - const packageInputs = pkgInfo.policy_templates[0].inputs; + const packageInputs = packagePolicyTemplate.inputs; const packageInput = packageInputs.find((pkgInput) => pkgInput.type === input.type); if (!packageInput) { throw new Error(`Input template not found, unable to find input type ${input.type}`); diff --git a/x-pack/plugins/fleet/server/types/models/package_policy.ts b/x-pack/plugins/fleet/server/types/models/package_policy.ts index 3735cfffeaa715..e69e38c1872846 100644 --- a/x-pack/plugins/fleet/server/types/models/package_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/package_policy.ts @@ -45,6 +45,7 @@ const PackagePolicyBaseSchema = { inputs: schema.arrayOf( schema.object({ type: schema.string(), + policy_template: schema.maybe(schema.string()), enabled: schema.boolean(), keep_enabled: schema.maybe(schema.boolean()), vars: schema.maybe(ConfigRecordSchema), diff --git a/x-pack/plugins/lens/public/app_plugin/app.tsx b/x-pack/plugins/lens/public/app_plugin/app.tsx index 61ed2934a40011..a439a3b5788fb8 100644 --- a/x-pack/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/plugins/lens/public/app_plugin/app.tsx @@ -351,7 +351,7 @@ export function App({ return ( <> -
+
{ - if (!activeData) { - return; - } - const datatables = Object.values(activeData); - const content = datatables.reduce>( - (memo, datatable, i) => { - // skip empty datatables - if (datatable) { - const postFix = datatables.length > 1 ? `-${i + 1}` : ''; + const topNavConfig = useMemo( + () => + getLensTopNavConfig({ + showSaveAndReturn: Boolean( + isLinkedToOriginatingApp && + // Temporarily required until the 'by value' paradigm is default. + (dashboardFeatureFlag.allowByValueEmbeddables || Boolean(initialInput)) + ), + enableExportToCSV: Boolean(isSaveable && activeData && Object.keys(activeData).length), + isByValueMode: getIsByValueMode(), + allowByValue: dashboardFeatureFlag.allowByValueEmbeddables, + showCancel: Boolean(isLinkedToOriginatingApp), + savingToLibraryPermitted, + savingToDashboardPermitted, + actions: { + exportToCSV: () => { + if (!activeData) { + return; + } + const datatables = Object.values(activeData); + const content = datatables.reduce>( + (memo, datatable, i) => { + // skip empty datatables + if (datatable) { + const postFix = datatables.length > 1 ? `-${i + 1}` : ''; - memo[`${lastKnownDoc?.title || unsavedTitle}${postFix}.csv`] = { - content: exporters.datatableToCSV(datatable, { - csvSeparator: uiSettings.get('csv:separator', ','), - quoteValues: uiSettings.get('csv:quoteValues', true), - formatFactory: data.fieldFormats.deserialize, - }), - type: exporters.CSV_MIME_TYPE, - }; + memo[`${lastKnownDoc?.title || unsavedTitle}${postFix}.csv`] = { + content: exporters.datatableToCSV(datatable, { + csvSeparator: uiSettings.get('csv:separator', ','), + quoteValues: uiSettings.get('csv:quoteValues', true), + formatFactory: data.fieldFormats.deserialize, + }), + type: exporters.CSV_MIME_TYPE, + }; + } + return memo; + }, + {} + ); + if (content) { + downloadMultipleAs(content); } - return memo; }, - {} - ); - if (content) { - downloadMultipleAs(content); - } - }, - saveAndReturn: () => { - if (savingToDashboardPermitted && lastKnownDoc) { - // disabling the validation on app leave because the document has been saved. - onAppLeave((actions) => { - return actions.default(); - }); - runSave( - { - newTitle: lastKnownDoc.title, - newCopyOnSave: false, - isTitleDuplicateConfirmed: false, - returnToOrigin: true, - }, - { - saveToLibrary: - (initialInput && attributeService.inputIsRefType(initialInput)) ?? false, + saveAndReturn: () => { + if (savingToDashboardPermitted && lastKnownDoc) { + // disabling the validation on app leave because the document has been saved. + onAppLeave((actions) => { + return actions.default(); + }); + runSave( + { + newTitle: lastKnownDoc.title, + newCopyOnSave: false, + isTitleDuplicateConfirmed: false, + returnToOrigin: true, + }, + { + saveToLibrary: + (initialInput && attributeService.inputIsRefType(initialInput)) ?? false, + } + ); } - ); - } - }, - showSaveModal: () => { - if (savingToDashboardPermitted || savingToLibraryPermitted) { - setIsSaveModalVisible(true); - } - }, - cancel: () => { - if (redirectToOrigin) { - redirectToOrigin(); + }, + showSaveModal: () => { + if (savingToDashboardPermitted || savingToLibraryPermitted) { + setIsSaveModalVisible(true); + } + }, + cancel: () => { + if (redirectToOrigin) { + redirectToOrigin(); + } + }, + }, + }), + [ + activeData, + attributeService, + dashboardFeatureFlag.allowByValueEmbeddables, + data.fieldFormats.deserialize, + getIsByValueMode, + initialInput, + isLinkedToOriginatingApp, + isSaveable, + lastKnownDoc, + onAppLeave, + redirectToOrigin, + runSave, + savingToDashboardPermitted, + savingToLibraryPermitted, + setIsSaveModalVisible, + uiSettings, + unsavedTitle, + ] + ); + + const onQuerySubmitWrapped = useCallback( + (payload) => { + const { dateRange, query: newQuery } = payload; + const currentRange = data.query.timefilter.timefilter.getTime(); + if (dateRange.from !== currentRange.from || dateRange.to !== currentRange.to) { + data.query.timefilter.timefilter.setTime(dateRange); + trackUiEvent('app_date_change'); + } else { + // Query has changed, renew the session id. + // Time change will be picked up by the time subscription + dispatchSetState({ searchSessionId: data.search.session.start() }); + trackUiEvent('app_query_change'); + } + if (newQuery) { + if (!isEqual(newQuery, query)) { + dispatchSetState({ query: newQuery }); } - }, + } }, - }); + [data.query.timefilter.timefilter, data.search.session, dispatchSetState, query] + ); + + const onSavedWrapped = useCallback( + (newSavedQuery) => { + dispatchSetState({ savedQuery: newSavedQuery }); + }, + [dispatchSetState] + ); + + const onSavedQueryUpdatedWrapped = useCallback( + (newSavedQuery) => { + const savedQueryFilters = newSavedQuery.attributes.filters || []; + const globalFilters = data.query.filterManager.getGlobalFilters(); + data.query.filterManager.setFilters([...globalFilters, ...savedQueryFilters]); + dispatchSetState({ + query: newSavedQuery.attributes.query, + savedQuery: { ...newSavedQuery }, + }); // Shallow query for reference issues + }, + [data.query.filterManager, dispatchSetState] + ); + + const onClearSavedQueryWrapped = useCallback(() => { + data.query.filterManager.setFilters(data.query.filterManager.getGlobalFilters()); + dispatchSetState({ + filters: data.query.filterManager.getGlobalFilters(), + query: data.query.queryString.getDefaultQuery(), + savedQuery: undefined, + }); + }, [data.query.filterManager, data.query.queryString, dispatchSetState]); return ( { - const { dateRange, query: newQuery } = payload; - const currentRange = data.query.timefilter.timefilter.getTime(); - if (dateRange.from !== currentRange.from || dateRange.to !== currentRange.to) { - data.query.timefilter.timefilter.setTime(dateRange); - trackUiEvent('app_date_change'); - } else { - // Query has changed, renew the session id. - // Time change will be picked up by the time subscription - dispatchSetState({ searchSessionId: data.search.session.start() }); - trackUiEvent('app_query_change'); - } - if (newQuery) { - if (!isEqual(newQuery, query)) { - dispatchSetState({ query: newQuery }); - } - } - }} - onSaved={(newSavedQuery) => { - dispatchSetState({ savedQuery: newSavedQuery }); - }} - onSavedQueryUpdated={(newSavedQuery) => { - const savedQueryFilters = newSavedQuery.attributes.filters || []; - const globalFilters = data.query.filterManager.getGlobalFilters(); - data.query.filterManager.setFilters([...globalFilters, ...savedQueryFilters]); - dispatchSetState({ - query: newSavedQuery.attributes.query, - savedQuery: { ...newSavedQuery }, - }); // Shallow query for reference issues - }} - onClearSavedQuery={() => { - data.query.filterManager.setFilters(data.query.filterManager.getGlobalFilters()); - dispatchSetState({ - filters: data.query.filterManager.getGlobalFilters(), - query: data.query.queryString.getDefaultQuery(), - savedQuery: undefined, - }); - }} + onQuerySubmit={onQuerySubmitWrapped} + onSaved={onSavedWrapped} + onSavedQueryUpdated={onSavedQueryUpdatedWrapped} + onClearSavedQuery={onClearSavedQueryWrapped} indexPatterns={indexPatternsForTopNav} query={query} dateRangeFrom={from} diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx index 67255dc8a953ea..aa8c6ffb26d170 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx @@ -192,5 +192,16 @@ describe('datatable cell renderer', () => { style: expect.objectContaining({ color: 'blue' }), }); }); + + it('should not color the cell when the value is an array', async () => { + const columnConfig = getColumnConfiguration(); + columnConfig.columns[0].colorMode = 'cell'; + + const { setCellProps } = await renderCellComponent(columnConfig, { + table: { ...table, rows: [{ a: [10, 123] }] }, + }); + + expect(setCellProps).not.toHaveBeenCalled(); + }); }); }); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx index a6c50f00cb77fd..14b8c8a36b431c 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.tsx @@ -13,6 +13,7 @@ import type { DataContextType } from './types'; import { ColumnConfig } from './table_basic'; import { getContrastColor } from '../../shared_components/coloring/utils'; import { getOriginalId } from '../transpose_helpers'; +import { getNumericValue } from './shared_utils'; export const createGridCell = ( formatters: Record>, @@ -37,7 +38,11 @@ export const createGridCell = ( if (minMaxByColumnId?.[originalId]) { if (colorMode !== 'none' && palette?.params && getColorForValue) { // workout the bucket the value belongs to - const color = getColorForValue(rowValue, palette.params, minMaxByColumnId[originalId]); + const color = getColorForValue( + getNumericValue(rowValue), + palette.params, + minMaxByColumnId[originalId] + ); if (color) { const style = { [colorMode === 'cell' ? 'backgroundColor' : 'color']: color }; if (colorMode === 'cell' && color) { diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx index ba24da8309ed7c..5c53d40f999b77 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx @@ -51,7 +51,7 @@ export const createGridColumns = ( columnId, }: Pick) => { const rowValue = table.rows[rowIndex][columnId]; - const column = columnsReverseLookup[columnId]; + const column = columnsReverseLookup?.[columnId]; const contentsIsDefined = rowValue != null; const cellContent = formatFactory(column?.meta?.params).convert(rowValue); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/shared_utils.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/shared_utils.tsx index 92a949e65c67ea..815da92d9fca97 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/shared_utils.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/shared_utils.tsx @@ -8,6 +8,13 @@ import { Datatable } from 'src/plugins/expressions'; import { getOriginalId } from '../transpose_helpers'; +export function getNumericValue(rowValue: number | number[] | undefined) { + if (rowValue == null || Array.isArray(rowValue)) { + return; + } + return rowValue; +} + export const findMinMaxByColumnId = (columnIds: string[], table: Datatable | undefined) => { const minMax: Record = {}; @@ -17,12 +24,13 @@ export const findMinMaxByColumnId = (columnIds: string[], table: Datatable | und minMax[originalId] = minMax[originalId] || { max: -Infinity, min: Infinity }; table.rows.forEach((row) => { const rowValue = row[columnId]; - if (rowValue != null) { - if (minMax[originalId].min > rowValue) { - minMax[originalId].min = rowValue; + const numericValue = getNumericValue(rowValue); + if (numericValue != null) { + if (minMax[originalId].min > numericValue) { + minMax[originalId].min = numericValue; } - if (minMax[originalId].max < rowValue) { - minMax[originalId].max = rowValue; + if (minMax[originalId].max < numericValue) { + minMax[originalId].max = numericValue; } } }); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx index 3936fb9e1a1b12..1ec48f516bd32d 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx @@ -76,6 +76,8 @@ describe('ConfigPanel', () => { framePublicAPI: frame, dispatch: jest.fn(), core: coreMock.createStart(), + isFullscreen: false, + toggleFullscreen: jest.fn(), }; } @@ -119,19 +121,23 @@ describe('ConfigPanel', () => { expect(component.find(LayerPanel).exists()).toBe(false); }); - it('allow datasources and visualizations to use setters', () => { + it('allow datasources and visualizations to use setters', async () => { const props = getDefaultProps(); const component = mountWithIntl(); const { updateDatasource, updateAll } = component.find(LayerPanel).props(); const updater = () => 'updated'; updateDatasource('ds1', updater); + // wait for one tick so async updater has a chance to trigger + await new Promise((r) => setTimeout(r, 0)); expect(props.dispatch).toHaveBeenCalledTimes(1); expect(props.dispatch.mock.calls[0][0].updater(props.datasourceStates.ds1.state)).toEqual( 'updated' ); updateAll('ds1', updater, props.visualizationState); + // wait for one tick so async updater has a chance to trigger + await new Promise((r) => setTimeout(r, 0)); expect(props.dispatch).toHaveBeenCalledTimes(2); expect(props.dispatch.mock.calls[0][0].updater(props.datasourceStates.ds1.state)).toEqual( 'updated' diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx index c1ab2b4586ab33..81c044af532fbf 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx @@ -71,32 +71,54 @@ export function LayerPanels( }, [dispatch] ); + const updateDatasourceAsync = useMemo( + () => (datasourceId: string, newState: unknown) => { + // React will synchronously update if this is triggered from a third party component, + // which we don't want. The timeout lets user interaction have priority, then React updates. + setTimeout(() => { + updateDatasource(datasourceId, newState); + }, 0); + }, + [updateDatasource] + ); const updateAll = useMemo( () => (datasourceId: string, newDatasourceState: unknown, newVisualizationState: unknown) => { - dispatch({ - type: 'UPDATE_STATE', - subType: 'UPDATE_ALL_STATES', - updater: (prevState) => { - const updatedDatasourceState = - typeof newDatasourceState === 'function' - ? newDatasourceState(prevState.datasourceStates[datasourceId].state) - : newDatasourceState; - return { - ...prevState, - datasourceStates: { - ...prevState.datasourceStates, - [datasourceId]: { - state: updatedDatasourceState, - isLoading: false, + // React will synchronously update if this is triggered from a third party component, + // which we don't want. The timeout lets user interaction have priority, then React updates. + setTimeout(() => { + dispatch({ + type: 'UPDATE_STATE', + subType: 'UPDATE_ALL_STATES', + updater: (prevState) => { + const updatedDatasourceState = + typeof newDatasourceState === 'function' + ? newDatasourceState(prevState.datasourceStates[datasourceId].state) + : newDatasourceState; + return { + ...prevState, + datasourceStates: { + ...prevState.datasourceStates, + [datasourceId]: { + state: updatedDatasourceState, + isLoading: false, + }, + }, + visualization: { + ...prevState.visualization, + state: newVisualizationState, }, - }, - visualization: { - ...prevState.visualization, - state: newVisualizationState, - }, - stagedPreview: undefined, - }; - }, + stagedPreview: undefined, + }; + }, + }); + }, 0); + }, + [dispatch] + ); + const toggleFullscreen = useMemo( + () => () => { + dispatch({ + type: 'TOGGLE_FULLSCREEN', }); }, [dispatch] @@ -118,6 +140,7 @@ export function LayerPanels( visualizationState={visualizationState} updateVisualization={setVisualizationState} updateDatasource={updateDatasource} + updateDatasourceAsync={updateDatasourceAsync} updateAll={updateAll} isOnlyLayer={layerIds.length === 1} onRemoveLayer={() => { @@ -135,6 +158,7 @@ export function LayerPanels( }); removeLayerRef(layerId); }} + toggleFullscreen={toggleFullscreen} /> ) : null )} diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss index 91cd706ea77d11..135286fc2172bb 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss @@ -8,21 +8,36 @@ position: absolute; left: 0; animation: euiFlyout $euiAnimSpeedNormal $euiAnimSlightResistance; + @include euiBreakpoint('l', 'xl') { top: 0 !important; height: 100% !important; } + @include euiBreakpoint('xs', 's', 'm') { @include euiFlyout; } + + .lnsFrameLayout__sidebar-isFullscreen & { + border-left: $euiBorderThin; // Force border regardless of theme in fullscreen + box-shadow: none; + } } .lnsDimensionContainer__footer { padding: $euiSizeS; + + .lnsFrameLayout__sidebar-isFullscreen & { + display: none; + } } .lnsDimensionContainer__header { padding: $euiSizeS $euiSizeXS; + + .lnsFrameLayout__sidebar-isFullscreen & { + display: none; + } } .lnsDimensionContainer__headerTitle { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx index b14d391c2c9696..2f3eb5043d6106 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx @@ -29,26 +29,33 @@ export function DimensionContainer({ groupLabel, handleClose, panel, + isFullscreen, panelRef, }: { isOpen: boolean; - handleClose: () => void; - panel: React.ReactElement; + handleClose: () => boolean; + panel: React.ReactElement | null; groupLabel: string; + isFullscreen: boolean; panelRef: (el: HTMLDivElement) => void; }) { const [focusTrapIsEnabled, setFocusTrapIsEnabled] = useState(false); const closeFlyout = useCallback(() => { - handleClose(); - setFocusTrapIsEnabled(false); + const canClose = handleClose(); + if (canClose) { + setFocusTrapIsEnabled(false); + } + return canClose; }, [handleClose]); const closeOnEscape = useCallback( (event: KeyboardEvent) => { if (event.key === keys.ESCAPE) { - event.preventDefault(); - closeFlyout(); + const canClose = closeFlyout(); + if (canClose) { + event.preventDefault(); + } } }, [closeFlyout] @@ -69,7 +76,15 @@ export function DimensionContainer({
- + { + if (isFullscreen) { + return; + } + closeFlyout(); + }} + isDisabled={!isOpen} + >
{ visualizationState: 'state', updateVisualization: jest.fn(), updateDatasource: jest.fn(), + updateDatasourceAsync: jest.fn(), updateAll: jest.fn(), framePublicAPI: frame, isOnlyLayer: true, @@ -86,6 +87,8 @@ describe('LayerPanel', () => { core: coreMock.createStart(), layerIndex: 0, registerNewLayerRef: jest.fn(), + isFullscreen: false, + toggleFullscreen: jest.fn(), }; } @@ -255,7 +258,7 @@ describe('LayerPanel', () => { it('should not update the visualization if the datasource is incomplete', () => { (generateId as jest.Mock).mockReturnValue(`newid`); const updateAll = jest.fn(); - const updateDatasource = jest.fn(); + const updateDatasourceAsync = jest.fn(); mockVisualization.getConfiguration.mockReturnValue({ groups: [ @@ -273,7 +276,7 @@ describe('LayerPanel', () => { const component = mountWithIntl( ); @@ -292,15 +295,88 @@ describe('LayerPanel', () => { mockDatasource.renderDimensionEditor.mock.calls.length - 1 ][1].setState; + act(() => { + stateFn( + { + indexPatternId: '1', + columns: {}, + columnOrder: [], + incompleteColumns: { newId: { operationType: 'count' } }, + }, + { isDimensionComplete: false } + ); + }); + expect(updateAll).not.toHaveBeenCalled(); + expect(updateDatasourceAsync).toHaveBeenCalled(); + act(() => { stateFn({ indexPatternId: '1', columns: {}, columnOrder: [], - incompleteColumns: { newId: { operationType: 'count' } }, }); }); - expect(updateAll).not.toHaveBeenCalled(); + expect(updateAll).toHaveBeenCalled(); + }); + + it('should remove the dimension when the datasource marks it as removed', () => { + const updateAll = jest.fn(); + const updateDatasource = jest.fn(); + + mockVisualization.getConfiguration.mockReturnValue({ + groups: [ + { + groupLabel: 'A', + groupId: 'a', + accessors: [{ columnId: 'y' }], + filterOperations: () => true, + supportsMoreColumns: true, + dataTestSubj: 'lnsGroup', + }, + ], + }); + + const component = mountWithIntl( + + ); + + act(() => { + component.find('[data-test-subj="lnsLayerPanel-dimensionLink"]').first().simulate('click'); + }); + component.update(); + + expect(mockDatasource.renderDimensionEditor).toHaveBeenCalledWith( + expect.any(Element), + expect.objectContaining({ columnId: 'y' }) + ); + const stateFn = + mockDatasource.renderDimensionEditor.mock.calls[ + mockDatasource.renderDimensionEditor.mock.calls.length - 1 + ][1].setState; act(() => { stateFn( @@ -308,11 +384,19 @@ describe('LayerPanel', () => { indexPatternId: '1', columns: {}, columnOrder: [], + incompleteColumns: { y: { operationType: 'average' } }, }, - { shouldReplaceDimension: true } + { + isDimensionComplete: false, + } ); }); expect(updateAll).toHaveBeenCalled(); + expect(mockVisualization.removeDimension).toHaveBeenCalledWith( + expect.objectContaining({ + columnId: 'y', + }) + ); }); it('should keep the DimensionContainer open when configuring a new dimension', () => { @@ -331,6 +415,7 @@ describe('LayerPanel', () => { accessors: [], filterOperations: () => true, supportsMoreColumns: true, + enableDimensionEditor: true, dataTestSubj: 'lnsGroup', }, ], @@ -345,6 +430,7 @@ describe('LayerPanel', () => { accessors: [{ columnId: 'newid' }], filterOperations: () => true, supportsMoreColumns: false, + enableDimensionEditor: true, dataTestSubj: 'lnsGroup', }, ], @@ -357,6 +443,20 @@ describe('LayerPanel', () => { component.update(); expect(component.find('EuiFlyoutHeader').exists()).toBe(true); + + const lastArgs = + mockDatasource.renderDimensionEditor.mock.calls[ + mockDatasource.renderDimensionEditor.mock.calls.length - 1 + ][1]; + + // Simulate what is called by the dimension editor + act(() => { + lastArgs.setState(lastArgs.state, { + isDimensionComplete: true, + }); + }); + + expect(mockVisualization.renderDimensionEditor).toHaveBeenCalled(); }); it('should close the DimensionContainer when the active visualization changes', () => { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index a605a94a346468..3a299de0fca6a3 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -42,6 +42,7 @@ export function LayerPanel( isOnlyLayer: boolean; updateVisualization: StateSetter; updateDatasource: (datasourceId: string, newState: unknown) => void; + updateDatasourceAsync: (datasourceId: string, newState: unknown) => void; updateAll: ( datasourceId: string, newDatasourcestate: unknown, @@ -49,6 +50,8 @@ export function LayerPanel( ) => void; onRemoveLayer: () => void; registerNewLayerRef: (layerId: string, instance: HTMLDivElement | null) => void; + toggleFullscreen: () => void; + isFullscreen: boolean; } ) { const [activeDimension, setActiveDimension] = useState( @@ -65,6 +68,8 @@ export function LayerPanel( activeVisualization, updateVisualization, updateDatasource, + toggleFullscreen, + isFullscreen, } = props; const datasourcePublicAPI = framePublicAPI.datasourceLayers[layerId]; @@ -197,9 +202,16 @@ export function LayerPanel( setNextFocusedButtonId, ]); + const isDimensionPanelOpen = Boolean(activeId); + return ( <> -
+
@@ -407,9 +419,16 @@ export function LayerPanel( (panelRef.current = el)} - isOpen={!!activeId} + isOpen={isDimensionPanelOpen} + isFullscreen={isFullscreen} groupLabel={activeGroup?.groupLabel || ''} handleClose={() => { + if ( + layerDatasource.canCloseDimensionEditor && + !layerDatasource.canCloseDimensionEditor(layerDatasourceState) + ) { + return false; + } if (layerDatasource.updateStateOnCloseDimension) { const newState = layerDatasource.updateStateOnCloseDimension({ state: layerDatasourceState, @@ -421,9 +440,13 @@ export function LayerPanel( } } setActiveDimension(initialActiveDimensionState); + if (isFullscreen) { + toggleFullscreen(); + } + return true; }} panel={ - <> +
{activeGroup && activeId && ( { - if (shouldReplaceDimension || shouldRemoveDimension) { + if (allAccessors.includes(activeId)) { + if (isDimensionComplete) { + props.updateDatasourceAsync(datasourceId, newState); + } else { + // The datasource can indicate that the previously-valid column is no longer + // complete, which clears the visualization. This keeps the flyout open and reuses + // the previous columnId + props.updateAll( + datasourceId, + newState, + activeVisualization.removeDimension({ + layerId, + columnId: activeId, + prevState: props.visualizationState, + }) + ); + } + } else if (isDimensionComplete) { props.updateAll( datasourceId, newState, - shouldRemoveDimension - ? activeVisualization.removeDimension({ - layerId, - columnId: activeId, - prevState: props.visualizationState, - }) - : activeVisualization.setDimension({ - layerId, - groupId: activeGroup.groupId, - columnId: activeId, - prevState: props.visualizationState, - }) + activeVisualization.setDimension({ + layerId, + groupId: activeGroup.groupId, + columnId: activeId, + prevState: props.visualizationState, + }) ); + setActiveDimension({ ...activeDimension, isNew: false }); } else { - props.updateDatasource(datasourceId, newState); + props.updateDatasourceAsync(datasourceId, newState); } - setActiveDimension({ - ...activeDimension, - isNew: false, - }); }, }} /> )} {activeGroup && activeId && + !isFullscreen && !activeDimension.isNew && activeVisualization.renderDimensionEditor && activeGroup?.enableDimensionEditor && ( @@ -491,7 +519,7 @@ export function LayerPanel( />
)} - +
} /> diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts index 37b2198cfd51f9..1af8c16fa1395f 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/types.ts @@ -29,6 +29,7 @@ export interface ConfigPanelWrapperProps { } >; core: DatasourceDimensionEditorProps['core']; + isFullscreen: boolean; } export interface LayerPanelProps { @@ -46,6 +47,7 @@ export interface LayerPanelProps { } >; core: DatasourceDimensionEditorProps['core']; + isFullscreen: boolean; } export interface LayerDatasourceDropProps { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx index 4710e03d336bcf..161b0125a172a3 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useEffect, useReducer, useState, useCallback } from 'react'; +import React, { useEffect, useReducer, useState, useCallback, useRef } from 'react'; import { CoreStart } from 'kibana/public'; import { isEqual } from 'lodash'; import { PaletteRegistry } from 'src/plugins/charts/public'; @@ -30,6 +30,7 @@ import { applyVisualizeFieldSuggestions, getTopSuggestionForField, switchToSuggestion, + Suggestion, } from './suggestion_helpers'; import { trackUiEvent } from '../../lens_ui_telemetry'; import { @@ -327,45 +328,37 @@ export function EditorFrame(props: EditorFrameProps) { ] ); - const getSuggestionForField = React.useCallback( - (field: DragDropIdentifier) => { - const { activeDatasourceId, datasourceStates } = state; - const activeVisualizationId = state.visualization.activeId; - const visualizationState = state.visualization.state; - const { visualizationMap, datasourceMap } = props; + // Using a ref to prevent rerenders in the child components while keeping the latest state + const getSuggestionForField = useRef<(field: DragDropIdentifier) => Suggestion | undefined>(); + getSuggestionForField.current = (field: DragDropIdentifier) => { + const { activeDatasourceId, datasourceStates } = state; + const activeVisualizationId = state.visualization.activeId; + const visualizationState = state.visualization.state; + const { visualizationMap, datasourceMap } = props; - if (!field || !activeDatasourceId) { - return; - } + if (!field || !activeDatasourceId) { + return; + } - return getTopSuggestionForField( - datasourceLayers, - activeVisualizationId, - visualizationMap, - visualizationState, - datasourceMap[activeDatasourceId], - datasourceStates, - field - ); - }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [ - state.visualization.state, - props.datasourceMap, - props.visualizationMap, - state.activeDatasourceId, - state.datasourceStates, - ] - ); + return getTopSuggestionForField( + datasourceLayers, + activeVisualizationId, + visualizationMap, + visualizationState, + datasourceMap[activeDatasourceId], + datasourceStates, + field + ); + }; const hasSuggestionForField = useCallback( - (field: DragDropIdentifier) => getSuggestionForField(field) !== undefined, + (field: DragDropIdentifier) => getSuggestionForField.current!(field) !== undefined, [getSuggestionForField] ); const dropOntoWorkspace = useCallback( (field) => { - const suggestion = getSuggestionForField(field); + const suggestion = getSuggestionForField.current!(field); if (suggestion) { trackUiEvent('drop_onto_workspace'); switchToSuggestion(dispatch, suggestion, 'SWITCH_VISUALIZATION'); @@ -377,6 +370,7 @@ export function EditorFrame(props: EditorFrameProps) { return ( ) } @@ -429,11 +424,12 @@ export function EditorFrame(props: EditorFrameProps) { visualizationState={state.visualization.state} visualizationMap={props.visualizationMap} dispatch={dispatch} + isFullscreen={Boolean(state.isFullscreenDatasource)} ExpressionRenderer={props.ExpressionRenderer} core={props.core} plugins={props.plugins} visualizeTriggerFieldContext={visualizeTriggerFieldContext} - getSuggestionForField={getSuggestionForField} + getSuggestionForField={getSuggestionForField.current} /> ) } diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.scss b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.scss index 0756c13f6999bf..282e69cd7636c7 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.scss +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.scss @@ -67,9 +67,16 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ padding: $euiSize $euiSize 0; position: relative; z-index: $lnsZLevel1; + &:first-child { padding-left: $euiSize; } + + &.lnsFrameLayout__pageBody-isFullscreen { + background: $euiColorEmptyShade; + flex: 1; + padding: 0; + } } .lnsFrameLayout__sidebar { @@ -81,6 +88,13 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ position: relative; } +.lnsFrameLayout-isFullscreen .lnsFrameLayout__sidebar--left, +.lnsFrameLayout-isFullscreen .lnsFrameLayout__suggestionPanel { + // Hide the datapanel and suggestions in fullscreen mode. Using display: none does trigger + // a rerender when the container becomes visible again, maybe pushing offscreen is better + display: none; +} + .lnsFrameLayout__sidebar--right { flex-basis: 25%; background-color: lightOrDarkTheme($euiColorLightestShade, $euiColorInk); @@ -106,3 +120,8 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ } } } + +.lnsFrameLayout__sidebar-isFullscreen { + flex: 1; + max-width: none; +} diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index a54901a2a2fe1d..f27e0f9c24d7bd 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -10,23 +10,32 @@ import './frame_layout.scss'; import React from 'react'; import { EuiPage, EuiPageBody, EuiScreenReaderOnly } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import classNames from 'classnames'; export interface FrameLayoutProps { dataPanel: React.ReactNode; configPanel?: React.ReactNode; suggestionsPanel?: React.ReactNode; workspacePanel?: React.ReactNode; + isFullscreen?: boolean; } export function FrameLayout(props: FrameLayoutProps) { return ( - + -
+

{i18n.translate('xpack.lens.section.dataPanelLabel', { @@ -36,7 +45,13 @@ export function FrameLayout(props: FrameLayoutProps) { {props.dataPanel}

-
+

{i18n.translate('xpack.lens.section.workspaceLabel', { @@ -45,10 +60,13 @@ export function FrameLayout(props: FrameLayoutProps) {

{props.workspacePanel} - {props.suggestionsPanel} +
{props.suggestionsPanel}
diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_management.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_management.ts index aa365d1e66d6c5..a87aa7a2cb4282 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_management.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_management.ts @@ -22,6 +22,7 @@ export interface EditorFrameState extends PreviewState { description?: string; stagedPreview?: PreviewState; activeDatasourceId: string | null; + isFullscreenDatasource?: boolean; } export type Action = @@ -90,6 +91,9 @@ export type Action = | { type: 'SWITCH_DATASOURCE'; newDatasourceId: string; + } + | { + type: 'TOGGLE_FULLSCREEN'; }; export function getActiveDatasourceIdFromDoc(doc?: Document) { @@ -281,6 +285,8 @@ export const reducer = (state: EditorFrameState, action: Action): EditorFrameSta }, stagedPreview: action.clearStagedPreview ? undefined : state.stagedPreview, }; + case 'TOGGLE_FULLSCREEN': + return { ...state, isFullscreenDatasource: !state.isFullscreenDatasource }; default: return state; } diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx index 0c2eb4f39d8959..8107b6646500d5 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx @@ -200,15 +200,16 @@ export function SuggestionPanel({ visualizationState: currentVisualizationState, activeData: frame.activeData, }) - .filter((suggestion) => !suggestion.hide) .filter( ({ + hide, visualizationId, visualizationState: suggestionVisualizationState, datasourceState: suggestionDatasourceState, datasourceId: suggetionDatasourceId, }) => { return ( + !hide && validateDatasourceAndVisualization( suggetionDatasourceId ? datasourceMap[suggetionDatasourceId] : null, suggestionDatasourceState, diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index 1d248c4411023c..38e9bb868b26aa 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -64,6 +64,8 @@ const defaultProps = { data: mockDataPlugin(), }, getSuggestionForField: () => undefined, + isFullscreen: false, + toggleFullscreen: jest.fn(), }; describe('workspace_panel', () => { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 45abbf120042d0..01d4e84ec4374d 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -79,6 +79,7 @@ export interface WorkspacePanelProps { title?: string; visualizeTriggerFieldContext?: VisualizeFieldContext; getSuggestionForField: (field: DragDropIdentifier) => Suggestion | undefined; + isFullscreen: boolean; } interface WorkspaceState { @@ -134,6 +135,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ title, visualizeTriggerFieldContext, suggestionForDraggedField, + isFullscreen, }: Omit & { suggestionForDraggedField: Suggestion | undefined; }) { @@ -346,6 +348,8 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ ); }; + const element = expression !== null ? renderVisualization() : renderEmptyWorkspace(); + const dragDropContext = useContext(DragContext); const renderDragDrop = () => { @@ -363,7 +367,10 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ customWorkspaceRenderer() ) : ( - {renderVisualization()} - {Boolean(suggestionForDraggedField) && expression !== null && renderEmptyWorkspace()} + {element} ); @@ -389,6 +395,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ datasourceStates={datasourceStates} datasourceMap={datasourceMap} visualizationMap={visualizationMap} + isFullscreen={isFullscreen} > {renderDragDrop()} diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss index e687e478cd3680..21e3f9aa36674b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss @@ -31,6 +31,10 @@ overflow: hidden; } } + + &.lnsWorkspacePanelWrapper--fullscreen { + margin-bottom: 0; + } } .lnsWorkspacePanel__dragDrop { @@ -62,6 +66,10 @@ animation: lnsWorkspacePanel__illustrationPulseContinuous 1.5s ease-in-out 0s infinite normal forwards; } } + + &.lnsWorkspacePanel__dragDrop--fullscreen { + border: none; + } } .lnsWorkspacePanel__emptyContent { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx index 7bb467df9ab0e1..c18b362e2faa4e 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx @@ -37,6 +37,7 @@ describe('workspace_panel_wrapper', () => { visualizationMap={{ myVis: mockVisualization }} datasourceMap={{}} datasourceStates={{}} + isFullscreen={false} > @@ -58,6 +59,7 @@ describe('workspace_panel_wrapper', () => { visualizationMap={{ myVis: { ...mockVisualization, renderToolbar: renderToolbarMock } }} datasourceMap={{}} datasourceStates={{}} + isFullscreen={false} /> ); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index ec12e9e4002039..6724002d23e0bb 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -10,6 +10,7 @@ import './workspace_panel_wrapper.scss'; import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiPageContent, EuiFlexGroup, EuiFlexItem, EuiScreenReaderOnly } from '@elastic/eui'; +import classNames from 'classnames'; import { Datasource, FramePublicAPI, Visualization } from '../../../types'; import { NativeRenderer } from '../../../native_renderer'; import { Action } from '../state_management'; @@ -32,6 +33,7 @@ export interface WorkspacePanelWrapperProps { state: unknown; } >; + isFullscreen: boolean; } export function WorkspacePanelWrapper({ @@ -44,6 +46,7 @@ export function WorkspacePanelWrapper({ visualizationMap, datasourceMap, datasourceStates, + isFullscreen, }: WorkspacePanelWrapperProps) { const activeVisualization = visualizationId ? visualizationMap[visualizationId] : null; const setVisualizationState = useCallback( @@ -85,40 +88,42 @@ export function WorkspacePanelWrapper({ wrap={true} justifyContent="spaceBetween" > - - - - - - {activeVisualization && activeVisualization.renderToolbar && ( + {!isFullscreen ? ( + + - - )} - - + {activeVisualization && activeVisualization.renderToolbar && ( + + + + )} + + + ) : null} {warningMessages && warningMessages.length ? ( {warningMessages} @@ -126,7 +131,11 @@ export function WorkspacePanelWrapper({
- +

{title || diff --git a/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx b/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx index 38669d72474df1..1762e7ff20fabb 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx @@ -57,6 +57,7 @@ export function createMockVisualization(): jest.Mocked { setDimension: jest.fn(), removeDimension: jest.fn(), getErrorMessages: jest.fn((_state) => undefined), + renderDimensionEditor: jest.fn(), }; } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.scss b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.scss index bf833c4a369325..874291ae25e341 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.scss +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.scss @@ -2,7 +2,27 @@ height: 100%; } -.lnsIndexPatternDimensionEditor__section { +.lnsIndexPatternDimensionEditor__header { + position: sticky; + top: 0; + background: $euiColorEmptyShade; + // Raise it above the elements that are after it in DOM order + z-index: $euiZLevel1; +} + +.lnsIndexPatternDimensionEditor-isFullscreen { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + + .lnsIndexPatternDimensionEditor__section { + height: 100%; + } +} + +.lnsIndexPatternDimensionEditor__section--padded { padding: $euiSizeS; } @@ -10,6 +30,14 @@ background-color: $euiColorLightestShade; } +.lnsIndexPatternDimensionEditor__section--top { + border-bottom: $euiBorderThin; +} + +.lnsIndexPatternDimensionEditor__section--bottom { + border-top: $euiBorderThin; +} + .lnsIndexPatternDimensionEditor__columns { column-count: 2; column-gap: $euiSizeXL; @@ -29,3 +57,9 @@ padding-top: 0; padding-bottom: 0; } + +.lnsIndexPatternDimensionEditor__warning { + @include kbnThemeStyle('v7') { + border: none; + } +} diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx index 2ae7b9403a46db..3dd2d4a4ba3f50 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx @@ -6,7 +6,7 @@ */ import './dimension_editor.scss'; -import React, { useState, useMemo } from 'react'; +import React, { useState, useMemo, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiListGroup, @@ -17,6 +17,9 @@ import { EuiFormLabel, EuiToolTip, EuiText, + EuiTabs, + EuiTab, + EuiCallOut, } from '@elastic/eui'; import { IndexPatternDimensionEditorProps } from './dimension_panel'; import { OperationSupportMatrix } from './operation_support'; @@ -91,6 +94,8 @@ export function DimensionEditor(props: DimensionEditorProps) { hideGrouping, dateRange, dimensionGroups, + toggleFullscreen, + isFullscreen, } = props; const services = { data: props.data, @@ -101,30 +106,34 @@ export function DimensionEditor(props: DimensionEditorProps) { }; const { fieldByOperation, operationWithoutField } = operationSupportMatrix; + const selectedOperationDefinition = + selectedColumn && operationDefinitionMap[selectedColumn.operationType]; + const setStateWrapper = ( setter: IndexPatternLayer | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) ) => { + const prevOperationType = + operationDefinitionMap[state.layers[layerId].columns[columnId]?.operationType]?.input; + const hypotheticalLayer = typeof setter === 'function' ? setter(state.layers[layerId]) : setter; const hasIncompleteColumns = Boolean(hypotheticalLayer.incompleteColumns?.[columnId]); - const prevOperationType = - operationDefinitionMap[hypotheticalLayer.columns[columnId]?.operationType]?.input; setState( (prevState) => { const layer = typeof setter === 'function' ? setter(prevState.layers[layerId]) : setter; return mergeLayer({ state: prevState, layerId, newLayer: layer }); }, { - shouldReplaceDimension: Boolean(hypotheticalLayer.columns[columnId]), - // clear the dimension if there's an incomplete column pending && previous operation was a fullReference operation - shouldRemoveDimension: Boolean( - hasIncompleteColumns && prevOperationType === 'fullReference' - ), + isDimensionComplete: + prevOperationType === 'fullReference' + ? !hasIncompleteColumns + : Boolean(hypotheticalLayer.columns[columnId]), } ); }; - const selectedOperationDefinition = - selectedColumn && operationDefinitionMap[selectedColumn.operationType]; + const setIsCloseable = (isCloseable: boolean) => { + setState((prevState) => ({ ...prevState, isDimensionClosePrevented: !isCloseable })); + }; const incompleteInfo = (state.layers[layerId].incompleteColumns ?? {})[columnId]; const incompleteOperation = incompleteInfo?.operationType; @@ -132,14 +141,16 @@ export function DimensionEditor(props: DimensionEditorProps) { const ParamEditor = selectedOperationDefinition?.paramEditor; + const [temporaryQuickFunction, setQuickFunction] = useState(false); + const possibleOperations = useMemo(() => { return Object.values(operationDefinitionMap) .filter(({ hidden }) => !hidden) + .filter(({ type }) => fieldByOperation[type]?.size || operationWithoutField.has(type)) .sort((op1, op2) => { return op1.displayName.localeCompare(op2.displayName); }) - .map((def) => def.type) - .filter((type) => fieldByOperation[type]?.size || operationWithoutField.has(type)); + .map((def) => def.type); }, [fieldByOperation, operationWithoutField]); const [filterByOpenInitially, setFilterByOpenInitally] = useState(false); @@ -245,37 +256,44 @@ export function DimensionEditor(props: DimensionEditorProps) { visualizationGroups: dimensionGroups, targetGroup: props.groupId, }); + if (temporaryQuickFunction && newLayer.columns[columnId].operationType !== 'formula') { + // Only switch the tab once the formula is fully removed + setQuickFunction(false); + } setStateWrapper(newLayer); trackUiEvent(`indexpattern_dimension_operation_${operationType}`); return; } else if (!selectedColumn || !compatibleWithCurrentField) { const possibleFields = fieldByOperation[operationType] || new Set(); + let newLayer: IndexPatternLayer; if (possibleFields.size === 1) { - setStateWrapper( - insertOrReplaceColumn({ - layer: props.state.layers[props.layerId], - indexPattern: currentIndexPattern, - columnId, - op: operationType, - field: currentIndexPattern.getFieldByName(possibleFields.values().next().value), - visualizationGroups: dimensionGroups, - targetGroup: props.groupId, - }) - ); + newLayer = insertOrReplaceColumn({ + layer: props.state.layers[props.layerId], + indexPattern: currentIndexPattern, + columnId, + op: operationType, + field: currentIndexPattern.getFieldByName(possibleFields.values().next().value), + visualizationGroups: dimensionGroups, + targetGroup: props.groupId, + }); } else { - setStateWrapper( - insertOrReplaceColumn({ - layer: props.state.layers[props.layerId], - indexPattern: currentIndexPattern, - columnId, - op: operationType, - field: undefined, - visualizationGroups: dimensionGroups, - targetGroup: props.groupId, - }) - ); + newLayer = insertOrReplaceColumn({ + layer: props.state.layers[props.layerId], + indexPattern: currentIndexPattern, + columnId, + op: operationType, + field: undefined, + visualizationGroups: dimensionGroups, + targetGroup: props.groupId, + }); + // ); + } + if (temporaryQuickFunction && newLayer.columns[columnId].operationType !== 'formula') { + // Only switch the tab once the formula is fully removed + setQuickFunction(false); } + setStateWrapper(newLayer); trackUiEvent(`indexpattern_dimension_operation_${operationType}`); return; } @@ -287,6 +305,9 @@ export function DimensionEditor(props: DimensionEditorProps) { return; } + if (temporaryQuickFunction) { + setQuickFunction(false); + } const newLayer = replaceColumn({ layer: props.state.layers[props.layerId], indexPattern: currentIndexPattern, @@ -315,9 +336,34 @@ export function DimensionEditor(props: DimensionEditorProps) { currentFieldIsInvalid ); - return ( -
-
+ const shouldDisplayExtraOptions = + !currentFieldIsInvalid && + !incompleteInfo && + selectedColumn && + selectedColumn.operationType !== 'formula'; + + const quickFunctions = ( + <> + {temporaryQuickFunction && selectedColumn?.operationType === 'formula' && ( + <> + +

+ {i18n.translate('xpack.lens.indexPattern.formulaWarningText', { + defaultMessage: 'To overwrite your formula, select a quick function', + })} +

+
+ + )} +
{i18n.translate('xpack.lens.indexPattern.functionsLabel', { defaultMessage: 'Select a function', @@ -336,7 +382,7 @@ export function DimensionEditor(props: DimensionEditorProps) { />
-
+
{!incompleteInfo && selectedColumn && 'references' in selectedColumn && @@ -375,6 +421,9 @@ export function DimensionEditor(props: DimensionEditorProps) { currentColumn: state.layers[layerId].columns[columnId], })} dimensionGroups={dimensionGroups} + isFullscreen={isFullscreen} + toggleFullscreen={toggleFullscreen} + setIsCloseable={setIsCloseable} {...services} /> ); @@ -385,7 +434,8 @@ export function DimensionEditor(props: DimensionEditorProps) { {!selectedColumn || selectedOperationDefinition?.input === 'field' || - (incompleteOperation && operationDefinitionMap[incompleteOperation].input === 'field') ? ( + (incompleteOperation && operationDefinitionMap[incompleteOperation].input === 'field') || + temporaryQuickFunction ? ( ) : null} - {!currentFieldIsInvalid && !incompleteInfo && selectedColumn && ParamEditor && ( - <> - - + {shouldDisplayExtraOptions && ParamEditor && ( + )} {!currentFieldIsInvalid && !incompleteInfo && selectedColumn && ( @@ -546,9 +597,96 @@ export function DimensionEditor(props: DimensionEditorProps) {
+ + ); - {!currentFieldIsInvalid && ( -
+ const formulaTab = ParamEditor ? ( + + ) : null; + + const onFormatChange = useCallback( + (newFormat) => { + setState( + mergeLayer({ + state, + layerId, + newLayer: updateColumnParam({ + layer: state.layers[layerId], + columnId, + paramName: 'format', + value: newFormat, + }), + }) + ); + }, + [columnId, layerId, setState, state] + ); + + return ( +
+ {!isFullscreen && operationSupportMatrix.operationWithoutField.has('formula') ? ( + + { + if (selectedColumn?.operationType === 'formula') { + setQuickFunction(true); + } + }} + > + {i18n.translate('xpack.lens.indexPattern.quickFunctionsLabel', { + defaultMessage: 'Quick functions', + })} + + { + if (selectedColumn?.operationType !== 'formula') { + setQuickFunction(false); + const newLayer = insertOrReplaceColumn({ + layer: props.state.layers[props.layerId], + indexPattern: currentIndexPattern, + columnId, + op: 'formula', + visualizationGroups: dimensionGroups, + }); + setStateWrapper(newLayer); + trackUiEvent(`indexpattern_dimension_operation_formula`); + return; + } else { + setQuickFunction(false); + } + }} + > + {i18n.translate('xpack.lens.indexPattern.formulaLabel', { + defaultMessage: 'Formula', + })} + + + ) : null} + + {isFullscreen + ? formulaTab + : selectedOperationDefinition?.type === 'formula' && !temporaryQuickFunction + ? formulaTab + : quickFunctions} + + {!isFullscreen && !currentFieldIsInvalid && !temporaryQuickFunction && ( +
{!incompleteInfo && selectedColumn && ( )} - {!incompleteInfo && !hideGrouping && ( + {!isFullscreen && !incompleteInfo && !hideGrouping && ( )} - {selectedColumn && + {!isFullscreen && + selectedColumn && (selectedColumn.dataType === 'number' || selectedColumn.operationType === 'range') ? ( - { - setState( - mergeLayer({ - state, - layerId, - newLayer: updateColumnParam({ - layer: state.layers[layerId], - columnId, - paramName: 'format', - value: newFormat, - }), - }) - ); - }} - /> + ) : null}
)}
); } + function getErrorMessage( selectedColumn: IndexPatternColumn | undefined, incompleteOperation: boolean, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx index 03db6141b917f9..7e45b295215631 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx @@ -208,6 +208,8 @@ describe('IndexPatternDimensionEditorPanel', () => { core: {} as CoreSetup, dimensionGroups: [], groupId: 'a', + isFullscreen: false, + toggleFullscreen: jest.fn(), }; jest.clearAllMocks(); @@ -500,10 +502,7 @@ describe('IndexPatternDimensionEditorPanel', () => { comboBox.prop('onChange')!([option]); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({ ...initialState, layers: { @@ -535,10 +534,7 @@ describe('IndexPatternDimensionEditorPanel', () => { comboBox.prop('onChange')!([option]); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({ ...state, layers: { @@ -569,10 +565,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-min"]').simulate('click'); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, layers: { @@ -643,10 +636,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-min"]').simulate('click'); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, layers: { @@ -681,10 +671,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-min"]').simulate('click'); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, layers: { @@ -750,10 +737,7 @@ describe('IndexPatternDimensionEditorPanel', () => { .simulate('click'); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, layers: { @@ -879,7 +863,7 @@ describe('IndexPatternDimensionEditorPanel', () => { expect(setState.mock.calls[0]).toEqual([ expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: false }, + { isDimensionComplete: false }, ]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, @@ -948,7 +932,7 @@ describe('IndexPatternDimensionEditorPanel', () => { // Now check that the dimension gets cleaned up on state update expect(setState.mock.calls[0]).toEqual([ expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: false }, + { isDimensionComplete: false }, ]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, @@ -1042,10 +1026,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); expect(setState.mock.calls.length).toEqual(2); - expect(setState.mock.calls[1]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[1]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[1][0](state)).toEqual({ ...state, layers: { @@ -1143,10 +1124,7 @@ describe('IndexPatternDimensionEditorPanel', () => { .find('[data-test-subj="indexPattern-time-scaling-enable"]') .hostNodes() .simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1175,10 +1153,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper .find('button[data-test-subj="lns-indexPatternDimension-count incompatible"]') .simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1205,10 +1180,7 @@ describe('IndexPatternDimensionEditorPanel', () => { }); wrapper = mount(); wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1239,10 +1211,7 @@ describe('IndexPatternDimensionEditorPanel', () => { .prop('onChange')!(({ target: { value: 'h' }, } as unknown) as ChangeEvent); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1269,10 +1238,7 @@ describe('IndexPatternDimensionEditorPanel', () => { .prop('onChange')!(({ target: { value: 'h' }, } as unknown) as ChangeEvent); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1300,10 +1266,7 @@ describe('IndexPatternDimensionEditorPanel', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any {} as any ); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1593,10 +1556,7 @@ describe('IndexPatternDimensionEditorPanel', () => { .find('[data-test-subj="indexPattern-filter-by-enable"]') .hostNodes() .simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1627,10 +1587,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper .find('button[data-test-subj="lns-indexPatternDimension-count incompatible"]') .simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1656,10 +1613,7 @@ describe('IndexPatternDimensionEditorPanel', () => { language: 'kuery', query: 'c: d', }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1688,10 +1642,7 @@ describe('IndexPatternDimensionEditorPanel', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any {} as any ); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](props.state)).toEqual({ ...props.state, layers: { @@ -1743,10 +1694,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: false }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: false }]); expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({ ...state, layers: { @@ -1810,10 +1758,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](initialState)).toEqual({ ...initialState, layers: { @@ -1838,10 +1783,7 @@ describe('IndexPatternDimensionEditorPanel', () => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](state)).toEqual({ ...state, layers: { @@ -1975,10 +1917,7 @@ describe('IndexPatternDimensionEditorPanel', () => { comboBox.prop('onChange')!([option]); }); - expect(setState.mock.calls[0]).toEqual([ - expect.any(Function), - { shouldRemoveDimension: false, shouldReplaceDimension: true }, - ]); + expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]); expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({ ...state, layers: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/droppable.test.ts b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/droppable.test.ts index a77a980257c88c..56d255ec02227c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/droppable.test.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/droppable.test.ts @@ -284,6 +284,8 @@ describe('IndexPatternDimensionEditorPanel', () => { } as unknown) as DataPublicPluginStart, core: {} as CoreSetup, dimensionGroups: [], + isFullscreen: false, + toggleFullscreen: () => {}, }; jest.clearAllMocks(); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx index 3a57579583c90c..ff10810208e706 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/format_selector.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useState } from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRow, EuiComboBox, EuiSpacer, EuiRange } from '@elastic/eui'; import { IndexPatternColumn } from '../indexpattern'; @@ -28,6 +28,13 @@ const supportedFormats: Record = { }, }; +const defaultOption = { + value: '', + label: i18n.translate('xpack.lens.indexPattern.defaultFormatLabel', { + defaultMessage: 'Default', + }), +}; + interface FormatSelectorProps { selectedColumn: IndexPatternColumn; onChange: (newFormat?: { id: string; params?: Record }) => void; @@ -37,6 +44,8 @@ interface State { decimalPlaces: number; } +const singleSelectionOption = { asPlainText: true }; + export function FormatSelector(props: FormatSelectorProps) { const { selectedColumn, onChange } = props; @@ -51,13 +60,6 @@ export function FormatSelector(props: FormatSelectorProps) { const selectedFormat = currentFormat?.id ? supportedFormats[currentFormat.id] : undefined; - const defaultOption = { - value: '', - label: i18n.translate('xpack.lens.indexPattern.defaultFormatLabel', { - defaultMessage: 'Default', - }), - }; - const label = i18n.translate('xpack.lens.indexPattern.columnFormatLabel', { defaultMessage: 'Value format', }); @@ -66,6 +68,48 @@ export function FormatSelector(props: FormatSelectorProps) { defaultMessage: 'Decimals', }); + const stableOptions = useMemo( + () => [ + defaultOption, + ...Object.entries(supportedFormats).map(([id, format]) => ({ + value: id, + label: format.title ?? id, + })), + ], + [] + ); + + const onChangeWrapped = useCallback( + (choices) => { + if (choices.length === 0) { + return; + } + + if (!choices[0].value) { + onChange(); + return; + } + onChange({ + id: choices[0].value, + params: { decimals: state.decimalPlaces }, + }); + }, + [onChange, state.decimalPlaces] + ); + + const currentOption = useMemo( + () => + currentFormat + ? [ + { + value: currentFormat.id, + label: selectedFormat?.title ?? currentFormat.id, + }, + ] + : [defaultOption], + [currentFormat, selectedFormat?.title] + ); + return ( <> @@ -76,38 +120,10 @@ export function FormatSelector(props: FormatSelectorProps) { isClearable={false} data-test-subj="indexPattern-dimension-format" aria-label={label} - singleSelection={{ asPlainText: true }} - options={[ - defaultOption, - ...Object.entries(supportedFormats).map(([id, format]) => ({ - value: id, - label: format.title ?? id, - })), - ]} - selectedOptions={ - currentFormat - ? [ - { - value: currentFormat.id, - label: selectedFormat?.title ?? currentFormat.id, - }, - ] - : [defaultOption] - } - onChange={(choices) => { - if (choices.length === 0) { - return; - } - - if (!choices[0].value) { - onChange(); - return; - } - onChange({ - id: choices[0].value, - params: { decimals: state.decimalPlaces }, - }); - }} + singleSelection={singleSelectionOption} + options={stableOptions} + selectedOptions={currentOption} + onChange={onChangeWrapped} /> {currentFormat ? ( <> diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts index 504aa0912f9cc4..7a7297e77bcf28 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/operation_support.ts @@ -5,9 +5,10 @@ * 2.0. */ -import { DatasourceDimensionDropProps } from '../../types'; +import memoizeOne from 'memoize-one'; +import { DatasourceDimensionDropProps, OperationMetadata } from '../../types'; import { OperationType } from '../indexpattern'; -import { memoizedGetAvailableOperationsByMetadata } from '../operations'; +import { memoizedGetAvailableOperationsByMetadata, OperationFieldTuple } from '../operations'; import { IndexPatternPrivateState } from '../types'; export interface OperationSupportMatrix { @@ -21,17 +22,16 @@ type Props = Pick< 'layerId' | 'columnId' | 'state' | 'filterOperations' >; -// TODO: the support matrix should be available outside of the dimension panel - -// TODO: This code has historically been memoized, as a potentially performance -// sensitive task. If we can add memoization without breaking the behavior, we should. -export const getOperationSupportMatrix = (props: Props): OperationSupportMatrix => { - const layerId = props.layerId; - const currentIndexPattern = props.state.indexPatterns[props.state.layers[layerId].indexPatternId]; - - const filteredOperationsByMetadata = memoizedGetAvailableOperationsByMetadata( - currentIndexPattern - ).filter((operation) => props.filterOperations(operation.operationMetaData)); +function computeOperationMatrix( + operationsByMetadata: Array<{ + operationMetaData: OperationMetadata; + operations: OperationFieldTuple[]; + }>, + filterOperations: (operation: OperationMetadata) => boolean +) { + const filteredOperationsByMetadata = operationsByMetadata.filter((operation) => + filterOperations(operation.operationMetaData) + ); const supportedOperationsByField: Partial>> = {}; const supportedOperationsWithoutField: Set = new Set(); @@ -59,4 +59,16 @@ export const getOperationSupportMatrix = (props: Props): OperationSupportMatrix operationWithoutField: supportedOperationsWithoutField, fieldByOperation: supportedFieldsByOperation, }; +} + +// memoize based on latest execution. It supports multiple args +const memoizedComputeOperationsMatrix = memoizeOne(computeOperationMatrix); + +// TODO: the support matrix should be available outside of the dimension panel +export const getOperationSupportMatrix = (props: Props): OperationSupportMatrix => { + const layerId = props.layerId; + const currentIndexPattern = props.state.indexPatterns[props.state.layers[layerId].indexPatternId]; + + const operationsByMetadata = memoizedGetAvailableOperationsByMetadata(currentIndexPattern); + return memoizedComputeOperationsMatrix(operationsByMetadata, props.filterOperations); }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx index 645b6bfe70a97c..fd3ad9a4e5dd54 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.test.tsx @@ -51,6 +51,9 @@ describe('reference editor', () => { http: {} as HttpSetup, data: {} as DataPublicPluginStart, dimensionGroups: [], + isFullscreen: false, + toggleFullscreen: jest.fn(), + setIsCloseable: jest.fn(), }; } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.tsx index c473be05ba3154..b0cdf96f928f93 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/reference_editor.tsx @@ -47,10 +47,14 @@ export interface ReferenceEditorProps { setter: IndexPatternLayer | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) ) => void; currentIndexPattern: IndexPattern; + existingFields: IndexPatternPrivateState['existingFields']; dateRange: DateRange; labelAppend?: EuiFormRowProps['labelAppend']; dimensionGroups: VisualizationDimensionGroupConfig[]; + isFullscreen: boolean; + toggleFullscreen: () => void; + setIsCloseable: (isCloseable: boolean) => void; // Services uiSettings: IUiSettingsClient; @@ -72,6 +76,9 @@ export function ReferenceEditor(props: ReferenceEditorProps) { dateRange, labelAppend, dimensionGroups, + isFullscreen, + toggleFullscreen, + setIsCloseable, ...services } = props; @@ -347,6 +354,9 @@ export function ReferenceEditor(props: ReferenceEditorProps) { indexPattern={currentIndexPattern} dateRange={dateRange} operationDefinitionMap={operationDefinitionMap} + isFullscreen={isFullscreen} + toggleFullscreen={toggleFullscreen} + setIsCloseable={setIsCloseable} {...services} /> diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx index 7cb49de15c0665..bc2184bd9edb7b 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx @@ -323,6 +323,11 @@ export function getIndexPatternDatasource({ domElement ); }, + + canCloseDimensionEditor: (state) => { + return !state.isDimensionClosePrevented; + }, + getDropProps, onDrop, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx index 864a3a6f089db7..93ea3069894d32 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.test.tsx @@ -16,6 +16,7 @@ import { } from './indexpattern_suggestions'; import { documentField } from './document_field'; import { getFieldByNameFactory } from './pure_helpers'; +import { isEqual } from 'lodash'; jest.mock('./loader'); jest.mock('../id_generator'); @@ -867,10 +868,7 @@ describe('IndexPattern Data Source suggestions', () => { searchable: true, }); - expect(suggestions).toHaveLength(1); - // Check that the suggestion is a single metric - expect(suggestions[0].table.columns).toHaveLength(1); - expect(suggestions[0].table.columns[0].operation.isBucketed).toBeFalsy(); + expect(suggestions).toHaveLength(0); }); it('appends a terms column with default size on string field', () => { @@ -1025,6 +1023,24 @@ describe('IndexPattern Data Source suggestions', () => { expect(suggestions).not.toContain(expect.objectContaining({ changeType: 'extended' })); }); + it('skips metric only suggestion when the field is already in use', () => { + const initialState = stateWithNonEmptyTables(); + const suggestions = getDatasourceSuggestionsForField(initialState, '1', { + name: 'bytes', + displayName: 'bytes', + type: 'number', + aggregatable: true, + searchable: true, + }); + + expect( + suggestions.some( + (suggestion) => + suggestion.table.changeType === 'initial' && suggestion.table.columns.length === 1 + ) + ).toBeFalsy(); + }); + it('skips duplicates when the document-specific field is already in use', () => { const initialState = stateWithNonEmptyTables(); const modifiedState: IndexPatternPrivateState = { @@ -2344,7 +2360,7 @@ describe('IndexPattern Data Source suggestions', () => { ); }); - it('will skip a reduced suggestion when handling multiple references', () => { + it('will create reduced suggestions with all referenced children when handling references', () => { const initialState = testInitialState(); const state: IndexPatternPrivateState = { ...initialState, @@ -2352,7 +2368,17 @@ describe('IndexPattern Data Source suggestions', () => { ...initialState.layers, first: { ...initialState.layers.first, - columnOrder: ['date', 'metric', 'metric2', 'ref', 'ref2'], + columnOrder: [ + 'date', + 'metric', + 'metric2', + 'ref', + 'ref2', + 'ref3', + 'ref4', + 'metric3', + 'metric4', + ], columns: { date: { @@ -2384,6 +2410,20 @@ describe('IndexPattern Data Source suggestions', () => { operationType: 'count', sourceField: 'Records', }, + metric3: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'count', + sourceField: 'Records', + }, + metric4: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'count', + sourceField: 'Records', + }, ref2: { label: '', dataType: 'number', @@ -2391,22 +2431,163 @@ describe('IndexPattern Data Source suggestions', () => { operationType: 'cumulative_sum', references: ['metric2'], }, + ref3: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'math', + references: ['ref4', 'metric3'], + params: { + tinymathAst: '', + }, + }, + ref4: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'math', + references: ['metric4'], + params: { + tinymathAst: '', + }, + }, }, }, }, }; - const result = getSuggestionSubset(getDatasourceSuggestionsFromCurrentState(state)); - - expect(result).not.toContainEqual( - expect.objectContaining({ - table: expect.objectContaining({ - changeType: 'reduced', - }), - }) - ); + const result = getDatasourceSuggestionsFromCurrentState(state); + + // only generate suggestions for top level metrics + expect( + result.filter((suggestion) => suggestion.table.changeType === 'reduced').length + ).toEqual(3); + + // top level "ref" column + expect( + result.some( + (suggestion) => + suggestion.table.changeType === 'reduced' && + isEqual(suggestion.state.layers.first.columnOrder, ['ref', 'metric']) + ) + ).toBeTruthy(); + + // top level "ref2" column + expect( + result.some( + (suggestion) => + suggestion.table.changeType === 'reduced' && + isEqual(suggestion.state.layers.first.columnOrder, ['ref2', 'metric2']) + ) + ).toBeTruthy(); + + // top level "ref3" column + expect( + result.some( + (suggestion) => + suggestion.table.changeType === 'reduced' && + isEqual(suggestion.state.layers.first.columnOrder, [ + 'ref3', + 'ref4', + 'metric3', + 'metric4', + ]) + ) + ).toBeTruthy(); }); }); + + it('will leave dangling references in place', () => { + const initialState = testInitialState(); + const state: IndexPatternPrivateState = { + ...initialState, + layers: { + ...initialState.layers, + first: { + ...initialState.layers.first, + columnOrder: ['date', 'ref'], + + columns: { + date: { + label: '', + dataType: 'date', + isBucketed: true, + operationType: 'date_histogram', + sourceField: 'timestamp', + params: { interval: 'auto' }, + }, + ref: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'cumulative_sum', + references: ['non_existing_metric'], + }, + }, + }, + }, + }; + + const result = getDatasourceSuggestionsFromCurrentState(state); + + // only generate suggestions for top level metrics + expect( + result.filter((suggestion) => suggestion.table.changeType === 'reduced').length + ).toEqual(1); + + // top level "ref" column + expect( + result.some( + (suggestion) => + suggestion.table.changeType === 'reduced' && + isEqual(suggestion.state.layers.first.columnOrder, ['ref']) + ) + ).toBeTruthy(); + }); + + it('will not suggest reduced tables if there is just a referenced top level metric', () => { + const initialState = testInitialState(); + const state: IndexPatternPrivateState = { + ...initialState, + layers: { + ...initialState.layers, + first: { + ...initialState.layers.first, + columnOrder: ['ref', 'metric'], + + columns: { + ref: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'math', + params: { + tinymathAst: '', + }, + references: ['metric'], + }, + metric: { + label: '', + dataType: 'number', + isBucketed: false, + operationType: 'count', + sourceField: 'Records', + }, + }, + }, + }, + }; + + const result = getDatasourceSuggestionsFromCurrentState(state); + + expect( + result.filter((suggestion) => suggestion.table.changeType === 'unchanged').length + ).toEqual(1); + + expect( + result.filter((suggestion) => suggestion.table.changeType === 'reduced').length + ).toEqual(0); + }); }); }); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts index 803ba9f5bae5dc..cff036db4813bb 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern_suggestions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { flatten, minBy, pick, mapValues } from 'lodash'; +import { flatten, minBy, pick, mapValues, partition } from 'lodash'; import { i18n } from '@kbn/i18n'; import { generateId } from '../id_generator'; import { DatasourceSuggestion, TableChangeType } from '../types'; @@ -20,6 +20,7 @@ import { OperationType, getExistingColumnGroups, isReferenced, + getReferencedColumnIds, } from './operations'; import { hasField } from './utils'; import { @@ -254,9 +255,11 @@ function getExistingLayerSuggestionsForField( } } - const metricSuggestion = createMetricSuggestion(indexPattern, layerId, state, field); - if (metricSuggestion) { - suggestions.push(metricSuggestion); + if (!fieldInUse) { + const metricSuggestion = createMetricSuggestion(indexPattern, layerId, state, field); + if (metricSuggestion) { + suggestions.push(metricSuggestion); + } } return suggestions; @@ -514,8 +517,11 @@ function createAlternativeMetricSuggestions( ) { const layer = state.layers[layerId]; const suggestions: Array> = []; + const topLevelMetricColumns = layer.columnOrder.filter( + (columnId) => !isReferenced(layer, columnId) + ); - layer.columnOrder.forEach((columnId) => { + topLevelMetricColumns.forEach((columnId) => { const column = layer.columns[columnId]; if (!hasField(column)) { return; @@ -580,11 +586,13 @@ function createSuggestionWithDefaultDateHistogram( function createSimplifiedTableSuggestions(state: IndexPatternPrivateState, layerId: string) { const layer = state.layers[layerId]; - const [ - availableBucketedColumns, - availableMetricColumns, - availableReferenceColumns, - ] = getExistingColumnGroups(layer); + const [availableBucketedColumns, availableMetricColumns] = partition( + layer.columnOrder, + (colId) => layer.columns[colId].isBucketed + ); + const topLevelMetricColumns = availableMetricColumns.filter( + (columnId) => !isReferenced(layer, columnId) + ); return flatten( availableBucketedColumns.map((_col, index) => { @@ -593,46 +601,60 @@ function createSimplifiedTableSuggestions(state: IndexPatternPrivateState, layer const allMetricsSuggestion = { ...layer, columnOrder: [...bucketedColumns, ...availableMetricColumns], + noBuckets: false, }; - if (availableBucketedColumns.length <= 1 || availableReferenceColumns.length) { - // Don't simplify when dealing with single-bucket table. Also don't break - // reference-based columns by removing buckets. + if (availableBucketedColumns.length <= 1) { + // Don't simplify when dealing with single-bucket table. return []; - } else if (availableMetricColumns.length > 1) { - return [{ ...layer, columnOrder: [...bucketedColumns, availableMetricColumns[0]] }]; + } else if (topLevelMetricColumns.length > 1) { + return [ + { + ...layer, + columnOrder: [ + ...bucketedColumns, + topLevelMetricColumns[0], + ...getReferencedColumnIds(layer, topLevelMetricColumns[0]), + ], + noBuckets: false, + }, + ]; } else { return allMetricsSuggestion; } }) ) .concat( - availableReferenceColumns.length - ? [] - : availableMetricColumns.map((columnId) => { - return { ...layer, columnOrder: [columnId] }; + // if there is just a single top level metric, the unchanged suggestion will take care of this case - only split up if there are multiple metrics or at least one bucket + availableBucketedColumns.length > 0 || topLevelMetricColumns.length > 1 + ? topLevelMetricColumns.map((columnId) => { + return { + ...layer, + columnOrder: [columnId, ...getReferencedColumnIds(layer, columnId)], + noBuckets: true, + }; }) + : [] ) - .map((updatedLayer) => { + .map(({ noBuckets, ...updatedLayer }) => { return buildSuggestion({ state, layerId, updatedLayer, changeType: 'reduced', - label: - updatedLayer.columnOrder.length === 1 - ? getMetricSuggestionTitle(updatedLayer, availableMetricColumns.length === 1) - : undefined, + label: noBuckets + ? getMetricSuggestionTitle(updatedLayer, availableMetricColumns.length === 1) + : undefined, }); }); } -function getMetricSuggestionTitle(layer: IndexPatternLayer, onlyMetric: boolean) { +function getMetricSuggestionTitle(layer: IndexPatternLayer, onlySimpleMetric: boolean) { const { operationType, label } = layer.columns[layer.columnOrder[0]]; return i18n.translate('xpack.lens.indexpattern.suggestions.overallLabel', { defaultMessage: '{operation} overall', values: { - operation: onlyMetric ? operationDefinitionMap[operationType].displayName : label, + operation: onlySimpleMetric ? operationDefinitionMap[operationType].displayName : label, }, description: 'Title of a suggested chart containing only a single numerical metric calculated over all available data', diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/__mocks__/index.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/__mocks__/index.ts index 40d7e3ef94ad68..d6429fb67e9a1d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/__mocks__/index.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/__mocks__/index.ts @@ -17,6 +17,7 @@ jest.spyOn(actualHelpers, 'insertOrReplaceColumn'); jest.spyOn(actualHelpers, 'insertNewColumn'); jest.spyOn(actualHelpers, 'replaceColumn'); jest.spyOn(actualHelpers, 'getErrorMessages'); +jest.spyOn(actualHelpers, 'getColumnOrder'); export const { getAvailableOperationsByMetadata, @@ -48,6 +49,8 @@ export const { resetIncomplete, isOperationAllowedAsReference, canTransition, + isColumnValidAsReference, + getManagedColumnsFrom, } = actualHelpers; export const { adjustTimeScaleLabelSuffix, DEFAULT_TIME_SCALE } = actualTimeScaleUtils; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx index 823ec3eb58a924..396eae9b39c412 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/counter_rate.tsx @@ -121,5 +121,23 @@ export const counterRateOperation: OperationDefinition< }, timeScalingMode: 'mandatory', filterable: true, + documentation: { + section: 'calculation', + signature: i18n.translate('xpack.lens.indexPattern.counterRate.signature', { + defaultMessage: 'metric: number', + }), + description: i18n.translate('xpack.lens.indexPattern.counterRate.documentation', { + defaultMessage: ` +Calculates the rate of an ever increasing counter. This function will only yield helpful results on counter metric fields which contain a measurement of some kind monotonically growing over time. +If the value does get smaller, it will interpret this as a counter reset. To get most precise results, \`counter_rate\` should be calculated on the \`max\` of a field. + +This calculation will be done separately for separate series defined by filters or top values dimensions. +It uses the current interval when used in Formula. + +Example: Visualize the rate of bytes received over time by a memcached server: +\`counter_rate(max(memcached.stats.read.bytes))\` + `, + }), + }, shiftable: true, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx index c4f01e27be886f..f39e5587b398c0 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/cumulative_sum.tsx @@ -117,5 +117,21 @@ export const cumulativeSumOperation: OperationDefinition< )?.join(', '); }, filterable: true, + documentation: { + section: 'calculation', + signature: i18n.translate('xpack.lens.indexPattern.cumulative_sum.signature', { + defaultMessage: 'metric: number', + }), + description: i18n.translate('xpack.lens.indexPattern.cumulativeSum.documentation', { + defaultMessage: ` +Calculates the cumulative sum of a metric over time, adding all previous values of a series to each value. To use this function, you need to configure a date histogram dimension as well. + +This calculation will be done separately for separate series defined by filters or top values dimensions. + +Example: Visualize the received bytes accumulated over time: +\`cumulative_sum(sum(bytes))\` + `, + }), + }, shiftable: true, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx index 7c48b5742b8dbb..e103acd9ab6779 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/differences.tsx @@ -109,5 +109,22 @@ export const derivativeOperation: OperationDefinition< }, timeScalingMode: 'optional', filterable: true, + documentation: { + section: 'calculation', + signature: i18n.translate('xpack.lens.indexPattern.differences.signature', { + defaultMessage: 'metric: number', + }), + description: i18n.translate('xpack.lens.indexPattern.differences.documentation', { + defaultMessage: ` +Calculates the difference to the last value of a metric over time. To use this function, you need to configure a date histogram dimension as well. +Differences requires the data to be sequential. If your data is empty when using differences, try increasing the date histogram interval. + +This calculation will be done separately for separate series defined by filters or top values dimensions. + +Example: Visualize the change in bytes received over time: +\`differences(sum(bytes))\` + `, + }), + }, shiftable: true, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx index a3d0241d4887e9..ee305bc043f1be 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/moving_average.tsx @@ -65,7 +65,9 @@ export const movingAverageOperation: OperationDefinition< validateMetadata: (meta) => meta.dataType === 'number' && !meta.isBucketed, }, ], - operationParams: [{ name: 'window', type: 'number', required: true }], + operationParams: [ + { name: 'window', type: 'number', required: false, defaultValue: WINDOW_DEFAULT_VALUE }, + ], getPossibleOperation: (indexPattern) => { if (hasDateField(indexPattern)) { return { @@ -130,6 +132,28 @@ export const movingAverageOperation: OperationDefinition< }, timeScalingMode: 'optional', filterable: true, + documentation: { + section: 'calculation', + signature: i18n.translate('xpack.lens.indexPattern.moving_average.signature', { + defaultMessage: 'metric: number, [window]: number', + }), + description: i18n.translate('xpack.lens.indexPattern.movingAverage.documentation', { + defaultMessage: ` +Calculates the moving average of a metric over time, averaging the last n-th values to calculate the current value. To use this function, you need to configure a date histogram dimension as well. +The default window value is {defaultValue}. + +This calculation will be done separately for separate series defined by filters or top values dimensions. + +Takes a named parameter \`window\` which specifies how many last values to include in the average calculation for the current value. + +Example: Smooth a line of measurements: +\`moving_average(sum(bytes), window=5)\` + `, + values: { + defaultValue: WINDOW_DEFAULT_VALUE, + }, + }), + }, shiftable: true, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx index 1911af0a6f679b..4da8a3ca0eb24e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/cardinality.tsx @@ -116,4 +116,21 @@ export const cardinalityOperation: OperationDefinition { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx index 46fddd9b1ffbf4..75068817c61237 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx @@ -28,6 +28,9 @@ const defaultProps = { http: {} as HttpSetup, indexPattern: createMockedIndexPattern(), operationDefinitionMap: {}, + isFullscreen: false, + toggleFullscreen: jest.fn(), + setIsCloseable: jest.fn(), }; // mocking random id generator function diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss new file mode 100644 index 00000000000000..14b3fc33efb4e6 --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss @@ -0,0 +1,167 @@ +.lnsFormula { + display: flex; + flex-direction: column; + + .lnsIndexPatternDimensionEditor-isFullscreen & { + height: 100%; + } + + & > * { + flex: 1; + min-height: 0; + } + + & > * + * { + border-top: $euiBorderThin; + } +} + +.lnsFormula__editor { + border-bottom: $euiBorderThin; + + .lnsIndexPatternDimensionEditor-isFullscreen & { + border-bottom: none; + display: flex; + flex-direction: column; + } + + & > * + * { + border-top: $euiBorderThin; + } +} + +.lnsFormula__editorHeader, +.lnsFormula__editorFooter { + padding: $euiSizeS; +} + +.lnsFormula__editorFooter { + // make sure docs are rendered in front of monaco + z-index: 1; + background-color: $euiColorLightestShade; +} + +.lnsFormula__editorHeaderGroup, +.lnsFormula__editorFooterGroup { + display: block; // Overrides EUI's styling of `display: flex` on `EuiFlexItem` components +} + +.lnsFormula__editorContent { + position: relative; + height: 201px; +} + +.lnsFormula__editorPlaceholder { + position: absolute; + top: 0; + left: $euiSize; + right: 0; + color: $euiTextSubduedColor; + // Matches monaco editor + font-family: Menlo, Monaco, 'Courier New', monospace; + pointer-events: none; +} + +.lnsIndexPatternDimensionEditor-isFullscreen .lnsFormula__editorContent { + flex: 1; + min-height: 201px; +} + +.lnsFormula__warningText + .lnsFormula__warningText { + margin-top: $euiSizeS; + border-top: $euiBorderThin; + padding-top: $euiSizeS; +} + +.lnsFormula__editorHelp--inline { + align-items: center; + display: flex; + padding: $euiSizeXS; + + & > * + * { + margin-left: $euiSizeXS; + } +} + +.lnsFormula__editorError { + white-space: nowrap; +} + +.lnsFormula__docs { + background: $euiColorEmptyShade; +} + +.lnsFormula__docs--inline { + display: flex; + flex-direction: column; + // make sure docs are rendered in front of monaco + z-index: 1; +} + +.lnsFormula__docsContent { + .lnsFormula__docs--overlay & { + height: 40vh; + width: #{'min(75vh, 90vw)'}; + } + + .lnsFormula__docs--inline & { + flex: 1; + min-height: 0; + } + + & > * + * { + border-left: $euiBorderThin; + } +} + +.lnsFormula__docsSidebar { + background: $euiColorLightestShade; +} + +.lnsFormula__docsSidebarInner { + min-height: 0; + + & > * + * { + border-top: $euiBorderThin; + } +} + +.lnsFormula__docsSearch { + padding: $euiSizeS; +} + +.lnsFormula__docsNav { + @include euiYScroll; +} + +.lnsFormula__docsNavGroup { + padding: $euiSizeS; + + & + & { + border-top: $euiBorderThin; + } +} + +.lnsFormula__docsNavGroupLink { + font-weight: inherit; +} + +.lnsFormula__docsText { + @include euiYScroll; + padding: $euiSize; +} + +.lnsFormula__docsTextGroup, +.lnsFormula__docsTextItem { + margin-top: $euiSizeXXL; +} + +.lnsFormula__docsTextGroup { + border-top: $euiBorderThin; + padding-top: $euiSizeXXL; +} + +.lnsFormulaOverflow { + // Needs to be higher than the modal and all flyouts + z-index: $euiZLevel9 + 1; +} diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_editor.tsx new file mode 100644 index 00000000000000..312ceb116dcede --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_editor.tsx @@ -0,0 +1,791 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useCallback, useEffect, useState, useMemo } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiButtonIcon, + EuiButtonEmpty, + EuiFlexGroup, + EuiFlexItem, + EuiIcon, + EuiLink, + EuiPopover, + EuiText, + EuiToolTip, + EuiSpacer, +} from '@elastic/eui'; +import useUnmount from 'react-use/lib/useUnmount'; +import { monaco } from '@kbn/monaco'; +import classNames from 'classnames'; +import { CodeEditor } from '../../../../../../../../../src/plugins/kibana_react/public'; +import type { CodeEditorProps } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { useDebounceWithOptions } from '../../../../../shared_components'; +import { ParamEditorProps } from '../../index'; +import { getManagedColumnsFrom } from '../../../layer_helpers'; +import { ErrorWrapper, runASTValidation, tryToParse } from '../validation'; +import { + LensMathSuggestion, + SUGGESTION_TYPE, + suggest, + getSuggestion, + getSignatureHelp, + getHover, + getTokenInfo, + offsetToRowColumn, + monacoPositionToOffset, +} from './math_completion'; +import { LANGUAGE_ID } from './math_tokenization'; +import { MemoizedFormulaHelp } from './formula_help'; +import { trackUiEvent } from '../../../../../lens_ui_telemetry'; + +import './formula.scss'; +import { FormulaIndexPatternColumn } from '../formula'; +import { regenerateLayerFromAst } from '../parse'; +import { filterByVisibleOperation } from '../util'; + +export const MemoizedFormulaEditor = React.memo(FormulaEditor); + +export function FormulaEditor({ + layer, + updateLayer, + currentColumn, + columnId, + indexPattern, + operationDefinitionMap, + data, + toggleFullscreen, + isFullscreen, + setIsCloseable, +}: ParamEditorProps) { + const [text, setText] = useState(currentColumn.params.formula); + const [warnings, setWarnings] = useState< + Array<{ severity: monaco.MarkerSeverity; message: string }> + >([]); + const [isHelpOpen, setIsHelpOpen] = useState(isFullscreen); + const [isWarningOpen, setIsWarningOpen] = useState(false); + const [isWordWrapped, toggleWordWrap] = useState(true); + const editorModel = React.useRef(); + const overflowDiv1 = React.useRef(); + const disposables = React.useRef([]); + const editor1 = React.useRef(); + + const visibleOperationsMap = useMemo(() => filterByVisibleOperation(operationDefinitionMap), [ + operationDefinitionMap, + ]); + + // The Monaco editor needs to have the overflowDiv in the first render. Using an effect + // requires a second render to work, so we are using an if statement to guarantee it happens + // on first render + if (!overflowDiv1?.current) { + const node1 = (overflowDiv1.current = document.createElement('div')); + node1.setAttribute('data-test-subj', 'lnsFormulaWidget'); + // Monaco CSS is targeted on the monaco-editor class + node1.classList.add('lnsFormulaOverflow', 'monaco-editor'); + document.body.appendChild(node1); + } + + // Clean up the monaco editor and DOM on unmount + useEffect(() => { + const model = editorModel; + const allDisposables = disposables; + const editor1ref = editor1; + return () => { + model.current?.dispose(); + overflowDiv1.current?.parentNode?.removeChild(overflowDiv1.current); + editor1ref.current?.dispose(); + allDisposables.current?.forEach((d) => d.dispose()); + }; + }, []); + + useUnmount(() => { + setIsCloseable(true); + // If the text is not synced, update the column. + if (text !== currentColumn.params.formula) { + updateLayer((prevLayer) => { + return regenerateLayerFromAst( + text || '', + prevLayer, + columnId, + currentColumn, + indexPattern, + operationDefinitionMap + ).newLayer; + }); + } + }); + + useDebounceWithOptions( + () => { + if (!editorModel.current) return; + + if (!text) { + setWarnings([]); + monaco.editor.setModelMarkers(editorModel.current, 'LENS', []); + if (currentColumn.params.formula) { + // Only submit if valid + const { newLayer } = regenerateLayerFromAst( + text || '', + layer, + columnId, + currentColumn, + indexPattern, + operationDefinitionMap + ); + updateLayer(newLayer); + } + + return; + } + + let errors: ErrorWrapper[] = []; + + const { root, error } = tryToParse(text, visibleOperationsMap); + if (error) { + errors = [error]; + } else if (root) { + const validationErrors = runASTValidation(root, layer, indexPattern, visibleOperationsMap); + if (validationErrors.length) { + errors = validationErrors; + } + } + + if (errors.length) { + if (currentColumn.params.isFormulaBroken) { + // If the formula is already broken, show the latest error message in the workspace + if (currentColumn.params.formula !== text) { + updateLayer( + regenerateLayerFromAst( + text || '', + layer, + columnId, + currentColumn, + indexPattern, + visibleOperationsMap + ).newLayer + ); + } + } + + const markers = errors.flatMap((innerError) => { + if (innerError.locations.length) { + return innerError.locations.map((location) => { + const startPosition = offsetToRowColumn(text, location.min); + const endPosition = offsetToRowColumn(text, location.max); + return { + message: innerError.message, + startColumn: startPosition.column + 1, + startLineNumber: startPosition.lineNumber, + endColumn: endPosition.column + 1, + endLineNumber: endPosition.lineNumber, + severity: + innerError.severity === 'warning' + ? monaco.MarkerSeverity.Warning + : monaco.MarkerSeverity.Error, + }; + }); + } else { + // Parse errors return no location info + const startPosition = offsetToRowColumn(text, 0); + const endPosition = offsetToRowColumn(text, text.length - 1); + return [ + { + message: innerError.message, + startColumn: startPosition.column + 1, + startLineNumber: startPosition.lineNumber, + endColumn: endPosition.column + 1, + endLineNumber: endPosition.lineNumber, + severity: + innerError.severity === 'warning' + ? monaco.MarkerSeverity.Warning + : monaco.MarkerSeverity.Error, + }, + ]; + } + }); + + monaco.editor.setModelMarkers(editorModel.current, 'LENS', markers); + setWarnings(markers.map(({ severity, message }) => ({ severity, message }))); + } else { + monaco.editor.setModelMarkers(editorModel.current, 'LENS', []); + + // Only submit if valid + const { newLayer, locations } = regenerateLayerFromAst( + text || '', + layer, + columnId, + currentColumn, + indexPattern, + visibleOperationsMap + ); + updateLayer(newLayer); + + const managedColumns = getManagedColumnsFrom(columnId, newLayer.columns); + const markers: monaco.editor.IMarkerData[] = managedColumns + .flatMap(([id, column]) => { + if (locations[id]) { + const def = visibleOperationsMap[column.operationType]; + if (def.getErrorMessage) { + const messages = def.getErrorMessage( + newLayer, + id, + indexPattern, + visibleOperationsMap + ); + if (messages) { + const startPosition = offsetToRowColumn(text, locations[id].min); + const endPosition = offsetToRowColumn(text, locations[id].max); + return [ + { + message: messages.join(', '), + startColumn: startPosition.column + 1, + startLineNumber: startPosition.lineNumber, + endColumn: endPosition.column + 1, + endLineNumber: endPosition.lineNumber, + severity: monaco.MarkerSeverity.Warning, + }, + ]; + } + } + } + return []; + }) + .filter((marker) => marker); + setWarnings(markers.map(({ severity, message }) => ({ severity, message }))); + monaco.editor.setModelMarkers(editorModel.current, 'LENS', markers); + } + }, + // Make it validate on flyout open in case of a broken formula left over + // from a previous edit + { skipFirstRender: false }, + 256, + [text] + ); + + const errorCount = warnings.filter((marker) => marker.severity === monaco.MarkerSeverity.Error) + .length; + const warningCount = warnings.filter( + (marker) => marker.severity === monaco.MarkerSeverity.Warning + ).length; + + /** + * The way that Monaco requests autocompletion is not intuitive, but the way we use it + * we fetch new suggestions in these scenarios: + * + * - If the user types one of the trigger characters, suggestions are always fetched + * - When the user selects the kql= suggestion, we tell Monaco to trigger new suggestions after + * - When the user types the first character into an empty text box, Monaco requests suggestions + * + * Monaco also triggers suggestions automatically when there are no suggestions being displayed + * and the user types a non-whitespace character. + * + * While suggestions are being displayed, Monaco uses an in-memory cache of the last known suggestions. + */ + const provideCompletionItems = useCallback( + async ( + model: monaco.editor.ITextModel, + position: monaco.Position, + context: monaco.languages.CompletionContext + ) => { + const innerText = model.getValue(); + let aSuggestions: { list: LensMathSuggestion[]; type: SUGGESTION_TYPE } = { + list: [], + type: SUGGESTION_TYPE.FIELD, + }; + const offset = monacoPositionToOffset(innerText, position); + + if (context.triggerCharacter === '(') { + // Monaco usually inserts the end quote and reports the position is after the end quote + if (innerText.slice(offset - 1, offset + 1) === '()') { + position = position.delta(0, -1); + } + const wordUntil = model.getWordAtPosition(position.delta(0, -3)); + if (wordUntil) { + // Retrieve suggestions for subexpressions + aSuggestions = await suggest({ + expression: innerText, + zeroIndexedOffset: offset, + context, + indexPattern, + operationDefinitionMap: visibleOperationsMap, + data, + }); + } + } else { + aSuggestions = await suggest({ + expression: innerText, + zeroIndexedOffset: offset, + context, + indexPattern, + operationDefinitionMap: visibleOperationsMap, + data, + }); + } + + return { + suggestions: aSuggestions.list.map((s) => + getSuggestion(s, aSuggestions.type, visibleOperationsMap, context.triggerCharacter) + ), + }; + }, + [indexPattern, visibleOperationsMap, data] + ); + + const provideSignatureHelp = useCallback( + async ( + model: monaco.editor.ITextModel, + position: monaco.Position, + token: monaco.CancellationToken, + context: monaco.languages.SignatureHelpContext + ) => { + const innerText = model.getValue(); + const textRange = model.getFullModelRange(); + + const lengthAfterPosition = model.getValueLengthInRange({ + startLineNumber: position.lineNumber, + startColumn: position.column, + endLineNumber: textRange.endLineNumber, + endColumn: textRange.endColumn, + }); + return getSignatureHelp( + model.getValue(), + innerText.length - lengthAfterPosition, + visibleOperationsMap + ); + }, + [visibleOperationsMap] + ); + + const provideHover = useCallback( + async ( + model: monaco.editor.ITextModel, + position: monaco.Position, + token: monaco.CancellationToken + ) => { + const innerText = model.getValue(); + const textRange = model.getFullModelRange(); + + const lengthAfterPosition = model.getValueLengthInRange({ + startLineNumber: position.lineNumber, + startColumn: position.column, + endLineNumber: textRange.endLineNumber, + endColumn: textRange.endColumn, + }); + return getHover( + model.getValue(), + innerText.length - lengthAfterPosition, + visibleOperationsMap + ); + }, + [visibleOperationsMap] + ); + + const onTypeHandler = useCallback( + (e: monaco.editor.IModelContentChangedEvent, editor: monaco.editor.IStandaloneCodeEditor) => { + if (e.isFlush || e.isRedoing || e.isUndoing) { + return; + } + if (e.changes.length === 1) { + const char = e.changes[0].text; + if (char !== '=' && char !== "'") { + return; + } + const currentPosition = e.changes[0].range; + if (currentPosition) { + const currentText = editor.getValue(); + const offset = monacoPositionToOffset( + currentText, + new monaco.Position(currentPosition.startLineNumber, currentPosition.startColumn) + ); + let tokenInfo = getTokenInfo(currentText, offset + 1); + + if (!tokenInfo && char === "'") { + // try again this time replacing the current quote with an escaped quote + const line = currentText; + const lineEscaped = line.substring(0, offset) + "\\'" + line.substring(offset + 1); + tokenInfo = getTokenInfo(lineEscaped, offset + 2); + } + + const isSingleQuoteCase = /'LENS_MATH_MARKER/; + // Make sure that we are only adding kql='' or lucene='', and also + // check that the = sign isn't inside the KQL expression like kql='=' + if ( + !tokenInfo || + typeof tokenInfo.ast === 'number' || + tokenInfo.ast.type !== 'namedArgument' || + (tokenInfo.ast.name !== 'kql' && tokenInfo.ast.name !== 'lucene') || + (tokenInfo.ast.value !== 'LENS_MATH_MARKER' && + !isSingleQuoteCase.test(tokenInfo.ast.value)) + ) { + return; + } + + let editOperation: monaco.editor.IIdentifiedSingleEditOperation | null = null; + const cursorOffset = 2; + if (char === '=') { + editOperation = { + range: { + ...currentPosition, + // Insert after the current char + startColumn: currentPosition.startColumn + 1, + endColumn: currentPosition.startColumn + 1, + }, + text: `''`, + }; + } + if (char === "'") { + editOperation = { + range: { + ...currentPosition, + // Insert after the current char + startColumn: currentPosition.startColumn, + endColumn: currentPosition.startColumn + 1, + }, + text: `\\'`, + }; + } + + if (editOperation) { + setTimeout(() => { + editor.executeEdits( + 'LENS', + [editOperation!], + [ + // After inserting, move the cursor in between the single quotes or after the escaped quote + new monaco.Selection( + currentPosition.startLineNumber, + currentPosition.startColumn + cursorOffset, + currentPosition.startLineNumber, + currentPosition.startColumn + cursorOffset + ), + ] + ); + + // Need to move these sync to prevent race conditions between a fast user typing a single quote + // after an = char + // Timeout is required because otherwise the cursor position is not updated. + editor.setPosition({ + column: currentPosition.startColumn + cursorOffset, + lineNumber: currentPosition.startLineNumber, + }); + editor.trigger('lens', 'editor.action.triggerSuggest', {}); + }, 0); + } + } + } + }, + [] + ); + + const codeEditorOptions: CodeEditorProps = { + languageId: LANGUAGE_ID, + value: text ?? '', + onChange: setText, + options: { + automaticLayout: false, + fontSize: 14, + folding: false, + lineNumbers: 'off', + scrollBeyondLastLine: false, + minimap: { enabled: false }, + wordWrap: isWordWrapped ? 'on' : 'off', + // Disable suggestions that appear when we don't provide a default suggestion + wordBasedSuggestions: false, + autoIndent: 'brackets', + wrappingIndent: 'none', + dimension: { width: 320, height: 200 }, + fixedOverflowWidgets: true, + matchBrackets: 'always', + }, + }; + + useEffect(() => { + // Because the monaco model is owned by Lens, we need to manually attach and remove handlers + const { dispose: dispose1 } = monaco.languages.registerCompletionItemProvider(LANGUAGE_ID, { + triggerCharacters: ['.', '(', '=', ' ', ':', `'`], + provideCompletionItems, + }); + const { dispose: dispose2 } = monaco.languages.registerSignatureHelpProvider(LANGUAGE_ID, { + signatureHelpTriggerCharacters: ['(', '='], + provideSignatureHelp, + }); + const { dispose: dispose3 } = monaco.languages.registerHoverProvider(LANGUAGE_ID, { + provideHover, + }); + return () => { + dispose1(); + dispose2(); + dispose3(); + }; + }, [provideCompletionItems, provideSignatureHelp, provideHover]); + + // The Monaco editor will lazily load Monaco, which takes a render cycle to trigger. This can cause differences + // in the behavior of Monaco when it's first loaded and then reloaded. + return ( +
+
+
+
+
+ + + {/* TODO: Replace `bolt` with `wordWrap` icon (after latest EUI is deployed) and hook up button to enable/disable word wrapping. */} + + { + editor1.current?.updateOptions({ + wordWrap: isWordWrapped ? 'off' : 'on', + }); + toggleWordWrap(!isWordWrapped); + }} + /> + + + + + {/* TODO: Replace `bolt` with `fullScreenExit` icon (after latest EUI is deployed). */} + { + toggleFullscreen(); + // Help text opens when entering full screen, and closes when leaving full screen + setIsHelpOpen(!isFullscreen); + trackUiEvent('toggle_formula_fullscreen'); + }} + iconType={isFullscreen ? 'bolt' : 'fullScreen'} + size="xs" + color="text" + flush="right" + data-test-subj="lnsFormula-fullscreen" + > + {isFullscreen + ? i18n.translate('xpack.lens.formula.fullScreenExitLabel', { + defaultMessage: 'Collapse', + }) + : i18n.translate('xpack.lens.formula.fullScreenEnterLabel', { + defaultMessage: 'Expand', + })} + + + +
+ +
+ { + editor1.current = editor; + const model = editor.getModel(); + if (model) { + editorModel.current = model; + } + disposables.current.push( + editor.onDidFocusEditorWidget(() => { + setTimeout(() => { + setIsCloseable(false); + }); + }) + ); + disposables.current.push( + editor.onDidBlurEditorWidget(() => { + setTimeout(() => { + setIsCloseable(true); + }); + }) + ); + // If we ever introduce a second Monaco editor, we need to toggle + // the typing handler to the active editor to maintain the cursor + disposables.current.push( + editor.onDidChangeModelContent((e) => { + onTypeHandler(e, editor); + }) + ); + }} + /> + + {!text ? ( +
+ + {i18n.translate('xpack.lens.formulaPlaceholderText', { + defaultMessage: 'Type a formula by combining functions with math, like:', + })} + + +
count() + 1
+
+ ) : null} +
+ +
+ + + {isFullscreen ? ( + + setIsHelpOpen(!isHelpOpen)} + > + + + + + ) : ( + + setIsHelpOpen(false)} + ownFocus={false} + button={ + setIsHelpOpen(!isHelpOpen)} + iconType="help" + color="text" + size="s" + aria-label={i18n.translate( + 'xpack.lens.formula.editorHelpInlineShowToolTip', + { + defaultMessage: 'Show function reference', + } + )} + /> + } + > + + + + )} + + + {errorCount || warningCount ? ( + + setIsWarningOpen(false)} + button={ + { + setIsWarningOpen(!isWarningOpen); + }} + > + {errorCount + ? i18n.translate('xpack.lens.formulaErrorCount', { + defaultMessage: + '{count} {count, plural, one {error} other {errors}}', + values: { count: errorCount }, + }) + : null} + {warningCount + ? i18n.translate('xpack.lens.formulaWarningCount', { + defaultMessage: + '{count} {count, plural, one {warning} other {warnings}}', + values: { count: warningCount }, + }) + : null} + + } + > + {warnings.map(({ message, severity }, index) => ( +
+ + {message} + +
+ ))} +
+
+ ) : null} +
+
+
+ + {isFullscreen && isHelpOpen ? ( +
+ +
+ ) : null} +
+
+
+ ); +} diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx new file mode 100644 index 00000000000000..afe5471666b22b --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx @@ -0,0 +1,469 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useEffect, useRef, useState, useMemo } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiLink, + EuiPopoverTitle, + EuiText, + EuiListGroupItem, + EuiListGroup, + EuiTitle, + EuiFieldSearch, + EuiHighlight, +} from '@elastic/eui'; +import { Markdown } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { IndexPattern } from '../../../../types'; +import { tinymathFunctions } from '../util'; +import { getPossibleFunctions } from './math_completion'; +import { hasFunctionFieldArgument } from '../validation'; + +import type { + GenericOperationDefinition, + IndexPatternColumn, + OperationDefinition, + ParamEditorProps, +} from '../../index'; +import type { FormulaIndexPatternColumn } from '../formula'; + +function FormulaHelp({ + indexPattern, + operationDefinitionMap, + isFullscreen, +}: { + indexPattern: IndexPattern; + operationDefinitionMap: Record; + isFullscreen: boolean; +}) { + const [selectedFunction, setSelectedFunction] = useState(); + const scrollTargets = useRef>({}); + + useEffect(() => { + if (selectedFunction && scrollTargets.current[selectedFunction]) { + scrollTargets.current[selectedFunction].scrollIntoView(); + } + }, [selectedFunction]); + + const helpGroups: Array<{ + label: string; + description?: string; + items: Array<{ label: string; description?: JSX.Element }>; + }> = []; + + helpGroups.push({ + label: i18n.translate('xpack.lens.formulaDocumentationHeading', { + defaultMessage: 'How it works', + }), + items: [], + }); + + helpGroups.push({ + label: i18n.translate('xpack.lens.formulaDocumentation.elasticsearchSection', { + defaultMessage: 'Elasticsearch', + }), + description: i18n.translate('xpack.lens.formulaDocumentation.elasticsearchSectionDescription', { + defaultMessage: + 'These functions will be executed on the raw documents for each row of the resulting table, aggregating all documents matching the break down dimensions into a single value.', + }), + items: [], + }); + + const availableFunctions = getPossibleFunctions(indexPattern); + + // Es aggs + helpGroups[1].items.push( + ...availableFunctions + .filter( + (key) => + key in operationDefinitionMap && + operationDefinitionMap[key].documentation?.section === 'elasticsearch' + ) + .sort() + .map((key) => ({ + label: key, + description: ( + <> +

+ {key}({operationDefinitionMap[key].documentation?.signature}) +

+ + {operationDefinitionMap[key].documentation?.description ? ( + + ) : null} + + ), + })) + ); + + helpGroups.push({ + label: i18n.translate('xpack.lens.formulaDocumentation.columnCalculationSection', { + defaultMessage: 'Column-wise calculation', + }), + description: i18n.translate( + 'xpack.lens.formulaDocumentation.columnCalculationSectionDescription', + { + defaultMessage: + 'These functions will be executed for reach row of the resulting table, using data from cells from other rows as well as the current value.', + } + ), + items: [], + }); + + // Calculations aggs + helpGroups[2].items.push( + ...availableFunctions + .filter( + (key) => + key in operationDefinitionMap && + operationDefinitionMap[key].documentation?.section === 'calculation' + ) + .sort() + .map((key) => ({ + label: key, + description: ( + <> +

+ {key}({operationDefinitionMap[key].documentation?.signature}) +

+ + {operationDefinitionMap[key].documentation?.description ? ( + + ) : null} + + ), + checked: + selectedFunction === `${key}: ${operationDefinitionMap[key].displayName}` + ? ('on' as const) + : undefined, + })) + ); + + helpGroups.push({ + label: i18n.translate('xpack.lens.formulaDocumentation.mathSection', { + defaultMessage: 'Math', + }), + description: i18n.translate('xpack.lens.formulaDocumentation.mathSectionDescription', { + defaultMessage: + 'These functions will be executed for reach row of the resulting table using single values from the same row calculated using other functions.', + }), + items: [], + }); + + const tinymathFns = useMemo(() => { + return getPossibleFunctions(indexPattern) + .filter((key) => key in tinymathFunctions) + .sort() + .map((key) => { + const [description, examples] = tinymathFunctions[key].help.split(`\`\`\``); + return { + label: key, + description: description.replace(/\n/g, '\n\n'), + examples: examples ? `\`\`\`${examples}\`\`\`` : '', + }; + }); + }, [indexPattern]); + + helpGroups[3].items.push( + ...tinymathFns.map(({ label, description, examples }) => { + return { + label, + description: ( + <> +

{getFunctionSignatureLabel(label, operationDefinitionMap)}

+ + + + ), + }; + }) + ); + + const [searchText, setSearchText] = useState(''); + + const normalizedSearchText = searchText.trim().toLocaleLowerCase(); + + const filteredHelpGroups = helpGroups + .map((group) => { + const items = group.items.filter((helpItem) => { + return ( + !normalizedSearchText || helpItem.label.toLocaleLowerCase().includes(normalizedSearchText) + ); + }); + return { ...group, items }; + }) + .filter((group) => { + if (group.items.length > 0 || !normalizedSearchText) { + return true; + } + return group.label.toLocaleLowerCase().includes(normalizedSearchText); + }); + + return ( + <> + + {i18n.translate('xpack.lens.formulaDocumentation.header', { + defaultMessage: 'Formula reference', + })} + + + + + + + { + setSearchText(e.target.value); + }} + placeholder={i18n.translate('xpack.lens.formulaSearchPlaceholder', { + defaultMessage: 'Search functions', + })} + /> + + + + {filteredHelpGroups.map((helpGroup, index) => { + return ( + + ); + })} + + + + + + +
{ + if (el) { + scrollTargets.current[helpGroups[0].label] = el; + } + }} + > + +
+ + {helpGroups.slice(1).map((helpGroup, index) => { + return ( +
{ + if (el) { + scrollTargets.current[helpGroup.label] = el; + } + }} + > +

{helpGroup.label}

+ +

{helpGroup.description}

+ + {helpGroups[index + 1].items.map((helpItem) => { + return ( +
{ + if (el) { + scrollTargets.current[helpItem.label] = el; + } + }} + > + {helpItem.description} +
+ ); + })} +
+ ); + })} +
+
+
+ + ); +} + +export const MemoizedFormulaHelp = React.memo(FormulaHelp); + +export function getFunctionSignatureLabel( + name: string, + operationDefinitionMap: ParamEditorProps['operationDefinitionMap'], + firstParam?: { label: string | [number, number] } | null +): string { + if (tinymathFunctions[name]) { + return `${name}(${tinymathFunctions[name].positionalArguments + .map(({ name: argName, optional, type }) => `[${argName}]${optional ? '?' : ''}: ${type}`) + .join(', ')})`; + } + if (operationDefinitionMap[name]) { + const def = operationDefinitionMap[name]; + let extraArgs = ''; + if (def.filterable) { + extraArgs += hasFunctionFieldArgument(name) || 'operationParams' in def ? ',' : ''; + extraArgs += i18n.translate('xpack.lens.formula.kqlExtraArguments', { + defaultMessage: '[kql]?: string, [lucene]?: string', + }); + } + return `${name}(${def.documentation?.signature}${extraArgs})`; + } + return ''; +} + +function getFunctionArgumentsStringified( + params: Required< + OperationDefinition + >['operationParams'] +) { + return params + .map( + ({ name, type: argType, defaultValue = 5 }) => + `${name}=${argType === 'string' ? `"${defaultValue}"` : defaultValue}` + ) + .join(', '); +} + +/** + * Get an array of strings containing all possible information about a specific + * operation type: examples and infos. + */ +export function getHelpTextContent( + type: string, + operationDefinitionMap: ParamEditorProps['operationDefinitionMap'] +): { description: string; examples: string[] } { + const definition = operationDefinitionMap[type]; + const description = definition.documentation?.description ?? ''; + + // as for the time being just add examples text. + // Later will enrich with more information taken from the operation definitions. + const examples: string[] = []; + // If the description already contain examples skip it + if (!/Example/.test(description)) { + if (!hasFunctionFieldArgument(type)) { + // ideally this should have the same example automation as the operations below + examples.push(`${type}()`); + return { description, examples }; + } + if (definition.input === 'field') { + const mandatoryArgs = definition.operationParams?.filter(({ required }) => required) || []; + if (mandatoryArgs.length === 0) { + examples.push(`${type}(bytes)`); + } + if (mandatoryArgs.length) { + const additionalArgs = getFunctionArgumentsStringified(mandatoryArgs); + examples.push(`${type}(bytes, ${additionalArgs})`); + } + if ( + definition.operationParams && + mandatoryArgs.length !== definition.operationParams.length + ) { + const additionalArgs = getFunctionArgumentsStringified(definition.operationParams); + examples.push(`${type}(bytes, ${additionalArgs})`); + } + } + if (definition.input === 'fullReference') { + const mandatoryArgs = definition.operationParams?.filter(({ required }) => required) || []; + if (mandatoryArgs.length === 0) { + examples.push(`${type}(sum(bytes))`); + } + if (mandatoryArgs.length) { + const additionalArgs = getFunctionArgumentsStringified(mandatoryArgs); + examples.push(`${type}(sum(bytes), ${additionalArgs})`); + } + if ( + definition.operationParams && + mandatoryArgs.length !== definition.operationParams.length + ) { + const additionalArgs = getFunctionArgumentsStringified(definition.operationParams); + examples.push(`${type}(sum(bytes), ${additionalArgs})`); + } + } + } + return { description, examples }; +} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/hooks/index.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/index.ts similarity index 88% rename from x-pack/plugins/fleet/public/applications/fleet/sections/agents/hooks/index.tsx rename to x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/index.ts index d9b3bcd80752dc..4b6acefa6b30ad 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/hooks/index.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export * from './use_platform'; +export * from './formula_editor'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.test.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.test.ts new file mode 100644 index 00000000000000..9cd748f5759c98 --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.test.ts @@ -0,0 +1,386 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { parse } from '@kbn/tinymath'; +import { monaco } from '@kbn/monaco'; +import { createMockedIndexPattern } from '../../../../mocks'; +import { GenericOperationDefinition } from '../../index'; +import type { IndexPatternField } from '../../../../types'; +import type { OperationMetadata } from '../../../../../types'; +import { dataPluginMock } from '../../../../../../../../../src/plugins/data/public/mocks'; +import { tinymathFunctions } from '../util'; +import { + getSignatureHelp, + getHover, + suggest, + monacoPositionToOffset, + getInfoAtZeroIndexedPosition, +} from './math_completion'; + +const buildGenericColumn = (type: string) => { + return ({ field }: { field?: IndexPatternField }) => { + return { + label: type, + dataType: 'number', + operationType: type, + sourceField: field?.name ?? undefined, + isBucketed: false, + scale: 'ratio', + timeScale: false, + }; + }; +}; + +const numericOperation = () => ({ dataType: 'number', isBucketed: false }); +const stringOperation = () => ({ dataType: 'string', isBucketed: true }); + +// Only one of each type is needed +const operationDefinitionMap: Record = { + sum: ({ + type: 'sum', + input: 'field', + buildColumn: buildGenericColumn('sum'), + getPossibleOperationForField: (field: IndexPatternField) => + field.type === 'number' ? numericOperation() : null, + documentation: { + section: 'elasticsearch', + signature: 'field: string', + description: 'description', + }, + } as unknown) as GenericOperationDefinition, + count: ({ + type: 'count', + input: 'field', + buildColumn: buildGenericColumn('count'), + getPossibleOperationForField: (field: IndexPatternField) => + field.name === 'Records' ? numericOperation() : null, + } as unknown) as GenericOperationDefinition, + last_value: ({ + type: 'last_value', + input: 'field', + buildColumn: buildGenericColumn('last_value'), + getPossibleOperationForField: (field: IndexPatternField) => ({ + dataType: field.type, + isBucketed: false, + }), + } as unknown) as GenericOperationDefinition, + moving_average: ({ + type: 'moving_average', + input: 'fullReference', + requiredReferences: [ + { + input: ['field', 'managedReference'], + validateMetadata: (meta: OperationMetadata) => + meta.dataType === 'number' && !meta.isBucketed, + }, + ], + operationParams: [{ name: 'window', type: 'number', required: true }], + buildColumn: buildGenericColumn('moving_average'), + getPossibleOperation: numericOperation, + } as unknown) as GenericOperationDefinition, + cumulative_sum: ({ + type: 'cumulative_sum', + input: 'fullReference', + buildColumn: buildGenericColumn('cumulative_sum'), + getPossibleOperation: numericOperation, + } as unknown) as GenericOperationDefinition, + terms: ({ + type: 'terms', + input: 'field', + getPossibleOperationForField: stringOperation, + } as unknown) as GenericOperationDefinition, +}; + +describe('math completion', () => { + describe('signature help', () => { + function unwrapSignatures(signatureResult: monaco.languages.SignatureHelpResult) { + return signatureResult.value.signatures[0]; + } + + it('should silently handle parse errors', () => { + expect(unwrapSignatures(getSignatureHelp('sum(', 4, operationDefinitionMap))).toBeUndefined(); + }); + + it('should return a signature for a field-based ES function', () => { + expect(unwrapSignatures(getSignatureHelp('sum()', 4, operationDefinitionMap))).toEqual({ + label: 'sum(field: string)', + documentation: { value: 'description' }, + parameters: [{ label: 'field' }], + }); + }); + + it('should return a signature for count', () => { + expect(unwrapSignatures(getSignatureHelp('count()', 6, operationDefinitionMap))).toEqual({ + label: 'count(undefined)', + documentation: { value: '' }, + parameters: [], + }); + }); + + it('should return a signature for a function with named parameters', () => { + expect( + unwrapSignatures( + getSignatureHelp('2 * moving_average(count(), window=)', 35, operationDefinitionMap) + ) + ).toEqual({ + label: expect.stringContaining('moving_average('), + documentation: { value: '' }, + parameters: [ + { label: 'function' }, + { + label: 'window=number', + documentation: 'Required', + }, + ], + }); + }); + + it('should return a signature for an inner function', () => { + expect( + unwrapSignatures( + getSignatureHelp('2 * moving_average(count())', 25, operationDefinitionMap) + ) + ).toEqual({ + label: expect.stringContaining('count('), + parameters: [], + documentation: { value: '' }, + }); + }); + + it('should return a signature for a complex tinymath function', () => { + // 15 is the whitespace between the two arguments + expect( + unwrapSignatures(getSignatureHelp('clamp(count(), 5)', 15, operationDefinitionMap)) + ).toEqual({ + label: expect.stringContaining('clamp('), + documentation: { value: '' }, + parameters: [ + { label: 'value', documentation: '' }, + { label: 'min', documentation: '' }, + { label: 'max', documentation: '' }, + ], + }); + }); + }); + + describe('hover provider', () => { + it('should silently handle parse errors', () => { + expect(getHover('sum(', 2, operationDefinitionMap)).toEqual({ contents: [] }); + }); + + it('should show signature for a field-based ES function', () => { + expect(getHover('sum()', 2, operationDefinitionMap)).toEqual({ + contents: [{ value: 'sum(field: string)' }], + }); + }); + + it('should show signature for count', () => { + expect(getHover('count()', 2, operationDefinitionMap)).toEqual({ + contents: [{ value: expect.stringContaining('count(') }], + }); + }); + + it('should show signature for a function with named parameters', () => { + expect(getHover('2 * moving_average(count())', 10, operationDefinitionMap)).toEqual({ + contents: [{ value: expect.stringContaining('moving_average(') }], + }); + }); + + it('should show signature for an inner function', () => { + expect(getHover('2 * moving_average(count())', 22, operationDefinitionMap)).toEqual({ + contents: [{ value: expect.stringContaining('count(') }], + }); + }); + + it('should show signature for a complex tinymath function', () => { + expect(getHover('clamp(count(), 5)', 2, operationDefinitionMap)).toEqual({ + contents: [{ value: expect.stringContaining('clamp([value]: number') }], + }); + }); + }); + + describe('autocomplete', () => { + it('should list all valid functions at the top level (fake test)', async () => { + // This test forces an invalid scenario, since the autocomplete actually requires + // some typing + const results = await suggest({ + expression: '', + zeroIndexedOffset: 1, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: '', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toHaveLength(4 + Object.keys(tinymathFunctions).length); + ['sum', 'moving_average', 'cumulative_sum', 'last_value'].forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'operation' }])); + }); + Object.keys(tinymathFunctions).forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'operation' }])); + }); + }); + + it('should list all valid sub-functions for a fullReference', async () => { + const results = await suggest({ + expression: 'moving_average()', + zeroIndexedOffset: 15, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: '(', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toHaveLength(2); + ['sum', 'last_value'].forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'operation' }])); + }); + }); + + it('should list all valid named arguments for a fullReference', async () => { + const results = await suggest({ + expression: 'moving_average(count(),)', + zeroIndexedOffset: 23, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: ',', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toEqual(['window']); + }); + + it('should not list named arguments when they are already in use', async () => { + const results = await suggest({ + expression: 'moving_average(count(), window=5, )', + zeroIndexedOffset: 34, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: ',', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toEqual([]); + }); + + it('should list all valid positional arguments for a tinymath function used by name', async () => { + const results = await suggest({ + expression: 'divide(count(), )', + zeroIndexedOffset: 16, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: ',', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toHaveLength(4 + Object.keys(tinymathFunctions).length); + ['sum', 'moving_average', 'cumulative_sum', 'last_value'].forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'math' }])); + }); + Object.keys(tinymathFunctions).forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'math' }])); + }); + }); + + it('should list all valid positional arguments for a tinymath function used with alias', async () => { + const results = await suggest({ + expression: 'count() / ', + zeroIndexedOffset: 10, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: ',', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toHaveLength(4 + Object.keys(tinymathFunctions).length); + ['sum', 'moving_average', 'cumulative_sum', 'last_value'].forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'math' }])); + }); + Object.keys(tinymathFunctions).forEach((key) => { + expect(results.list).toEqual(expect.arrayContaining([{ label: key, type: 'math' }])); + }); + }); + + it('should not autocomplete any fields for the count function', async () => { + const results = await suggest({ + expression: 'count()', + zeroIndexedOffset: 6, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: '(', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toHaveLength(0); + }); + + it('should autocomplete and validate the right type of field', async () => { + const results = await suggest({ + expression: 'sum()', + zeroIndexedOffset: 4, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: '(', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toEqual(['bytes', 'memory']); + }); + + it('should autocomplete only operations that provide numeric output', async () => { + const results = await suggest({ + expression: 'last_value()', + zeroIndexedOffset: 11, + context: { + triggerKind: monaco.languages.CompletionTriggerKind.TriggerCharacter, + triggerCharacter: '(', + }, + indexPattern: createMockedIndexPattern(), + operationDefinitionMap, + data: dataPluginMock.createStartContract(), + }); + expect(results.list).toEqual(['bytes', 'memory']); + }); + }); + + describe('monacoPositionToOffset', () => { + it('should work with multi-line strings accounting for newline characters', () => { + const input = `012 +456 +89')`; + expect(input[monacoPositionToOffset(input, new monaco.Position(1, 1))]).toEqual('0'); + expect(input[monacoPositionToOffset(input, new monaco.Position(3, 2))]).toEqual('9'); + }); + }); + + describe('getInfoAtZeroIndexedPosition', () => { + it('should return the location for a function inside multiple levels of math', () => { + const expression = `count() + 5 + average(LENS_MATH_MARKER)`; + const ast = parse(expression); + expect(getInfoAtZeroIndexedPosition(ast, 22)).toEqual({ + ast: expect.objectContaining({ value: 'LENS_MATH_MARKER' }), + parent: expect.objectContaining({ name: 'average' }), + }); + }); + }); +}); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.ts new file mode 100644 index 00000000000000..df747e532b38a0 --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_completion.ts @@ -0,0 +1,594 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { uniq, startsWith } from 'lodash'; +import { i18n } from '@kbn/i18n'; +import { monaco } from '@kbn/monaco'; +import { + parse, + TinymathLocation, + TinymathAST, + TinymathFunction, + TinymathNamedArgument, +} from '@kbn/tinymath'; +import type { + DataPublicPluginStart, + QuerySuggestion, +} from '../../../../../../../../../src/plugins/data/public'; +import { IndexPattern } from '../../../../types'; +import { memoizedGetAvailableOperationsByMetadata } from '../../../operations'; +import { tinymathFunctions, groupArgsByType } from '../util'; +import type { GenericOperationDefinition } from '../..'; +import { getFunctionSignatureLabel, getHelpTextContent } from './formula_help'; +import { hasFunctionFieldArgument } from '../validation'; + +export enum SUGGESTION_TYPE { + FIELD = 'field', + NAMED_ARGUMENT = 'named_argument', + FUNCTIONS = 'functions', + KQL = 'kql', +} + +export type LensMathSuggestion = + | string + | { + label: string; + type: 'operation' | 'math'; + } + | QuerySuggestion; + +export interface LensMathSuggestions { + list: LensMathSuggestion[]; + type: SUGGESTION_TYPE; +} + +function inLocation(cursorPosition: number, location: TinymathLocation) { + return cursorPosition >= location.min && cursorPosition < location.max; +} + +const MARKER = 'LENS_MATH_MARKER'; + +export function getInfoAtZeroIndexedPosition( + ast: TinymathAST, + zeroIndexedPosition: number, + parent?: TinymathFunction +): undefined | { ast: TinymathAST; parent?: TinymathFunction } { + if (typeof ast === 'number') { + return; + } + // +, -, *, and / do not have location any more + if (ast.location && !inLocation(zeroIndexedPosition, ast.location)) { + return; + } + if (ast.type === 'function') { + const [match] = ast.args + .map((arg) => getInfoAtZeroIndexedPosition(arg, zeroIndexedPosition, ast)) + .filter((a) => a); + if (match) { + return match; + } else if (ast.location) { + return { ast }; + } else { + // None of the arguments match, but we don't know the position so it's not a match + return; + } + } + return { + ast, + parent, + }; +} + +export function offsetToRowColumn(expression: string, offset: number): monaco.Position { + const lines = expression.split(/\n/); + let remainingChars = offset; + let lineNumber = 1; + for (const line of lines) { + if (line.length >= remainingChars) { + return new monaco.Position(lineNumber, remainingChars); + } + remainingChars -= line.length + 1; + lineNumber++; + } + + throw new Error('Algorithm failure'); +} + +export function monacoPositionToOffset(expression: string, position: monaco.Position): number { + const lines = expression.split(/\n/); + return lines + .slice(0, position.lineNumber) + .reduce( + (prev, current, index) => + prev + (index === position.lineNumber - 1 ? position.column - 1 : current.length + 1), + 0 + ); +} + +export async function suggest({ + expression, + zeroIndexedOffset, + context, + indexPattern, + operationDefinitionMap, + data, +}: { + expression: string; + zeroIndexedOffset: number; + context: monaco.languages.CompletionContext; + indexPattern: IndexPattern; + operationDefinitionMap: Record; + data: DataPublicPluginStart; +}): Promise<{ list: LensMathSuggestion[]; type: SUGGESTION_TYPE }> { + const text = + expression.substr(0, zeroIndexedOffset) + MARKER + expression.substr(zeroIndexedOffset); + try { + const ast = parse(text); + + const tokenInfo = getInfoAtZeroIndexedPosition(ast, zeroIndexedOffset); + const tokenAst = tokenInfo?.ast; + + const isNamedArgument = + tokenInfo?.parent && + typeof tokenAst !== 'number' && + tokenAst && + 'type' in tokenAst && + tokenAst.type === 'namedArgument'; + if (tokenInfo?.parent && (context.triggerCharacter === '=' || isNamedArgument)) { + return await getNamedArgumentSuggestions({ + ast: tokenAst as TinymathNamedArgument, + data, + indexPattern, + }); + } else if (tokenInfo?.parent) { + return getArgumentSuggestions( + tokenInfo.parent, + tokenInfo.parent.args.findIndex((a) => a === tokenAst), + indexPattern, + operationDefinitionMap + ); + } + if ( + typeof tokenAst === 'object' && + Boolean(tokenAst.type === 'variable' || tokenAst.type === 'function') + ) { + const nameWithMarker = tokenAst.type === 'function' ? tokenAst.name : tokenAst.value; + return getFunctionSuggestions( + nameWithMarker.split(MARKER)[0], + indexPattern, + operationDefinitionMap + ); + } + } catch (e) { + // Fail silently + } + return { list: [], type: SUGGESTION_TYPE.FIELD }; +} + +export function getPossibleFunctions( + indexPattern: IndexPattern, + operationDefinitionMap?: Record +) { + const available = memoizedGetAvailableOperationsByMetadata(indexPattern, operationDefinitionMap); + const possibleOperationNames: string[] = []; + available.forEach((a) => { + if (a.operationMetaData.dataType === 'number' && !a.operationMetaData.isBucketed) { + possibleOperationNames.push( + ...a.operations.filter((o) => o.type !== 'managedReference').map((o) => o.operationType) + ); + } + }); + + return [...uniq(possibleOperationNames), ...Object.keys(tinymathFunctions)]; +} + +function getFunctionSuggestions( + prefix: string, + indexPattern: IndexPattern, + operationDefinitionMap: Record +) { + return { + list: uniq( + getPossibleFunctions(indexPattern, operationDefinitionMap).filter((func) => + startsWith(func, prefix) + ) + ).map((func) => ({ label: func, type: 'operation' as const })), + type: SUGGESTION_TYPE.FUNCTIONS, + }; +} + +function getArgumentSuggestions( + ast: TinymathFunction, + position: number, + indexPattern: IndexPattern, + operationDefinitionMap: Record +) { + const { name } = ast; + const operation = operationDefinitionMap[name]; + if (!operation && !tinymathFunctions[name]) { + return { list: [], type: SUGGESTION_TYPE.FIELD }; + } + + const tinymathFunction = tinymathFunctions[name]; + if (tinymathFunction) { + if (tinymathFunction.positionalArguments[position]) { + return { + list: uniq(getPossibleFunctions(indexPattern, operationDefinitionMap)).map((f) => ({ + type: 'math' as const, + label: f, + })), + type: SUGGESTION_TYPE.FUNCTIONS, + }; + } + return { list: [], type: SUGGESTION_TYPE.FIELD }; + } + + if (position > 0 || !hasFunctionFieldArgument(operation.type)) { + const { namedArguments } = groupArgsByType(ast.args); + const list = []; + if (operation.filterable) { + if (!namedArguments.find((arg) => arg.name === 'kql')) { + list.push('kql'); + } + if (!namedArguments.find((arg) => arg.name === 'lucene')) { + list.push('lucene'); + } + } + if ('operationParams' in operation) { + // Exclude any previously used named args + list.push( + ...operation + .operationParams!.filter( + (param) => + // Keep the param if it's the first use + !namedArguments.find((arg) => arg.name === param.name) + ) + .map((p) => p.name) + ); + } + return { list, type: SUGGESTION_TYPE.NAMED_ARGUMENT }; + } + + if (operation.input === 'field' && position === 0) { + const available = memoizedGetAvailableOperationsByMetadata( + indexPattern, + operationDefinitionMap + ); + // TODO: This only allow numeric functions, will reject last_value(string) for example. + const validOperation = available.find( + ({ operationMetaData }) => + operationMetaData.dataType === 'number' && !operationMetaData.isBucketed + ); + if (validOperation) { + const fields = validOperation.operations + .filter((op) => op.operationType === operation.type) + .map((op) => ('field' in op ? op.field : undefined)) + .filter((field) => field); + return { list: fields as string[], type: SUGGESTION_TYPE.FIELD }; + } else { + return { list: [], type: SUGGESTION_TYPE.FIELD }; + } + } + + if (operation.input === 'fullReference') { + const available = memoizedGetAvailableOperationsByMetadata( + indexPattern, + operationDefinitionMap + ); + const possibleOperationNames: string[] = []; + available.forEach((a) => { + if ( + operation.requiredReferences.some((requirement) => + requirement.validateMetadata(a.operationMetaData) + ) + ) { + possibleOperationNames.push( + ...a.operations + .filter((o) => + operation.requiredReferences.some((requirement) => requirement.input.includes(o.type)) + ) + .map((o) => o.operationType) + ); + } + }); + return { + list: uniq(possibleOperationNames).map((n) => ({ label: n, type: 'operation' as const })), + type: SUGGESTION_TYPE.FUNCTIONS, + }; + } + + return { list: [], type: SUGGESTION_TYPE.FIELD }; +} + +export async function getNamedArgumentSuggestions({ + ast, + data, + indexPattern, +}: { + ast: TinymathNamedArgument; + indexPattern: IndexPattern; + data: DataPublicPluginStart; +}) { + if (ast.name !== 'kql' && ast.name !== 'lucene') { + return { list: [], type: SUGGESTION_TYPE.KQL }; + } + if (!data.autocomplete.hasQuerySuggestions(ast.name === 'kql' ? 'kuery' : 'lucene')) { + return { list: [], type: SUGGESTION_TYPE.KQL }; + } + + const query = ast.value.split(MARKER)[0]; + const position = ast.value.indexOf(MARKER) + 1; + + const suggestions = await data.autocomplete.getQuerySuggestions({ + language: ast.name === 'kql' ? 'kuery' : 'lucene', + query, + selectionStart: position, + selectionEnd: position, + indexPatterns: [indexPattern], + boolFilter: [], + }); + return { + list: suggestions ?? [], + type: SUGGESTION_TYPE.KQL, + }; +} + +const TRIGGER_SUGGESTION_COMMAND = { + title: 'Trigger Suggestion Dialog', + id: 'editor.action.triggerSuggest', +}; + +export function getSuggestion( + suggestion: LensMathSuggestion, + type: SUGGESTION_TYPE, + operationDefinitionMap: Record, + triggerChar: string | undefined +): monaco.languages.CompletionItem { + let kind: monaco.languages.CompletionItemKind = monaco.languages.CompletionItemKind.Method; + let label: string = + typeof suggestion === 'string' + ? suggestion + : 'label' in suggestion + ? suggestion.label + : suggestion.text; + let insertText: string | undefined; + let insertTextRules: monaco.languages.CompletionItem['insertTextRules']; + let detail: string = ''; + let command: monaco.languages.CompletionItem['command']; + let sortText: string = ''; + const filterText: string = label; + + switch (type) { + case SUGGESTION_TYPE.FIELD: + kind = monaco.languages.CompletionItemKind.Value; + break; + case SUGGESTION_TYPE.FUNCTIONS: + insertText = `${label}($0)`; + insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet; + if (typeof suggestion !== 'string') { + if ('text' in suggestion) break; + label = getFunctionSignatureLabel(suggestion.label, operationDefinitionMap); + const tinymathFunction = tinymathFunctions[suggestion.label]; + if (tinymathFunction) { + detail = 'TinyMath'; + kind = monaco.languages.CompletionItemKind.Method; + } else { + kind = monaco.languages.CompletionItemKind.Constant; + detail = 'Elasticsearch'; + // Always put ES functions first + sortText = `0${label}`; + command = TRIGGER_SUGGESTION_COMMAND; + } + } + break; + case SUGGESTION_TYPE.NAMED_ARGUMENT: + kind = monaco.languages.CompletionItemKind.Keyword; + if (label === 'kql' || label === 'lucene') { + command = TRIGGER_SUGGESTION_COMMAND; + insertText = `${label}='$0'`; + insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet; + sortText = `zzz${label}`; + } + label = `${label}=`; + detail = ''; + break; + case SUGGESTION_TYPE.KQL: + if (triggerChar === ':') { + insertText = `${triggerChar} ${label}`; + } else { + // concatenate KQL suggestion for faster query composition + command = TRIGGER_SUGGESTION_COMMAND; + } + if (label.includes(`'`)) { + insertText = (insertText || label).replaceAll(`'`, "\\'"); + } + break; + } + + return { + detail, + kind, + label, + insertText: insertText ?? label, + insertTextRules, + command, + additionalTextEdits: [], + // @ts-expect-error Monaco says this type is required, but provides a default value + range: undefined, + sortText, + filterText, + }; +} + +function getOperationTypeHelp( + name: string, + operationDefinitionMap: Record +) { + const { description: descriptionInMarkdown, examples } = getHelpTextContent( + name, + operationDefinitionMap + ); + const examplesInMarkdown = examples.length + ? `\n\n**${i18n.translate('xpack.lens.formulaExampleMarkdown', { + defaultMessage: 'Examples', + })}** + + ${examples.map((example) => `\`${example}\``).join('\n\n')}` + : ''; + return { + value: `${descriptionInMarkdown}${examplesInMarkdown}`, + }; +} + +function getSignaturesForFunction( + name: string, + operationDefinitionMap: Record +) { + if (tinymathFunctions[name]) { + const stringify = getFunctionSignatureLabel(name, operationDefinitionMap); + const documentation = tinymathFunctions[name].help.replace(/\n/g, '\n\n'); + return [ + { + label: stringify, + documentation: { value: documentation }, + parameters: tinymathFunctions[name].positionalArguments.map((arg) => ({ + label: arg.name, + documentation: arg.optional + ? i18n.translate('xpack.lens.formula.optionalArgument', { + defaultMessage: 'Optional. Default value is {defaultValue}', + values: { + defaultValue: arg.defaultValue, + }, + }) + : '', + })), + }, + ]; + } + if (operationDefinitionMap[name]) { + const def = operationDefinitionMap[name]; + + const firstParam: monaco.languages.ParameterInformation | null = hasFunctionFieldArgument(name) + ? { + label: def.input === 'field' ? 'field' : def.input === 'fullReference' ? 'function' : '', + } + : null; + + const functionLabel = getFunctionSignatureLabel(name, operationDefinitionMap, firstParam); + const documentation = getOperationTypeHelp(name, operationDefinitionMap); + if ('operationParams' in def && def.operationParams) { + return [ + { + label: functionLabel, + parameters: [ + ...(firstParam ? [firstParam] : []), + ...def.operationParams.map((arg) => ({ + label: `${arg.name}=${arg.type}`, + documentation: arg.required + ? i18n.translate('xpack.lens.formula.requiredArgument', { + defaultMessage: 'Required', + }) + : '', + })), + ], + documentation, + }, + ]; + } + return [ + { + label: functionLabel, + parameters: firstParam ? [firstParam] : [], + documentation, + }, + ]; + } + return []; +} + +export function getSignatureHelp( + expression: string, + position: number, + operationDefinitionMap: Record +): monaco.languages.SignatureHelpResult { + const text = expression.substr(0, position) + MARKER + expression.substr(position); + try { + const ast = parse(text); + + const tokenInfo = getInfoAtZeroIndexedPosition(ast, position); + + let signatures: ReturnType = []; + let index = 0; + if (tokenInfo?.parent) { + const name = tokenInfo.parent.name; + // reference equality is fine here because of the way the getInfo function works + index = tokenInfo.parent.args.findIndex((arg) => arg === tokenInfo.ast); + signatures = getSignaturesForFunction(name, operationDefinitionMap); + } else if (typeof tokenInfo?.ast === 'object' && tokenInfo.ast.type === 'function') { + const name = tokenInfo.ast.name; + signatures = getSignaturesForFunction(name, operationDefinitionMap); + } + if (signatures.length) { + return { + value: { + // remove the documentation + signatures: signatures.map(({ documentation, ...signature }) => ({ + ...signature, + // extract only the first section (usually few lines) + documentation: { value: documentation.value.split('\n\n')[0] }, + })), + activeParameter: index, + activeSignature: 0, + }, + dispose: () => {}, + }; + } + } catch (e) { + // do nothing + } + return { value: { signatures: [], activeParameter: 0, activeSignature: 0 }, dispose: () => {} }; +} + +export function getHover( + expression: string, + position: number, + operationDefinitionMap: Record +): monaco.languages.Hover { + try { + const ast = parse(expression); + + const tokenInfo = getInfoAtZeroIndexedPosition(ast, position); + + if (!tokenInfo || typeof tokenInfo.ast === 'number' || !('name' in tokenInfo.ast)) { + return { contents: [] }; + } + + const name = tokenInfo.ast.name; + const signatures = getSignaturesForFunction(name, operationDefinitionMap); + if (signatures.length) { + const { label } = signatures[0]; + + return { + contents: [{ value: label }], + }; + } + } catch (e) { + // do nothing + } + return { contents: [] }; +} + +export function getTokenInfo(expression: string, position: number) { + const text = expression.substr(0, position) + MARKER + expression.substr(position); + try { + const ast = parse(text); + + return getInfoAtZeroIndexedPosition(ast, position); + } catch (e) { + return; + } +} diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_tokenization.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_tokenization.tsx new file mode 100644 index 00000000000000..17394560f8031c --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/math_tokenization.tsx @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { monaco } from '@kbn/monaco'; + +export const LANGUAGE_ID = 'lens_math'; +monaco.languages.register({ id: LANGUAGE_ID }); + +export const languageConfiguration: monaco.languages.LanguageConfiguration = { + wordPattern: /[^()'"\s]+/g, + brackets: [['(', ')']], + autoClosingPairs: [ + { open: '(', close: ')' }, + { open: `'`, close: `'` }, + { open: '"', close: '"' }, + ], + surroundingPairs: [ + { open: '(', close: ')' }, + { open: `'`, close: `'` }, + { open: '"', close: '"' }, + ], +}; + +export const lexerRules = { + defaultToken: 'invalid', + tokenPostfix: '', + ignoreCase: true, + brackets: [{ open: '(', close: ')', token: 'delimiter.parenthesis' }], + escapes: /\\(?:[\\"'])/, + tokenizer: { + root: [ + [/\s+/, 'whitespace'], + [/-?(\d*\.)?\d+([eE][+\-]?\d+)?/, 'number'], + [/[a-zA-Z0-9][a-zA-Z0-9_\-\.]*/, 'keyword'], + [/[,=:]/, 'delimiter'], + // strings double quoted + [/"([^"\\]|\\.)*$/, 'string.invalid'], // string without termination + [/"/, 'string', '@string_dq'], + // strings single quoted + [/'([^'\\]|\\.)*$/, 'string.invalid'], // string without termination + [/'/, 'string', '@string_sq'], + [/\+|\-|\*|\//, 'keyword.operator'], + [/[\(]/, 'delimiter'], + [/[\)]/, 'delimiter'], + ], + string_dq: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, 'string', '@pop'], + ], + string_sq: [ + [/[^\\']+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/'/, 'string', '@pop'], + ], + }, +} as monaco.languages.IMonarchLanguage; + +monaco.languages.setMonarchTokensProvider(LANGUAGE_ID, lexerRules); +monaco.languages.setLanguageConfiguration(LANGUAGE_ID, languageConfiguration); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx index 4a511e14d59e00..e1c722fd9cb38e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx @@ -14,8 +14,10 @@ import { tinymathFunctions } from './util'; jest.mock('../../layer_helpers', () => { return { - getColumnOrder: ({ columns }: { columns: Record }) => - Object.keys(columns), + getColumnOrder: jest.fn(({ columns }: { columns: Record }) => + Object.keys(columns) + ), + getManagedColumnsFrom: jest.fn().mockReturnValue([]), }; }); @@ -142,7 +144,7 @@ describe('formula', () => { indexPattern, }) ).toEqual({ - label: 'Formula', + label: 'average(bytes)', dataType: 'number', operationType: 'formula', isBucketed: false, @@ -170,7 +172,7 @@ describe('formula', () => { indexPattern, }) ).toEqual({ - label: 'Formula', + label: 'average(bytes)', dataType: 'number', operationType: 'formula', isBucketed: false, @@ -204,7 +206,7 @@ describe('formula', () => { indexPattern, }) ).toEqual({ - label: 'Formula', + label: `average(bytes, kql='category.keyword: "Men\\'s Clothing" or category.keyword: "Men\\'s Shoes"')`, dataType: 'number', operationType: 'formula', isBucketed: false, @@ -233,7 +235,7 @@ describe('formula', () => { indexPattern, }) ).toEqual({ - label: 'Formula', + label: `count(lucene='*')`, dataType: 'number', operationType: 'formula', isBucketed: false, @@ -291,7 +293,7 @@ describe('formula', () => { operationDefinitionMap ) ).toEqual({ - label: 'Formula', + label: 'moving_average(average(bytes), window=3)', dataType: 'number', operationType: 'formula', isBucketed: false, @@ -375,6 +377,7 @@ describe('formula', () => { ...layer.columns, col1: { ...currentColumn, + label: formula, params: { ...currentColumn.params, formula, @@ -415,6 +418,7 @@ describe('formula', () => { ...layer.columns, col1: { ...currentColumn, + label: 'average(bytes)', references: ['col1X1'], params: { ...currentColumn.params, @@ -565,7 +569,7 @@ describe('formula', () => { ).toEqual({ col1X0: { min: 15, max: 29 }, col1X2: { min: 0, max: 41 }, - col1X3: { min: 43, max: 50 }, + col1X3: { min: 42, max: 50 }, }); }); }); @@ -787,6 +791,34 @@ invalid: " } }); + it('returns an error if formula or math operations are used', () => { + const formulaFormulas = ['formula()', 'formula(bytes)', 'formula(formula())']; + + for (const formula of formulaFormulas) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(formula), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(['Operation formula not found']); + } + + const mathFormulas = ['math()', 'math(bytes)', 'math(math())']; + + for (const formula of mathFormulas) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(formula), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(['Operation math not found']); + } + }); + it('returns an error if field operation in formula have the wrong first argument', () => { const formulas = [ 'average(7)', @@ -897,6 +929,150 @@ invalid: " ).toEqual(undefined); }); + it('returns no error for a query edge case', () => { + const formulas = [ + `count(kql='')`, + `count(lucene='')`, + `moving_average(count(kql=''), window=7)`, + `count(kql='bytes >= 4000')`, + `count(kql='bytes <= 4000')`, + `count(kql='bytes = 4000')`, + ]; + for (const formula of formulas) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(formula), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(undefined); + } + }); + + it('returns an error for a query not wrapped in single quotes', () => { + const formulas = [ + `count(kql="")`, + `count(kql='")`, + `count(kql="')`, + `count(kql="category.keyword: *")`, + `count(kql='category.keyword: *")`, + `count(kql="category.keyword: *')`, + `count(kql='category.keyword: *)`, + `count(kql=category.keyword: *')`, + `count(kql=category.keyword: *)`, + `count(kql="category.keyword: "Men's Clothing" or category.keyword: "Men's Shoes"")`, + `count(lucene="category.keyword: *")`, + `count(lucene=category.keyword: *)`, + `count(lucene=category.keyword: *) + average(bytes)`, + `count(lucene='category.keyword: *') + count(kql=category.keyword: *)`, + `count(lucene='category.keyword: *") + count(kql='category.keyword: *")`, + `count(lucene='category.keyword: *') + count(kql=category.keyword: *, kql='category.keyword: *')`, + `count(lucene='category.keyword: *') + count(kql="category.keyword: *")`, + `moving_average(count(kql=category.keyword: *), window=7, kql=category.keywork: *)`, + `moving_average( + cumulative_sum( + 7 * clamp(sum(bytes), 0, last_value(memory) + max(memory)) + ), window=10, kql=category.keywork: * + )`, + ]; + for (const formula of formulas) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(formula), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(expect.arrayContaining([expect.stringMatching(`Single quotes are required`)])); + } + }); + + it('it returns parse fail error rather than query message if the formula is only a query condition (false positive cases for query checks)', () => { + const formulas = [ + `kql="category.keyword: *"`, + `kql=category.keyword: *`, + `kql='category.keyword: *'`, + `(kql="category.keyword: *")`, + `(kql=category.keyword: *)`, + `(lucene="category.keyword: *")`, + `(lucene=category.keyword: *)`, + `(lucene='category.keyword: *') + (kql=category.keyword: *)`, + `(lucene='category.keyword: *') + (kql=category.keyword: *, kql='category.keyword: *')`, + `(lucene='category.keyword: *') + (kql="category.keyword: *")`, + `((kql=category.keyword: *), window=7, kql=category.keywork: *)`, + `(, window=10, kql=category.keywork: *)`, + `( + , window=10, kql=category.keywork: * + )`, + ]; + for (const formula of formulas) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(formula), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual([`The Formula ${formula} cannot be parsed`]); + } + }); + + it('returns no error for a query wrapped in single quotes but with some whitespaces', () => { + const formulas = [ + `count(kql ='category.keyword: *')`, + `count(kql = 'category.keyword: *')`, + `count(kql = 'category.keyword: *')`, + ]; + for (const formula of formulas) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(formula), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(undefined); + } + }); + + it('returns an error for multiple queries submitted for the same function', () => { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(`count(kql='category.keyword: *', lucene='category.keyword: *')`), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(['Use only one of kql= or lucene=, not both']); + }); + + it("returns a clear error when there's a missing field for a function", () => { + for (const fn of ['average', 'terms', 'max', 'sum']) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(`${fn}()`), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual([`The first argument for ${fn} should be a field name. Found no field`]); + } + }); + + it("returns a clear error when there's a missing function for a fullReference operation", () => { + for (const fn of ['cumulative_sum', 'derivative']) { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula(`${fn}()`), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual([`The first argument for ${fn} should be a operation name. Found no operation`]); + } + }); + it('returns no error if a math operation is passed to fullReference operations', () => { const formulas = [ 'derivative(7+1)', diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx index de7ecb4bc75da3..3ed50906908762 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx @@ -10,8 +10,11 @@ import { OperationDefinition } from '../index'; import { ReferenceBasedIndexPatternColumn } from '../column_types'; import { IndexPattern } from '../../../types'; import { runASTValidation, tryToParse } from './validation'; +import { MemoizedFormulaEditor } from './editor'; import { regenerateLayerFromAst } from './parse'; import { generateFormula } from './generate'; +import { filterByVisibleOperation } from './util'; +import { getManagedColumnsFrom } from '../../layer_helpers'; const defaultLabel = i18n.translate('xpack.lens.indexPattern.formulaLabel', { defaultMessage: 'Formula', @@ -38,7 +41,7 @@ export const formulaOperation: OperationDefinition< > = { type: 'formula', displayName: defaultLabel, - getDefaultLabel: (column, indexPattern) => defaultLabel, + getDefaultLabel: (column, indexPattern) => column.params.formula ?? defaultLabel, input: 'managedReference', hidden: true, getDisabledStatus(indexPattern: IndexPattern) { @@ -49,13 +52,32 @@ export const formulaOperation: OperationDefinition< if (!column.params.formula || !operationDefinitionMap) { return; } - const { root, error } = tryToParse(column.params.formula); + + const visibleOperationsMap = filterByVisibleOperation(operationDefinitionMap); + const { root, error } = tryToParse(column.params.formula, visibleOperationsMap); if (error || !root) { return [error!.message]; } - const errors = runASTValidation(root, layer, indexPattern, operationDefinitionMap); - return errors.length ? errors.map(({ message }) => message) : undefined; + const errors = runASTValidation(root, layer, indexPattern, visibleOperationsMap); + + if (errors.length) { + return errors.map(({ message }) => message); + } + + const managedColumns = getManagedColumnsFrom(columnId, layer.columns); + const innerErrors = managedColumns + .flatMap(([id, col]) => { + const def = visibleOperationsMap[col.operationType]; + if (def?.getErrorMessage) { + const messages = def.getErrorMessage(layer, id, indexPattern, visibleOperationsMap); + return messages ? { message: messages.join(', ') } : []; + } + return []; + }) + .filter((marker) => marker); + + return innerErrors.length ? innerErrors.map(({ message }) => message) : undefined; }, getPossibleOperation() { return { @@ -72,8 +94,8 @@ export const formulaOperation: OperationDefinition< const label = !params?.isFormulaBroken ? useDisplayLabel ? currentColumn.label - : params?.formula - : ''; + : params?.formula ?? defaultLabel + : defaultLabel; return [ { @@ -81,21 +103,23 @@ export const formulaOperation: OperationDefinition< function: 'mapColumn', arguments: { id: [columnId], - name: [label || ''], + name: [label || defaultLabel], exp: [ { type: 'expression', - chain: [ - { - type: 'function', - function: 'math', - arguments: { - expression: [ - currentColumn.references.length ? `"${currentColumn.references[0]}"` : ``, - ], - }, - }, - ], + chain: currentColumn.references.length + ? [ + { + type: 'function', + function: 'math', + arguments: { + expression: [ + currentColumn.references.length ? `"${currentColumn.references[0]}"` : ``, + ], + }, + }, + ] + : [], }, ], }, @@ -119,7 +143,7 @@ export const formulaOperation: OperationDefinition< prevFormat = { format: previousColumn.params.format }; } return { - label: 'Formula', + label: previousFormula || defaultLabel, dataType: 'number', operationType: 'formula', isBucketed: false, @@ -152,4 +176,6 @@ export const formulaOperation: OperationDefinition< ); return newLayer; }, + + paramEditor: MemoizedFormulaEditor, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md new file mode 100644 index 00000000000000..ae244109ed53ee --- /dev/null +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md @@ -0,0 +1,28 @@ +Basic numeric functions that we already support in Lens: + +count() +count(normalize_unit='1s') +sum(field name) +avg(field name) +moving_average(sum(field name), window=5) +moving_average(sum(field name), window=5, normalize_unit='1s') +counter_rate(field name, normalize_unit='1s') +differences(count()) +differences(sum(bytes), normalize_unit='1s') +last_value(bytes, sort=timestamp) +percentile(bytes, percent=95) + +Adding features beyond what we already support. New features are: + +* Filtering +* Math across series +* Time offset + +count() * 100 +(count() / count(offset=-7d)) + min(field name) +sum(field name, filter='field.keyword: "KQL autocomplete inside math" AND field.value > 100') + +What about custom formatting using string manipulation? Probably not... + +(avg(bytes) / 1000) + 'kb' + \ No newline at end of file diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts index 3bfc6fcbfc011e..517cf5f1bbf45c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/parse.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { isObject } from 'lodash'; import type { TinymathAST, TinymathVariable, TinymathLocation } from '@kbn/tinymath'; import { OperationDefinition, GenericOperationDefinition, IndexPatternColumn } from '../index'; @@ -12,7 +13,12 @@ import { IndexPattern, IndexPatternLayer } from '../../../types'; import { mathOperation } from './math'; import { documentField } from '../../../document_field'; import { runASTValidation, shouldHaveFieldArgument, tryToParse } from './validation'; -import { findVariables, getOperationParams, groupArgsByType } from './util'; +import { + filterByVisibleOperation, + findVariables, + getOperationParams, + groupArgsByType, +} from './util'; import { FormulaIndexPatternColumn } from './formula'; import { getColumnOrder } from '../../layer_helpers'; @@ -27,7 +33,7 @@ function parseAndExtract( indexPattern: IndexPattern, operationDefinitionMap: Record ) { - const { root, error } = tryToParse(text); + const { root, error } = tryToParse(text, operationDefinitionMap); if (error || !root) { return { extracted: [], isValid: false }; } @@ -61,9 +67,9 @@ function extractColumns( const nodeOperation = operations[node.name]; if (!nodeOperation) { // it's a regular math node - const consumedArgs = node.args.map(parseNode).filter(Boolean) as Array< - number | TinymathVariable - >; + const consumedArgs = node.args + .map(parseNode) + .filter((n) => typeof n !== 'undefined' && n !== null) as Array; return { ...node, args: consumedArgs, @@ -168,7 +174,7 @@ export function regenerateLayerFromAst( layer, columnId, indexPattern, - operationDefinitionMap + filterByVisibleOperation(operationDefinitionMap) ); const columns = { ...layer.columns }; @@ -188,6 +194,12 @@ export function regenerateLayerFromAst( columns[columnId] = { ...currentColumn, + label: !currentColumn.customLabel + ? text ?? + i18n.translate('xpack.lens.indexPattern.formulaLabel', { + defaultMessage: 'Formula', + }) + : currentColumn.label, params: { ...currentColumn.params, formula: text, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/util.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/util.ts index 5d9a8647eb7ab0..dd95ebdec5b8ab 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/util.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/util.ts @@ -13,7 +13,7 @@ import type { TinymathNamedArgument, TinymathVariable, } from 'packages/kbn-tinymath'; -import type { OperationDefinition, IndexPatternColumn } from '../index'; +import type { OperationDefinition, IndexPatternColumn, GenericOperationDefinition } from '../index'; import type { GroupedNodes } from './types'; export function groupArgsByType(args: TinymathAST[]) { @@ -66,6 +66,16 @@ export function getOperationParams( }, {}); } +function getTypeI18n(type: string) { + if (type === 'number') { + return i18n.translate('xpack.lens.formula.number', { defaultMessage: 'number' }); + } + if (type === 'string') { + return i18n.translate('xpack.lens.formula.string', { defaultMessage: 'string' }); + } + return ''; +} + // Todo: i18n everything here export const tinymathFunctions: Record< string, @@ -73,145 +83,254 @@ export const tinymathFunctions: Record< positionalArguments: Array<{ name: string; optional?: boolean; + defaultValue?: string | number; + type?: string; }>; - // help: React.ReactElement; // Help is in Markdown format help: string; } > = { add: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }) }, - { name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }) }, + { + name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }), + type: getTypeI18n('number'), + }, + { + name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }), + type: getTypeI18n('number'), + }, ], help: ` +Adds up two numbers. Also works with + symbol -Example: ${'`count() + sum(bytes)`'} -Example: ${'`add(count(), 5)`'} + +Example: Calculate the sum of two fields + +${'`sum(price) + sum(tax)`'} + +Example: Offset count by a static value + +${'`add(count(), 5)`'} `, }, subtract: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }) }, - { name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }) }, + { + name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }), + type: getTypeI18n('number'), + }, + { + name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }), + type: getTypeI18n('number'), + }, ], help: ` +Subtracts the first number from the second number. Also works with ${'`-`'} symbol -Example: ${'`subtract(sum(bytes), avg(bytes))`'} + +Example: Calculate the range of a field +${'`subtract(max(bytes), min(bytes))`'} `, }, multiply: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }) }, - { name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }) }, + { + name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }), + type: getTypeI18n('number'), + }, + { + name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }), + type: getTypeI18n('number'), + }, ], help: ` -Also works with ${'`*`'} symbol -Example: ${'`multiply(sum(bytes), 2)`'} +Multiplies two numbers. +Also works with ${'`*`'} symbol. + +Example: Calculate price after current tax rate +${'`sum(bytes) * last_value(tax_rate)`'} + +Example: Calculate price after constant tax rate +${'`multiply(sum(price), 1.2)`'} `, }, divide: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }) }, - { name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }) }, + { + name: i18n.translate('xpack.lens.formula.left', { defaultMessage: 'left' }), + type: getTypeI18n('number'), + }, + { + name: i18n.translate('xpack.lens.formula.right', { defaultMessage: 'right' }), + type: getTypeI18n('number'), + }, ], help: ` +Divides the first number by the second number. Also works with ${'`/`'} symbol -Example: ${'`ceil(sum(bytes))`'} + +Example: Calculate profit margin +${'`sum(profit) / sum(revenue)`'} + +Example: ${'`divide(sum(bytes), 2)`'} `, }, abs: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` -Absolute value -Example: ${'`abs(sum(bytes))`'} +Calculates absolute value. A negative value is multiplied by -1, a positive value stays the same. + +Example: Calculate average distance to sea level ${'`abs(average(altitude))`'} `, }, cbrt: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` -Cube root of value -Example: ${'`cbrt(sum(bytes))`'} +Cube root of value. + +Example: Calculate side length from volume +${'`cbrt(last_value(volume))`'} `, }, ceil: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], + // signature: 'ceil(value: number)', help: ` -Ceiling of value, rounds up -Example: ${'`ceil(sum(bytes))`'} +Ceiling of value, rounds up. + +Example: Round up price to the next dollar +${'`ceil(sum(price))`'} `, }, clamp: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, - { name: i18n.translate('xpack.lens.formula.min', { defaultMessage: 'min' }) }, - { name: i18n.translate('xpack.lens.formula.max', { defaultMessage: 'max' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, + { + name: i18n.translate('xpack.lens.formula.min', { defaultMessage: 'min' }), + type: getTypeI18n('number'), + }, + { + name: i18n.translate('xpack.lens.formula.max', { defaultMessage: 'max' }), + type: getTypeI18n('number'), + }, ], + // signature: 'clamp(value: number, minimum: number, maximum: number)', help: ` -Limits the value from a minimum to maximum -Example: ${'`ceil(sum(bytes))`'} - `, +Limits the value from a minimum to maximum. + +Example: Make sure to catch outliers +\`\`\` +clamp( + average(bytes), + percentile(bytes, percentile=5), + percentile(bytes, percentile=95) +) +\`\`\` +`, }, cube: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` -Limits the value from a minimum to maximum -Example: ${'`ceil(sum(bytes))`'} +Calculates the cube of a number. + +Example: Calculate volume from side length +${'`cube(last_value(length))`'} `, }, exp: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` -Raises e to the nth power. -Example: ${'`exp(sum(bytes))`'} +Raises *e* to the nth power. + +Example: Calculate the natural exponential function + +${'`exp(last_value(duration))`'} `, }, fix: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` For positive values, takes the floor. For negative values, takes the ceiling. -Example: ${'`fix(sum(bytes))`'} + +Example: Rounding towards zero +${'`fix(sum(profit))`'} `, }, floor: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` Round down to nearest integer value -Example: ${'`floor(sum(bytes))`'} + +Example: Round down a price +${'`floor(sum(price))`'} `, }, log: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, { name: i18n.translate('xpack.lens.formula.base', { defaultMessage: 'base' }), optional: true, + defaultValue: 'e', + type: getTypeI18n('number'), }, ], help: ` -Logarithm with optional base. The natural base e is used as default. -Example: ${'`log(sum(bytes))`'} -Example: ${'`log(sum(bytes), 2)`'} +Logarithm with optional base. The natural base *e* is used as default. + +Example: Calculate number of bits required to store values +\`\`\` +log(sum(bytes)) +log(sum(bytes), 2) +\`\`\` `, }, // TODO: check if this is valid for Tinymath // log10: { // positionalArguments: [ - // { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + // { name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), type: getTypeI18n('number') }, // ], // help: ` // Base 10 logarithm. @@ -220,59 +339,89 @@ Example: ${'`log(sum(bytes), 2)`'} // }, mod: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, { name: i18n.translate('xpack.lens.formula.base', { defaultMessage: 'base' }), - optional: true, + type: getTypeI18n('number'), }, ], help: ` Remainder after dividing the function by a number -Example: ${'`mod(sum(bytes), 2)`'} + +Example: Calculate last three digits of a value +${'`mod(sum(price), 1000)`'} `, }, pow: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, { name: i18n.translate('xpack.lens.formula.base', { defaultMessage: 'base' }), + type: getTypeI18n('number'), }, ], help: ` Raises the value to a certain power. The second argument is required -Example: ${'`pow(sum(bytes), 3)`'} + +Example: Calculate volume based on side length +${'`pow(last_value(length), 3)`'} `, }, round: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, { name: i18n.translate('xpack.lens.formula.decimals', { defaultMessage: 'decimals' }), optional: true, + defaultValue: 0, + type: getTypeI18n('number'), }, ], help: ` Rounds to a specific number of decimal places, default of 0 -Example: ${'`round(sum(bytes))`'} -Example: ${'`round(sum(bytes), 2)`'} + +Examples: Round to the cent +\`\`\` +round(sum(bytes)) +round(sum(bytes), 2) +\`\`\` `, }, sqrt: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` Square root of a positive value only -Example: ${'`sqrt(sum(bytes))`'} + +Example: Calculate side length based on area +${'`sqrt(last_value(area))`'} `, }, square: { positionalArguments: [ - { name: i18n.translate('xpack.lens.formula.expression', { defaultMessage: 'expression' }) }, + { + name: i18n.translate('xpack.lens.formula.value', { defaultMessage: 'value' }), + type: getTypeI18n('number'), + }, ], help: ` Raise the value to the 2nd power -Example: ${'`square(sum(bytes))`'} + +Example: Calculate area based on side length +${'`square(last_value(length))`'} `, }, }; @@ -315,3 +464,11 @@ export function findVariables(node: TinymathAST | string): TinymathVariable[] { } return node.args.flatMap(findVariables); } + +export function filterByVisibleOperation( + operationDefinitionMap: Record +) { + return Object.fromEntries( + Object.entries(operationDefinitionMap).filter(([, operation]) => !operation.hidden) + ); +} diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts index 5145c7959f1bb5..992b8ee2422e90 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/validation.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { isObject } from 'lodash'; +import { isObject, partition } from 'lodash'; import { i18n } from '@kbn/i18n'; import { parse, TinymathLocation } from '@kbn/tinymath'; import type { TinymathAST, TinymathFunction, TinymathNamedArgument } from '@kbn/tinymath'; @@ -58,6 +58,10 @@ interface ValidationErrors { message: string; type: { operation: string; count: number; params: string }; }; + tooManyQueries: { + message: string; + type: {}; + }; } type ErrorTypes = keyof ValidationErrors; type ErrorValues = ValidationErrors[K]['type']; @@ -90,15 +94,76 @@ export function hasInvalidOperations( return { // avoid duplicates names: Array.from(new Set(nodes.map(({ name }) => name))), - locations: nodes.map(({ location }) => location), + locations: nodes.map(({ location }) => location).filter((a) => a) as TinymathLocation[], }; } +export const getRawQueryValidationError = (text: string, operations: Record) => { + // try to extract the query context here + const singleLine = text.split('\n').join(''); + const allArgs = singleLine.split(',').filter((args) => /(kql|lucene)/.test(args)); + // check for the presence of a valid ES operation + const containsOneValidOperation = Object.keys(operations).some((operation) => + singleLine.includes(operation) + ); + // no args or no valid operation, no more work to do here + if (allArgs.length === 0 || !containsOneValidOperation) { + return; + } + // at this point each entry in allArgs may contain one or more + // in the worst case it would be a math chain of count operation + // For instance: count(kql=...) + count(lucene=...) - count(kql=...) + // therefore before partition them, split them by "count" keywork and filter only string with a length + const flattenArgs = allArgs.flatMap((arg) => + arg.split('count').filter((subArg) => /(kql|lucene)/.test(subArg)) + ); + const [kqlQueries, luceneQueries] = partition(flattenArgs, (arg) => /kql/.test(arg)); + const errors = []; + for (const kqlQuery of kqlQueries) { + const result = validateQueryQuotes(kqlQuery, 'kql'); + if (result) { + errors.push(result); + } + } + for (const luceneQuery of luceneQueries) { + const result = validateQueryQuotes(luceneQuery, 'lucene'); + if (result) { + errors.push(result); + } + } + return errors.length ? errors : undefined; +}; + +const validateQueryQuotes = (rawQuery: string, language: 'kql' | 'lucene') => { + // check if the raw argument has the minimal requirements + // use the rest operator here to handle cases where comparison operations are used in the query + const [, ...rawValue] = rawQuery.split('='); + const fullRawValue = (rawValue || ['']).join(''); + const cleanedRawValue = fullRawValue.trim(); + // it must start with a single quote, and quotes must have a closure + if ( + cleanedRawValue.length && + (cleanedRawValue[0] !== "'" || !/'\s*([^']+?)\s*'/.test(fullRawValue)) && + // there's a special case when it's valid as two single quote strings + cleanedRawValue !== "''" + ) { + return i18n.translate('xpack.lens.indexPattern.formulaOperationQueryError', { + defaultMessage: `Single quotes are required for {language}='' at {rawQuery}`, + values: { language, rawQuery }, + }); + } +}; + export const getQueryValidationError = ( - query: string, - language: 'kql' | 'lucene', + { value: query, name: language, text }: TinymathNamedArgument, indexPattern: IndexPattern ): string | undefined => { + // check if the raw argument has the minimal requirements + const result = validateQueryQuotes(text, language as 'kql' | 'lucene'); + // forward the error here is ok? + if (result) { + return result; + } try { if (language === 'kql') { esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(query), indexPattern); @@ -113,7 +178,7 @@ export const getQueryValidationError = ( function getMessageFromId({ messageId, - values: { ...values }, + values, locations, }: { messageId: K; @@ -203,6 +268,11 @@ function getMessageFromId({ values: { operation: out.operation, count: out.count, params: out.params }, }); break; + case 'tooManyQueries': + message = i18n.translate('xpack.lens.indexPattern.formulaOperationDoubleQueryError', { + defaultMessage: 'Use only one of kql= or lucene=, not both', + }); + break; // case 'mathRequiresFunction': // message = i18n.translate('xpack.lens.indexPattern.formulaMathRequiresFunctionLabel', { // defaultMessage; 'The function {name} requires an Elasticsearch function', @@ -218,12 +288,22 @@ function getMessageFromId({ } export function tryToParse( - formula: string + formula: string, + operations: Record ): { root: TinymathAST; error: null } | { root: null; error: ErrorWrapper } { let root; try { root = parse(formula); } catch (e) { + // A tradeoff is required here, unless we want to reimplement a full parser + // Internally the function has the following logic: + // * if the formula contains no existing ES operation, assume it's a plain parse failure + // * if the formula contains at least one existing operation, check for query problems + const maybeQueryProblems = getRawQueryValidationError(formula, operations); + if (maybeQueryProblems) { + // need to emulate an error shape here + return { root: null, error: { message: maybeQueryProblems[0], locations: [] } }; + } return { root: null, error: getMessageFromId({ @@ -319,7 +399,10 @@ function getQueryValidationErrors( const errors: ErrorWrapper[] = []; (namedArguments ?? []).forEach((arg) => { if (arg.name === 'kql' || arg.name === 'lucene') { - const message = getQueryValidationError(arg.value, arg.name, indexPattern); + const message = getQueryValidationError( + arg as TinymathNamedArgument & { name: 'kql' | 'lucene' }, + indexPattern + ); if (message) { errors.push({ message, @@ -331,6 +414,12 @@ function getQueryValidationErrors( return errors; } +function checkSingleQuery(namedArguments: TinymathNamedArgument[] | undefined) { + return namedArguments + ? namedArguments.filter((arg) => arg.name === 'kql' || arg.name === 'lucene').length > 1 + : undefined; +} + function validateNameArguments( node: TinymathFunction, nodeOperation: @@ -349,7 +438,7 @@ function validateNameArguments( operation: node.name, params: missingParams.map(({ name }) => name).join(', '), }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } @@ -362,7 +451,7 @@ function validateNameArguments( operation: node.name, params: wrongTypeParams.map(({ name }) => name).join(', '), }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } @@ -375,7 +464,7 @@ function validateNameArguments( operation: node.name, params: duplicateParams.join(', '), }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } @@ -383,6 +472,16 @@ function validateNameArguments( if (queryValidationErrors.length) { errors.push(...queryValidationErrors); } + const hasTooManyQueries = checkSingleQuery(namedArguments); + if (hasTooManyQueries) { + errors.push( + getMessageFromId({ + messageId: 'tooManyQueries', + values: {}, + locations: node.location ? [node.location] : [], + }) + ); + } return errors; } @@ -426,7 +525,7 @@ function runFullASTValidation( type: 'field', argument: `math operation`, }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } else { @@ -436,9 +535,13 @@ function runFullASTValidation( values: { operation: node.name, type: 'field', - argument: getValueOrName(firstArg), + argument: + getValueOrName(firstArg) || + i18n.translate('xpack.lens.indexPattern.formulaNoFieldForOperation', { + defaultMessage: 'no field', + }), }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } @@ -452,7 +555,7 @@ function runFullASTValidation( values: { operation: node.name, }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } @@ -464,7 +567,7 @@ function runFullASTValidation( values: { operation: node.name, }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } else { @@ -493,9 +596,13 @@ function runFullASTValidation( values: { operation: node.name, type: 'operation', - argument: getValueOrName(firstArg), + argument: + getValueOrName(firstArg) || + i18n.translate('xpack.lens.indexPattern.formulaNoOperation', { + defaultMessage: 'no operation', + }), }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } @@ -506,7 +613,7 @@ function runFullASTValidation( values: { operation: node.name, }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } else { @@ -606,7 +713,11 @@ export function validateParams( } export function shouldHaveFieldArgument(node: TinymathFunction) { - return !['count'].includes(node.name); + return hasFunctionFieldArgument(node.name); +} + +export function hasFunctionFieldArgument(type: string) { + return !['count'].includes(type); } export function isFirstArgumentValidType(arg: TinymathAST, type: TinymathNodeTypes['type']) { @@ -628,7 +739,7 @@ export function validateMathNodes(root: TinymathAST, missingVariableSet: Set name).join(', '), }, - locations: [node.location], + locations: node.location ? [node.location] : [], }) ); } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts index 164415c1a1f6f3..a7bf415817797d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts @@ -153,6 +153,9 @@ export interface ParamEditorProps { updateLayer: ( setter: IndexPatternLayer | ((prevLayer: IndexPatternLayer) => IndexPatternLayer) ) => void; + toggleFullscreen: () => void; + setIsCloseable: (isCloseable: boolean) => void; + isFullscreen: boolean; columnId: string; indexPattern: IndexPattern; uiSettings: IUiSettingsClient; @@ -279,6 +282,11 @@ interface BaseOperationDefinitionProps { * Operations can be used as middleware for other operations, hence not shown in the panel UI */ hidden?: boolean; + documentation?: { + signature: string; + description: string; + section: 'elasticsearch' | 'calculation'; + }; } interface BaseBuildColumnArgs { @@ -290,6 +298,7 @@ interface OperationParam { name: string; type: string; required?: boolean; + defaultValue?: string | number; } interface FieldlessOperationDefinition { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx index 15ce3bdcd0b0f5..2ad91a7ba91a1e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.test.tsx @@ -30,6 +30,9 @@ const defaultProps = { hasRestrictions: false, } as IndexPattern, operationDefinitionMap: {}, + isFullscreen: false, + toggleFullscreen: jest.fn(), + setIsCloseable: jest.fn(), }; describe('last_value', () => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx index bde80accfbc676..bfc5ce39bc9390 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/last_value.tsx @@ -277,4 +277,20 @@ export const lastValueOperation: OperationDefinition ); }, + documentation: { + section: 'elasticsearch', + signature: i18n.translate('xpack.lens.indexPattern.lastValue.signature', { + defaultMessage: 'field: string', + }), + description: i18n.translate('xpack.lens.indexPattern.lastValue.documentation', { + defaultMessage: ` +Returns the value of a field from the last document, ordered by the default time field of the index pattern. + +This function is usefull the retrieve the latest state of an entity. + +Example: Get the current status of server A: +\`last_value(server.status, kql=\'server.name="A"\')\` + `, + }), + }, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx index 54a3ff0eb8bdbf..58fe91b23f2c7d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/metrics.tsx @@ -42,6 +42,7 @@ const supportedTypes = ['number', 'histogram']; function buildMetricOperation>({ type, displayName, + description, ofName, priority, optionalTimeScaling, @@ -51,6 +52,7 @@ function buildMetricOperation>({ ofName: (name: string) => string; priority?: number; optionalTimeScaling?: boolean; + description?: string; }) { const labelLookup = (name: string, column?: BaseIndexPatternColumn) => { const label = ofName(name); @@ -67,6 +69,7 @@ function buildMetricOperation>({ type, priority, displayName, + description, input: 'field', timeScalingMode: optionalTimeScaling ? 'optional' : undefined, getPossibleOperationForField: ({ aggregationRestrictions, aggregatable, type: fieldType }) => { @@ -131,6 +134,26 @@ function buildMetricOperation>({ getErrorMessage: (layer, columnId, indexPattern) => getInvalidFieldMessage(layer.columns[columnId] as FieldBasedIndexPatternColumn, indexPattern), filterable: true, + documentation: { + section: 'elasticsearch', + signature: i18n.translate('xpack.lens.indexPattern.metric.signature', { + defaultMessage: 'field: string', + }), + description: i18n.translate('xpack.lens.indexPattern.metric.documentation', { + defaultMessage: ` +Returns the {metric} of a field. This function only works for number fields. + +Example: Get the {metric} of price: +\`{metric}(price)\` + +Example: Get the {metric} of price for orders from the UK: +\`{metric}(price, kql='location:UK')\` + `, + values: { + metric: type, + }, + }), + }, shiftable: true, } as OperationDefinition; } @@ -151,6 +174,10 @@ export const minOperation = buildMetricOperation({ defaultMessage: 'Minimum of {name}', values: { name }, }), + description: i18n.translate('xpack.lens.indexPattern.min.description', { + defaultMessage: + 'A single-value metrics aggregation that returns the minimum value among the numeric values extracted from the aggregated documents.', + }), }); export const maxOperation = buildMetricOperation({ @@ -163,6 +190,10 @@ export const maxOperation = buildMetricOperation({ defaultMessage: 'Maximum of {name}', values: { name }, }), + description: i18n.translate('xpack.lens.indexPattern.max.description', { + defaultMessage: + 'A single-value metrics aggregation that returns the maximum value among the numeric values extracted from the aggregated documents.', + }), }); export const averageOperation = buildMetricOperation({ @@ -176,6 +207,10 @@ export const averageOperation = buildMetricOperation({ defaultMessage: 'Average of {name}', values: { name }, }), + description: i18n.translate('xpack.lens.indexPattern.avg.description', { + defaultMessage: + 'A single-value metric aggregation that computes the average of numeric values that are extracted from the aggregated documents', + }), }); export const sumOperation = buildMetricOperation({ @@ -190,6 +225,10 @@ export const sumOperation = buildMetricOperation({ values: { name }, }), optionalTimeScaling: true, + description: i18n.translate('xpack.lens.indexPattern.sum.description', { + defaultMessage: + 'A single-value metrics aggregation that sums up numeric values that are extracted from the aggregated documents.', + }), }); export const medianOperation = buildMetricOperation({ @@ -203,4 +242,8 @@ export const medianOperation = buildMetricOperation({ defaultMessage: 'Median of {name}', values: { name }, }), + description: i18n.translate('xpack.lens.indexPattern.median.description', { + defaultMessage: + 'A single-value metrics aggregation that computes the median value that are extracted from the aggregated documents.', + }), }); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx index 2b7104112d63eb..0a3462ef20f3f7 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.test.tsx @@ -32,6 +32,9 @@ const defaultProps = { hasRestrictions: false, } as IndexPattern, operationDefinitionMap: {}, + isFullscreen: false, + toggleFullscreen: jest.fn(), + setIsCloseable: jest.fn(), }; describe('percentile', () => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx index aa8f951d46b4f2..39b876050c2eae 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile.tsx @@ -59,7 +59,9 @@ export const percentileOperation: OperationDefinition { @@ -213,4 +215,18 @@ export const percentileOperation: OperationDefinition ); }, + documentation: { + section: 'elasticsearch', + signature: i18n.translate('xpack.lens.indexPattern.percentile.signature', { + defaultMessage: 'field: string, [percentile]: number', + }), + description: i18n.translate('xpack.lens.indexPattern.percentile.documentation', { + defaultMessage: ` +Returns the specified percentile of the values of a field. This is the value n percent of the values occuring in documents are smaller. + +Example: Get the number of bytes larger than 95 % of values: +\`percentile(bytes, percentile=95)\` + `, + }), + }, }; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx index 295f988c6e3906..ca4e6d5df0a3c4 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx @@ -102,6 +102,9 @@ const defaultOptions = { ]), }, operationDefinitionMap: {}, + isFullscreen: false, + toggleFullscreen: jest.fn(), + setIsCloseable: jest.fn(), }; describe('ranges', () => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/terms.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/terms.test.tsx index b272d1703377ce..32b7dfee828fce 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/terms.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/terms.test.tsx @@ -35,6 +35,9 @@ const defaultProps = { http: {} as HttpSetup, indexPattern: createMockedIndexPattern(), operationDefinitionMap: {}, + isFullscreen: false, + toggleFullscreen: jest.fn(), + setIsCloseable: jest.fn(), }; describe('terms', () => { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts index 38bc84ae9af357..ba3bee415f3f49 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.test.ts @@ -24,7 +24,7 @@ import type { IndexPattern, IndexPatternLayer } from '../types'; import { documentField } from '../document_field'; import { getFieldByNameFactory } from '../pure_helpers'; import { generateId } from '../../id_generator'; -import { createMockedFullReference } from './mocks'; +import { createMockedFullReference, createMockedManagedReference } from './mocks'; jest.mock('../operations'); jest.mock('../../id_generator'); @@ -91,10 +91,13 @@ describe('state_helpers', () => { // @ts-expect-error we are inserting an invalid type operationDefinitionMap.testReference = createMockedFullReference(); + // @ts-expect-error we are inserting an invalid type + operationDefinitionMap.managedReference = createMockedManagedReference(); }); afterEach(() => { delete operationDefinitionMap.testReference; + delete operationDefinitionMap.managedReference; }); describe('copyColumn', () => { @@ -102,19 +105,19 @@ describe('state_helpers', () => { const source = { dataType: 'number' as const, isBucketed: false, - label: 'Formula', + label: 'moving_average(sum(bytes), window=5)', operationType: 'formula' as const, params: { formula: 'moving_average(sum(bytes), window=5)', isFormulaBroken: false, }, - references: ['formulaX3'], + references: ['formulaX1'], }; const math = { customLabel: true, dataType: 'number' as const, isBucketed: false, - label: 'math', + label: 'formulaX2', operationType: 'math' as const, params: { tinymathAst: 'formulaX2' }, references: ['formulaX2'], @@ -135,7 +138,7 @@ describe('state_helpers', () => { label: 'formulaX2', operationType: 'moving_average' as const, params: { window: 5 }, - references: ['formulaX1'], + references: ['formulaX0'], }; expect( copyColumn({ @@ -387,6 +390,42 @@ describe('state_helpers', () => { ).toEqual(expect.objectContaining({ columnOrder: ['col1', 'col2', 'col3'] })); }); + it('should not change order of metrics and references on inserting new buckets', () => { + const layer: IndexPatternLayer = { + indexPatternId: '1', + columnOrder: ['col1', 'col2'], + columns: { + col1: { + label: 'Cumulative sum of count of records', + dataType: 'number', + isBucketed: false, + + // Private + operationType: 'cumulative_sum', + references: ['col2'], + }, + col2: { + label: 'Count of records', + dataType: 'document', + isBucketed: false, + + // Private + operationType: 'count', + sourceField: 'Records', + }, + }, + }; + expect( + insertNewColumn({ + layer, + indexPattern, + columnId: 'col3', + op: 'filters', + visualizationGroups: [], + }) + ).toEqual(expect.objectContaining({ columnOrder: ['col3', 'col1', 'col2'] })); + }); + it('should insert both incomplete states if the aggregation does not support the field', () => { expect( insertNewColumn({ @@ -2655,6 +2694,36 @@ describe('state_helpers', () => { expect(errors).toHaveLength(1); }); + it('should only collect the top level errors from managed references', () => { + const notCalledMock = jest.fn(); + const mock = jest.fn().mockReturnValue(['error 1']); + operationDefinitionMap.testReference.getErrorMessage = notCalledMock; + operationDefinitionMap.managedReference.getErrorMessage = mock; + const errors = getErrorMessages( + { + indexPatternId: '1', + columnOrder: [], + columns: { + col1: + // @ts-expect-error not statically analyzed + { operationType: 'managedReference', references: ['col2'] }, + col2: { + // @ts-expect-error not statically analyzed + operationType: 'testReference', + references: [], + }, + }, + }, + indexPattern, + {}, + '1', + {} + ); + expect(notCalledMock).not.toHaveBeenCalled(); + expect(mock).toHaveBeenCalledTimes(1); + expect(errors).toHaveLength(1); + }); + it('should ignore incompleteColumns when checking for errors', () => { const savedRef = jest.fn().mockReturnValue(['error 1']); const incompleteRef = jest.fn(); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts index 56fbb8edef5b43..b650a2818b2d48 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts @@ -169,6 +169,10 @@ export function insertNewColumn({ if (field) { throw new Error(`Can't create operation ${op} with the provided field ${field.name}`); } + if (operationDefinition.input === 'managedReference') { + // TODO: need to create on the fly the new columns for Formula, + // like we do for fullReferences to show a seamless transition + } const possibleOperation = operationDefinition.getPossibleOperation(); const isBucketed = Boolean(possibleOperation?.isBucketed); const addOperationFn = isBucketed ? addBucket : addMetric; @@ -358,9 +362,9 @@ export function replaceColumn({ tempLayer = resetIncomplete(tempLayer, columnId); if (previousDefinition.input === 'managedReference') { - // Every transition away from a managedReference resets it, we don't have a way to keep the state + // If the transition is incomplete, leave the managed state until it's finished. tempLayer = deleteColumn({ layer: tempLayer, columnId, indexPattern }); - return insertNewColumn({ + const hypotheticalLayer = insertNewColumn({ layer: tempLayer, columnId, indexPattern, @@ -368,6 +372,14 @@ export function replaceColumn({ field, visualizationGroups, }); + if (hypotheticalLayer.incompleteColumns && hypotheticalLayer.incompleteColumns[columnId]) { + return { + ...layer, + incompleteColumns: hypotheticalLayer.incompleteColumns, + }; + } else { + return hypotheticalLayer; + } } if (operationDefinition.input === 'fullReference') { @@ -859,7 +871,10 @@ function addBucket( visualizationGroups: VisualizationDimensionGroupConfig[], targetGroup?: string ): IndexPatternLayer { - const [buckets, metrics, references] = getExistingColumnGroups(layer); + const [buckets, metrics] = partition( + layer.columnOrder, + (colId) => layer.columns[colId].isBucketed + ); const oldDateHistogramIndex = layer.columnOrder.findIndex( (columnId) => layer.columns[columnId].operationType === 'date_histogram' @@ -873,12 +888,11 @@ function addBucket( addedColumnId, ...buckets.slice(oldDateHistogramIndex, buckets.length), ...metrics, - ...references, ]; } else { // Insert the new bucket after existing buckets. Users will see the same data // they already had, with an extra level of detail. - updatedColumnOrder = [...buckets, addedColumnId, ...metrics, ...references]; + updatedColumnOrder = [...buckets, addedColumnId, ...metrics]; } updatedColumnOrder = reorderByGroups( visualizationGroups, @@ -1169,8 +1183,20 @@ export function getErrorMessages( } > | undefined { - const errors = Object.entries(layer.columns) + const columns = Object.entries(layer.columns); + const visibleManagedReferences = columns.filter( + ([columnId, column]) => + !isReferenced(layer, columnId) && + operationDefinitionMap[column.operationType].input === 'managedReference' + ); + const skippedColumns = visibleManagedReferences.flatMap(([columnId]) => + getManagedColumnsFrom(columnId, layer.columns).map(([id]) => id) + ); + const errors = columns .flatMap(([columnId, column]) => { + if (skippedColumns.includes(columnId)) { + return; + } const def = operationDefinitionMap[column.operationType]; if (def.getErrorMessage) { return def.getErrorMessage(layer, columnId, indexPattern, operationDefinitionMap); @@ -1218,6 +1244,25 @@ export function isReferenced(layer: IndexPatternLayer, columnId: string): boolea return allReferences.includes(columnId); } +export function getReferencedColumnIds(layer: IndexPatternLayer, columnId: string): string[] { + const referencedIds: string[] = []; + function collect(id: string) { + const column = layer.columns[id]; + if (column && 'references' in column) { + const columnReferences = column.references; + // only record references which have created columns yet + const existingReferences = columnReferences.filter((reference) => + Boolean(layer.columns[reference]) + ); + referencedIds.push(...existingReferences); + existingReferences.forEach(collect); + } + } + collect(columnId); + + return referencedIds; +} + export function isOperationAllowedAsReference({ operationType, validation, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts index 4a2e065269063a..2d7e70179fb3f7 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/mocks.ts @@ -40,3 +40,28 @@ export const createMockedFullReference = () => { getErrorMessage: jest.fn(), }; }; + +export const createMockedManagedReference = () => { + return { + input: 'managedReference', + displayName: 'Managed reference test', + type: 'managedReference' as OperationType, + selectionStyle: 'full', + buildColumn: jest.fn((args) => { + return { + label: 'Test reference', + isBucketed: false, + dataType: 'number', + + operationType: 'testReference', + references: args.referenceIds, + }; + }), + filterable: true, + isTransferable: jest.fn(), + toExpression: jest.fn().mockReturnValue([]), + getPossibleOperation: jest.fn().mockReturnValue({ dataType: 'number', isBucketed: false }), + getDefaultLabel: jest.fn().mockReturnValue('Default label'), + getErrorMessage: jest.fn(), + }; +}; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts index 437d2af005961f..fc70be257c8ad9 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.ts @@ -93,7 +93,7 @@ export function isDocumentOperation(type: string) { return documentOperations.has(type); } -type OperationFieldTuple = +export type OperationFieldTuple = | { type: 'field'; operationType: OperationType; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/types.ts b/x-pack/plugins/lens/public/indexpattern_datasource/types.ts index 98dc767c44c7dd..f24c39f810b214 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/types.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/types.ts @@ -88,6 +88,8 @@ export interface IndexPatternPrivateState { isFirstExistenceFetch: boolean; existenceFetchFailed?: boolean; existenceFetchTimeout?: boolean; + + isDimensionClosePrevented?: boolean; } export interface IndexPatternRef { diff --git a/x-pack/plugins/lens/public/mocks.tsx b/x-pack/plugins/lens/public/mocks.tsx index 473c170aef2948..07935bb2f241b8 100644 --- a/x-pack/plugins/lens/public/mocks.tsx +++ b/x-pack/plugins/lens/public/mocks.tsx @@ -166,6 +166,9 @@ export function mockDataPlugin(sessionIdSubject = new Subject()) { nowProvider: { get: jest.fn(), }, + fieldFormats: { + deserialize: jest.fn(), + }, } as unknown) as DataPublicPluginStart; } diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index 33946166186722..b421d57dae6e1f 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -198,6 +198,11 @@ export interface Datasource { } ) => { dropTypes: DropType[]; nextLabel?: string } | undefined; onDrop: (props: DatasourceDimensionDropHandlerProps) => false | true | { deleted: string }; + /** + * The datasource is allowed to cancel a close event on the dimension editor, + * mainly used for formulas + */ + canCloseDimensionEditor?: (state: T) => boolean; getCustomWorkspaceRenderer?: ( state: T, dragging: DraggingIdentifier @@ -300,11 +305,15 @@ export type DatasourceDimensionEditorProps = DatasourceDimensionPro // Not a StateSetter because we have this unique use case of determining valid columns setState: ( newState: Parameters>[0], - publishToVisualization?: { shouldReplaceDimension?: boolean; shouldRemoveDimension?: boolean } + publishToVisualization?: { + isDimensionComplete?: boolean; + } ) => void; core: Pick; dateRange: DateRange; dimensionGroups: VisualizationDimensionGroupConfig[]; + toggleFullscreen: () => void; + isFullscreen: boolean; }; export type DatasourceDimensionTriggerProps = DatasourceDimensionProps; diff --git a/x-pack/plugins/lens/server/usage/schema.ts b/x-pack/plugins/lens/server/usage/schema.ts index ab3945a0162a68..c3608176717c56 100644 --- a/x-pack/plugins/lens/server/usage/schema.ts +++ b/x-pack/plugins/lens/server/usage/schema.ts @@ -14,6 +14,12 @@ const eventsSchema: MakeSchemaFrom = { type: 'long', _meta: { description: 'Number of times the user opened one of the in-product help popovers.' }, }, + toggle_fullscreen_formula: { + type: 'long', + _meta: { + description: 'Number of times the user toggled fullscreen mode on formula.', + }, + }, indexpattern_field_info_click: { type: 'long' }, loaded: { type: 'long' }, app_filters_updated: { type: 'long' }, @@ -162,6 +168,10 @@ const eventsSchema: MakeSchemaFrom = { type: 'long', _meta: { description: 'Number of times the moving average function was selected' }, }, + indexpattern_dimension_operation_formula: { + type: 'long', + _meta: { description: 'Number of times the formula function was selected' }, + }, }; const suggestionEventsSchema: MakeSchemaFrom = { @@ -183,6 +193,12 @@ const savedSchema: MakeSchemaFrom = { lnsDatatable: { type: 'long' }, lnsPie: { type: 'long' }, lnsMetric: { type: 'long' }, + formula: { + type: 'long', + _meta: { + description: 'Number of saved lens visualizations which are using at least one formula', + }, + }, }; export const lensUsageSchema: MakeSchemaFrom = { diff --git a/x-pack/plugins/lens/server/usage/visualization_counts.ts b/x-pack/plugins/lens/server/usage/visualization_counts.ts index 3b9bb99caf5b81..f0c48fb1152e81 100644 --- a/x-pack/plugins/lens/server/usage/visualization_counts.ts +++ b/x-pack/plugins/lens/server/usage/visualization_counts.ts @@ -43,6 +43,31 @@ export async function getVisualizationCounts( size: 100, }, }, + usesFormula: { + filter: { + match: { + operation_type: 'formula', + }, + }, + }, + }, + }, + }, + runtime_mappings: { + operation_type: { + type: 'keyword', + script: { + lang: 'painless', + source: `try { + if(doc['lens.state'].size() == 0) return; + HashMap layers = params['_source'].get('lens').get('state').get('datasourceStates').get('indexpattern').get('layers'); + for(layerId in layers.keySet()) { + HashMap columns = layers.get(layerId).get('columns'); + for(columnId in columns.keySet()) { + emit(columns.get(columnId).get('operationType')) + } + } + } catch(Exception e) {}`, }, }, }, @@ -56,16 +81,19 @@ export async function getVisualizationCounts( // eslint-disable-next-line @typescript-eslint/no-explicit-any function bucketsToObject(arg: any) { const obj: Record = {}; - arg.buckets.forEach((bucket: { key: string; doc_count: number }) => { + arg.byType.buckets.forEach((bucket: { key: string; doc_count: number }) => { obj[bucket.key] = bucket.doc_count + (obj[bucket.key] ?? 0); }); + if (arg.usesFormula.doc_count > 0) { + obj.formula = arg.usesFormula.doc_count; + } return obj; } return { - saved_overall: bucketsToObject(buckets.overall.byType), - saved_30_days: bucketsToObject(buckets.last30.byType), - saved_90_days: bucketsToObject(buckets.last90.byType), + saved_overall: bucketsToObject(buckets.overall), + saved_30_days: bucketsToObject(buckets.last30), + saved_90_days: bucketsToObject(buckets.last90), saved_overall_total: buckets.overall.doc_count, saved_30_days_total: buckets.last30.doc_count, saved_90_days_total: buckets.last90.doc_count, diff --git a/x-pack/plugins/ml/common/types/results.ts b/x-pack/plugins/ml/common/types/results.ts index 83de62d51671ea..fa40cefcaed48d 100644 --- a/x-pack/plugins/ml/common/types/results.ts +++ b/x-pack/plugins/ml/common/types/results.ts @@ -5,6 +5,28 @@ * 2.0. */ +import { estypes } from '@elastic/elasticsearch'; + export interface GetStoppedPartitionResult { jobs: string[] | Record; } +export interface GetDatafeedResultsChartDataResult { + bucketResults: number[][]; + datafeedResults: number[][]; +} + +export interface DatafeedResultsChartDataParams { + jobId: string; + start: number; + end: number; +} + +export const defaultSearchQuery: estypes.QueryDslQueryContainer = { + bool: { + must: [ + { + match_all: {}, + }, + ], + }, +}; diff --git a/x-pack/plugins/ml/kibana.json b/x-pack/plugins/ml/kibana.json index f34172765e1ddf..e3bcf307e6f009 100644 --- a/x-pack/plugins/ml/kibana.json +++ b/x-pack/plugins/ml/kibana.json @@ -39,7 +39,8 @@ "dashboard", "savedObjects", "home", - "maps" + "maps", + "usageCollection" ], "extraPublicDirs": [ "common" diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index f16a7c561ac5d6..8be513f372e56c 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -87,17 +87,22 @@ const App: FC = ({ coreStart, deps, appMountParams }) => { }; const I18nContext = coreStart.i18n.Context; + const ApplicationUsageTrackingProvider = + deps.usageCollection?.components.ApplicationUsageTrackingProvider ?? React.Fragment; + return ( /** RedirectAppLinks intercepts all tags to use navigateToUrl * avoiding full page reload **/ - - - - - + + + + + + + ); }; diff --git a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js index 472bde00e649ae..afed7e79ff757f 100644 --- a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js +++ b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js @@ -18,14 +18,13 @@ import React, { Component, Fragment, useContext } from 'react'; import memoizeOne from 'memoize-one'; import { EuiBadge, - EuiButtonIcon, + EuiButtonEmpty, EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiInMemoryTable, EuiLink, EuiLoadingSpinner, - EuiToolTip, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -52,6 +51,7 @@ import { ML_APP_URL_GENERATOR, ML_PAGES } from '../../../../../common/constants/ import { PLUGIN_ID } from '../../../../../common/constants/app'; import { timeFormatter } from '../../../../../common/util/date_utils'; import { MlAnnotationUpdatesContext } from '../../../contexts/ml/ml_annotation_updates_context'; +import { DatafeedModal } from '../../../jobs/jobs_list/components/datafeed_modal'; const CURRENT_SERIES = 'current_series'; /** @@ -79,6 +79,8 @@ class AnnotationsTableUI extends Component { this.props.jobs[0] !== undefined ? this.props.jobs[0].job_id : undefined, + datafeedModalVisible: false, + datafeedEnd: null, }; this.sorting = { sort: { field: 'timestamp', direction: 'asc' }, @@ -463,28 +465,62 @@ class AnnotationsTableUI extends Component { // find the original annotation because the table might not show everything const annotationId = annotation._id; const originalAnnotation = annotations.find((d) => d._id === annotationId); - const editAnnotationsTooltipText = ( + const editAnnotationsText = ( ); - const editAnnotationsTooltipAriaLabelText = i18n.translate( + const editAnnotationsAriaLabelText = i18n.translate( 'xpack.ml.annotationsTable.editAnnotationsTooltipAriaLabel', { defaultMessage: 'Edit annotation' } ); return ( - - annotationUpdatesService.setValue(originalAnnotation ?? annotation)} - iconType="pencil" - aria-label={editAnnotationsTooltipAriaLabelText} - /> - + annotationUpdatesService.setValue(originalAnnotation ?? annotation)} + > + {editAnnotationsText} + ); }, }); + if (this.state.jobId && this.props.jobs[0].analysis_config.bucket_span) { + // add datafeed modal action + actions.push({ + render: (annotation) => { + const viewDataFeedText = ( + + ); + const viewDataFeedTooltipAriaLabelText = i18n.translate( + 'xpack.ml.annotationsTable.viewDatafeedTooltipAriaLabel', + { defaultMessage: 'View datafeed' } + ); + return ( + + this.setState({ + datafeedModalVisible: true, + datafeedEnd: annotation.end_timestamp, + }) + } + > + {viewDataFeedText} + + ); + }, + }); + } + if (isSingleMetricViewerLinkVisible) { actions.push({ render: (annotation) => { @@ -510,14 +546,15 @@ class AnnotationsTableUI extends Component { ); return ( - - this.openSingleMetricView(annotation)} - disabled={!isDrillDownAvailable} - iconType="visLine" - aria-label={openInSingleMetricViewerAriaLabelText} - /> - + this.openSingleMetricView(annotation)} + > + {openInSingleMetricViewerTooltipText} + ); }, }); @@ -690,6 +727,19 @@ class AnnotationsTableUI extends Component { search={search} rowProps={getRowProps} /> + {this.state.jobId && this.state.datafeedModalVisible && this.state.datafeedEnd ? ( + { + this.setState({ + datafeedModalVisible: false, + }); + }} + end={this.state.datafeedEnd} + timefield={this.props.jobs[0].data_description.time_field} + jobId={this.state.jobId} + bucketSpan={this.props.jobs[0].analysis_config.bucket_span} + /> + ) : null} ); } diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/confusion_matrix_help_popover.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/confusion_matrix_help_popover.tsx new file mode 100644 index 00000000000000..34fad4d8acb45e --- /dev/null +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/confusion_matrix_help_popover.tsx @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { + HelpPopover, + HelpPopoverButton, +} from '../../../../../components/help_popover/help_popover'; + +export const MulticlassConfusionMatrixHelpPopover = () => { + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + + return ( + { + setIsPopoverOpen(!isPopoverOpen); + }} + /> + } + closePopover={() => setIsPopoverOpen(false)} + isOpen={isPopoverOpen} + title={i18n.translate('xpack.ml.dataframe.analytics.confusionMatrixPopoverTitle', { + defaultMessage: 'Normalized confusion matrix', + })} + > +

+ +

+

+ +

+

+ +

+

+ +

+
+ ); +}; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx index f37be6f6f0eb0e..bc1c9dbed1dcc7 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx @@ -50,6 +50,7 @@ import { import { isTrainingFilter } from './is_training_filter'; import { useRocCurve } from './use_roc_curve'; import { useConfusionMatrix } from './use_confusion_matrix'; +import { MulticlassConfusionMatrixHelpPopover } from './confusion_matrix_help_popover'; export interface EvaluatePanelProps { jobConfig: DataFrameAnalyticsConfig; @@ -288,21 +289,12 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, se {errorConfusionMatrix !== null && } {errorConfusionMatrix === null && ( <> - + {getHelpText(dataSubsetTitle)} - + {/* BEGIN TABLE ELEMENTS */} diff --git a/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.js b/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.js index 9da97f40f5ec66..4f4cd0f6ef1c9a 100644 --- a/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/components/custom_url_editor/utils.js @@ -17,10 +17,8 @@ import { parseInterval } from '../../../../../common/util/parse_interval'; import { replaceTokensInUrlValue, isValidLabel } from '../../../util/custom_url_utils'; import { getIndexPatternIdFromName } from '../../../util/index_utils'; import { ml } from '../../../services/ml_api_service'; -import { mlJobService } from '../../../services/job_service'; import { escapeForElasticsearchQuery } from '../../../util/string_utils'; import { getSavedObjectsClient, getGetUrlGenerator } from '../../../util/dependency_cache'; -import { getProcessedFields } from '../../../components/data_grid'; export function getNewCustomUrlDefaults(job, dashboards, indexPatterns) { // Returns the settings object in the format used by the custom URL editor @@ -266,8 +264,7 @@ function buildAppStateQueryParam(queryFieldNames) { // Builds the full URL for testing out a custom URL configuration, which // may contain dollar delimited partition / influencer entity tokens and // drilldown time range settings. -export function getTestUrl(job, customUrl) { - const urlValue = customUrl.url_value; +export async function getTestUrl(job, customUrl) { const bucketSpanSecs = parseInterval(job.analysis_config.bucket_span).asSeconds(); // By default, return configured url_value. Look to substitute any dollar-delimited @@ -289,64 +286,55 @@ export function getTestUrl(job, customUrl) { sort: [{ record_score: { order: 'desc' } }], }; - return new Promise((resolve, reject) => { - ml.results - .anomalySearch( - { - body, - }, - [job.job_id] - ) - .then((resp) => { - if (resp.hits.total.value > 0) { - const record = resp.hits.hits[0]._source; - testUrl = replaceTokensInUrlValue(customUrl, bucketSpanSecs, record, 'timestamp'); - resolve(testUrl); - } else { - // No anomalies yet for this job, so do a preview of the search - // configured in the job datafeed to obtain sample docs. - mlJobService.searchPreview(job).then((response) => { - let testDoc; - const docTimeFieldName = job.data_description.time_field; - - // Handle datafeeds which use aggregations or documents. - if (response.aggregations) { - // Create a dummy object which contains the fields necessary to build the URL. - const firstBucket = response.aggregations.buckets.buckets[0]; - testDoc = { - [docTimeFieldName]: firstBucket.key, - }; - - // Look for bucket aggregations which match the tokens in the URL. - urlValue.replace(/\$([^?&$\'"]{1,40})\$/g, (match, name) => { - if (name !== 'earliest' && name !== 'latest' && firstBucket[name] !== undefined) { - const tokenBuckets = firstBucket[name]; - if (tokenBuckets.buckets) { - testDoc[name] = tokenBuckets.buckets[0].key; - } - } - }); - } else { - if (response.hits.total.value > 0) { - testDoc = getProcessedFields(response.hits.hits[0].fields); - } - } - - if (testDoc !== undefined) { - testUrl = replaceTokensInUrlValue( - customUrl, - bucketSpanSecs, - testDoc, - docTimeFieldName - ); - } + let resp; + try { + resp = await ml.results.anomalySearch( + { + body, + }, + [job.job_id] + ); + } catch (error) { + // search may fail if the job doesn't already exist + // ignore this error as the outer function call will raise a toast + } - resolve(testUrl); - }); - } - }) - .catch((resp) => { - reject(resp); - }); - }); + if (resp && resp.hits.total.value > 0) { + const record = resp.hits.hits[0]._source; + testUrl = replaceTokensInUrlValue(customUrl, bucketSpanSecs, record, 'timestamp'); + return testUrl; + } else { + // No anomalies yet for this job, so do a preview of the search + // configured in the job datafeed to obtain sample docs. + + let { datafeed_config: datafeedConfig, ...jobConfig } = job; + try { + // attempt load the non-combined job and datafeed so they can be used in the datafeed preview + const [{ jobs }, { datafeeds }] = await Promise.all([ + ml.getJobs({ jobId: job.job_id }), + ml.getDatafeeds({ datafeedId: job.datafeed_config.datafeed_id }), + ]); + datafeedConfig = datafeeds[0]; + jobConfig = jobs[0]; + } catch (error) { + // jobs may not exist as this might be called from the AD job wizards + // ignore this error as the outer function call will raise a toast + } + + if (jobConfig === undefined || datafeedConfig === undefined) { + return testUrl; + } + + const preview = await ml.jobs.datafeedPreview(undefined, jobConfig, datafeedConfig); + + const docTimeFieldName = job.data_description.time_field; + + // Create a dummy object which contains the fields necessary to build the URL. + const firstBucket = preview[0]; + if (firstBucket !== undefined) { + testUrl = replaceTokensInUrlValue(customUrl, bucketSpanSecs, firstBucket, docTimeFieldName); + } + + return testUrl; + } } diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/constants.ts b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/constants.ts new file mode 100644 index 00000000000000..71f3795518bc95 --- /dev/null +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/constants.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { ChartSizeArray } from '@elastic/charts'; +import { i18n } from '@kbn/i18n'; + +export const CHART_DIRECTION = { + FORWARD: 'forward', + BACK: 'back', +} as const; +export type ChartDirectionType = typeof CHART_DIRECTION[keyof typeof CHART_DIRECTION]; + +// [width, height] +export const CHART_SIZE: ChartSizeArray = ['100%', 300]; + +export const TAB_IDS = { + CHART: 'chart', + MESSAGES: 'messages', +} as const; +export type TabIdsType = typeof TAB_IDS[keyof typeof TAB_IDS]; + +export const tabs = [ + { + id: TAB_IDS.CHART, + name: i18n.translate('xpack.ml.jobsList.datafeedModal.chartTabName', { + defaultMessage: 'Chart', + }), + disabled: false, + }, + { + id: TAB_IDS.MESSAGES, + name: i18n.translate('xpack.ml.jobsList.datafeedModal.messagesTabName', { + defaultMessage: 'Messages', + }), + disabled: false, + }, +]; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/datafeed_modal.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/datafeed_modal.tsx new file mode 100644 index 00000000000000..cf547a49cac4c3 --- /dev/null +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/datafeed_modal.tsx @@ -0,0 +1,362 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import moment from 'moment'; +import { + EuiButtonEmpty, + EuiDatePicker, + EuiFlexGroup, + EuiFlexItem, + EuiLoadingChart, + EuiModal, + EuiModalHeader, + EuiModalBody, + EuiSelect, + EuiSpacer, + EuiTabs, + EuiTab, + EuiToolTip, +} from '@elastic/eui'; +import { + Axis, + Chart, + CurveType, + LineSeries, + Position, + ScaleType, + Settings, + timeFormatter, +} from '@elastic/charts'; + +import { DATAFEED_STATE } from '../../../../../../common/constants/states'; +import { CombinedJobWithStats } from '../../../../../../common/types/anomaly_detection_jobs'; +import { useToastNotificationService } from '../../../../services/toast_notification_service'; +import { useMlApiContext } from '../../../../contexts/kibana'; +import { useCurrentEuiTheme } from '../../../../components/color_range_legend'; +import { JobMessagesPane } from '../job_details/job_messages_pane'; +import { EditQueryDelay } from './edit_query_delay'; +import { getIntervalOptions } from './get_interval_options'; +import { + CHART_DIRECTION, + ChartDirectionType, + CHART_SIZE, + tabs, + TAB_IDS, + TabIdsType, +} from './constants'; +import { loadFullJob } from '../utils'; + +const dateFormatter = timeFormatter('MM-DD HH:mm'); + +interface DatafeedModalProps { + jobId: string; + end: number; + onClose: (deletionApproved?: boolean) => void; +} + +export const DatafeedModal: FC = ({ jobId, end, onClose }) => { + const [data, setData] = useState<{ + datafeedConfig: CombinedJobWithStats['datafeed_config'] | undefined; + bucketSpan: string | undefined; + isInitialized: boolean; + }>({ datafeedConfig: undefined, bucketSpan: undefined, isInitialized: false }); + const [endDate, setEndDate] = useState(moment(end)); + const [interval, setInterval] = useState(); + const [selectedTabId, setSelectedTabId] = useState(TAB_IDS.CHART); + const [isLoadingChartData, setIsLoadingChartData] = useState(false); + const [bucketData, setBucketData] = useState([]); + const [sourceData, setSourceData] = useState([]); + + const { + results: { getDatafeedResultChartData }, + } = useMlApiContext(); + const { displayErrorToast } = useToastNotificationService(); + const { euiTheme } = useCurrentEuiTheme(); + + const onSelectedTabChanged = (id: TabIdsType) => { + setSelectedTabId(id); + }; + + const renderTabs = useCallback( + () => + tabs.map((tab, index) => ( + onSelectedTabChanged(tab.id)} + isSelected={tab.id === selectedTabId} + disabled={tab.disabled} + key={index} + > + {tab.name} + + )), + [selectedTabId] + ); + + const handleChange = (date: moment.Moment) => setEndDate(date); + + const handleEndDateChange = (direction: ChartDirectionType) => { + if (interval === undefined) return; + + const newEndDate = endDate.clone(); + const [count, type] = interval.split(' '); + + if (direction === CHART_DIRECTION.FORWARD) { + newEndDate.add(Number(count), type); + } else { + newEndDate.subtract(Number(count), type); + } + setEndDate(newEndDate); + }; + + const getChartData = useCallback(async () => { + if (interval === undefined) return; + + const endTimestamp = moment(endDate).valueOf(); + const [count, type] = interval.split(' '); + const startMoment = endDate.clone().subtract(Number(count), type); + const startTimestamp = moment(startMoment).valueOf(); + + try { + const chartData = await getDatafeedResultChartData(jobId, startTimestamp, endTimestamp); + + setSourceData(chartData.datafeedResults); + setBucketData(chartData.bucketResults); + } catch (error) { + const title = i18n.translate('xpack.ml.jobsList.datafeedModal.errorToastTitle', { + defaultMessage: 'Error fetching data', + }); + displayErrorToast(error, title); + } + setIsLoadingChartData(false); + }, [endDate, interval]); + + const getJobData = async () => { + try { + const job: CombinedJobWithStats = await loadFullJob(jobId); + setData({ + datafeedConfig: job.datafeed_config, + bucketSpan: job.analysis_config.bucket_span, + isInitialized: true, + }); + const intervalOptions = getIntervalOptions(job.analysis_config.bucket_span); + const initialInterval = intervalOptions.length + ? intervalOptions[intervalOptions.length - 1] + : undefined; + setInterval(initialInterval?.value || '72 hours'); + } catch (error) { + displayErrorToast(error); + } + }; + + useEffect(function loadJobWithDatafeed() { + getJobData(); + }, []); + + useEffect( + function loadChartData() { + if (interval !== undefined) { + setIsLoadingChartData(true); + getChartData(); + } + }, + [endDate, interval] + ); + + const { datafeedConfig, bucketSpan, isInitialized } = data; + + const intervalOptions = useMemo(() => { + if (bucketSpan === undefined) return []; + return getIntervalOptions(bucketSpan); + }, [bucketSpan]); + + return ( + + + + + + + + + + + + + + {renderTabs()} + + {isLoadingChartData || isInitialized === false ? : null} + {!isLoadingChartData && + isInitialized && + selectedTabId === TAB_IDS.CHART && + datafeedConfig !== undefined && + bucketSpan && ( + + + + + setInterval(e.target.value)} + aria-label={i18n.translate( + 'xpack.ml.jobsList.datafeedModal.intervalSelection', + { + defaultMessage: 'Datafeed modal chart interval selection', + } + )} + /> + + + + + + + + + + + } + > + { + handleEndDateChange(CHART_DIRECTION.BACK); + }} + iconType="arrowLeft" + /> + + + + + + + + + + + + + + } + > + { + handleEndDateChange(CHART_DIRECTION.FORWARD); + }} + iconType="arrowRight" + /> + + + + + + )} + {!isLoadingChartData && selectedTabId === TAB_IDS.MESSAGES ? ( + + ) : null} + + + ); +}; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/edit_query_delay.tsx b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/edit_query_delay.tsx new file mode 100644 index 00000000000000..5a25781a505d15 --- /dev/null +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/edit_query_delay.tsx @@ -0,0 +1,142 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { FC, useCallback, useState } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { + EuiButtonEmpty, + EuiFieldText, + EuiFlexGroup, + EuiFlexItem, + EuiFormRow, + EuiToolTip, +} from '@elastic/eui'; + +import { useMlApiContext } from '../../../../contexts/kibana'; +import { useToastNotificationService } from '../../../../services/toast_notification_service'; +import { Datafeed } from '../../../../../../common/types/anomaly_detection_jobs'; + +const tooltipContent = i18n.translate( + 'xpack.ml.jobsList.datafeedModal.editQueryDelay.tooltipContent', + { + defaultMessage: 'Cannot update query delay when datafeed is running.', + } +); + +export const EditQueryDelay: FC<{ + datafeedId: Datafeed['datafeed_id']; + queryDelay: Datafeed['query_delay']; + isEnabled: boolean; +}> = ({ datafeedId, queryDelay, isEnabled }) => { + const [newQueryDelay, setNewQueryDelay] = useState(); + const [isEditing, setIsEditing] = useState(false); + const { updateDatafeed } = useMlApiContext(); + const { displaySuccessToast, displayErrorToast } = useToastNotificationService(); + + const updateQueryDelay = useCallback(async () => { + try { + await updateDatafeed({ + datafeedId, + datafeedConfig: { query_delay: newQueryDelay }, + }); + displaySuccessToast( + i18n.translate( + 'xpack.ml.jobsList.datafeedModal.editQueryDelay.changesSavedNotificationMessage', + { + defaultMessage: 'Changes to query delay for {datafeedId} saved', + values: { + datafeedId, + }, + } + ) + ); + } catch (error) { + displayErrorToast( + error, + i18n.translate( + 'xpack.ml.jobsList.datafeedModal.editQueryDelay.changesNotSavedNotificationMessage', + { + defaultMessage: 'Could not save changes to query delay for {datafeedId}', + values: { + datafeedId, + }, + } + ) + ); + } + setIsEditing(false); + }, [datafeedId, newQueryDelay]); + + const editButton = ( + { + setIsEditing(true); + }} + iconType="pencil" + > + + + ); + + const editButtonWithTooltip = {editButton}; + + return ( + <> + {isEditing === false ? (isEnabled === false ? editButtonWithTooltip : editButton) : null} + {isEditing === true ? ( + + } + > + + + { + setNewQueryDelay(e.target.value); + }} + /> + + + + + + + + + + setIsEditing(false)}> + + + + + + + + ) : null} + + ); +}; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/get_interval_options.ts b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/get_interval_options.ts new file mode 100644 index 00000000000000..cc9431549c79c6 --- /dev/null +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/get_interval_options.ts @@ -0,0 +1,118 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; + +export const getIntervalOptions = (bucketSpan: string) => { + const unitMatch = bucketSpan.match(/[d | h| m | s]/g)!; + const unit = unitMatch[0]; + const count = Number(bucketSpan.replace(/[^0-9]/g, '')); + + const intervalOptions = []; + + if (['s', 'ms', 'micros', 'nanos'].includes(unit)) { + intervalOptions.push( + { + value: '1 hour', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.1hourOption', { + defaultMessage: '{count} hour', + values: { count: 1 }, + }), + }, + { + value: '2 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.2hourOption', { + defaultMessage: '{count} hours', + values: { count: 2 }, + }), + } + ); + } + + if ((unit === 'm' && count <= 4) || unit === 'h') { + intervalOptions.push( + { + value: '3 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.3hourOption', { + defaultMessage: '{count} hours', + values: { count: 3 }, + }), + }, + { + value: '8 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.8hourOption', { + defaultMessage: '{count} hours', + values: { count: 8 }, + }), + }, + { + value: '12 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.12hourOption', { + defaultMessage: '{count} hours', + values: { count: 12 }, + }), + }, + { + value: '24 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.24hourOption', { + defaultMessage: '{count} hours', + values: { count: 24 }, + }), + } + ); + } + + if ((unit === 'm' && count >= 5 && count <= 15) || unit === 'h') { + intervalOptions.push( + { + value: '48 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.48hourOption', { + defaultMessage: '{count} hours', + values: { count: 48 }, + }), + }, + { + value: '72 hours', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.72hourOption', { + defaultMessage: '{count} hours', + values: { count: 72 }, + }), + } + ); + } + + if ((unit === 'm' && count >= 10 && count <= 15) || unit === 'h' || unit === 'd') { + intervalOptions.push( + { + value: '5 days', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.5daysOption', { + defaultMessage: '{count} days', + values: { count: 5 }, + }), + }, + { + value: '7 days', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.7daysOption', { + defaultMessage: '{count} days', + values: { count: 7 }, + }), + } + ); + } + + if (unit === 'h' || unit === 'd') { + intervalOptions.push({ + value: '14 days', + text: i18n.translate('xpack.ml.jobsList.datafeedModal.14DaysOption', { + defaultMessage: '{count} days', + values: { count: 14 }, + }), + }); + } + + return intervalOptions; +}; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/index.ts b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/index.ts new file mode 100644 index 00000000000000..68c50c6663e1d9 --- /dev/null +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/datafeed_modal/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { DatafeedModal } from './datafeed_modal'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/datafeed_preview_tab.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/datafeed_preview_tab.js index e5fdae201eb04f..c24d8df3909fe7 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/datafeed_preview_tab.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/datafeed_preview_tab.js @@ -10,7 +10,7 @@ import React, { Component } from 'react'; import { EuiSpacer, EuiCallOut, EuiLoadingSpinner } from '@elastic/eui'; -import { mlJobService } from '../../../../services/job_service'; +import { ml } from '../../../../services/ml_api_service'; import { checkPermission } from '../../../../capabilities/check_capabilities'; import { ML_DATA_PREVIEW_COUNT } from '../../../../../../common/util/job_utils'; import { MLJobEditor } from '../ml_job_editor'; @@ -88,8 +88,8 @@ DatafeedPreviewPane.propTypes = { function updateDatafeedPreview(job, canPreviewDatafeed) { return new Promise((resolve, reject) => { if (canPreviewDatafeed) { - mlJobService - .getDatafeedPreview(job.datafeed_config.datafeed_id) + ml.jobs + .datafeedPreview(job.datafeed_config.datafeed_id) .then((resp) => { if (Array.isArray(resp)) { resolve(JSON.stringify(resp.slice(0, ML_DATA_PREVIEW_COUNT), null, 2)); diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js index bd85420397218d..cc6db66dc1cfd4 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js @@ -21,8 +21,8 @@ import { TIME_FORMAT } from '../../../../../../common/constants/time_format'; import { EuiBasicTable, EuiButtonIcon, - EuiScreenReaderOnly, EuiIcon, + EuiScreenReaderOnly, EuiToolTip, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.d.ts b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.d.ts index 82cbf8424973c3..76e1e87312a4a8 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.d.ts +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.d.ts @@ -5,4 +5,7 @@ * 2.0. */ +import { CombinedJobWithStats } from '../../../../../common/types/anomaly_detection_jobs'; + export function deleteJobs(jobs: Array<{ id: string }>, callback?: () => void): Promise; +export function loadFullJob(jobId: string): Promise; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/common/datafeed_preview_flyout/datafeed_preview.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/common/datafeed_preview_flyout/datafeed_preview.tsx index a4d9293e9369dc..c6d6e6789bd950 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/common/datafeed_preview_flyout/datafeed_preview.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/common/datafeed_preview_flyout/datafeed_preview.tsx @@ -19,15 +19,15 @@ import { import { CombinedJob } from '../../../../../../../../common/types/anomaly_detection_jobs'; import { MLJobEditor } from '../../../../../jobs_list/components/ml_job_editor'; -import { mlJobService } from '../../../../../../services/job_service'; -import { ML_DATA_PREVIEW_COUNT } from '../../../../../../../../common/util/job_utils'; -import { isPopulatedObject } from '../../../../../../../../common/util/object_utils'; -import { isMultiBucketAggregate } from '../../../../../../../../common/types/es_client'; +import { useMlApiContext } from '../../../../../../contexts/kibana'; export const DatafeedPreview: FC<{ combinedJob: CombinedJob | null; heightOffset?: number; }> = ({ combinedJob, heightOffset = 0 }) => { + const { + jobs: { datafeedPreview }, + } = useMlApiContext(); // the ace editor requires a fixed height const editorHeight = useMemo(() => `${window.innerHeight - 230 - heightOffset}px`, [ heightOffset, @@ -63,18 +63,17 @@ export const DatafeedPreview: FC<{ if (combinedJob.datafeed_config && combinedJob.datafeed_config.indices.length) { try { - const resp = await mlJobService.searchPreview(combinedJob); - let data = resp.hits.hits; - // the first item under aggregations can be any name - if (isPopulatedObject(resp.aggregations)) { - const accessor = Object.keys(resp.aggregations)[0]; - const aggregate = resp.aggregations[accessor]; - if (isMultiBucketAggregate(aggregate)) { - data = aggregate.buckets.slice(0, ML_DATA_PREVIEW_COUNT); - } + const { datafeed_config: datafeed, ...job } = combinedJob; + if (job.analysis_config.detectors.length === 0) { + setPreviewJsonString( + i18n.translate('xpack.ml.newJob.wizard.datafeedPreviewFlyout.noDetectors', { + defaultMessage: 'No detectors configured', + }) + ); + } else { + const preview = await datafeedPreview(undefined, job, datafeed); + setPreviewJsonString(JSON.stringify(preview, null, 2)); } - - setPreviewJsonString(JSON.stringify(data, null, 2)); } catch (error) { setPreviewJsonString(JSON.stringify(error, null, 2)); } diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/edit_job.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/edit_job.tsx index d2780691e551d9..408e86512ed6dc 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/edit_job.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/edit_job.tsx @@ -51,9 +51,9 @@ export const EditJob: FC = ({ job, jobOverride, existingGroupIds, ); const handleValidation = () => { - const jobGroupsValidationResult = - formState.jobGroups ?? - [].map((group) => groupValidator(group)).filter((result) => result !== null); + const jobGroupsValidationResult = (formState.jobGroups ?? []) + .map((group) => groupValidator(group)) + .filter((result) => result !== null); setValidationResult({ jobGroups: jobGroupsValidationResult, diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/job_item.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/job_item.tsx index b97c16e02d9007..0daf4f28f33d31 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/job_item.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/recognize/components/job_item.tsx @@ -87,12 +87,11 @@ export const JobItem: FC = memo( - {jobGroups ?? - [].map((group) => ( - - {group} - - ))} + {(jobGroups ?? []).map((group) => ( + + {group} + + ))} {setupResult && setupResult.error && ( diff --git a/x-pack/plugins/ml/public/application/routing/ml_page_wrapper.tsx b/x-pack/plugins/ml/public/application/routing/ml_page_wrapper.tsx new file mode 100644 index 00000000000000..e97ab0fb830a59 --- /dev/null +++ b/x-pack/plugins/ml/public/application/routing/ml_page_wrapper.tsx @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React, { FC } from 'react'; +import { TrackApplicationView } from '../../../../../../src/plugins/usage_collection/public'; + +export const MlPageWrapper: FC<{ path: string }> = ({ path, children }) => { + return {children}; +}; diff --git a/x-pack/plugins/ml/public/application/routing/router.tsx b/x-pack/plugins/ml/public/application/routing/router.tsx index 27de3781bc7abe..c2129ef18df3a0 100644 --- a/x-pack/plugins/ml/public/application/routing/router.tsx +++ b/x-pack/plugins/ml/public/application/routing/router.tsx @@ -18,6 +18,7 @@ import { MlContext, MlContextValue } from '../contexts/ml'; import { UrlStateProvider } from '../util/url_state'; import * as routes from './routes'; +import { MlPageWrapper } from './ml_page_wrapper'; // custom RouteProps making location non-optional interface MlRouteProps extends RouteProps { @@ -97,7 +98,9 @@ const MlRoutes: FC<{ window.setTimeout(() => { pageDeps.setBreadcrumbs(route.breadcrumbs); }); - return route.render(props, pageDeps); + return ( + {route.render(props, pageDeps)} + ); }} /> ); diff --git a/x-pack/plugins/ml/public/application/services/job_service.d.ts b/x-pack/plugins/ml/public/application/services/job_service.d.ts index ceadca12f87575..667f23da34aa04 100644 --- a/x-pack/plugins/ml/public/application/services/job_service.d.ts +++ b/x-pack/plugins/ml/public/application/services/job_service.d.ts @@ -41,7 +41,6 @@ declare interface JobService { ): Promise; createResultsUrl(jobId: string[], start: number, end: number, location: string): string; getJobAndGroupIds(): Promise; - searchPreview(job: CombinedJob): Promise>; getJob(jobId: string): CombinedJob; loadJobsWrapper(): Promise; } diff --git a/x-pack/plugins/ml/public/application/services/job_service.js b/x-pack/plugins/ml/public/application/services/job_service.js index 2fa60b8db83a7b..3c93c8a1ae85ac 100644 --- a/x-pack/plugins/ml/public/application/services/job_service.js +++ b/x-pack/plugins/ml/public/application/services/job_service.js @@ -347,11 +347,6 @@ class JobService { return job; } - searchPreview(combinedJob) { - const { datafeed_config: datafeed, ...job } = combinedJob; - return ml.jobs.datafeedPreview(job, datafeed); - } - openJob(jobId) { return ml.openJob({ jobId }); } @@ -435,10 +430,6 @@ class JobService { return datafeedId; } - getDatafeedPreview(datafeedId) { - return ml.datafeedPreview({ datafeedId }); - } - // get the list of job group ids as well as how many jobs are in each group getJobGroups() { const groups = []; diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts index d66805b4f737f3..1bfc597ba0b10f 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts @@ -235,7 +235,7 @@ export function mlApiServicesProvider(httpService: HttpService) { datafeedConfig, }: { datafeedId: string; - datafeedConfig: Datafeed; + datafeedConfig: Partial; }) { const body = JSON.stringify(datafeedConfig); return httpService.http({ diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts index 144492eacc2473..7cd08bc1fd15c1 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/jobs.ts @@ -330,8 +330,8 @@ export const jobsApiProvider = (httpService: HttpService) => ({ }); }, - datafeedPreview(job: Job, datafeed: Datafeed) { - const body = JSON.stringify({ job, datafeed }); + datafeedPreview(datafeedId?: string, job?: Job, datafeed?: Datafeed) { + const body = JSON.stringify({ datafeedId, job, datafeed }); return httpService.http<{ total: number; categories: Array<{ count?: number; category: Category }>; diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts index 76d6c19c165a18..19ba5aa304bf04 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts @@ -141,4 +141,17 @@ export const resultsApiProvider = (httpService: HttpService) => ({ body, }); }, + + getDatafeedResultChartData(jobId: string, start: number, end: number) { + const body = JSON.stringify({ + jobId, + start, + end, + }); + return httpService.http({ + path: `${basePath()}/results/datafeed_results_chart`, + method: 'POST', + body, + }); + }, }); diff --git a/x-pack/plugins/ml/public/plugin.ts b/x-pack/plugins/ml/public/plugin.ts index 1191f3b253fd7d..e3a4a8348ebc10 100644 --- a/x-pack/plugins/ml/public/plugin.ts +++ b/x-pack/plugins/ml/public/plugin.ts @@ -52,6 +52,7 @@ import { import { DataVisualizerPluginStart } from '../../data_visualizer/public'; import { PluginSetupContract as AlertingSetup } from '../../alerting/public'; import { registerManagementSection } from './application/management'; +import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public'; export interface MlStartDependencies { data: DataPublicPluginStart; @@ -78,6 +79,7 @@ export interface MlSetupDependencies { share: SharePluginSetup; triggersActionsUi?: TriggersAndActionsUIPublicPluginSetup; alerting?: AlertingSetup; + usageCollection?: UsageCollectionSetup; } export type MlCoreSetup = CoreSetup; @@ -121,6 +123,7 @@ export class MlPlugin implements Plugin { kibanaVersion, triggersActionsUi: pluginsStart.triggersActionsUi, dataVisualizer: pluginsStart.dataVisualizer, + usageCollection: pluginsSetup.usageCollection, }, params ); diff --git a/x-pack/plugins/ml/server/models/data_recognizer/modules/security_network/ml/datafeed_high_count_network_denies.json b/x-pack/plugins/ml/server/models/data_recognizer/modules/security_network/ml/datafeed_high_count_network_denies.json index a4412a6d732e99..3ff28ef3d8df3d 100755 --- a/x-pack/plugins/ml/server/models/data_recognizer/modules/security_network/ml/datafeed_high_count_network_denies.json +++ b/x-pack/plugins/ml/server/models/data_recognizer/modules/security_network/ml/datafeed_high_count_network_denies.json @@ -13,10 +13,29 @@ "term": { "event.category": "network" } - }, + } + ], + "must": [ { - "term": { - "event.outcome": "deny" + "bool": { + "should": [ + { + "match": { + "event.outcome": { + "query": "deny", + "operator": "OR" + } + } + }, + { + "match": { + "event.type": { + "query": "denied", + "operator": "OR" + } + } + } + ] } } ] diff --git a/x-pack/plugins/ml/server/models/job_service/datafeeds.ts b/x-pack/plugins/ml/server/models/job_service/datafeeds.ts index 5dfe1b5934fe9f..8b3f7f4b0b0eea 100644 --- a/x-pack/plugins/ml/server/models/job_service/datafeeds.ts +++ b/x-pack/plugins/ml/server/models/job_service/datafeeds.ts @@ -10,12 +10,8 @@ import { i18n } from '@kbn/i18n'; import { IScopedClusterClient } from 'kibana/server'; import { JOB_STATE, DATAFEED_STATE } from '../../../common/constants/states'; import { fillResultsWithTimeouts, isRequestTimeout } from './error_utils'; -import { Datafeed, DatafeedStats, Job } from '../../../common/types/anomaly_detection_jobs'; -import { ML_DATA_PREVIEW_COUNT } from '../../../common/util/job_utils'; -import { fieldsServiceProvider } from '../fields_service'; +import { Datafeed, DatafeedStats } from '../../../common/types/anomaly_detection_jobs'; import type { MlClient } from '../../lib/ml_client'; -import { parseInterval } from '../../../common/util/parse_interval'; -import { isPopulatedObject } from '../../../common/util/object_utils'; export interface MlDatafeedsResponse { datafeeds: Datafeed[]; @@ -235,154 +231,6 @@ export function datafeedsProvider(client: IScopedClusterClient, mlClient: MlClie } } - async function datafeedPreview(job: Job, datafeed: Datafeed) { - let query: any = { match_all: {} }; - if (datafeed.query) { - query = datafeed.query; - } - const { getTimeFieldRange } = fieldsServiceProvider(client); - const { start } = await getTimeFieldRange( - datafeed.indices, - job.data_description.time_field, - query, - datafeed.runtime_mappings, - datafeed.indices_options - ); - - // Get bucket span - // Get first doc time for datafeed - // Create a new query - must user query and must range query. - // Time range 'to' first doc time plus < 10 buckets - - // Do a preliminary search to get the date of the earliest doc matching the - // query in the datafeed. This will be used to apply a time range criteria - // on the datafeed search preview. - // This time filter is required for datafeed searches using aggregations to ensure - // the search does not create too many buckets (default 10000 max_bucket limit), - // but apply it to searches without aggregations too for consistency. - const bucketSpan = parseInterval(job.analysis_config.bucket_span); - if (bucketSpan === null) { - return; - } - const earliestMs = start.epoch; - const latestMs = +start.epoch + 10 * bucketSpan.asMilliseconds(); - - const body: any = { - query: { - bool: { - must: [ - { - range: { - [job.data_description.time_field]: { - gte: earliestMs, - lt: latestMs, - format: 'epoch_millis', - }, - }, - }, - query, - ], - }, - }, - }; - - // if aggs or aggregations is set, add it to the search - const aggregations = datafeed.aggs ?? datafeed.aggregations; - if (isPopulatedObject(aggregations)) { - body.size = 0; - body.aggregations = aggregations; - - // add script_fields if present - const scriptFields = datafeed.script_fields; - if (isPopulatedObject(scriptFields)) { - body.script_fields = scriptFields; - } - - // add runtime_mappings if present - const runtimeMappings = datafeed.runtime_mappings; - if (isPopulatedObject(runtimeMappings)) { - body.runtime_mappings = runtimeMappings; - } - } else { - // if aggregations is not set and retrieveWholeSource is not set, add all of the fields from the job - body.size = ML_DATA_PREVIEW_COUNT; - - // add script_fields if present - const scriptFields = datafeed.script_fields; - if (isPopulatedObject(scriptFields)) { - body.script_fields = scriptFields; - } - - // add runtime_mappings if present - const runtimeMappings = datafeed.runtime_mappings; - if (isPopulatedObject(runtimeMappings)) { - body.runtime_mappings = runtimeMappings; - } - - const fields = new Set(); - - // get fields from detectors - if (job.analysis_config.detectors) { - job.analysis_config.detectors.forEach((dtr) => { - if (dtr.by_field_name) { - fields.add(dtr.by_field_name); - } - if (dtr.field_name) { - fields.add(dtr.field_name); - } - if (dtr.over_field_name) { - fields.add(dtr.over_field_name); - } - if (dtr.partition_field_name) { - fields.add(dtr.partition_field_name); - } - }); - } - - // get fields from influencers - if (job.analysis_config.influencers) { - job.analysis_config.influencers.forEach((inf) => { - fields.add(inf); - }); - } - - // get fields from categorizationFieldName - if (job.analysis_config.categorization_field_name) { - fields.add(job.analysis_config.categorization_field_name); - } - - // get fields from summary_count_field_name - if (job.analysis_config.summary_count_field_name) { - fields.add(job.analysis_config.summary_count_field_name); - } - - // get fields from time_field - if (job.data_description.time_field) { - fields.add(job.data_description.time_field); - } - - // add runtime fields - if (runtimeMappings) { - Object.keys(runtimeMappings).forEach((fieldName) => { - fields.add(fieldName); - }); - } - - const fieldsList = [...fields]; - if (fieldsList.length) { - body.fields = fieldsList; - body._source = false; - } - } - const data = { - index: datafeed.indices, - body, - ...(datafeed.indices_options ?? {}), - }; - - return (await client.asCurrentUser.search(data)).body; - } - return { forceStartDatafeeds, stopDatafeeds, @@ -390,6 +238,5 @@ export function datafeedsProvider(client: IScopedClusterClient, mlClient: MlClie getDatafeedIdsByJobId, getJobIdsByDatafeedId, getDatafeedByJobId, - datafeedPreview, }; } diff --git a/x-pack/plugins/ml/server/models/results_service/results_service.ts b/x-pack/plugins/ml/server/models/results_service/results_service.ts index 225a988298b1cc..9413ee00184d20 100644 --- a/x-pack/plugins/ml/server/models/results_service/results_service.ts +++ b/x-pack/plugins/ml/server/models/results_service/results_service.ts @@ -5,9 +5,10 @@ * 2.0. */ -import { sortBy, slice, get } from 'lodash'; +import { sortBy, slice, get, cloneDeep } from 'lodash'; import moment from 'moment'; import Boom from '@hapi/boom'; +import { IScopedClusterClient } from 'kibana/server'; import { buildAnomalyTableItems } from './build_anomaly_table_items'; import { ANOMALIES_TABLE_DEFAULT_QUERY_SIZE } from '../../../common/constants/search'; import { getPartitionFieldsValuesFactory } from './get_partition_fields_values'; @@ -17,9 +18,15 @@ import { AnomalyRecordDoc, } from '../../../common/types/anomalies'; import { JOB_ID, PARTITION_FIELD_VALUE } from '../../../common/constants/anomalies'; -import { GetStoppedPartitionResult } from '../../../common/types/results'; +import { + GetStoppedPartitionResult, + GetDatafeedResultsChartDataResult, + defaultSearchQuery, + DatafeedResultsChartDataParams, +} from '../../../common/types/results'; import { MlJobsResponse } from '../../../common/types/job_service'; import type { MlClient } from '../../lib/ml_client'; +import { datafeedsProvider } from '../job_service/datafeeds'; // Service for carrying out Elasticsearch queries to obtain data for the // ML Results dashboards. @@ -37,7 +44,7 @@ interface Influencer { fieldValue: any; } -export function resultsServiceProvider(mlClient: MlClient) { +export function resultsServiceProvider(mlClient: MlClient, client?: IScopedClusterClient) { // Obtains data for the anomalies table, aggregating anomalies by day or hour as requested. // Return an Object with properties 'anomalies' and 'interval' (interval used to aggregate anomalies, // one of day, hour or second. Note 'auto' can be provided as the aggregationInterval in the request, @@ -605,6 +612,105 @@ export function resultsServiceProvider(mlClient: MlClient) { return finalResults; } + async function getDatafeedResultsChartData({ + jobId, + start, + end, + }: DatafeedResultsChartDataParams): Promise { + const finalResults: GetDatafeedResultsChartDataResult = { + bucketResults: [], + datafeedResults: [], + }; + + const { getDatafeedByJobId } = datafeedsProvider(client!, mlClient); + const datafeedConfig = await getDatafeedByJobId(jobId); + + const { body: jobsResponse } = await mlClient.getJobs({ job_id: jobId }); + if (jobsResponse.count === 0 || jobsResponse.jobs === undefined) { + throw Boom.notFound(`Job with the id "${jobId}" not found`); + } + + const jobConfig = jobsResponse.jobs[0]; + const timefield = jobConfig.data_description.time_field; + const bucketSpan = jobConfig.analysis_config.bucket_span; + + if (datafeedConfig === undefined) { + return finalResults; + } + + const rangeFilter = { + range: { + [timefield]: { gte: start, lte: end }, + }, + }; + + let datafeedQueryClone = + datafeedConfig.query !== undefined ? cloneDeep(datafeedConfig.query) : defaultSearchQuery; + + if (datafeedQueryClone.bool !== undefined) { + if (datafeedQueryClone.bool.filter === undefined) { + datafeedQueryClone.bool.filter = []; + } + if (Array.isArray(datafeedQueryClone.bool.filter)) { + datafeedQueryClone.bool.filter.push(rangeFilter); + } else { + // filter is an object so convert to array so we can add the rangeFilter + const filterQuery = cloneDeep(datafeedQueryClone.bool.filter); + datafeedQueryClone.bool.filter = [filterQuery, rangeFilter]; + } + } else { + // Not a bool query so convert to a bool query so we can add the range filter + datafeedQueryClone = { bool: { must: [datafeedQueryClone], filter: [rangeFilter] } }; + } + + const esSearchRequest = { + index: datafeedConfig.indices.join(','), + body: { + query: datafeedQueryClone, + ...(datafeedConfig.runtime_mappings + ? { runtime_mappings: datafeedConfig.runtime_mappings } + : {}), + aggs: { + doc_count_by_bucket_span: { + date_histogram: { + field: timefield, + fixed_interval: bucketSpan, + }, + }, + }, + size: 0, + }, + ...(datafeedConfig?.indices_options ?? {}), + }; + + if (client) { + const { + body: { aggregations }, + } = await client.asCurrentUser.search(esSearchRequest); + + finalResults.datafeedResults = + // @ts-expect-error incorrect search response type + aggregations?.doc_count_by_bucket_span?.buckets.map((result) => [ + result.key, + result.doc_count, + ]) || []; + } + + const bucketResp = await mlClient.getBuckets({ + job_id: jobId, + body: { desc: true, start: String(start), end: String(end), page: { from: 0, size: 1000 } }, + }); + + const bucketResults = bucketResp?.body?.buckets ?? []; + bucketResults.forEach((dataForTime) => { + const timestamp = Number(dataForTime?.timestamp); + const eventCount = dataForTime?.event_count; + finalResults.bucketResults.push([timestamp, eventCount]); + }); + + return finalResults; + } + return { getAnomaliesTableData, getCategoryDefinition, @@ -614,5 +720,6 @@ export function resultsServiceProvider(mlClient: MlClient) { getPartitionFieldsValues: getPartitionFieldsValuesFactory(mlClient), getCategorizerStats, getCategoryStoppedPartitions, + getDatafeedResultsChartData, }; } diff --git a/x-pack/plugins/ml/server/routes/apidoc.json b/x-pack/plugins/ml/server/routes/apidoc.json index 16cd3ea8df6295..ba712583f1b61e 100644 --- a/x-pack/plugins/ml/server/routes/apidoc.json +++ b/x-pack/plugins/ml/server/routes/apidoc.json @@ -48,6 +48,7 @@ "ResultsService", "GetAnomaliesTableData", + "GetDatafeedResultsChartData", "GetCategoryDefinition", "GetMaxAnomalyScore", "GetCategoryExamples", diff --git a/x-pack/plugins/ml/server/routes/job_service.ts b/x-pack/plugins/ml/server/routes/job_service.ts index 2dd85a8772f924..992822f6d6eb82 100644 --- a/x-pack/plugins/ml/server/routes/job_service.ts +++ b/x-pack/plugins/ml/server/routes/job_service.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { estypes } from '@elastic/elasticsearch'; import { schema } from '@kbn/config-schema'; import { wrapError } from '../client/error_wrapper'; import { RouteInitialization } from '../types'; @@ -806,23 +807,21 @@ export function jobServiceRoutes({ router, routeGuard }: RouteInitialization) { }, routeGuard.fullLicenseAPIGuard(async ({ client, mlClient, request, response }) => { try { - // @ts-ignore schema mismatch const { datafeedId, job, datafeed } = request.body; - if (datafeedId !== undefined) { - const { body } = await mlClient.previewDatafeed( - { - datafeed_id: datafeedId, - }, - getAuthorizationHeader(request) - ); - return response.ok({ - body, - }); - } - - const { datafeedPreview } = jobServiceProvider(client, mlClient); - const body = await datafeedPreview(job, datafeed); + const payload = + datafeedId !== undefined + ? { + datafeed_id: datafeedId, + } + : ({ + body: { + job_config: job, + datafeed_config: datafeed, + }, + } as estypes.MlPreviewDatafeedRequest); + + const { body } = await mlClient.previewDatafeed(payload, getAuthorizationHeader(request)); return response.ok({ body, }); diff --git a/x-pack/plugins/ml/server/routes/results_service.ts b/x-pack/plugins/ml/server/routes/results_service.ts index 1962463a066778..2cb34ce357fea5 100644 --- a/x-pack/plugins/ml/server/routes/results_service.ts +++ b/x-pack/plugins/ml/server/routes/results_service.ts @@ -11,6 +11,7 @@ import { anomaliesTableDataSchema, categoryDefinitionSchema, categoryExamplesSchema, + getDatafeedResultsChartDataSchema, maxAnomalyScoreSchema, partitionFieldValuesSchema, anomalySearchSchema, @@ -352,4 +353,37 @@ export function resultsServiceRoutes({ router, routeGuard }: RouteInitialization } }) ); + + /** + * @apiGroup ResultsService + * + * @api {post} /api/ml/results/datafeed_results_chart Get datafeed results chart data + * @apiName GetDatafeedResultsChartData + * @apiDescription Returns datafeed results chart data + * + * @apiSchema (body) getDatafeedResultsChartDataSchema + */ + router.post( + { + path: '/api/ml/results/datafeed_results_chart', + validate: { + body: getDatafeedResultsChartDataSchema, + }, + options: { + tags: ['access:ml:canGetJobs'], + }, + }, + routeGuard.fullLicenseAPIGuard(async ({ client, mlClient, request, response }) => { + try { + const { getDatafeedResultsChartData } = resultsServiceProvider(mlClient, client); + const resp = await getDatafeedResultsChartData(request.body); + + return response.ok({ + body: resp, + }); + } catch (e) { + return response.customError(wrapError(e)); + } + }) + ); } diff --git a/x-pack/plugins/ml/server/routes/schemas/anomaly_detectors_schema.ts b/x-pack/plugins/ml/server/routes/schemas/anomaly_detectors_schema.ts index 392c0d3514d648..ec39d08ee357d5 100644 --- a/x-pack/plugins/ml/server/routes/schemas/anomaly_detectors_schema.ts +++ b/x-pack/plugins/ml/server/routes/schemas/anomaly_detectors_schema.ts @@ -123,7 +123,7 @@ export const anomalyDetectionJobSchema = { job_id: schema.string(), job_type: schema.maybe(schema.string()), job_version: schema.maybe(schema.string()), - groups: schema.arrayOf(schema.maybe(schema.string())), + groups: schema.maybe(schema.arrayOf(schema.maybe(schema.string()))), model_plot_config: schema.maybe(schema.any()), model_plot: schema.maybe(schema.any()), model_size_stats: schema.maybe(schema.any()), diff --git a/x-pack/plugins/ml/server/routes/schemas/job_service_schema.ts b/x-pack/plugins/ml/server/routes/schemas/job_service_schema.ts index 45ef3e3f73b6ec..df91dea101c7cb 100644 --- a/x-pack/plugins/ml/server/routes/schemas/job_service_schema.ts +++ b/x-pack/plugins/ml/server/routes/schemas/job_service_schema.ts @@ -109,15 +109,32 @@ export const revertModelSnapshotSchema = schema.object({ ), }); -export const datafeedPreviewSchema = schema.oneOf([ - schema.object({ - job: schema.object(anomalyDetectionJobSchema), - datafeed: datafeedConfigSchema, - }), - schema.object({ - datafeedId: schema.string(), - }), -]); +export const datafeedPreviewSchema = schema.object( + { + job: schema.maybe(schema.object(anomalyDetectionJobSchema)), + datafeed: schema.maybe(datafeedConfigSchema), + datafeedId: schema.maybe(schema.string()), + }, + { + validate: (v) => { + const msg = 'supply either a datafeed_id for an existing job or a job and datafeed config'; + if (v.datafeedId !== undefined && (v.job !== undefined || v.datafeed !== undefined)) { + // datafeed_id is supplied but job and datafeed configs are also supplied + return msg; + } + + if (v.datafeedId === undefined && (v.job === undefined || v.datafeed === undefined)) { + // datafeed_id is not supplied but job or datafeed configs are missing + return msg; + } + + if (v.datafeedId === undefined && v.job === undefined && v.datafeed === undefined) { + // everything is missing + return msg; + } + }, + } +); export const jobsExistSchema = schema.object({ jobIds: schema.arrayOf(schema.string()), diff --git a/x-pack/plugins/ml/server/routes/schemas/results_service_schema.ts b/x-pack/plugins/ml/server/routes/schemas/results_service_schema.ts index 175300f88166a6..df4a56b06410b2 100644 --- a/x-pack/plugins/ml/server/routes/schemas/results_service_schema.ts +++ b/x-pack/plugins/ml/server/routes/schemas/results_service_schema.ts @@ -103,3 +103,12 @@ export const getCategorizerStoppedPartitionsSchema = schema.object({ */ fieldToBucket: schema.maybe(schema.string()), }); + +export const getDatafeedResultsChartDataSchema = schema.object({ + /** + * Job id to fetch the bucket results for + */ + jobId: schema.string(), + start: schema.number(), + end: schema.number(), +}); diff --git a/x-pack/plugins/observability/common/const.ts b/x-pack/plugins/observability/common/const.ts new file mode 100644 index 00000000000000..7065d8ccc6b344 --- /dev/null +++ b/x-pack/plugins/observability/common/const.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export const CASES_APP_ID = 'observabilityCases'; +export const OBSERVABILITY = 'observability'; diff --git a/x-pack/plugins/observability/kibana.json b/x-pack/plugins/observability/kibana.json index 52d5493ae69a49..d13140f0be16ce 100644 --- a/x-pack/plugins/observability/kibana.json +++ b/x-pack/plugins/observability/kibana.json @@ -7,14 +7,16 @@ "observability" ], "optionalPlugins": [ - "licensing", "home", - "usageCollection", - "lens" + "lens", + "licensing", + "usageCollection" ], "requiredPlugins": [ - "data", "alerting", + "cases", + "data", + "features", "ruleRegistry", "triggersActionsUi" ], diff --git a/x-pack/plugins/observability/public/components/app/cases/all_cases/index.tsx b/x-pack/plugins/observability/public/components/app/cases/all_cases/index.tsx new file mode 100644 index 00000000000000..1636d08aa56e4d --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/all_cases/index.tsx @@ -0,0 +1,74 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { + getCaseDetailsUrl, + getConfigureCasesUrl, + getCreateCaseUrl, + useFormatUrl, +} from '../../../../pages/cases/links'; +import { useKibana } from '../../../../utils/kibana_react'; +import { CASES_APP_ID, CASES_OWNER } from '../constants'; + +export interface AllCasesNavProps { + detailName: string; + search?: string; + subCaseId?: string; +} + +interface AllCasesProps { + userCanCrud: boolean; +} +export const AllCases = React.memo(({ userCanCrud }) => { + const { + cases: casesUi, + application: { navigateToApp }, + } = useKibana().services; + const { formatUrl } = useFormatUrl(CASES_APP_ID); + + return casesUi.getAllCases({ + caseDetailsNavigation: { + href: ({ detailName, subCaseId }: AllCasesNavProps) => { + return formatUrl(getCaseDetailsUrl({ id: detailName, subCaseId })); + }, + onClick: async ({ detailName, subCaseId, search }: AllCasesNavProps) => + navigateToApp(`${CASES_APP_ID}`, { + path: getCaseDetailsUrl({ id: detailName, subCaseId }), + }), + }, + configureCasesNavigation: { + href: formatUrl(getConfigureCasesUrl()), + onClick: async (ev) => { + if (ev != null) { + ev.preventDefault(); + } + return navigateToApp(`${CASES_APP_ID}`, { + path: getConfigureCasesUrl(), + }); + }, + }, + createCaseNavigation: { + href: formatUrl(getCreateCaseUrl()), + onClick: async (ev) => { + if (ev != null) { + ev.preventDefault(); + } + return navigateToApp(`${CASES_APP_ID}`, { + path: getCreateCaseUrl(), + }); + }, + }, + disableAlerts: true, + showTitle: false, + userCanCrud, + owner: [CASES_OWNER], + }); +}); + +AllCases.displayName = 'AllCases'; diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/callout.test.tsx b/x-pack/plugins/observability/public/components/app/cases/callout/callout.test.tsx new file mode 100644 index 00000000000000..b0b6fc0e3b7933 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/callout.test.tsx @@ -0,0 +1,90 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { mount } from 'enzyme'; + +import { CallOut, CallOutProps } from './callout'; + +describe('Callout', () => { + const defaultProps: CallOutProps = { + id: 'md5-hex', + type: 'primary', + title: 'a tittle', + messages: [ + { + id: 'generic-error', + title: 'message-one', + description:

{'error'}

, + }, + ], + showCallOut: true, + handleDismissCallout: jest.fn(), + }; + + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('renders the callout', () => { + const wrapper = mount(); + expect(wrapper.find(`[data-test-subj="case-callout-md5-hex"]`).exists()).toBeTruthy(); + expect(wrapper.find(`[data-test-subj="callout-messages-md5-hex"]`).exists()).toBeTruthy(); + expect(wrapper.find(`[data-test-subj="callout-dismiss-md5-hex"]`).exists()).toBeTruthy(); + }); + + it('hides the callout', () => { + const wrapper = mount(); + expect(wrapper.find(`[data-test-subj="case-callout-md5-hex"]`).exists()).toBeFalsy(); + }); + + it('does not show any messages when the list is empty', () => { + const wrapper = mount(); + expect(wrapper.find(`[data-test-subj="callout-messages-md5-hex"]`).exists()).toBeFalsy(); + }); + + it('transform the button color correctly - primary', () => { + const wrapper = mount(); + const className = + wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).first().prop('className') ?? + ''; + expect(className.includes('euiButton--primary')).toBeTruthy(); + }); + + it('transform the button color correctly - success', () => { + const wrapper = mount(); + const className = + wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).first().prop('className') ?? + ''; + expect(className.includes('euiButton--secondary')).toBeTruthy(); + }); + + it('transform the button color correctly - warning', () => { + const wrapper = mount(); + const className = + wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).first().prop('className') ?? + ''; + expect(className.includes('euiButton--warning')).toBeTruthy(); + }); + + it('transform the button color correctly - danger', () => { + const wrapper = mount(); + const className = + wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).first().prop('className') ?? + ''; + expect(className.includes('euiButton--danger')).toBeTruthy(); + }); + + it('dismiss the callout correctly', () => { + const wrapper = mount(); + expect(wrapper.find(`[data-test-subj="callout-dismiss-md5-hex"]`).exists()).toBeTruthy(); + wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).simulate('click'); + wrapper.update(); + + expect(defaultProps.handleDismissCallout).toHaveBeenCalledWith('md5-hex', 'primary'); + }); +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/callout.tsx b/x-pack/plugins/observability/public/components/app/cases/callout/callout.tsx new file mode 100644 index 00000000000000..4cb3875f75acbb --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/callout.tsx @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiCallOut, EuiButton, EuiDescriptionList } from '@elastic/eui'; +import { isEmpty } from 'lodash/fp'; +import React, { memo, useCallback } from 'react'; + +import { ErrorMessage } from './types'; +import * as i18n from './translations'; + +export interface CallOutProps { + id: string; + type: NonNullable; + title: string; + messages: ErrorMessage[]; + showCallOut: boolean; + handleDismissCallout: (id: string, type: NonNullable) => void; +} + +function CallOutComponent({ + id, + type, + title, + messages, + showCallOut, + handleDismissCallout, +}: CallOutProps) { + const handleCallOut = useCallback(() => handleDismissCallout(id, type), [ + handleDismissCallout, + id, + type, + ]); + + return showCallOut && !isEmpty(messages) ? ( + + + + {i18n.DISMISS_CALLOUT} + + + ) : null; +} + +export const CallOut = memo(CallOutComponent); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/helpers.test.tsx b/x-pack/plugins/observability/public/components/app/cases/callout/helpers.test.tsx new file mode 100644 index 00000000000000..b5b92a33748742 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/helpers.test.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import md5 from 'md5'; +import { createCalloutId } from './helpers'; + +describe('createCalloutId', () => { + it('creates id correctly with one id', () => { + const digest = md5('one'); + const id = createCalloutId(['one']); + expect(id).toBe(digest); + }); + + it('creates id correctly with multiples ids', () => { + const digest = md5('one|two|three'); + const id = createCalloutId(['one', 'two', 'three']); + expect(id).toBe(digest); + }); + + it('creates id correctly with multiples ids and delimiter', () => { + const digest = md5('one,two,three'); + const id = createCalloutId(['one', 'two', 'three'], ','); + expect(id).toBe(digest); + }); +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/helpers.tsx b/x-pack/plugins/observability/public/components/app/cases/callout/helpers.tsx new file mode 100644 index 00000000000000..29b17cd426c58b --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/helpers.tsx @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import md5 from 'md5'; + +import * as i18n from './translations'; +import { ErrorMessage } from './types'; + +export const permissionsReadOnlyErrorMessage: ErrorMessage = { + id: 'read-only-privileges-error', + title: i18n.READ_ONLY_FEATURE_TITLE, + description: <>{i18n.READ_ONLY_FEATURE_MSG}, + errorType: 'warning', +}; + +export const createCalloutId = (ids: string[], delimiter: string = '|'): string => + md5(ids.join(delimiter)); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/index.test.tsx b/x-pack/plugins/observability/public/components/app/cases/callout/index.test.tsx new file mode 100644 index 00000000000000..e7ed339d99e907 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/index.test.tsx @@ -0,0 +1,216 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { mount } from 'enzyme'; + +import { EuiThemeProvider } from '../../../../../../../../src/plugins/kibana_react/common'; +import { useMessagesStorage } from '../../../../hooks/use_messages_storage'; +import { createCalloutId } from './helpers'; +import { CaseCallOut, CaseCallOutProps } from '.'; + +jest.mock('../../../../hooks/use_messages_storage'); +const useSecurityLocalStorageMock = useMessagesStorage as jest.Mock; +const securityLocalStorageMock = { + getMessages: jest.fn(() => []), + addMessage: jest.fn(), +}; + +describe('CaseCallOut ', () => { + beforeEach(() => { + jest.clearAllMocks(); + useSecurityLocalStorageMock.mockImplementation(() => securityLocalStorageMock); + }); + + it('renders a callout correctly', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { id: 'message-one', title: 'title', description:

{'we have two messages'}

}, + { id: 'message-two', title: 'title', description:

{'for real'}

}, + ], + }; + const wrapper = mount( + + + + ); + + const id = createCalloutId(['message-one', 'message-two']); + expect(wrapper.find(`[data-test-subj="callout-messages-${id}"]`).last().exists()).toBeTruthy(); + }); + + it('groups the messages correctly', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { + id: 'message-one', + title: 'title one', + description:

{'we have two messages'}

, + errorType: 'danger', + }, + { id: 'message-two', title: 'title two', description:

{'for real'}

}, + ], + }; + + const wrapper = mount( + + + + ); + + const idDanger = createCalloutId(['message-one']); + const idPrimary = createCalloutId(['message-two']); + + expect( + wrapper.find(`[data-test-subj="case-callout-${idPrimary}"]`).last().exists() + ).toBeTruthy(); + expect( + wrapper.find(`[data-test-subj="case-callout-${idDanger}"]`).last().exists() + ).toBeTruthy(); + }); + + it('dismisses the callout correctly', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { id: 'message-one', title: 'title', description:

{'we have two messages'}

}, + ], + }; + const wrapper = mount( + + + + ); + + const id = createCalloutId(['message-one']); + + expect(wrapper.find(`[data-test-subj="case-callout-${id}"]`).last().exists()).toBeTruthy(); + wrapper.find(`[data-test-subj="callout-dismiss-${id}"]`).last().simulate('click'); + expect(wrapper.find(`[data-test-subj="case-callout-${id}"]`).exists()).toBeFalsy(); + }); + + it('persist the callout of type primary when dismissed', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { id: 'message-one', title: 'title', description:

{'we have two messages'}

}, + ], + }; + + const wrapper = mount( + + + + ); + + const id = createCalloutId(['message-one']); + expect(securityLocalStorageMock.getMessages).toHaveBeenCalledWith('observability'); + wrapper.find(`[data-test-subj="callout-dismiss-${id}"]`).last().simulate('click'); + expect(securityLocalStorageMock.addMessage).toHaveBeenCalledWith('observability', id); + }); + + it('do not show the callout if is in the localStorage', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { id: 'message-one', title: 'title', description:

{'we have two messages'}

}, + ], + }; + + const id = createCalloutId(['message-one']); + + useSecurityLocalStorageMock.mockImplementation(() => ({ + ...securityLocalStorageMock, + getMessages: jest.fn(() => [id]), + })); + + const wrapper = mount( + + + + ); + + expect(wrapper.find(`[data-test-subj="case-callout-${id}"]`).last().exists()).toBeFalsy(); + }); + + it('do not persist a callout of type danger', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { + id: 'message-one', + title: 'title one', + description:

{'we have two messages'}

, + errorType: 'danger', + }, + ], + }; + + const wrapper = mount( + + + + ); + + const id = createCalloutId(['message-one']); + wrapper.find(`button[data-test-subj="callout-dismiss-${id}"]`).simulate('click'); + wrapper.update(); + expect(securityLocalStorageMock.addMessage).not.toHaveBeenCalled(); + }); + + it('do not persist a callout of type warning', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { + id: 'message-one', + title: 'title one', + description:

{'we have two messages'}

, + errorType: 'warning', + }, + ], + }; + + const wrapper = mount( + + + + ); + + const id = createCalloutId(['message-one']); + wrapper.find(`button[data-test-subj="callout-dismiss-${id}"]`).simulate('click'); + wrapper.update(); + expect(securityLocalStorageMock.addMessage).not.toHaveBeenCalled(); + }); + + it('do not persist a callout of type success', () => { + const props: CaseCallOutProps = { + title: 'hey title', + messages: [ + { + id: 'message-one', + title: 'title one', + description:

{'we have two messages'}

, + errorType: 'success', + }, + ], + }; + + const wrapper = mount( + + + + ); + + const id = createCalloutId(['message-one']); + wrapper.find(`button[data-test-subj="callout-dismiss-${id}"]`).simulate('click'); + wrapper.update(); + expect(securityLocalStorageMock.addMessage).not.toHaveBeenCalled(); + }); +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/index.tsx b/x-pack/plugins/observability/public/components/app/cases/callout/index.tsx new file mode 100644 index 00000000000000..43cb6fd352a53e --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/index.tsx @@ -0,0 +1,104 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiSpacer } from '@elastic/eui'; +import React, { memo, useCallback, useState, useMemo } from 'react'; + +import { CallOut } from './callout'; +import { ErrorMessage } from './types'; +import { createCalloutId } from './helpers'; +import { useMessagesStorage } from '../../../../hooks/use_messages_storage'; +import { OBSERVABILITY } from '../../../../../common/const'; + +export * from './helpers'; + +export interface CaseCallOutProps { + title: string; + messages?: ErrorMessage[]; +} + +type GroupByTypeMessages = { + [key in NonNullable]: { + messagesId: string[]; + messages: ErrorMessage[]; + }; +}; + +interface CalloutVisibility { + [index: string]: boolean; +} + +function CaseCallOutComponent({ title, messages = [] }: CaseCallOutProps) { + const { getMessages, addMessage } = useMessagesStorage(); + + const caseMessages = useMemo(() => getMessages(OBSERVABILITY), [getMessages]); + const dismissedCallouts = useMemo( + () => + caseMessages.reduce( + (acc: CalloutVisibility, id) => ({ + ...acc, + [id]: false, + }), + {} + ), + [caseMessages] + ); + + const [calloutVisibility, setCalloutVisibility] = useState(dismissedCallouts); + const handleCallOut = useCallback( + (id, type) => { + setCalloutVisibility((prevState) => ({ ...prevState, [id]: false })); + if (type === 'primary') { + addMessage(OBSERVABILITY, id); + } + }, + [setCalloutVisibility, addMessage] + ); + + const groupedByTypeErrorMessages = useMemo( + () => + messages.reduce( + (acc: GroupByTypeMessages, currentMessage: ErrorMessage) => { + const type = currentMessage.errorType == null ? 'primary' : currentMessage.errorType; + return { + ...acc, + [type]: { + messagesId: [...(acc[type]?.messagesId ?? []), currentMessage.id], + messages: [...(acc[type]?.messages ?? []), currentMessage], + }, + }; + }, + {} as GroupByTypeMessages + ), + [messages] + ); + + return ( + <> + {(Object.keys(groupedByTypeErrorMessages) as Array).map( + (type: NonNullable) => { + const id = createCalloutId(groupedByTypeErrorMessages[type].messagesId); + return ( + + + + + ); + } + )} + + ); +} + +export const CaseCallOut = memo(CaseCallOutComponent); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/translations.ts b/x-pack/plugins/observability/public/components/app/cases/callout/translations.ts new file mode 100644 index 00000000000000..cb7236b445be12 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/translations.ts @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; + +export const READ_ONLY_FEATURE_TITLE = i18n.translate( + 'xpack.observability.cases.readOnlyFeatureTitle', + { + defaultMessage: 'You cannot open new or update existing cases', + } +); + +export const READ_ONLY_FEATURE_MSG = i18n.translate( + 'xpack.observability.cases.readOnlyFeatureDescription', + { + defaultMessage: + 'You only have privileges to view cases. If you need to open and update cases, contact your Kibana administrator.', + } +); + +export const DISMISS_CALLOUT = i18n.translate( + 'xpack.observability.cases.dismissErrorsPushServiceCallOutTitle', + { + defaultMessage: 'Dismiss', + } +); diff --git a/x-pack/plugins/observability/public/components/app/cases/callout/types.ts b/x-pack/plugins/observability/public/components/app/cases/callout/types.ts new file mode 100644 index 00000000000000..84d79ee391b8ff --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/callout/types.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export interface ErrorMessage { + id: string; + title: string; + description: JSX.Element; + errorType?: 'primary' | 'success' | 'warning' | 'danger'; +} diff --git a/x-pack/plugins/observability/public/components/app/cases/case_view/helpers.ts b/x-pack/plugins/observability/public/components/app/cases/case_view/helpers.ts new file mode 100644 index 00000000000000..b180c15b4487ab --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/case_view/helpers.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { Ecs } from '../../../../../../cases/common'; + +// no alerts in observability so far +// dummy hook for now as hooks cannot be called conditionally +export const useFetchAlertData = (): [boolean, Record] => [false, {}]; diff --git a/x-pack/plugins/observability/public/components/app/cases/case_view/index.tsx b/x-pack/plugins/observability/public/components/app/cases/case_view/index.tsx new file mode 100644 index 00000000000000..3267f7bb17cce6 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/case_view/index.tsx @@ -0,0 +1,122 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useCallback, useState } from 'react'; +import { + getCaseDetailsUrl, + getCaseDetailsUrlWithCommentId, + getCaseUrl, + getConfigureCasesUrl, + useFormatUrl, +} from '../../../../pages/cases/links'; +import { Case } from '../../../../../../cases/common'; +import { useFetchAlertData } from './helpers'; +import { useKibana } from '../../../../utils/kibana_react'; +import { CASES_APP_ID } from '../constants'; +import { casesBreadcrumbs, useBreadcrumbs } from '../../../../hooks/use_breadcrumbs'; + +interface Props { + caseId: string; + subCaseId?: string; + userCanCrud: boolean; +} + +export interface OnUpdateFields { + key: keyof Case; + value: Case[keyof Case]; + onSuccess?: () => void; + onError?: () => void; +} + +export interface CaseProps extends Props { + fetchCase: () => void; + caseData: Case; + updateCase: (newCase: Case) => void; +} + +export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => { + const [caseTitle, setCaseTitle] = useState(null); + + const { cases: casesUi, application } = useKibana().services; + const { navigateToApp } = application; + const allCasesLink = getCaseUrl(); + const { formatUrl } = useFormatUrl(CASES_APP_ID); + const href = formatUrl(allCasesLink); + useBreadcrumbs([ + { ...casesBreadcrumbs.cases, href }, + ...(caseTitle !== null + ? [ + { + text: caseTitle, + }, + ] + : []), + ]); + + const onCaseDataSuccess = useCallback( + (data: Case) => { + if (caseTitle === null) { + setCaseTitle(data.title); + } + }, + [caseTitle] + ); + + const configureCasesLink = getConfigureCasesUrl(); + const allCasesHref = href; + const configureCasesHref = formatUrl(configureCasesLink); + const caseDetailsHref = formatUrl(getCaseDetailsUrl({ id: caseId }), { absolute: true }); + const getCaseDetailHrefWithCommentId = useCallback( + (commentId: string) => + formatUrl(getCaseDetailsUrlWithCommentId({ id: caseId, commentId, subCaseId }), { + absolute: true, + }), + [caseId, formatUrl, subCaseId] + ); + + return casesUi.getCaseView({ + allCasesNavigation: { + href: allCasesHref, + onClick: async (ev) => { + if (ev != null) { + ev.preventDefault(); + } + return navigateToApp(`${CASES_APP_ID}`, { + path: allCasesLink, + }); + }, + }, + caseDetailsNavigation: { + href: caseDetailsHref, + onClick: async (ev) => { + if (ev != null) { + ev.preventDefault(); + } + return navigateToApp(`${CASES_APP_ID}`, { + path: getCaseDetailsUrl({ id: caseId }), + }); + }, + }, + caseId, + configureCasesNavigation: { + href: configureCasesHref, + onClick: async (ev) => { + if (ev != null) { + ev.preventDefault(); + } + return navigateToApp(`${CASES_APP_ID}`, { + path: configureCasesLink, + }); + }, + }, + getCaseDetailHrefWithCommentId, + onCaseDataSuccess, + subCaseId, + useFetchAlertData, + userCanCrud, + }); +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/constants.ts b/x-pack/plugins/observability/public/components/app/cases/constants.ts new file mode 100644 index 00000000000000..3c1f868fec084f --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/constants.ts @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { CASES_APP_ID } from '../../../../common/const'; + +export { CASES_APP_ID }; +export const CASES_OWNER = 'observability'; diff --git a/x-pack/plugins/observability/public/components/app/cases/create/flyout.test.tsx b/x-pack/plugins/observability/public/components/app/cases/create/flyout.test.tsx new file mode 100644 index 00000000000000..c3580671237471 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/create/flyout.test.tsx @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { mount } from 'enzyme'; +import { EuiThemeProvider } from '../../../../../../../../src/plugins/kibana_react/common'; + +import { CreateCaseFlyout } from './flyout'; + +jest.mock('../../../../utils/kibana_react', () => ({ + useKibana: () => ({ + services: { + cases: { + getCreateCase: jest.fn(), + }, + }, + }), +})); +const onCloseFlyout = jest.fn(); +const onSuccess = jest.fn(); +const defaultProps = { + onCloseFlyout, + onSuccess, +}; + +describe('CreateCaseFlyout', () => { + beforeEach(() => { + jest.resetAllMocks(); + }); + + it('renders', () => { + const wrapper = mount( + + + + ); + + expect(wrapper.find(`[data-test-subj='create-case-flyout']`).exists()).toBeTruthy(); + }); + + it('Closing modal calls onCloseCaseModal', () => { + const wrapper = mount( + + + + ); + + wrapper.find('.euiFlyout__closeButton').first().simulate('click'); + expect(onCloseFlyout).toBeCalled(); + }); +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/create/flyout.tsx b/x-pack/plugins/observability/public/components/app/cases/create/flyout.tsx new file mode 100644 index 00000000000000..df29d02e8d830e --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/create/flyout.tsx @@ -0,0 +1,81 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { memo } from 'react'; +import styled from 'styled-components'; +import { EuiFlyout, EuiFlyoutHeader, EuiTitle, EuiFlyoutBody } from '@elastic/eui'; + +import * as i18n from '../translations'; +import { Case } from '../../../../../../cases/common'; +import { CASES_OWNER } from '../constants'; +import { useKibana } from '../../../../utils/kibana_react'; + +export interface CreateCaseModalProps { + afterCaseCreated?: (theCase: Case) => Promise; + onCloseFlyout: () => void; + onSuccess: (theCase: Case) => Promise; +} + +const StyledFlyout = styled(EuiFlyout)` + ${({ theme }) => ` + z-index: ${theme.eui.euiZModal}; + `} +`; +// Adding bottom padding because timeline's +// bottom bar gonna hide the submit button. +// might not need for obs, test this when implementing this component +const StyledEuiFlyoutBody = styled(EuiFlyoutBody)` + ${({ theme }) => ` + && .euiFlyoutBody__overflow { + overflow-y: auto; + overflow-x: hidden; + } + + && .euiFlyoutBody__overflowContent { + display: block; + padding: ${theme.eui.paddingSizes.l} ${theme.eui.paddingSizes.l} 70px; + height: auto; + } + `} +`; + +const FormWrapper = styled.div` + width: 100%; +`; + +function CreateCaseFlyoutComponent({ + afterCaseCreated, + onCloseFlyout, + onSuccess, +}: CreateCaseModalProps) { + const { cases } = useKibana().services; + return ( + + + +

{i18n.CREATE_TITLE}

+
+
+ + + {cases.getCreateCase({ + afterCaseCreated, + onCancel: onCloseFlyout, + onSuccess, + withSteps: false, + owner: [CASES_OWNER], + })} + + +
+ ); +} +// not yet used +// committing for use with alerting #RAC +export const CreateCaseFlyout = memo(CreateCaseFlyoutComponent); + +CreateCaseFlyout.displayName = 'CreateCaseFlyout'; diff --git a/x-pack/plugins/observability/public/components/app/cases/create/index.test.tsx b/x-pack/plugins/observability/public/components/app/cases/create/index.test.tsx new file mode 100644 index 00000000000000..ec7511836328b0 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/create/index.test.tsx @@ -0,0 +1,90 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { mount } from 'enzyme'; +import { waitFor } from '@testing-library/react'; +import { EuiThemeProvider } from '../../../../../../../../src/plugins/kibana_react/common'; +import { Create } from '.'; +import { useKibana } from '../../../../utils/kibana_react'; +import { basicCase } from '../../../../../../cases/public/containers/mock'; +import { CASES_APP_ID, CASES_OWNER } from '../constants'; +import { Case } from '../../../../../../cases/common'; +import { getCaseDetailsUrl } from '../../../../pages/cases/links'; + +jest.mock('../../../../utils/kibana_react'); + +describe('Create case', () => { + const mockCreateCase = jest.fn(); + const mockNavigateToApp = jest.fn(); + beforeEach(() => { + jest.resetAllMocks(); + (useKibana as jest.Mock).mockReturnValue({ + services: { + cases: { + getCreateCase: mockCreateCase, + }, + application: { navigateToApp: mockNavigateToApp }, + }, + }); + }); + + it('it renders', () => { + mount( + + + + ); + + expect(mockCreateCase).toHaveBeenCalled(); + expect(mockCreateCase.mock.calls[0][0].owner).toEqual([CASES_OWNER]); + }); + + it('should redirect to all cases on cancel click', async () => { + (useKibana as jest.Mock).mockReturnValue({ + services: { + cases: { + getCreateCase: ({ onCancel }: { onCancel: () => Promise }) => { + onCancel(); + }, + }, + application: { navigateToApp: mockNavigateToApp }, + }, + }); + mount( + + + + ); + + await waitFor(() => expect(mockNavigateToApp).toHaveBeenCalledWith(`${CASES_APP_ID}`)); + }); + + it('should redirect to new case when posting the case', async () => { + (useKibana as jest.Mock).mockReturnValue({ + services: { + cases: { + getCreateCase: ({ onSuccess }: { onSuccess: (theCase: Case) => Promise }) => { + onSuccess(basicCase); + }, + }, + application: { navigateToApp: mockNavigateToApp }, + }, + }); + mount( + + + + ); + + await waitFor(() => + expect(mockNavigateToApp).toHaveBeenNthCalledWith(1, `${CASES_APP_ID}`, { + path: getCaseDetailsUrl({ id: basicCase.id }), + }) + ); + }); +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/create/index.tsx b/x-pack/plugins/observability/public/components/app/cases/create/index.tsx new file mode 100644 index 00000000000000..d7e2daea2490b4 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/create/index.tsx @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useCallback } from 'react'; +import { EuiPanel } from '@elastic/eui'; + +import { useKibana } from '../../../../utils/kibana_react'; +import { getCaseDetailsUrl } from '../../../../pages/cases/links'; +import { CASES_APP_ID, CASES_OWNER } from '../constants'; + +export const Create = React.memo(() => { + const { + cases, + application: { navigateToApp }, + } = useKibana().services; + const onSuccess = useCallback( + async ({ id }) => + navigateToApp(`${CASES_APP_ID}`, { + path: getCaseDetailsUrl({ id }), + }), + [navigateToApp] + ); + + const handleSetIsCancel = useCallback(() => navigateToApp(`${CASES_APP_ID}`), [navigateToApp]); + + return ( + + {cases.getCreateCase({ + disableAlerts: true, + onCancel: handleSetIsCancel, + onSuccess, + owner: [CASES_OWNER], + })} + + ); +}); + +Create.displayName = 'Create'; diff --git a/x-pack/plugins/observability/public/components/app/cases/translations.ts b/x-pack/plugins/observability/public/components/app/cases/translations.ts new file mode 100644 index 00000000000000..1a5abe218edf52 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/translations.ts @@ -0,0 +1,203 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; + +export const CASES_FEATURE_NO_PERMISSIONS_TITLE = i18n.translate( + 'xpack.observability.cases.caseFeatureNoPermissionsTitle', + { + defaultMessage: 'Kibana feature privileges required', + } +); + +export const CASES_FEATURE_NO_PERMISSIONS_MSG = i18n.translate( + 'xpack.observability.cases.caseFeatureNoPermissionsMessage', + { + defaultMessage: + 'To view cases, you must have privileges for the Cases feature in the Kibana space. For more information, contact your Kibana administrator.', + } +); +export const BACK_TO_ALL = i18n.translate('xpack.observability.cases.caseView.backLabel', { + defaultMessage: 'Back to cases', +}); + +export const CANCEL = i18n.translate('xpack.observability.cases.caseView.cancel', { + defaultMessage: 'Cancel', +}); + +export const DELETE_CASE = i18n.translate( + 'xpack.observability.cases.confirmDeleteCase.deleteCase', + { + defaultMessage: 'Delete case', + } +); + +export const DELETE_CASES = i18n.translate( + 'xpack.observability.cases.confirmDeleteCase.deleteCases', + { + defaultMessage: 'Delete cases', + } +); + +export const NAME = i18n.translate('xpack.observability.cases.caseView.name', { + defaultMessage: 'Name', +}); + +export const REPORTER = i18n.translate('xpack.observability.cases.caseView.reporterLabel', { + defaultMessage: 'Reporter', +}); + +export const PARTICIPANTS = i18n.translate('xpack.observability.cases.caseView.particpantsLabel', { + defaultMessage: 'Participants', +}); + +export const CREATE_TITLE = i18n.translate('xpack.observability.cases.caseView.create', { + defaultMessage: 'Create new case', +}); + +export const DESCRIPTION = i18n.translate('xpack.observability.cases.caseView.description', { + defaultMessage: 'Description', +}); + +export const DESCRIPTION_REQUIRED = i18n.translate( + 'xpack.observability.cases.createCase.descriptionFieldRequiredError', + { + defaultMessage: 'A description is required.', + } +); + +export const COMMENT_REQUIRED = i18n.translate( + 'xpack.observability.cases.caseView.commentFieldRequiredError', + { + defaultMessage: 'A comment is required.', + } +); + +export const REQUIRED_FIELD = i18n.translate( + 'xpack.observability.cases.caseView.fieldRequiredError', + { + defaultMessage: 'Required field', + } +); + +export const EDIT = i18n.translate('xpack.observability.cases.caseView.edit', { + defaultMessage: 'Edit', +}); + +export const OPTIONAL = i18n.translate('xpack.observability.cases.caseView.optional', { + defaultMessage: 'Optional', +}); + +export const PAGE_TITLE = i18n.translate('xpack.observability.cases.pageTitle', { + defaultMessage: 'Cases', +}); + +export const CREATE_CASE = i18n.translate('xpack.observability.cases.caseView.createCase', { + defaultMessage: 'Create case', +}); + +export const CLOSE_CASE = i18n.translate('xpack.observability.cases.caseView.closeCase', { + defaultMessage: 'Close case', +}); + +export const REOPEN_CASE = i18n.translate('xpack.observability.cases.caseView.reopenCase', { + defaultMessage: 'Reopen case', +}); + +export const CASE_NAME = i18n.translate('xpack.observability.cases.caseView.caseName', { + defaultMessage: 'Case name', +}); + +export const TO = i18n.translate('xpack.observability.cases.caseView.to', { + defaultMessage: 'to', +}); + +export const TAGS = i18n.translate('xpack.observability.cases.caseView.tags', { + defaultMessage: 'Tags', +}); + +export const ACTIONS = i18n.translate('xpack.observability.cases.allCases.actions', { + defaultMessage: 'Actions', +}); + +export const NO_TAGS_AVAILABLE = i18n.translate( + 'xpack.observability.cases.allCases.noTagsAvailable', + { + defaultMessage: 'No tags available', + } +); + +export const NO_REPORTERS_AVAILABLE = i18n.translate( + 'xpack.observability.cases.caseView.noReportersAvailable', + { + defaultMessage: 'No reporters available.', + } +); + +export const COMMENTS = i18n.translate('xpack.observability.cases.allCases.comments', { + defaultMessage: 'Comments', +}); + +export const TAGS_HELP = i18n.translate('xpack.observability.cases.createCase.fieldTagsHelpText', { + defaultMessage: + 'Type one or more custom identifying tags for this case. Press enter after each tag to begin a new one.', +}); + +export const NO_TAGS = i18n.translate('xpack.observability.cases.caseView.noTags', { + defaultMessage: 'No tags are currently assigned to this case.', +}); + +export const TITLE_REQUIRED = i18n.translate( + 'xpack.observability.cases.createCase.titleFieldRequiredError', + { + defaultMessage: 'A title is required.', + } +); + +export const CONFIGURE_CASES_PAGE_TITLE = i18n.translate( + 'xpack.observability.cases.configureCases.headerTitle', + { + defaultMessage: 'Configure cases', + } +); + +export const CONFIGURE_CASES_BUTTON = i18n.translate( + 'xpack.observability.cases.configureCasesButton', + { + defaultMessage: 'Edit external connection', + } +); + +export const ADD_COMMENT = i18n.translate('xpack.observability.cases.caseView.comment.addComment', { + defaultMessage: 'Add comment', +}); + +export const ADD_COMMENT_HELP_TEXT = i18n.translate( + 'xpack.observability.cases.caseView.comment.addCommentHelpText', + { + defaultMessage: 'Add a new comment...', + } +); + +export const SAVE = i18n.translate('xpack.observability.cases.caseView.description.save', { + defaultMessage: 'Save', +}); + +export const GO_TO_DOCUMENTATION = i18n.translate( + 'xpack.observability.cases.caseView.goToDocumentationButton', + { + defaultMessage: 'View documentation', + } +); + +export const CONNECTORS = i18n.translate('xpack.observability.cases.caseView.connectors', { + defaultMessage: 'External Incident Management System', +}); + +export const EDIT_CONNECTOR = i18n.translate('xpack.observability.cases.caseView.editConnector', { + defaultMessage: 'Change external incident management system', +}); diff --git a/x-pack/plugins/observability/public/components/app/cases/wrappers/index.tsx b/x-pack/plugins/observability/public/components/app/cases/wrappers/index.tsx new file mode 100644 index 00000000000000..477fb77d98ee80 --- /dev/null +++ b/x-pack/plugins/observability/public/components/app/cases/wrappers/index.tsx @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import styled from 'styled-components'; + +export const WhitePageWrapper = styled.div` + background-color: ${({ theme }) => theme.eui.euiColorEmptyShade}; + border-top: ${({ theme }) => theme.eui.euiBorderThin}; + flex: 1 1 auto; +`; + +export const SectionWrapper = styled.div` + box-sizing: content-box; + margin: 0 auto; + max-width: 1175px; + width: 100%; +`; diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/field_formats.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/field_formats.ts index f1fc5f310b8ef3..25f258e17307dc 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/field_formats.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/field_formats.ts @@ -12,6 +12,7 @@ import { LCP_FIELD, TBT_FIELD, TRANSACTION_DURATION, + TRANSACTION_TIME_TO_FIRST_BYTE, } from '../constants/elasticsearch_fieldnames'; export const rumFieldFormats: FieldFormat[] = [ @@ -24,6 +25,7 @@ export const rumFieldFormats: FieldFormat[] = [ outputFormat: 'asSeconds', showSuffix: true, outputPrecision: 1, + useShortSuffix: true, }, }, }, @@ -33,8 +35,9 @@ export const rumFieldFormats: FieldFormat[] = [ id: 'duration', params: { inputFormat: 'milliseconds', - outputFormat: 'asSeconds', + outputFormat: 'humanizePrecise', showSuffix: true, + useShortSuffix: true, }, }, }, @@ -44,8 +47,9 @@ export const rumFieldFormats: FieldFormat[] = [ id: 'duration', params: { inputFormat: 'milliseconds', - outputFormat: 'asSeconds', + outputFormat: 'humanizePrecise', showSuffix: true, + useShortSuffix: true, }, }, }, @@ -55,8 +59,9 @@ export const rumFieldFormats: FieldFormat[] = [ id: 'duration', params: { inputFormat: 'milliseconds', - outputFormat: 'asSeconds', + outputFormat: 'humanizePrecise', showSuffix: true, + useShortSuffix: true, }, }, }, @@ -66,8 +71,21 @@ export const rumFieldFormats: FieldFormat[] = [ id: 'duration', params: { inputFormat: 'milliseconds', - outputFormat: 'asSeconds', + outputFormat: 'humanizePrecise', + showSuffix: true, + useShortSuffix: true, + }, + }, + }, + { + field: TRANSACTION_TIME_TO_FIRST_BYTE, + format: { + id: 'duration', + params: { + inputFormat: 'milliseconds', + outputFormat: 'humanizePrecise', showSuffix: true, + useShortSuffix: true, }, }, }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/kpi_trends_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/kpi_trends_config.ts index 5e2d3440526b54..f6c683caaa0391 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/kpi_trends_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/kpi_trends_config.ts @@ -44,7 +44,7 @@ export function getKPITrendsLensConfig({ seriesId, indexPattern }: ConfigProps): id: seriesId, defaultSeriesType: 'bar_stacked', reportType: 'kpi-trends', - seriesTypes: ['bar', 'bar_stacked'], + seriesTypes: [], xAxisColumn: { sourceField: '@timestamp', }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/performance_dist_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/performance_dist_config.ts index 0dc582c5683dda..4a1521c834806c 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/performance_dist_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/rum/performance_dist_config.ts @@ -44,7 +44,7 @@ export function getPerformanceDistLensConfig({ seriesId, indexPattern }: ConfigP id: seriesId ?? 'unique-key', reportType: 'page-load-dist', defaultSeriesType: 'line', - seriesTypes: ['line', 'bar'], + seriesTypes: [], xAxisColumn: { sourceField: 'performance.metric', }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/field_formats.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/field_formats.ts index 8dad1839f0bcd9..5c91e3924cbb7c 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/field_formats.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/field_formats.ts @@ -14,9 +14,10 @@ export const syntheticsFieldFormats: FieldFormat[] = [ id: 'duration', params: { inputFormat: 'microseconds', - outputFormat: 'asMilliseconds', - outputPrecision: 0, + outputFormat: 'humanizePrecise', + outputPrecision: 1, showSuffix: true, + useShortSuffix: true, }, }, }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_duration_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_duration_config.ts index 698b8f9e951e16..5e8a43ccf2ef46 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_duration_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_duration_config.ts @@ -15,7 +15,7 @@ export function getMonitorDurationConfig({ seriesId, indexPattern }: ConfigProps id: seriesId, reportType: 'uptime-duration', defaultSeriesType: 'line', - seriesTypes: ['line', 'bar_stacked'], + seriesTypes: [], xAxisColumn: { sourceField: '@timestamp', }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_pings_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_pings_config.ts index fc33c37c7bcad1..697a940f666f76 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_pings_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/monitor_pings_config.ts @@ -15,7 +15,7 @@ export function getMonitorPingsConfig({ seriesId, indexPattern }: ConfigProps): id: seriesId, reportType: 'uptime-pings', defaultSeriesType: 'bar_stacked', - seriesTypes: ['bar_stacked', 'bar'], + seriesTypes: [], xAxisColumn: { sourceField: '@timestamp', }, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts index c3dd824e441a8b..87772532f410d6 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/types.ts @@ -108,13 +108,14 @@ export type AppDataType = 'synthetics' | 'ux' | 'infra_logs' | 'infra_metrics' | type FormatType = 'duration' | 'number'; type InputFormat = 'microseconds' | 'milliseconds' | 'seconds'; -type OutputFormat = 'asSeconds' | 'asMilliseconds' | 'humanize'; +type OutputFormat = 'asSeconds' | 'asMilliseconds' | 'humanize' | 'humanizePrecise'; export interface FieldFormatParams { inputFormat: InputFormat; outputFormat: OutputFormat; outputPrecision?: number; showSuffix?: boolean; + useShortSuffix?: boolean; } export interface FieldFormat { diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.test.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.test.ts index ade74e7c6744ea..a8c5c1a0a3b79e 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.test.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.test.ts @@ -17,23 +17,53 @@ const fieldFormats = { outputFormat: 'asSeconds', outputPrecision: 1, showSuffix: true, + useShortSuffix: true, }, }, 'transaction.experience.fid': { id: 'duration', - params: { inputFormat: 'milliseconds', outputFormat: 'asSeconds', showSuffix: true }, + params: { + inputFormat: 'milliseconds', + outputFormat: 'humanizePrecise', + showSuffix: true, + useShortSuffix: true, + }, }, 'transaction.experience.tbt': { id: 'duration', - params: { inputFormat: 'milliseconds', outputFormat: 'asSeconds', showSuffix: true }, + params: { + inputFormat: 'milliseconds', + outputFormat: 'humanizePrecise', + showSuffix: true, + useShortSuffix: true, + }, }, 'transaction.marks.agent.firstContentfulPaint': { id: 'duration', - params: { inputFormat: 'milliseconds', outputFormat: 'asSeconds', showSuffix: true }, + params: { + inputFormat: 'milliseconds', + outputFormat: 'humanizePrecise', + showSuffix: true, + useShortSuffix: true, + }, }, 'transaction.marks.agent.largestContentfulPaint': { id: 'duration', - params: { inputFormat: 'milliseconds', outputFormat: 'asSeconds', showSuffix: true }, + params: { + inputFormat: 'milliseconds', + outputFormat: 'humanizePrecise', + showSuffix: true, + useShortSuffix: true, + }, + }, + 'transaction.marks.agent.timeToFirstByte': { + id: 'duration', + params: { + inputFormat: 'milliseconds', + outputFormat: 'humanizePrecise', + showSuffix: true, + useShortSuffix: true, + }, }, }; diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.ts index c265bad56e8645..858eb52555da60 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/utils/observability_index_patterns.ts @@ -60,6 +60,7 @@ export function isParamsSame(param1: IFieldFormat['_params'], param2: FieldForma const isSame = param1?.inputFormat === param2?.inputFormat && param1?.outputFormat === param2?.outputFormat && + param1?.useShortSuffix === param2?.useShortSuffix && param1?.showSuffix === param2?.showSuffix; if (param2.outputPrecision !== undefined) { diff --git a/x-pack/plugins/observability/public/hooks/use_breadcrumbs.ts b/x-pack/plugins/observability/public/hooks/use_breadcrumbs.ts index d31b6b52744c0c..090031e314fd1a 100644 --- a/x-pack/plugins/observability/public/hooks/use_breadcrumbs.ts +++ b/x-pack/plugins/observability/public/hooks/use_breadcrumbs.ts @@ -9,8 +9,8 @@ import { ChromeBreadcrumb } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { MouseEvent, useEffect } from 'react'; import { EuiBreadcrumb } from '@elastic/eui'; -import { useKibana } from '../../../../../src/plugins/kibana_react/public'; import { useQueryParams } from './use_query_params'; +import { useKibana } from '../utils/kibana_react'; function handleBreadcrumbClick( breadcrumbs: ChromeBreadcrumb[], @@ -39,17 +39,35 @@ export const makeBaseBreadcrumb = (href: string): EuiBreadcrumb => { href, }; }; - +export const casesBreadcrumbs = { + cases: { + text: i18n.translate('xpack.observability.breadcrumbs.observability.cases', { + defaultMessage: 'Cases', + }), + }, + create: { + text: i18n.translate('xpack.observability.breadcrumbs.observability.cases.create', { + defaultMessage: 'Create', + }), + }, + configure: { + text: i18n.translate('xpack.observability.breadcrumbs.observability.cases.configure', { + defaultMessage: 'Configure', + }), + }, +}; export const useBreadcrumbs = (extraCrumbs: ChromeBreadcrumb[]) => { const params = useQueryParams(); const { - services: { chrome, application }, + services: { + chrome: { setBreadcrumbs }, + application: { getUrlForApp, navigateToUrl }, + }, } = useKibana(); - const setBreadcrumbs = chrome?.setBreadcrumbs; - const appPath = application?.getUrlForApp('observability-overview') ?? ''; - const navigate = application?.navigateToUrl; + const appPath = getUrlForApp('observability-overview') ?? ''; + const navigate = navigateToUrl; useEffect(() => { if (setBreadcrumbs) { diff --git a/x-pack/plugins/observability/public/hooks/use_get_user_cases_permissions.tsx b/x-pack/plugins/observability/public/hooks/use_get_user_cases_permissions.tsx new file mode 100644 index 00000000000000..9f4ed59a45f2b6 --- /dev/null +++ b/x-pack/plugins/observability/public/hooks/use_get_user_cases_permissions.tsx @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useEffect, useState } from 'react'; +import { useKibana } from '../utils/kibana_react'; +import { CASES_APP_ID } from '../../common/const'; + +export interface UseGetUserCasesPermissions { + crud: boolean; + read: boolean; +} + +export function useGetUserCasesPermissions() { + const [casesPermissions, setCasesPermissions] = useState(null); + const uiCapabilities = useKibana().services.application.capabilities; + + useEffect(() => { + const capabilitiesCanUserCRUD: boolean = + typeof uiCapabilities[CASES_APP_ID].crud_cases === 'boolean' + ? (uiCapabilities[CASES_APP_ID].crud_cases as boolean) + : false; + const capabilitiesCanUserRead: boolean = + typeof uiCapabilities[CASES_APP_ID].read_cases === 'boolean' + ? (uiCapabilities[CASES_APP_ID].read_cases as boolean) + : false; + setCasesPermissions({ + crud: capabilitiesCanUserCRUD, + read: capabilitiesCanUserRead, + }); + }, [uiCapabilities]); + + return casesPermissions; +} diff --git a/x-pack/plugins/observability/public/hooks/use_messages_storage.tsx b/x-pack/plugins/observability/public/hooks/use_messages_storage.tsx new file mode 100644 index 00000000000000..d67910f00dc769 --- /dev/null +++ b/x-pack/plugins/observability/public/hooks/use_messages_storage.tsx @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useCallback } from 'react'; +import { useKibana } from '../utils/kibana_react'; + +export interface UseMessagesStorage { + getMessages: (plugin: string) => string[]; + addMessage: (plugin: string, id: string) => void; + removeMessage: (plugin: string, id: string) => void; + clearAllMessages: (plugin: string) => void; + hasMessage: (plugin: string, id: string) => boolean; +} + +export const useMessagesStorage = (): UseMessagesStorage => { + const { storage } = useKibana().services; + + const getMessages = useCallback( + (plugin: string): string[] => storage.get(`${plugin}-messages`) ?? [], + [storage] + ); + + const addMessage = useCallback( + (plugin: string, id: string) => { + const pluginStorage = storage.get(`${plugin}-messages`) ?? []; + storage.set(`${plugin}-messages`, [...pluginStorage, id]); + }, + [storage] + ); + + const hasMessage = useCallback( + (plugin: string, id: string): boolean => { + const pluginStorage = storage.get(`${plugin}-messages`) ?? []; + return pluginStorage.includes((val: string) => val === id); + }, + [storage] + ); + + const removeMessage = useCallback( + (plugin: string, id: string) => { + const pluginStorage = storage.get(`${plugin}-messages`) ?? []; + storage.set( + `${plugin}-messages`, + pluginStorage.filter((val: string) => val !== id) + ); + }, + [storage] + ); + + const clearAllMessages = useCallback( + (plugin: string): string[] => storage.remove(`${plugin}-messages`), + [storage] + ); + + return { + getMessages, + addMessage, + clearAllMessages, + removeMessage, + hasMessage, + }; +}; diff --git a/x-pack/plugins/observability/public/pages/cases/all_cases.tsx b/x-pack/plugins/observability/public/pages/cases/all_cases.tsx new file mode 100644 index 00000000000000..4131cdc40738f2 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/all_cases.tsx @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import { AllCases } from '../../components/app/cases/all_cases'; +import * as i18n from '../../components/app/cases/translations'; + +import { permissionsReadOnlyErrorMessage, CaseCallOut } from '../../components/app/cases/callout'; +import { CaseFeatureNoPermissions } from './feature_no_permissions'; +import { useGetUserCasesPermissions } from '../../hooks/use_get_user_cases_permissions'; +import { usePluginContext } from '../../hooks/use_plugin_context'; + +export const AllCasesPage = React.memo(() => { + const userPermissions = useGetUserCasesPermissions(); + const { ObservabilityPageTemplate } = usePluginContext(); + return userPermissions == null || userPermissions?.read ? ( + <> + {userPermissions != null && !userPermissions?.crud && userPermissions?.read && ( + + )} + {i18n.PAGE_TITLE}, + }} + > + + + + ) : ( + + ); +}); + +AllCasesPage.displayName = 'AllCasesPage'; diff --git a/x-pack/plugins/observability/public/pages/cases/case_details.tsx b/x-pack/plugins/observability/public/pages/cases/case_details.tsx new file mode 100644 index 00000000000000..78f1cb313ea9b4 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/case_details.tsx @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { useParams } from 'react-router-dom'; + +import { CaseView } from '../../components/app/cases/case_view'; +import { useGetUserCasesPermissions } from '../../hooks/use_get_user_cases_permissions'; +import { useKibana } from '../../utils/kibana_react'; +import { CASES_APP_ID } from '../../components/app/cases/constants'; +import { CaseCallOut, permissionsReadOnlyErrorMessage } from '../../components/app/cases/callout'; + +export const CaseDetailsPage = React.memo(() => { + const { + application: { navigateToApp }, + } = useKibana().services; + const userPermissions = useGetUserCasesPermissions(); + const { detailName: caseId, subCaseId } = useParams<{ + detailName?: string; + subCaseId?: string; + }>(); + + if (userPermissions != null && !userPermissions.read) { + navigateToApp(`${CASES_APP_ID}`); + return null; + } + + return caseId != null ? ( + <> + {userPermissions != null && !userPermissions?.crud && userPermissions?.read && ( + + )} + + + ) : null; +}); + +CaseDetailsPage.displayName = 'CaseDetailsPage'; diff --git a/x-pack/plugins/observability/public/pages/cases/cases.stories.tsx b/x-pack/plugins/observability/public/pages/cases/cases.stories.tsx index 49df932766b335..13d8795193238d 100644 --- a/x-pack/plugins/observability/public/pages/cases/cases.stories.tsx +++ b/x-pack/plugins/observability/public/pages/cases/cases.stories.tsx @@ -6,12 +6,11 @@ */ import React, { ComponentType } from 'react'; -import { CasesPage } from '.'; -import { RouteParams } from '../../routes'; +import { AllCasesPage } from './all_cases'; export default { title: 'app/Cases', - component: CasesPage, + component: AllCasesPage, decorators: [ (Story: ComponentType) => { return ; @@ -20,5 +19,5 @@ export default { }; export function EmptyState() { - return } />; + return ; } diff --git a/x-pack/plugins/observability/public/pages/cases/configure_cases.tsx b/x-pack/plugins/observability/public/pages/cases/configure_cases.tsx new file mode 100644 index 00000000000000..acc6bdf68fba75 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/configure_cases.tsx @@ -0,0 +1,71 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useCallback } from 'react'; +import styled from 'styled-components'; + +import { EuiButtonEmpty } from '@elastic/eui'; +import * as i18n from '../../components/app/cases/translations'; +import { CASES_APP_ID, CASES_OWNER } from '../../components/app/cases/constants'; +import { useKibana } from '../../utils/kibana_react'; +import { useGetUserCasesPermissions } from '../../hooks/use_get_user_cases_permissions'; +import { usePluginContext } from '../../hooks/use_plugin_context'; +import { casesBreadcrumbs, useBreadcrumbs } from '../../hooks/use_breadcrumbs'; +import { getCaseUrl, useFormatUrl } from './links'; + +const ButtonEmpty = styled(EuiButtonEmpty)` + display: block; +`; +function ConfigureCasesPageComponent() { + const { + cases, + application: { navigateToApp }, + } = useKibana().services; + const userPermissions = useGetUserCasesPermissions(); + const { ObservabilityPageTemplate } = usePluginContext(); + const onClickGoToCases = useCallback( + async (ev) => { + ev.preventDefault(); + return navigateToApp(`${CASES_APP_ID}`); + }, + [navigateToApp] + ); + const { formatUrl } = useFormatUrl(CASES_APP_ID); + const href = formatUrl(getCaseUrl()); + useBreadcrumbs([{ ...casesBreadcrumbs.cases, href }, casesBreadcrumbs.configure]); + if (userPermissions != null && !userPermissions.read) { + navigateToApp(`${CASES_APP_ID}`); + return null; + } + + return ( + + + {i18n.BACK_TO_ALL} + + {i18n.CONFIGURE_CASES_PAGE_TITLE} + + ), + }} + > + {cases.getConfigureCases({ + userCanCrud: userPermissions?.crud ?? false, + owner: [CASES_OWNER], + })} + + ); +} + +export const ConfigureCasesPage = React.memo(ConfigureCasesPageComponent); diff --git a/x-pack/plugins/observability/public/pages/cases/create_case.tsx b/x-pack/plugins/observability/public/pages/cases/create_case.tsx new file mode 100644 index 00000000000000..d0e25e6263075b --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/create_case.tsx @@ -0,0 +1,65 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useCallback } from 'react'; +import { EuiButtonEmpty } from '@elastic/eui'; +import styled from 'styled-components'; +import * as i18n from '../../components/app/cases/translations'; +import { Create } from '../../components/app/cases/create'; +import { CASES_APP_ID } from '../../components/app/cases/constants'; +import { useKibana } from '../../utils/kibana_react'; +import { useGetUserCasesPermissions } from '../../hooks/use_get_user_cases_permissions'; +import { usePluginContext } from '../../hooks/use_plugin_context'; +import { getCaseUrl, useFormatUrl } from './links'; +import { casesBreadcrumbs, useBreadcrumbs } from '../../hooks/use_breadcrumbs'; + +const ButtonEmpty = styled(EuiButtonEmpty)` + display: block; +`; +ButtonEmpty.displayName = 'ButtonEmpty'; +export const CreateCasePage = React.memo(() => { + const userPermissions = useGetUserCasesPermissions(); + const { ObservabilityPageTemplate } = usePluginContext(); + const { + application: { navigateToApp }, + } = useKibana().services; + + const goTo = useCallback( + async (ev) => { + ev.preventDefault(); + return navigateToApp(CASES_APP_ID); + }, + [navigateToApp] + ); + + const { formatUrl } = useFormatUrl(CASES_APP_ID); + const href = formatUrl(getCaseUrl()); + useBreadcrumbs([{ ...casesBreadcrumbs.cases, href }, casesBreadcrumbs.create]); + if (userPermissions != null && !userPermissions.crud) { + navigateToApp(`${CASES_APP_ID}`); + return null; + } + + return ( + + + {i18n.BACK_TO_ALL} + + {i18n.CREATE_TITLE} + + ), + }} + > + + + ); +}); + +CreateCasePage.displayName = 'CreateCasePage'; diff --git a/x-pack/plugins/observability/public/pages/cases/empty_page.tsx b/x-pack/plugins/observability/public/pages/cases/empty_page.tsx new file mode 100644 index 00000000000000..c6fc4b59ef77c3 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/empty_page.tsx @@ -0,0 +1,118 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { + EuiButton, + EuiEmptyPrompt, + EuiFlexGroup, + EuiFlexItem, + IconType, + EuiCard, +} from '@elastic/eui'; +import React, { MouseEventHandler, ReactNode, useMemo } from 'react'; +import styled from 'styled-components'; + +const EmptyPrompt = styled(EuiEmptyPrompt)` + align-self: center; /* Corrects horizontal centering in IE11 */ + max-width: 60em; +`; + +EmptyPrompt.displayName = 'EmptyPrompt'; + +interface EmptyPageActions { + icon?: IconType; + label: string; + target?: string; + url: string; + descriptionTitle?: string; + description?: string; + fill?: boolean; + onClick?: MouseEventHandler; +} + +export type EmptyPageActionsProps = Record; + +interface EmptyPageProps { + actions: EmptyPageActionsProps; + 'data-test-subj'?: string; + message?: ReactNode; + title: string; +} + +const EmptyPageComponent = React.memo(({ actions, message, title, ...rest }) => { + const titles = Object.keys(actions); + const maxItemWidth = 283; + const renderActions = useMemo( + () => + Object.values(actions) + .filter((a) => a.label && a.url) + .map( + ( + { icon, label, target, url, descriptionTitle, description, onClick, fill = true }, + idx + ) => + descriptionTitle != null || description != null ? ( + + + {label} + + } + /> + + ) : ( + + {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} + + {label} + + + ) + ), + [actions, titles] + ); + + return ( + {title}

} + body={message &&

{message}

} + actions={{renderActions}} + {...rest} + /> + ); +}); + +EmptyPageComponent.displayName = 'EmptyPageComponent'; + +export const EmptyPage = React.memo(EmptyPageComponent); +EmptyPage.displayName = 'EmptyPage'; diff --git a/x-pack/plugins/observability/public/pages/cases/feature_no_permissions.tsx b/x-pack/plugins/observability/public/pages/cases/feature_no_permissions.tsx new file mode 100644 index 00000000000000..5075570c15b3eb --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/feature_no_permissions.tsx @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useMemo } from 'react'; + +import { EmptyPage } from './empty_page'; +import * as i18n from '../../components/app/cases/translations'; +import { useKibana } from '../../utils/kibana_react'; + +export const CaseFeatureNoPermissions = React.memo(() => { + const docLinks = useKibana().services.docLinks; + const actions = useMemo( + () => ({ + savedObject: { + icon: 'documents', + label: i18n.GO_TO_DOCUMENTATION, + url: `${docLinks.ELASTIC_WEBSITE_URL}guide/en/security/${docLinks.DOC_LINK_VERSION}s`, + target: '_blank', + }, + }), + [docLinks] + ); + + return ( + + ); +}); + +CaseFeatureNoPermissions.displayName = 'CaseSavedObjectNoPermissions'; diff --git a/x-pack/plugins/observability/public/pages/cases/index.tsx b/x-pack/plugins/observability/public/pages/cases/index.tsx deleted file mode 100644 index 7f6bce7d486f3a..00000000000000 --- a/x-pack/plugins/observability/public/pages/cases/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { EuiCallOut, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import React from 'react'; -import { ExperimentalBadge } from '../../components/shared/experimental_badge'; -import { RouteParams } from '../../routes'; -import { usePluginContext } from '../../hooks/use_plugin_context'; - -interface CasesProps { - routeParams: RouteParams<'/cases'>; -} - -export function CasesPage(props: CasesProps) { - const { ObservabilityPageTemplate } = usePluginContext(); - return ( - - {i18n.translate('xpack.observability.casesTitle', { defaultMessage: 'Cases' })}{' '} - - - ), - }} - > - - - -

- {i18n.translate('xpack.observability.casesDisclaimerText', { - defaultMessage: 'This is the future home of cases.', - })} -

-
-
-
-
- ); -} diff --git a/x-pack/plugins/observability/public/pages/cases/links.ts b/x-pack/plugins/observability/public/pages/cases/links.ts new file mode 100644 index 00000000000000..768d74ec4e7ee3 --- /dev/null +++ b/x-pack/plugins/observability/public/pages/cases/links.ts @@ -0,0 +1,59 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useCallback } from 'react'; +import { isEmpty } from 'lodash/fp'; +import { useKibana } from '../../utils/kibana_react'; + +export const getCaseDetailsUrl = ({ id, subCaseId }: { id: string; subCaseId?: string }) => { + if (subCaseId) { + return `/${encodeURIComponent(id)}/sub-cases/${encodeURIComponent(subCaseId)}`; + } + return `/${encodeURIComponent(id)}`; +}; +interface FormatUrlOptions { + absolute: boolean; +} + +export type FormatUrl = (path: string, options?: Partial) => string; +export const useFormatUrl = (appId: string) => { + const { getUrlForApp } = useKibana().services.application; + const formatUrl = useCallback( + (path: string, { absolute = false } = {}) => { + const pathArr = path.split('?'); + const formattedPath = `${pathArr[0]}${isEmpty(pathArr[1]) ? '' : `?${pathArr[1]}`}`; + return getUrlForApp(`${appId}`, { + path: formattedPath, + absolute, + }); + }, + [appId, getUrlForApp] + ); + return { formatUrl }; +}; + +export const getCaseDetailsUrlWithCommentId = ({ + id, + commentId, + subCaseId, +}: { + id: string; + commentId: string; + subCaseId?: string; +}) => { + if (subCaseId) { + return `/${encodeURIComponent(id)}/sub-cases/${encodeURIComponent( + subCaseId + )}/${encodeURIComponent(commentId)}`; + } + return `/${encodeURIComponent(id)}/${encodeURIComponent(commentId)}`; +}; + +export const getCreateCaseUrl = () => `/create`; + +export const getConfigureCasesUrl = () => `/configure`; +export const getCaseUrl = () => `/`; diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index c1b18e37faee8a..03c3fb3c27e58e 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -36,6 +36,8 @@ import { toggleOverviewLinkInNav } from './toggle_overview_link_in_nav'; import { ConfigSchema } from '.'; import { createObservabilityRuleTypeRegistry } from './rules/create_observability_rule_type_registry'; import { createLazyObservabilityPageTemplate } from './components/shared'; +import { CASES_APP_ID } from './components/app/cases/constants'; +import { CasesUiStart } from '../../cases/public'; export type ObservabilityPublicSetup = ReturnType; @@ -46,6 +48,7 @@ export interface ObservabilityPublicPluginsSetup { } export interface ObservabilityPublicPluginsStart { + cases: CasesUiStart; home?: HomePublicPluginStart; triggersActionsUi: TriggersAndActionsUIPublicPluginStart; data: DataPublicPluginStart; @@ -63,6 +66,7 @@ export class Plugin ObservabilityPublicPluginsStart > { private readonly appUpdater$ = new BehaviorSubject(() => ({})); + private readonly casesAppUpdater$ = new BehaviorSubject(() => ({})); private readonly navigationRegistry = createNavigationRegistry(); constructor(private readonly initializerContext: PluginInitializerContext) { @@ -111,7 +115,6 @@ export class Plugin mount, updater$, }); - if (config.unsafe.alertingExperience.enabled) { coreSetup.application.register({ id: 'observability-alerts', @@ -127,14 +130,14 @@ export class Plugin if (config.unsafe.cases.enabled) { coreSetup.application.register({ - id: 'observability-cases', + id: CASES_APP_ID, title: 'Cases', appRoute: '/app/observability/cases', order: 8050, category, euiIconType, mount, - updater$, + updater$: this.casesAppUpdater$, }); } @@ -188,7 +191,7 @@ export class Plugin }; } public start({ application }: CoreStart) { - toggleOverviewLinkInNav(this.appUpdater$, application); + toggleOverviewLinkInNav(this.appUpdater$, this.casesAppUpdater$, application); const PageTemplate = createLazyObservabilityPageTemplate({ currentAppId$: application.currentAppId$, diff --git a/x-pack/plugins/observability/public/routes/index.tsx b/x-pack/plugins/observability/public/routes/index.tsx index 6e180347106d6e..a2a67a42bd166a 100644 --- a/x-pack/plugins/observability/public/routes/index.tsx +++ b/x-pack/plugins/observability/public/routes/index.tsx @@ -13,8 +13,12 @@ import { LandingPage } from '../pages/landing'; import { OverviewPage } from '../pages/overview'; import { jsonRt } from './json_rt'; import { AlertsPage } from '../pages/alerts'; -import { CasesPage } from '../pages/cases'; +import { CreateCasePage } from '../pages/cases/create_case'; import { ExploratoryViewPage } from '../components/shared/exploratory_view'; +import { CaseDetailsPage } from '../pages/cases/case_details'; +import { ConfigureCasesPage } from '../pages/cases/configure_cases'; +import { AllCasesPage } from '../pages/cases/all_cases'; +import { casesBreadcrumbs } from '../hooks/use_breadcrumbs'; import { alertStatusRt } from '../../common/typings'; export type RouteParams = DecodeParams; @@ -78,24 +82,36 @@ export const routes = { ], }, '/cases': { - handler: (routeParams: any) => { - return ; + handler: () => { + return ; + }, + params: {}, + breadcrumb: [casesBreadcrumbs.cases], + }, + '/cases/create': { + handler: () => { + return ; + }, + params: {}, + breadcrumb: [casesBreadcrumbs.cases, casesBreadcrumbs.create], + }, + '/cases/configure': { + handler: () => { + return ; + }, + params: {}, + breadcrumb: [casesBreadcrumbs.cases, casesBreadcrumbs.configure], + }, + '/cases/:detailName': { + handler: () => { + return ; }, params: { - query: t.partial({ - rangeFrom: t.string, - rangeTo: t.string, - refreshPaused: jsonRt.pipe(t.boolean), - refreshInterval: jsonRt.pipe(t.number), + path: t.partial({ + detailName: t.string, }), }, - breadcrumb: [ - { - text: i18n.translate('xpack.observability.cases.breadcrumb', { - defaultMessage: 'Cases', - }), - }, - ], + breadcrumb: [casesBreadcrumbs.cases], }, '/alerts': { handler: (routeParams: any) => { diff --git a/x-pack/plugins/observability/public/toggle_overview_link_in_nav.test.tsx b/x-pack/plugins/observability/public/toggle_overview_link_in_nav.test.tsx index bbcc12b4831830..caee692ced2c57 100644 --- a/x-pack/plugins/observability/public/toggle_overview_link_in_nav.test.tsx +++ b/x-pack/plugins/observability/public/toggle_overview_link_in_nav.test.tsx @@ -14,6 +14,7 @@ import { toggleOverviewLinkInNav } from './toggle_overview_link_in_nav'; describe('toggleOverviewLinkInNav', () => { let applicationStart: ReturnType; let subjectMock: jest.Mocked>; + let casesMock: jest.Mocked>; beforeEach(() => { applicationStart = applicationServiceMock.createStartContract(); @@ -34,7 +35,7 @@ describe('toggleOverviewLinkInNav', () => { }, }; - toggleOverviewLinkInNav(subjectMock, applicationStart); + toggleOverviewLinkInNav(subjectMock, casesMock, applicationStart); expect(subjectMock.next).toHaveBeenCalledTimes(1); const updater = subjectMock.next.mock.calls[0][0]!; @@ -54,7 +55,7 @@ describe('toggleOverviewLinkInNav', () => { }, }; - toggleOverviewLinkInNav(subjectMock, applicationStart); + toggleOverviewLinkInNav(subjectMock, casesMock, applicationStart); expect(subjectMock.next).not.toHaveBeenCalled(); }); diff --git a/x-pack/plugins/observability/public/toggle_overview_link_in_nav.tsx b/x-pack/plugins/observability/public/toggle_overview_link_in_nav.tsx index 5110db15def88f..fd30bf3b73f151 100644 --- a/x-pack/plugins/observability/public/toggle_overview_link_in_nav.tsx +++ b/x-pack/plugins/observability/public/toggle_overview_link_in_nav.tsx @@ -7,13 +7,22 @@ import { Subject } from 'rxjs'; import { AppNavLinkStatus, AppUpdater, ApplicationStart } from '../../../../src/core/public'; +import { CASES_APP_ID } from '../common/const'; export function toggleOverviewLinkInNav( updater$: Subject, + casesUpdater$: Subject, { capabilities }: ApplicationStart ) { - const { apm, logs, metrics, uptime } = capabilities.navLinks; + const { apm, logs, metrics, uptime, [CASES_APP_ID]: cases } = capabilities.navLinks; const someVisible = Object.values({ apm, logs, metrics, uptime }).some((visible) => visible); + + // if cases is enabled then we want to show it in the sidebar but not the navigation unless one of the other features + // is enabled + if (cases) { + casesUpdater$.next(() => ({ navLinkStatus: AppNavLinkStatus.visible })); + } + if (!someVisible) { updater$.next(() => ({ navLinkStatus: AppNavLinkStatus.hidden, diff --git a/x-pack/plugins/observability/public/utils/kibana_react.ts b/x-pack/plugins/observability/public/utils/kibana_react.ts new file mode 100644 index 00000000000000..532003e30a1601 --- /dev/null +++ b/x-pack/plugins/observability/public/utils/kibana_react.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { CoreStart } from 'kibana/public'; +import { useKibana } from '../../../../../src/plugins/kibana_react/public'; +import { Storage } from '../../../../../src/plugins/kibana_utils/public'; +import { ObservabilityPublicPluginsStart } from '../plugin'; + +export type StartServices = CoreStart & + ObservabilityPublicPluginsStart & { + storage: Storage; + }; +const useTypedKibana = () => useKibana(); + +export { useTypedKibana as useKibana }; diff --git a/x-pack/plugins/observability/server/plugin.ts b/x-pack/plugins/observability/server/plugin.ts index 9eff1b08cead98..cfcaeb25d29e40 100644 --- a/x-pack/plugins/observability/server/plugin.ts +++ b/x-pack/plugins/observability/server/plugin.ts @@ -5,7 +5,13 @@ * 2.0. */ -import { PluginInitializerContext, Plugin, CoreSetup } from 'src/core/server'; +import { i18n } from '@kbn/i18n'; +import { + PluginInitializerContext, + Plugin, + CoreSetup, + DEFAULT_APP_CATEGORIES, +} from '../../../../src/core/server'; import { RuleDataClient } from '../../rule_registry/server'; import { ObservabilityConfig } from '.'; import { @@ -14,23 +20,65 @@ import { AnnotationsAPI, } from './lib/annotations/bootstrap_annotations'; import type { RuleRegistryPluginSetupContract } from '../../rule_registry/server'; +import { PluginSetupContract as FeaturesSetup } from '../../features/server'; import { uiSettings } from './ui_settings'; import { registerRoutes } from './routes/register_routes'; import { getGlobalObservabilityServerRouteRepository } from './routes/get_global_observability_server_route_repository'; +import { CASES_APP_ID, OBSERVABILITY } from '../common/const'; export type ObservabilityPluginSetup = ReturnType; +interface PluginSetup { + features: FeaturesSetup; + ruleRegistry: RuleRegistryPluginSetupContract; +} + export class ObservabilityPlugin implements Plugin { constructor(private readonly initContext: PluginInitializerContext) { this.initContext = initContext; } - public setup( - core: CoreSetup, - plugins: { - ruleRegistry: RuleRegistryPluginSetupContract; - } - ) { + public setup(core: CoreSetup, plugins: PluginSetup) { + plugins.features.registerKibanaFeature({ + id: CASES_APP_ID, + name: i18n.translate('xpack.observability.featureRegistry.linkObservabilityTitle', { + defaultMessage: 'Cases', + }), + order: 1100, + category: DEFAULT_APP_CATEGORIES.observability, + app: [CASES_APP_ID, 'kibana'], + catalogue: [OBSERVABILITY], + cases: [OBSERVABILITY], + privileges: { + all: { + app: [CASES_APP_ID, 'kibana'], + catalogue: [OBSERVABILITY], + cases: { + all: [OBSERVABILITY], + }, + api: [], + savedObject: { + all: [], + read: [], + }, + ui: ['crud_cases', 'read_cases'], // uiCapabilities[CASES_APP_ID].crud_cases or read_cases + }, + read: { + app: [CASES_APP_ID, 'kibana'], + catalogue: [OBSERVABILITY], + cases: { + read: [OBSERVABILITY], + }, + api: [], + savedObject: { + all: [], + read: [], + }, + ui: ['read_cases'], // uiCapabilities[uiCapabilities[CASES_APP_ID]].read_cases + }, + }, + }); + const config = this.initContext.config.get(); let annotationsApiPromise: Promise | undefined; diff --git a/x-pack/plugins/observability/tsconfig.json b/x-pack/plugins/observability/tsconfig.json index 814d55bfd61fb2..b6ed0a0a3d17f6 100644 --- a/x-pack/plugins/observability/tsconfig.json +++ b/x-pack/plugins/observability/tsconfig.json @@ -24,6 +24,7 @@ { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, { "path": "../alerting/tsconfig.json" }, { "path": "../licensing/tsconfig.json" }, + { "path": "../cases/tsconfig.json" }, { "path": "../lens/tsconfig.json" }, { "path": "../rule_registry/tsconfig.json" }, { "path": "../translations/tsconfig.json" } diff --git a/x-pack/plugins/reporting/common/constants.ts b/x-pack/plugins/reporting/common/constants.ts index 2a95557473fc09..f20c6c2d52fdd8 100644 --- a/x-pack/plugins/reporting/common/constants.ts +++ b/x-pack/plugins/reporting/common/constants.ts @@ -53,6 +53,7 @@ export const UI_SETTINGS_CSV_QUOTE_VALUES = 'csv:quoteValues'; export const UI_SETTINGS_DATEFORMAT_TZ = 'dateFormat:tz'; export const LAYOUT_TYPES = { + CANVAS: 'canvas', PRESERVE_LAYOUT: 'preserve_layout', PRINT: 'print', }; diff --git a/x-pack/plugins/reporting/public/components/__snapshots__/screen_capture_panel_content.test.tsx.snap b/x-pack/plugins/reporting/public/components/__snapshots__/screen_capture_panel_content.test.tsx.snap new file mode 100644 index 00000000000000..a6753211fba3b3 --- /dev/null +++ b/x-pack/plugins/reporting/public/components/__snapshots__/screen_capture_panel_content.test.tsx.snap @@ -0,0 +1,1191 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ScreenCapturePanelContent properly renders a view with "canvas" layout option 1`] = ` + +
+ +
+

+ + + Analytical Apps can take a minute or two to generate based upon the size of your test-object-type. + + +

+
+
+ +
+ + + } + labelType="label" + > +
+
+ + } + onBlur={[Function]} + onChange={[Function]} + onFocus={[Function]} + > +
+ + + + + Full page layout + + + +
+
+ +
+ + + Remove borders and footer logo + + +
+
+
+
+
+ + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+

+ + + Alternatively, copy this POST URL to call generation from outside Kibana or from Watcher. + + +

+
+
+ +
+ + + + + + + + + + + + +
+
+ +
+
+ +
+ +`; + +exports[`ScreenCapturePanelContent properly renders a view with "print" layout option 1`] = ` + +
+ +
+

+ + + Analytical Apps can take a minute or two to generate based upon the size of your test-object-type. + + +

+
+
+ +
+ + + } + labelType="label" + > +
+
+ + } + onBlur={[Function]} + onChange={[Function]} + onFocus={[Function]} + > +
+ + + + + Optimize for printing + + + +
+
+ +
+ + + Uses multiple pages, showing at most 2 visualizations per page + + +
+
+
+
+
+ + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+

+ + + Alternatively, copy this POST URL to call generation from outside Kibana or from Watcher. + + +

+
+
+ +
+ + + + + + + + + + + + +
+
+ +
+
+ +
+ +`; + +exports[`ScreenCapturePanelContent renders the default view properly 1`] = ` + +
+ +
+

+ + + Analytical Apps can take a minute or two to generate based upon the size of your test-object-type. + + +

+
+
+ +
+ + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+

+ + + Alternatively, copy this POST URL to call generation from outside Kibana or from Watcher. + + +

+
+
+ +
+ + + + + + + + + + + + +
+
+ +
+
+ +
+ +`; diff --git a/x-pack/plugins/reporting/public/components/index.ts b/x-pack/plugins/reporting/public/components/index.ts index 4adcc347dc7043..b8cccda2a6613b 100644 --- a/x-pack/plugins/reporting/public/components/index.ts +++ b/x-pack/plugins/reporting/public/components/index.ts @@ -11,3 +11,4 @@ export { getWarningFormulasToast } from './job_warning_formulas'; export { getWarningMaxSizeToast } from './job_warning_max_size'; export { getGeneralErrorToast } from './general_error'; export { ScreenCapturePanelContent } from './screen_capture_panel_content'; +export { getSharedComponents } from './shared'; diff --git a/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx b/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx index a38c37c8086893..4d7828b7894072 100644 --- a/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx +++ b/x-pack/plugins/reporting/public/components/reporting_panel_content.tsx @@ -5,7 +5,17 @@ * 2.0. */ -import { EuiButton, EuiCopy, EuiForm, EuiFormRow, EuiSpacer, EuiText } from '@elastic/eui'; +import { + EuiAccordion, + EuiButton, + EuiCopy, + EuiForm, + EuiFormRow, + EuiHorizontalRule, + EuiSpacer, + EuiText, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React, { Component, ReactElement } from 'react'; import { ToastsSetup } from 'src/core/public'; @@ -20,14 +30,12 @@ export interface Props { toasts: ToastsSetup; reportType: string; - /** - * Whether the report to be generated requires saved state that is not captured in the URL submitted to the report generator. - */ + /** Whether the report to be generated requires saved state that is not captured in the URL submitted to the report generator. **/ requiresSavedState: boolean; layoutId: string | undefined; objectId?: string; getJobParams: () => BaseParams; - options?: ReactElement; + options?: ReactElement | null; isDirty?: boolean; onClose?: () => void; intl: InjectedIntl; @@ -110,50 +118,61 @@ class ReportingPanelContentUi extends Component { ); } - const reportMsg = ( - - ); - return ( -

{reportMsg}

+

+ +

{this.props.options} {this.renderGenerateReportButton(false)} - - -

- -

-
- + - - {(copy) => ( - + + + +

- - )} - +

+
+ + + + {(copy) => ( + + + + )} + +
); } @@ -247,44 +266,12 @@ class ReportingPanelContentUi extends Component { } }) .catch((error: any) => { - if (error.message === 'not exportable') { - return this.props.toasts.addWarning({ - title: intl.formatMessage( - { - id: 'xpack.reporting.panelContent.whatCanBeExportedWarningTitle', - defaultMessage: 'Only saved {objectType} can be exported', - }, - { objectType: this.state.objectType } - ), - text: toMountPoint( - - ), - }); - } - - const defaultMessage = - error?.res?.status === 403 ? ( - - ) : ( - - ); - - this.props.toasts.addDanger({ + this.props.toasts.addError(error, { title: intl.formatMessage({ id: 'xpack.reporting.panelContent.notification.reportingErrorTitle', - defaultMessage: 'Reporting error', + defaultMessage: 'Failed to create report', }), - text: toMountPoint(error.message || defaultMessage), - 'data-test-subj': 'queueReportError', + toastMessage: error.body.message, }); }); }; diff --git a/x-pack/plugins/reporting/public/components/screen_capture_panel_content.test.tsx b/x-pack/plugins/reporting/public/components/screen_capture_panel_content.test.tsx new file mode 100644 index 00000000000000..84a6dcc3c0ba3f --- /dev/null +++ b/x-pack/plugins/reporting/public/components/screen_capture_panel_content.test.tsx @@ -0,0 +1,74 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { mount } from 'enzyme'; +import React from 'react'; +import { IntlProvider } from 'react-intl'; +import { coreMock } from '../../../../../src/core/public/mocks'; +import { BaseParams } from '../../common/types'; +import { ReportingAPIClient } from '../lib/reporting_api_client'; +import { ScreenCapturePanelContent } from './screen_capture_panel_content'; + +const getJobParamsDefault: () => BaseParams = () => ({ + objectType: 'test-object-type', + title: 'Test Report Title', + browserTimezone: 'America/New_York', +}); + +test('ScreenCapturePanelContent renders the default view properly', () => { + const coreSetup = coreMock.createSetup(); + const component = mount( + + + + ); + expect(component.find('EuiForm')).toMatchSnapshot(); + expect(component.text()).not.toMatch('Full page layout'); + expect(component.text()).not.toMatch('Optimize for printing'); +}); + +test('ScreenCapturePanelContent properly renders a view with "canvas" layout option', () => { + const coreSetup = coreMock.createSetup(); + const component = mount( + + + + ); + expect(component.find('EuiForm')).toMatchSnapshot(); + expect(component.text()).toMatch('Full page layout'); +}); + +test('ScreenCapturePanelContent properly renders a view with "print" layout option', () => { + const coreSetup = coreMock.createSetup(); + const component = mount( + + + + ); + expect(component.find('EuiForm')).toMatchSnapshot(); + expect(component.text()).toMatch('Optimize for printing'); +}); diff --git a/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx b/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx index 21497ed2891562..fd6003f8656e87 100644 --- a/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx +++ b/x-pack/plugins/reporting/public/components/screen_capture_panel_content.tsx @@ -5,11 +5,13 @@ * 2.0. */ -import { EuiSpacer, EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; +import { EuiFormRow, EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import React, { Component, Fragment } from 'react'; +import moment from 'moment'; +import React, { Component } from 'react'; import { ToastsSetup } from 'src/core/public'; -import { BaseParams } from '../../common/types'; +import { getDefaultLayoutSelectors } from '../../common'; +import { BaseParams, LayoutParams } from '../../common/types'; import { ReportingAPIClient } from '../lib/reporting_api_client'; import { ReportingPanelContent } from './reporting_panel_content'; @@ -17,33 +19,33 @@ export interface Props { apiClient: ReportingAPIClient; toasts: ToastsSetup; reportType: string; + layoutOption?: 'canvas' | 'print'; objectId?: string; getJobParams: () => BaseParams; + requiresSavedState: boolean; isDirty?: boolean; onClose?: () => void; } interface State { - isPreserveLayoutSupported: boolean; usePrintLayout: boolean; + useCanvasLayout: boolean; } export class ScreenCapturePanelContent extends Component { constructor(props: Props) { super(props); - const { objectType } = props.getJobParams(); - const isPreserveLayoutSupported = props.reportType !== 'png' && objectType !== 'visualization'; this.state = { - isPreserveLayoutSupported, usePrintLayout: false, + useCanvasLayout: false, }; } public render() { return ( { } private renderOptions = () => { - if (this.state.isPreserveLayoutSupported) { + if (this.props.layoutOption === 'print') { return ( - + + } + > { onChange={this.handlePrintLayoutChange} data-test-subj="usePrintLayout" /> - - + ); } - return ( - - - - ); + if (this.props.layoutOption === 'canvas') { + return ( + + } + > + + } + checked={this.state.useCanvasLayout} + onChange={this.handleCanvasLayoutChange} + data-test-subj="reportModeToggle" + /> + + ); + } + + return null; }; private handlePrintLayoutChange = (evt: EuiSwitchEvent) => { - this.setState({ usePrintLayout: evt.target.checked }); + this.setState({ usePrintLayout: evt.target.checked, useCanvasLayout: false }); }; - private getLayout = () => { + private handleCanvasLayoutChange = (evt: EuiSwitchEvent) => { + this.setState({ useCanvasLayout: evt.target.checked, usePrintLayout: false }); + }; + + private getLayout = (): Required => { + const { layout: outerLayout } = this.props.getJobParams(); + + let dimensions = outerLayout?.dimensions; + if (!dimensions) { + const el = document.querySelector('[data-shared-items-container]'); + const { height, width } = el ? el.getBoundingClientRect() : { height: 768, width: 1024 }; + dimensions = { height, width }; + } + + let selectors = outerLayout?.selectors; + if (!selectors) { + selectors = getDefaultLayoutSelectors(); + } + if (this.state.usePrintLayout) { - return { id: 'print' }; + return { id: 'print', dimensions, selectors }; } - const el = document.querySelector('[data-shared-items-container]'); - const bounds = el ? el.getBoundingClientRect() : { height: 768, width: 1024 }; + if (this.state.useCanvasLayout) { + return { id: 'canvas', dimensions, selectors }; + } - return { - id: this.props.reportType === 'png' ? 'png' : 'preserve_layout', - dimensions: { - height: bounds.height, - width: bounds.width, - }, - }; + return { id: 'preserve_layout', dimensions, selectors }; }; - private getJobParams = () => { + private getJobParams = (): Required => { + const outerParams = this.props.getJobParams(); + let browserTimezone = outerParams.browserTimezone; + if (!browserTimezone) { + browserTimezone = moment.tz.guess(); + } + return { ...this.props.getJobParams(), layout: this.getLayout(), + browserTimezone, }; }; } diff --git a/x-pack/plugins/reporting/public/components/shared/get_shared_components.tsx b/x-pack/plugins/reporting/public/components/shared/get_shared_components.tsx new file mode 100644 index 00000000000000..12d70c87019754 --- /dev/null +++ b/x-pack/plugins/reporting/public/components/shared/get_shared_components.tsx @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { CoreSetup } from 'kibana/public'; +import React from 'react'; +import { ReportingAPIClient } from '../..'; +import { PDF_REPORT_TYPE } from '../../../common/constants'; +import type { Props as PanelPropsScreenCapture } from '../screen_capture_panel_content'; +import { ScreenCapturePanelContent } from '../screen_capture_panel_content_lazy'; + +interface IncludeOnCloseFn { + onClose: () => void; +} + +type PropsPDF = Pick & IncludeOnCloseFn; + +/* + * As of 7.14, the only shared component is a PDF report that is suited for Canvas integration. + * This is not planned to expand, as work is to be done on moving the export-type implementations out of Reporting + * Related Discuss issue: https://github.com/elastic/kibana/issues/101422 + */ +export function getSharedComponents(core: CoreSetup) { + return { + ReportingPanelPDF(props: PropsPDF) { + return ( + + ); + }, + }; +} diff --git a/x-pack/plugins/reporting/public/components/shared/index.tsx b/x-pack/plugins/reporting/public/components/shared/index.tsx new file mode 100644 index 00000000000000..592538f1b84ccf --- /dev/null +++ b/x-pack/plugins/reporting/public/components/shared/index.tsx @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { getSharedComponents } from './get_shared_components'; diff --git a/x-pack/plugins/reporting/public/index.ts b/x-pack/plugins/reporting/public/index.ts index 7c82fda7554d4c..7179a81664b6f7 100644 --- a/x-pack/plugins/reporting/public/index.ts +++ b/x-pack/plugins/reporting/public/index.ts @@ -7,24 +7,20 @@ import { PluginInitializerContext } from 'src/core/public'; import { getDefaultLayoutSelectors } from '../common'; -import { ScreenCapturePanelContent } from './components/screen_capture_panel_content'; -import * as jobCompletionNotifications from './lib/job_completion_notifications'; +import { getSharedComponents } from './components'; import { ReportingAPIClient } from './lib/reporting_api_client'; import { ReportingPublicPlugin } from './plugin'; export interface ReportingSetup { - components: { - ScreenCapturePanel: typeof ScreenCapturePanelContent; - }; getDefaultLayoutSelectors: typeof getDefaultLayoutSelectors; - ReportingAPIClient: typeof ReportingAPIClient; usesUiCapabilities: () => boolean; + components: ReturnType; } export type ReportingStart = ReportingSetup; export { constants, getDefaultLayoutSelectors } from '../common'; -export { ReportingAPIClient, ReportingPublicPlugin as Plugin, jobCompletionNotifications }; +export { ReportingAPIClient, ReportingPublicPlugin as Plugin }; export function plugin(initializerContext: PluginInitializerContext) { return new ReportingPublicPlugin(initializerContext); diff --git a/x-pack/plugins/reporting/public/mocks.ts b/x-pack/plugins/reporting/public/mocks.ts new file mode 100644 index 00000000000000..414d1b0ae70fe3 --- /dev/null +++ b/x-pack/plugins/reporting/public/mocks.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { coreMock } from 'src/core/public/mocks'; +import { ReportingSetup } from '.'; +import { getDefaultLayoutSelectors } from '../common'; +import { getSharedComponents } from './components/shared'; + +type Setup = jest.Mocked; + +const createSetupContract = (): Setup => { + const coreSetup = coreMock.createSetup(); + return { + getDefaultLayoutSelectors: jest.fn().mockImplementation(getDefaultLayoutSelectors), + usesUiCapabilities: jest.fn().mockImplementation(() => true), + components: getSharedComponents(coreSetup), + }; +}; + +export const reportingPluginMock = { + createSetupContract, + createStartContract: createSetupContract, +}; diff --git a/x-pack/plugins/reporting/public/plugin.ts b/x-pack/plugins/reporting/public/plugin.ts index ff0d425faf54a5..577732fdb13927 100644 --- a/x-pack/plugins/reporting/public/plugin.ts +++ b/x-pack/plugins/reporting/public/plugin.ts @@ -29,10 +29,7 @@ import { constants, getDefaultLayoutSelectors } from '../common'; import { durationToNumber } from '../common/schema_utils'; import { JobId, JobSummarySet } from '../common/types'; import { ReportingSetup, ReportingStart } from './'; -import { - getGeneralErrorToast, - ScreenCapturePanelContent as ScreenCapturePanel, -} from './components'; +import { getGeneralErrorToast, getSharedComponents } from './components'; import { ReportingAPIClient } from './lib/reporting_api_client'; import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler'; import { ReportingCsvPanelAction } from './panel_actions/get_csv_panel_action'; @@ -86,7 +83,6 @@ export class ReportingPublicPlugin ReportingPublicPluginSetupDendencies, ReportingPublicPluginStartDendencies > { - private readonly contract: ReportingStart; private readonly stop$ = new Rx.ReplaySubject(1); private readonly title = i18n.translate('xpack.reporting.management.reportingTitle', { defaultMessage: 'Reporting', @@ -95,21 +91,30 @@ export class ReportingPublicPlugin defaultMessage: 'Reporting', }); private config: ClientConfigType; + private contract?: ReportingSetup; constructor(initializerContext: PluginInitializerContext) { this.config = initializerContext.config.get(); + } + + private getContract(core?: CoreSetup) { + if (core) { + this.contract = { + getDefaultLayoutSelectors, + usesUiCapabilities: () => this.config.roles?.enabled === false, + components: getSharedComponents(core), + }; + } - this.contract = { - ReportingAPIClient, - components: { ScreenCapturePanel }, - getDefaultLayoutSelectors, - usesUiCapabilities: () => this.config.roles?.enabled === false, - }; + if (!this.contract) { + throw new Error(`Setup error in Reporting plugin!`); + } + + return this.contract; } public setup(core: CoreSetup, setupDeps: ReportingPublicPluginSetupDendencies) { - const { http, notifications, getStartServices, uiSettings } = core; - const { toasts } = notifications; + const { http, getStartServices, uiSettings } = core; const { home, management, @@ -163,6 +168,9 @@ export class ReportingPublicPlugin new ReportingCsvPanelAction({ core, startServices$, license$, usesUiCapabilities }) ); + const reportingStart = this.getContract(core); + const { toasts } = core.notifications; + share.register( ReportingCsvShareProvider({ apiClient, @@ -173,6 +181,7 @@ export class ReportingPublicPlugin usesUiCapabilities, }) ); + share.register( reportingScreenshotShareProvider({ apiClient, @@ -184,7 +193,7 @@ export class ReportingPublicPlugin }) ); - return this.contract; + return reportingStart; } public start(core: CoreStart) { @@ -203,7 +212,7 @@ export class ReportingPublicPlugin ) .subscribe(); - return this.contract; + return this.getContract(); } public stop() { diff --git a/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx b/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx index fc732b0ec7dfbe..7fe5268fc99102 100644 --- a/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx +++ b/x-pack/plugins/reporting/public/share_context_menu/register_csv_reporting.tsx @@ -65,13 +65,7 @@ export const ReportingCsvShareProvider = ({ ? moment.tz.guess() : uiSettings.get('dateFormat:tz'); - const getShareMenuItems = ({ - objectType, - objectId, - sharingData, - onClose, - isDirty, - }: ShareContext) => { + const getShareMenuItems = ({ objectType, objectId, sharingData, onClose }: ShareContext) => { if ('search' !== objectType) { return []; } @@ -114,7 +108,6 @@ export const ReportingCsvShareProvider = ({ layoutId={undefined} objectId={objectId} getJobParams={getJobParams} - isDirty={isDirty} onClose={onClose} /> ), diff --git a/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx b/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx index f4a952ef58298e..42f6ee5fcb898b 100644 --- a/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx +++ b/x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx @@ -11,7 +11,7 @@ import React from 'react'; import * as Rx from 'rxjs'; import type { IUiSettingsClient, ToastsSetup } from 'src/core/public'; import { CoreStart } from 'src/core/public'; -import type { ShareContext } from '../../../../../src/plugins/share/public'; +import { ShareContext } from 'src/plugins/share/public'; import type { LicensingPluginSetup } from '../../../licensing/public'; import type { LayoutParams } from '../../common/types'; import type { JobParamsPNG } from '../../server/export_types/png/types'; @@ -167,6 +167,7 @@ export const reportingScreenshotShareProvider = ({ toasts={toasts} reportType="png" objectId={objectId} + requiresSavedState={true} getJobParams={getPngJobParams({ shareableUrl, apiClient, @@ -203,6 +204,8 @@ export const reportingScreenshotShareProvider = ({ toasts={toasts} reportType="printablePdf" objectId={objectId} + requiresSavedState={true} + layoutOption={objectType === 'dashboard' ? 'print' : undefined} getJobParams={getPdfJobParams({ shareableUrl, apiClient, diff --git a/x-pack/plugins/security/common/index.ts b/x-pack/plugins/security/common/index.ts index 034c25758a1f0c..ac5d252c98a8b2 100644 --- a/x-pack/plugins/security/common/index.ts +++ b/x-pack/plugins/security/common/index.ts @@ -5,5 +5,5 @@ * 2.0. */ -export { SecurityLicense } from './licensing'; -export { AuthenticatedUser } from './model'; +export type { SecurityLicense } from './licensing'; +export type { AuthenticatedUser } from './model'; diff --git a/x-pack/plugins/security/public/account_management/change_password/change_password.tsx b/x-pack/plugins/security/public/account_management/change_password/change_password.tsx index 90d63d8b43bc79..ac0e284c8b9ad4 100644 --- a/x-pack/plugins/security/public/account_management/change_password/change_password.tsx +++ b/x-pack/plugins/security/public/account_management/change_password/change_password.tsx @@ -17,13 +17,16 @@ import { canUserChangePassword } from '../../../common/model'; import type { UserAPIClient } from '../../management/users'; import { ChangePasswordForm } from '../../management/users/components/change_password_form'; -interface Props { +export interface ChangePasswordProps { user: AuthenticatedUser; +} + +export interface ChangePasswordPropsInternal extends ChangePasswordProps { userAPIClient: PublicMethodsOf; notifications: NotificationsSetup; } -export class ChangePassword extends Component { +export class ChangePassword extends Component { public render() { const canChangePassword = canUserChangePassword(this.props.user); diff --git a/x-pack/plugins/security/public/account_management/change_password/change_password_async.tsx b/x-pack/plugins/security/public/account_management/change_password/change_password_async.tsx new file mode 100644 index 00000000000000..a4ad769146e59c --- /dev/null +++ b/x-pack/plugins/security/public/account_management/change_password/change_password_async.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; + +import type { CoreStart } from 'src/core/public'; + +import { UserAPIClient } from '../../management/users'; +import type { ChangePasswordProps } from './change_password'; + +export const getChangePasswordComponent = async ( + core: CoreStart +): Promise> => { + const { ChangePassword } = await import('./change_password'); + + return (props: ChangePasswordProps) => { + return ( + + ); + }; +}; diff --git a/x-pack/plugins/security/public/account_management/change_password/index.ts b/x-pack/plugins/security/public/account_management/change_password/index.ts index c73b497512cdf0..028d0f6cc74974 100644 --- a/x-pack/plugins/security/public/account_management/change_password/index.ts +++ b/x-pack/plugins/security/public/account_management/change_password/index.ts @@ -6,3 +6,5 @@ */ export { ChangePassword } from './change_password'; + +export type { ChangePasswordProps } from './change_password'; diff --git a/x-pack/plugins/security/public/account_management/index.ts b/x-pack/plugins/security/public/account_management/index.ts index bfba213c632d00..2d1045723a6e1b 100644 --- a/x-pack/plugins/security/public/account_management/index.ts +++ b/x-pack/plugins/security/public/account_management/index.ts @@ -6,3 +6,6 @@ */ export { accountManagementApp } from './account_management_app'; + +export type { ChangePasswordProps } from './change_password'; +export type { PersonalInfoProps } from './personal_info'; diff --git a/x-pack/plugins/security/public/account_management/personal_info/index.ts b/x-pack/plugins/security/public/account_management/personal_info/index.ts index a7d2873e853917..6dc6489afa8c5b 100644 --- a/x-pack/plugins/security/public/account_management/personal_info/index.ts +++ b/x-pack/plugins/security/public/account_management/personal_info/index.ts @@ -6,3 +6,5 @@ */ export { PersonalInfo } from './personal_info'; + +export type { PersonalInfoProps } from './personal_info'; diff --git a/x-pack/plugins/security/public/account_management/personal_info/personal_info.tsx b/x-pack/plugins/security/public/account_management/personal_info/personal_info.tsx index e9de2b8a69bfaa..20b21fc0c30ce6 100644 --- a/x-pack/plugins/security/public/account_management/personal_info/personal_info.tsx +++ b/x-pack/plugins/security/public/account_management/personal_info/personal_info.tsx @@ -12,11 +12,11 @@ import { FormattedMessage } from '@kbn/i18n/react'; import type { AuthenticatedUser } from '../../../common/model'; -interface Props { +export interface PersonalInfoProps { user: AuthenticatedUser; } -export const PersonalInfo = (props: Props) => { +export const PersonalInfo = (props: PersonalInfoProps) => { return ( > => { + const { PersonalInfo } = await import('./personal_info'); + return (props: PersonalInfoProps) => { + return ; + }; +}; diff --git a/x-pack/plugins/security/public/management/management_service.test.ts b/x-pack/plugins/security/public/management/management_service.test.ts index b21897377d5eb2..e969c8fcd0dbc8 100644 --- a/x-pack/plugins/security/public/management/management_service.test.ts +++ b/x-pack/plugins/security/public/management/management_service.test.ts @@ -40,6 +40,7 @@ describe('ManagementService', () => { security: mockSection, } as DefinedSections, }, + locator: {} as any, }; const service = new ManagementService(); @@ -101,6 +102,7 @@ describe('ManagementService', () => { security: mockSection, } as DefinedSections, }, + locator: {} as any, }; service.setup({ diff --git a/x-pack/plugins/security/public/mocks.ts b/x-pack/plugins/security/public/mocks.ts index 829c3ced9dddb3..b936f8d01cfd51 100644 --- a/x-pack/plugins/security/public/mocks.ts +++ b/x-pack/plugins/security/public/mocks.ts @@ -11,6 +11,7 @@ import { mockAuthenticatedUser } from '../common/model/authenticated_user.mock'; import { authenticationMock } from './authentication/index.mock'; import { navControlServiceMock } from './nav_control/index.mock'; import { createSessionTimeoutMock } from './session/session_timeout.mock'; +import { getUiApiMock } from './ui_api/index.mock'; function createSetupMock() { return { @@ -23,6 +24,7 @@ function createStartMock() { return { authc: authenticationMock.createStart(), navControlService: navControlServiceMock.createStart(), + uiApi: getUiApiMock.createStart(), }; } diff --git a/x-pack/plugins/security/public/plugin.test.tsx b/x-pack/plugins/security/public/plugin.test.tsx index 9c31919bd5d295..c4c551e4bb5b5a 100644 --- a/x-pack/plugins/security/public/plugin.test.tsx +++ b/x-pack/plugins/security/public/plugin.test.tsx @@ -100,6 +100,12 @@ describe('Security Plugin', () => { features: {} as FeaturesPluginStart, }) ).toEqual({ + uiApi: { + components: { + getChangePassword: expect.any(Function), + getPersonalInfo: expect.any(Function), + }, + }, authc: { getCurrentUser: expect.any(Function), areAPIKeysEnabled: expect.any(Function), diff --git a/x-pack/plugins/security/public/plugin.tsx b/x-pack/plugins/security/public/plugin.tsx index 69533ea534802b..fbb282ee246f93 100644 --- a/x-pack/plugins/security/public/plugin.tsx +++ b/x-pack/plugins/security/public/plugin.tsx @@ -30,6 +30,8 @@ import type { SecurityNavControlServiceStart } from './nav_control'; import { SecurityNavControlService } from './nav_control'; import { SecurityCheckupService } from './security_checkup'; import { SessionExpired, SessionTimeout, UnauthorizedResponseHttpInterceptor } from './session'; +import type { UiApi } from './ui_api'; +import { getUiApi } from './ui_api'; export interface PluginSetupDependencies { licensing: LicensingPluginSetup; @@ -150,6 +152,7 @@ export class SecurityPlugin } return { + uiApi: getUiApi({ core }), navControlService: this.navControlService.start({ core }), authc: this.authc as AuthenticationServiceStart, }; @@ -184,4 +187,8 @@ export interface SecurityPluginStart { * Exposes authentication information about the currently logged in user. */ authc: AuthenticationServiceStart; + /** + * Exposes UI components that will be loaded asynchronously. + */ + uiApi: UiApi; } diff --git a/x-pack/plugins/security/public/suspense_error_boundary/index.ts b/x-pack/plugins/security/public/suspense_error_boundary/index.ts new file mode 100644 index 00000000000000..061923c8445c2d --- /dev/null +++ b/x-pack/plugins/security/public/suspense_error_boundary/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { SuspenseErrorBoundary } from './suspense_error_boundary'; diff --git a/x-pack/plugins/security/public/suspense_error_boundary/suspense_error_boundary.tsx b/x-pack/plugins/security/public/suspense_error_boundary/suspense_error_boundary.tsx new file mode 100644 index 00000000000000..313401ff45bd94 --- /dev/null +++ b/x-pack/plugins/security/public/suspense_error_boundary/suspense_error_boundary.tsx @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiLoadingSpinner } from '@elastic/eui'; +import type { PropsWithChildren } from 'react'; +import React, { Component, Suspense } from 'react'; + +import { i18n } from '@kbn/i18n'; +import type { NotificationsStart } from 'src/core/public'; + +interface Props { + notifications: NotificationsStart; +} + +interface State { + error: Error | null; +} + +export class SuspenseErrorBoundary extends Component, State> { + state: State = { + error: null, + }; + + static getDerivedStateFromError(error: Error) { + // Update state so next render shows fallback UI. + return { error }; + } + + public componentDidCatch(error: Error) { + const { notifications } = this.props; + if (notifications) { + const title = i18n.translate('xpack.security.uiApi.errorBoundaryToastTitle', { + defaultMessage: 'Failed to load Kibana asset', + }); + const toastMessage = i18n.translate('xpack.security.uiApi.errorBoundaryToastMessage', { + defaultMessage: 'Reload page to continue.', + }); + notifications.toasts.addError(error, { title, toastMessage }); + } + } + + render() { + const { children, notifications } = this.props; + const { error } = this.state; + if (!notifications || error) { + return null; + } + return }>{children}; + } +} diff --git a/x-pack/plugins/security/public/ui_api/components.tsx b/x-pack/plugins/security/public/ui_api/components.tsx new file mode 100644 index 00000000000000..a488bc359b5383 --- /dev/null +++ b/x-pack/plugins/security/public/ui_api/components.tsx @@ -0,0 +1,43 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { FC, PropsWithChildren, PropsWithRef } from 'react'; +import React from 'react'; + +import type { CoreStart } from 'src/core/public'; + +/** + * We're importing specific files here instead of passing them + * through the index file. It helps to keep the bundle size low. + * + * Importing async components through the index file increases the bundle size. + * It happens because the bundle starts to also include all the sync dependencies + * available through the index file. + */ +import { getChangePasswordComponent } from '../account_management/change_password/change_password_async'; +import { getPersonalInfoComponent } from '../account_management/personal_info/personal_info_async'; +import { LazyWrapper } from './lazy_wrapper'; + +export interface GetComponentsOptions { + core: CoreStart; +} + +export const getComponents = ({ core }: GetComponentsOptions) => { + /** + * Returns a function that creates a lazy-loading version of a component. + */ + function wrapLazy(fn: () => Promise>) { + return (props: JSX.IntrinsicAttributes & PropsWithRef>) => ( + + ); + } + + return { + getPersonalInfo: wrapLazy(getPersonalInfoComponent), + getChangePassword: wrapLazy(() => getChangePasswordComponent(core)), + }; +}; diff --git a/x-pack/plugins/security/public/ui_api/index.mock.ts b/x-pack/plugins/security/public/ui_api/index.mock.ts new file mode 100644 index 00000000000000..c35f9342be6caf --- /dev/null +++ b/x-pack/plugins/security/public/ui_api/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { UiApi } from './'; + +export const getUiApiMock = { + createStart: (): jest.Mocked => ({ + components: { + getPersonalInfo: jest.fn(), + getChangePassword: jest.fn(), + }, + }), +}; diff --git a/x-pack/plugins/security/public/ui_api/index.ts b/x-pack/plugins/security/public/ui_api/index.ts new file mode 100644 index 00000000000000..e53564074940ad --- /dev/null +++ b/x-pack/plugins/security/public/ui_api/index.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { ReactElement } from 'react'; + +import type { CoreStart } from 'src/core/public'; + +import type { ChangePasswordProps, PersonalInfoProps } from '../account_management'; +import { getComponents } from './components'; + +interface GetUiApiOptions { + core: CoreStart; +} + +type LazyComponentFn = (props: T) => ReactElement; + +export interface UiApi { + components: { + getPersonalInfo: LazyComponentFn; + getChangePassword: LazyComponentFn; + }; +} + +export const getUiApi = ({ core }: GetUiApiOptions): UiApi => { + const components = getComponents({ core }); + + return { + components, + }; +}; diff --git a/x-pack/plugins/security/public/ui_api/lazy_wrapper.tsx b/x-pack/plugins/security/public/ui_api/lazy_wrapper.tsx new file mode 100644 index 00000000000000..6a37b35df7327f --- /dev/null +++ b/x-pack/plugins/security/public/ui_api/lazy_wrapper.tsx @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { FC, PropsWithChildren, PropsWithRef, ReactElement } from 'react'; +import React, { lazy, useMemo } from 'react'; + +import type { CoreStart } from 'src/core/public'; + +import { SuspenseErrorBoundary } from '../suspense_error_boundary'; + +interface InternalProps { + fn: () => Promise>; + core: CoreStart; + props: JSX.IntrinsicAttributes & PropsWithRef>; +} + +export const LazyWrapper: (props: InternalProps) => ReactElement | null = ({ + fn, + core, + props, +}) => { + const { notifications } = core; + + const LazyComponent = useMemo(() => lazy(() => fn().then((x) => ({ default: x }))), [fn]); + + if (!notifications) { + return null; + } + + return ( + + + + ); +}; diff --git a/x-pack/plugins/security/server/authentication/authentication_service.mock.ts b/x-pack/plugins/security/server/authentication/authentication_service.mock.ts index ba73d3b196d2f8..9014e504b405b9 100644 --- a/x-pack/plugins/security/server/authentication/authentication_service.mock.ts +++ b/x-pack/plugins/security/server/authentication/authentication_service.mock.ts @@ -8,10 +8,10 @@ import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import { apiKeysMock } from './api_keys/api_keys.mock'; -import type { AuthenticationServiceStartInternal } from './authentication_service'; +import type { InternalAuthenticationServiceStart } from './authentication_service'; export const authenticationServiceMock = { - createStart: (): DeeplyMockedKeys => ({ + createStart: (): DeeplyMockedKeys => ({ apiKeys: apiKeysMock.create(), login: jest.fn(), logout: jest.fn(), diff --git a/x-pack/plugins/security/server/authentication/authentication_service.ts b/x-pack/plugins/security/server/authentication/authentication_service.ts index 946fedbeee04ff..79dcfb8d804b26 100644 --- a/x-pack/plugins/security/server/authentication/authentication_service.ts +++ b/x-pack/plugins/security/server/authentication/authentication_service.ts @@ -51,7 +51,7 @@ interface AuthenticationServiceStartParams { loggers: LoggerFactory; } -export interface AuthenticationServiceStartInternal extends AuthenticationServiceStart { +export interface InternalAuthenticationServiceStart extends AuthenticationServiceStart { apiKeys: Pick< APIKeys, | 'areAPIKeysEnabled' @@ -227,7 +227,7 @@ export class AuthenticationService { legacyAuditLogger, loggers, session, - }: AuthenticationServiceStartParams): AuthenticationServiceStartInternal { + }: AuthenticationServiceStartParams): InternalAuthenticationServiceStart { const apiKeys = new APIKeys({ clusterClient, logger: this.logger.get('api-key'), diff --git a/x-pack/plugins/security/server/authentication/index.ts b/x-pack/plugins/security/server/authentication/index.ts index 4f82c5653baa9a..1e46d2aaf560ed 100644 --- a/x-pack/plugins/security/server/authentication/index.ts +++ b/x-pack/plugins/security/server/authentication/index.ts @@ -9,7 +9,7 @@ export { canRedirectRequest } from './can_redirect_request'; export { AuthenticationService, AuthenticationServiceStart, - AuthenticationServiceStartInternal, + InternalAuthenticationServiceStart, } from './authentication_service'; export { AuthenticationResult } from './authentication_result'; export { DeauthenticationResult } from './deauthentication_result'; diff --git a/x-pack/plugins/security/server/authorization/actions/actions.ts b/x-pack/plugins/security/server/authorization/actions/actions.ts index d0466645213fa3..0234c3bc82042d 100644 --- a/x-pack/plugins/security/server/authorization/actions/actions.ts +++ b/x-pack/plugins/security/server/authorization/actions/actions.ts @@ -15,7 +15,7 @@ import { UIActions } from './ui'; /** Actions are used to create the "actions" that are associated with Elasticsearch's * application privileges, and are used to perform the authorization checks implemented - * by the various `checkPrivilegesWithRequest` derivatives + * by the various `checkPrivilegesWithRequest` derivatives. */ export class Actions { public readonly api = new ApiActions(this.versionNumber); diff --git a/x-pack/plugins/security/server/authorization/authorization_service.tsx b/x-pack/plugins/security/server/authorization/authorization_service.tsx index c5adb3aff670e0..0777c231ecd89d 100644 --- a/x-pack/plugins/security/server/authorization/authorization_service.tsx +++ b/x-pack/plugins/security/server/authorization/authorization_service.tsx @@ -89,7 +89,7 @@ export interface AuthorizationServiceSetup { /** * Actions are used to create the "actions" that are associated with Elasticsearch's * application privileges, and are used to perform the authorization checks implemented - * by the various `checkPrivilegesWithRequest` derivatives + * by the various `checkPrivilegesWithRequest` derivatives. */ actions: Actions; checkPrivilegesWithRequest: CheckPrivilegesWithRequest; diff --git a/x-pack/plugins/security/server/plugin.ts b/x-pack/plugins/security/server/plugin.ts index 98f1335b534505..d0403c0f170ea8 100644 --- a/x-pack/plugins/security/server/plugin.ts +++ b/x-pack/plugins/security/server/plugin.ts @@ -37,12 +37,11 @@ import type { AuditServiceSetup } from './audit'; import { AuditService, SecurityAuditLogger } from './audit'; import type { AuthenticationServiceStart, - AuthenticationServiceStartInternal, + InternalAuthenticationServiceStart, } from './authentication'; import { AuthenticationService } from './authentication'; -import type { AuthorizationServiceSetup } from './authorization'; +import type { AuthorizationServiceSetup, AuthorizationServiceSetupInternal } from './authorization'; import { AuthorizationService } from './authorization'; -import type { AuthorizationServiceSetupInternal } from './authorization/authorization_service'; import type { ConfigSchema, ConfigType } from './config'; import { createConfig } from './config'; import { ElasticsearchService } from './elasticsearch'; @@ -156,7 +155,7 @@ export class SecurityPlugin private readonly authenticationService = new AuthenticationService( this.initializerContext.logger.get('authentication') ); - private authenticationStart?: AuthenticationServiceStartInternal; + private authenticationStart?: InternalAuthenticationServiceStart; private readonly getAuthentication = () => { if (!this.authenticationStart) { throw new Error(`authenticationStart is not registered!`); diff --git a/x-pack/plugins/security/server/routes/api_keys/create.test.ts b/x-pack/plugins/security/server/routes/api_keys/create.test.ts index ee28681adbd5f2..a86481b8016e8f 100644 --- a/x-pack/plugins/security/server/routes/api_keys/create.test.ts +++ b/x-pack/plugins/security/server/routes/api_keys/create.test.ts @@ -12,7 +12,7 @@ import type { RequestHandler } from 'src/core/server'; import { kibanaResponseFactory } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; -import type { AuthenticationServiceStartInternal } from '../../authentication'; +import type { InternalAuthenticationServiceStart } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { SecurityRequestHandlerContext } from '../../types'; import { routeDefinitionParamsMock } from '../index.mock'; @@ -28,7 +28,7 @@ describe('Create API Key route', () => { } let routeHandler: RequestHandler; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; beforeEach(() => { authc = authenticationServiceMock.createStart(); const mockRouteDefinitionParams = routeDefinitionParamsMock.create(); diff --git a/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts b/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts index 1000e79563b571..6a477d2600d3e2 100644 --- a/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts +++ b/x-pack/plugins/security/server/routes/api_keys/enabled.test.ts @@ -12,7 +12,7 @@ import type { RequestHandler } from 'src/core/server'; import { kibanaResponseFactory } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; -import type { AuthenticationServiceStartInternal } from '../../authentication'; +import type { InternalAuthenticationServiceStart } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { SecurityRequestHandlerContext } from '../../types'; import { routeDefinitionParamsMock } from '../index.mock'; @@ -28,7 +28,7 @@ describe('API keys enabled', () => { } let routeHandler: RequestHandler; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; beforeEach(() => { authc = authenticationServiceMock.createStart(); const mockRouteDefinitionParams = routeDefinitionParamsMock.create(); diff --git a/x-pack/plugins/security/server/routes/authentication/common.test.ts b/x-pack/plugins/security/server/routes/authentication/common.test.ts index 5acc5817bfb3e9..8320f88d1242a2 100644 --- a/x-pack/plugins/security/server/routes/authentication/common.test.ts +++ b/x-pack/plugins/security/server/routes/authentication/common.test.ts @@ -13,7 +13,7 @@ import { httpServerMock } from 'src/core/server/mocks'; import type { SecurityLicense, SecurityLicenseFeatures } from '../../../common/licensing'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; -import type { AuthenticationServiceStartInternal } from '../../authentication'; +import type { InternalAuthenticationServiceStart } from '../../authentication'; import { AuthenticationResult, DeauthenticationResult, @@ -28,7 +28,7 @@ import { defineCommonRoutes } from './common'; describe('Common authentication routes', () => { let router: jest.Mocked; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; let license: jest.Mocked; let mockContext: SecurityRequestHandlerContext; beforeEach(() => { diff --git a/x-pack/plugins/security/server/routes/authentication/saml.test.ts b/x-pack/plugins/security/server/routes/authentication/saml.test.ts index c28c435217ef3a..d27ea5f6dca710 100644 --- a/x-pack/plugins/security/server/routes/authentication/saml.test.ts +++ b/x-pack/plugins/security/server/routes/authentication/saml.test.ts @@ -11,7 +11,7 @@ import type { RequestHandler, RouteConfig } from 'src/core/server'; import { httpServerMock } from 'src/core/server/mocks'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; -import type { AuthenticationServiceStartInternal } from '../../authentication'; +import type { InternalAuthenticationServiceStart } from '../../authentication'; import { AuthenticationResult, SAMLLogin } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { SecurityRouter } from '../../types'; @@ -21,7 +21,7 @@ import { defineSAMLRoutes } from './saml'; describe('SAML authentication routes', () => { let router: jest.Mocked; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; beforeEach(() => { const routeParamsMock = routeDefinitionParamsMock.create(); router = routeParamsMock.router; diff --git a/x-pack/plugins/security/server/routes/index.ts b/x-pack/plugins/security/server/routes/index.ts index e36ca1b9ab72e5..7a4310da3e4c7c 100644 --- a/x-pack/plugins/security/server/routes/index.ts +++ b/x-pack/plugins/security/server/routes/index.ts @@ -10,7 +10,7 @@ import type { HttpResources, IBasePath, Logger } from 'src/core/server'; import type { KibanaFeature } from '../../../features/server'; import type { SecurityLicense } from '../../common/licensing'; -import type { AuthenticationServiceStartInternal } from '../authentication'; +import type { InternalAuthenticationServiceStart } from '../authentication'; import type { AuthorizationServiceSetupInternal } from '../authorization'; import type { ConfigType } from '../config'; import type { SecurityFeatureUsageServiceStart } from '../feature_usage'; @@ -39,7 +39,7 @@ export interface RouteDefinitionParams { license: SecurityLicense; getFeatures: () => Promise; getFeatureUsageService: () => SecurityFeatureUsageServiceStart; - getAuthenticationService: () => AuthenticationServiceStartInternal; + getAuthenticationService: () => InternalAuthenticationServiceStart; } export function defineRoutes(params: RouteDefinitionParams) { diff --git a/x-pack/plugins/security/server/routes/users/change_password.test.ts b/x-pack/plugins/security/server/routes/users/change_password.test.ts index e5f4381a204212..fba7bf4f872e7f 100644 --- a/x-pack/plugins/security/server/routes/users/change_password.test.ts +++ b/x-pack/plugins/security/server/routes/users/change_password.test.ts @@ -16,7 +16,7 @@ import { coreMock, httpServerMock } from 'src/core/server/mocks'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; import { AuthenticationResult } from '../../authentication'; -import type { AuthenticationServiceStartInternal } from '../../authentication/authentication_service'; +import type { InternalAuthenticationServiceStart } from '../../authentication'; import { authenticationServiceMock } from '../../authentication/authentication_service.mock'; import type { Session } from '../../session_management'; import { sessionMock } from '../../session_management/session.mock'; @@ -26,7 +26,7 @@ import { defineChangeUserPasswordRoutes } from './change_password'; describe('Change password', () => { let router: jest.Mocked; - let authc: DeeplyMockedKeys; + let authc: DeeplyMockedKeys; let session: jest.Mocked>; let routeHandler: RequestHandler; let routeConfig: RouteConfig; diff --git a/x-pack/plugins/security/server/saved_objects/index.ts b/x-pack/plugins/security/server/saved_objects/index.ts index 837b3c594d3968..364f639e9e9a3c 100644 --- a/x-pack/plugins/security/server/saved_objects/index.ts +++ b/x-pack/plugins/security/server/saved_objects/index.ts @@ -9,7 +9,7 @@ import type { CoreSetup, LegacyRequest } from 'src/core/server'; import { KibanaRequest, SavedObjectsClient } from '../../../../../src/core/server'; import type { AuditServiceSetup, SecurityAuditLogger } from '../audit'; -import type { AuthorizationServiceSetupInternal } from '../authorization/authorization_service'; +import type { AuthorizationServiceSetupInternal } from '../authorization'; import type { SpacesService } from '../plugin'; import { SecureSavedObjectsClientWrapper } from './secure_saved_objects_client_wrapper'; diff --git a/x-pack/plugins/security_solution/common/endpoint/schema/common.ts b/x-pack/plugins/security_solution/common/endpoint/schema/common.ts index ee59ce12f98124..0aff91aafa5998 100644 --- a/x-pack/plugins/security_solution/common/endpoint/schema/common.ts +++ b/x-pack/plugins/security_solution/common/endpoint/schema/common.ts @@ -15,6 +15,7 @@ export type CompressionAlgorithm = t.TypeOf; export const compressionAlgorithmDispatch = t.keyof({ zlib: null, + none: null, }); export type CompressionAlgorithmDispatch = t.TypeOf; diff --git a/x-pack/plugins/security_solution/common/endpoint/types/actions.ts b/x-pack/plugins/security_solution/common/endpoint/types/actions.ts index 33072e8df5cec5..937025f35dadcd 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/actions.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/actions.ts @@ -6,7 +6,7 @@ */ import { TypeOf } from '@kbn/config-schema'; -import { HostIsolationRequestSchema } from '../schema/actions'; +import { ActionStatusRequestSchema, HostIsolationRequestSchema } from '../schema/actions'; export type ISOLATION_ACTIONS = 'isolate' | 'unisolate'; @@ -44,10 +44,16 @@ export interface HostIsolationResponse { action: string; } -export interface PendingActionsResponse { +export interface EndpointPendingActions { agent_id: string; pending_actions: { /** Number of actions pending for each type. The `key` could be one of the `ISOLATION_ACTIONS` values. */ [key: string]: number; }; } + +export interface PendingActionsResponse { + data: EndpointPendingActions[]; +} + +export type PendingActionsRequestQuery = TypeOf; diff --git a/x-pack/plugins/security_solution/public/cases/components/callout/callout.test.tsx b/x-pack/plugins/security_solution/public/cases/components/callout/callout.test.tsx index 926fe7b63fb5af..0a0caa40a8783e 100644 --- a/x-pack/plugins/security_solution/public/cases/components/callout/callout.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/callout/callout.test.tsx @@ -80,7 +80,7 @@ describe('Callout', () => { }); it('dismiss the callout correctly', () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.find(`[data-test-subj="callout-dismiss-md5-hex"]`).exists()).toBeTruthy(); wrapper.find(`button[data-test-subj="callout-dismiss-md5-hex"]`).simulate('click'); wrapper.update(); diff --git a/x-pack/plugins/security_solution/public/cases/components/callout/callout.tsx b/x-pack/plugins/security_solution/public/cases/components/callout/callout.tsx index 8e2f439f02c4bd..4cd7fad10fe70c 100644 --- a/x-pack/plugins/security_solution/public/cases/components/callout/callout.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/callout/callout.tsx @@ -35,11 +35,9 @@ const CallOutComponent = ({ type, ]); - return showCallOut ? ( + return showCallOut && !isEmpty(messages) ? ( - {!isEmpty(messages) && ( - - )} + {i18n.READ_ONLY_FEATURE_MSG}, diff --git a/x-pack/plugins/security_solution/public/cases/pages/case.tsx b/x-pack/plugins/security_solution/public/cases/pages/case.tsx index 4ec29b676afe6e..9613e327ebe9f3 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/case.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/case.tsx @@ -12,7 +12,7 @@ import { useGetUserCasesPermissions } from '../../common/lib/kibana'; import { SpyRoute } from '../../common/utils/route/spy_routes'; import { AllCases } from '../components/all_cases'; -import { savedObjectReadOnlyErrorMessage, CaseCallOut } from '../components/callout'; +import { permissionsReadOnlyErrorMessage, CaseCallOut } from '../components/callout'; import { CaseFeatureNoPermissions } from './feature_no_permissions'; import { SecurityPageName } from '../../app/types'; @@ -24,8 +24,8 @@ export const CasesPage = React.memo(() => { {userPermissions != null && !userPermissions?.crud && userPermissions?.read && ( )} diff --git a/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx b/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx index 03407c7a5adaab..bbc29828731cb4 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx @@ -16,7 +16,7 @@ import { useGetUserCasesPermissions } from '../../common/lib/kibana'; import { getCaseUrl } from '../../common/components/link_to'; import { navTabs } from '../../app/home/home_navigations'; import { CaseView } from '../components/case_view'; -import { savedObjectReadOnlyErrorMessage, CaseCallOut } from '../components/callout'; +import { permissionsReadOnlyErrorMessage, CaseCallOut } from '../components/callout'; export const CaseDetailsPage = React.memo(() => { const history = useHistory(); @@ -37,8 +37,8 @@ export const CaseDetailsPage = React.memo(() => { {userPermissions != null && !userPermissions?.crud && userPermissions?.read && ( )} => { + return KibanaServices.get().http.get(ACTION_STATUS_ROUTE, { + query: { + agent_ids: agentIds, + }, + }); +}; diff --git a/x-pack/plugins/security_solution/public/common/lib/endpoint_pending_actions/index.ts b/x-pack/plugins/security_solution/public/common/lib/endpoint_pending_actions/index.ts new file mode 100644 index 00000000000000..e3f7c7c3be90e0 --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/lib/endpoint_pending_actions/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export * from './endpoint_pending_actions'; diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts index 4edbd5ab7e180c..3baa6580b36fbe 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts @@ -25,7 +25,7 @@ import { UpdateAlertStatusProps, CasesFromAlertsResponse, } from './types'; -import { isolateHost, unIsolateHost } from '../../../../common/lib/host_isolation'; +import { isolateHost, unIsolateHost } from '../../../../common/lib/endpoint_isolation'; import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables'; /** diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts index 6548d8a10ce97f..98ef5a341ac9ef 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts @@ -41,7 +41,7 @@ import { hostIsolationHttpMocks, hostIsolationRequestBodyMock, hostIsolationResponseMock, -} from '../../../../common/lib/host_isolation/mocks'; +} from '../../../../common/lib/endpoint_isolation/mocks'; import { FleetActionGenerator } from '../../../../../common/endpoint/data_generators/fleet_action_generator'; jest.mock('../../policy/store/services/ingest', () => ({ diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts index b62663bd787503..a1da3c072293ea 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { HttpStart } from 'kibana/public'; +import { Dispatch } from 'redux'; +import { CoreStart, HttpStart } from 'kibana/public'; import { EndpointAction, HostInfo, @@ -13,6 +14,7 @@ import { HostIsolationResponse, HostResultList, Immutable, + ImmutableObject, } from '../../../../../common/endpoint/types'; import { GetPolicyListResponse } from '../../policy/types'; import { ImmutableMiddlewareAPI, ImmutableMiddlewareFactory } from '../../../../common/store'; @@ -51,9 +53,10 @@ import { createLoadedResourceState, createLoadingResourceState, } from '../../../state'; -import { isolateHost, unIsolateHost } from '../../../../common/lib/host_isolation'; +import { isolateHost, unIsolateHost } from '../../../../common/lib/endpoint_isolation'; import { AppAction } from '../../../../common/store/actions'; import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables'; +import { ServerReturnedEndpointPackageInfo } from './action'; type EndpointPageStore = ImmutableMiddlewareAPI; @@ -78,26 +81,14 @@ export const endpointMiddlewareFactory: ImmutableMiddlewareFactory, + dispatch: Dispatch, + coreStart: CoreStart +) { + if (endpointPackageInfo(state)) return; + + try { + const packageInfo = await sendGetEndpointSecurityPackage(coreStart.http); + dispatch({ + type: 'serverReturnedEndpointPackageInfo', + payload: packageInfo, + }); + } catch (error) { + // Ignore Errors, since this should not hinder the user's ability to use the UI + // eslint-disable-next-line no-console + console.error(error); + } +} diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx index 509bb7b4cf7111..aa1c47a3102d90 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx @@ -29,7 +29,7 @@ import { POLICY_STATUS_TO_TEXT } from './host_constants'; import { mockPolicyResultList } from '../../policy/store/test_mock_utils'; import { getEndpointDetailsPath } from '../../../common/routing'; import { KibanaServices, useKibana, useToasts } from '../../../../common/lib/kibana'; -import { hostIsolationHttpMocks } from '../../../../common/lib/host_isolation/mocks'; +import { hostIsolationHttpMocks } from '../../../../common/lib/endpoint_isolation/mocks'; import { fireEvent } from '@testing-library/dom'; import { isFailedResourceState, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx index 06b42145a6d48c..4d1ab0f3de8252 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx @@ -157,9 +157,9 @@ export const EndpointList = () => { const handleCreatePolicyClick = useNavigateToAppEventHandler( 'fleet', { - path: `#/policies/add-integration${ + path: `#/integrations/${ endpointPackageVersion ? `/endpoint-${endpointPackageVersion}` : '' - }`, + }/add-integration`, state: { onCancelNavigateTo: [ 'securitySolution:administration', diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.test.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.test.ts index 5229e4078eb0dc..530a18cd8a3120 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.test.ts @@ -22,6 +22,11 @@ import { EventFiltersListPageState, EventFiltersService } from '../types'; import { getFoundExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/found_exception_list_item_schema.mock'; import { isFailedResourceState, isLoadedResourceState } from '../../../state'; import { getListFetchError } from './selector'; +import type { + ExceptionListItemSchema, + CreateExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; +import { Immutable } from '../../../../../common/endpoint/types'; const createEventFiltersServiceMock = (): jest.Mocked => ({ addEventFilters: jest.fn(), @@ -208,6 +213,38 @@ describe('Event filters middleware', () => { }); }); + it('does submit when entry has empty comments with white spaces', async () => { + service.addEventFilters.mockImplementation( + async (exception: Immutable) => { + expect(exception.comments).toStrictEqual(createdEventFilterEntryMock().comments); + return createdEventFilterEntryMock(); + } + ); + const entry = getInitialExceptionFromEvent(ecsEventMock()); + store.dispatch({ + type: 'eventFiltersInitForm', + payload: { entry }, + }); + + store.dispatch({ + type: 'eventFiltersChangeForm', + payload: { newComment: ' ', entry }, + }); + + store.dispatch({ type: 'eventFiltersCreateStart' }); + await spyMiddleware.waitForAction('eventFiltersFormStateChanged'); + expect(store.getState()).toStrictEqual({ + ...initialState, + form: { + ...store.getState().form, + submissionResourceState: { + type: 'LoadedResourceState', + data: createdEventFilterEntryMock(), + }, + }, + }); + }); + it('does throw error when creating', async () => { service.addEventFilters.mockRejectedValue({ body: { message: 'error message', statusCode: 500, error: 'Internal Server Error' }, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts index a115ee9961de42..c1ade4e2cadeca 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts @@ -57,7 +57,8 @@ const addNewComments = ( ): UpdateExceptionListItemSchema | CreateExceptionListItemSchema => { if (newComment) { if (!entry.comments) entry.comments = []; - entry.comments.push({ comment: newComment }); + const trimmedComment = newComment.trim(); + if (trimmedComment) entry.comments.push({ comment: trimmedComment }); } return entry; }; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.test.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.test.ts index ed665135317af4..5366b6dcf155aa 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.test.ts @@ -88,6 +88,25 @@ describe('event filters reducer', () => { }); }); + it('clean form after change form status', () => { + const entry = getInitialExceptionFromEvent(ecsEventMock()); + const nameChanged = 'name changed'; + const newComment = 'new comment'; + const result = eventFiltersPageReducer(initialState, { + type: 'eventFiltersChangeForm', + payload: { entry: { ...entry, name: nameChanged }, newComment }, + }); + const cleanState = eventFiltersPageReducer(result, { + type: 'eventFiltersInitForm', + payload: { entry }, + }); + + expect(cleanState).toStrictEqual({ + ...initialState, + form: { ...initialState.form, entry, hasNameError: true, newComment: '' }, + }); + }); + it('create is success and force list refresh', () => { const initialStateWithListPageActive = { ...initialState, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.ts index d69efb689c8779..28292bdb1ed1cd 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/reducer.ts @@ -86,6 +86,7 @@ const eventFiltersInitForm: CaseReducer = (state, action) entry: action.payload.entry, hasNameError: !action.payload.entry.name, hasOSError: !action.payload.entry.os_types?.length, + newComment: '', submissionResourceState: { type: 'UninitialisedResourceState', }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx index 1407e5f64f156a..d01ccea5ba1f4a 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_details.test.tsx @@ -63,7 +63,7 @@ describe('Policy Details', () => { describe('when displayed with invalid id', () => { let releaseApiFailure: () => void; beforeEach(() => { - http.get.mockImplementationOnce(async () => { + http.get.mockImplementation(async () => { await new Promise((_, reject) => { releaseApiFailure = reject.bind(null, new Error('policy not found')); }); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx index 691601b69e3cd7..adc9438f27d743 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx @@ -633,18 +633,21 @@ describe('When on the Trusted Apps Page', () => { }); }); - it('should close the flyout', async () => { + it('should close the flyout', () => { expect(renderResult.queryByTestId('addTrustedAppFlyout')).toBeNull(); }); - it('should show success toast notification', async () => { + it('should show success toast notification', () => { expect(coreStart.notifications.toasts.addSuccess.mock.calls[0][0]).toEqual( '"one app" has been added to the Trusted Applications list.' ); }); - it('should trigger the List to reload', async () => { - expect(coreStart.http.get.mock.calls[0][0]).toEqual(TRUSTED_APPS_LIST_API); + it('should trigger the List to reload', () => { + const isCalled = coreStart.http.get.mock.calls.some( + (call) => call[0].toString() === TRUSTED_APPS_LIST_API + ); + expect(isCalled).toEqual(true); }); }); @@ -666,18 +669,18 @@ describe('When on the Trusted Apps Page', () => { }); }); - it('should continue to show the flyout', async () => { + it('should continue to show the flyout', () => { expect(renderResult.getByTestId('addTrustedAppFlyout')).not.toBeNull(); }); - it('should enable the Cancel Button', async () => { + it('should enable the Cancel Button', () => { expect( (renderResult.getByTestId('addTrustedAppFlyout-cancelButton') as HTMLButtonElement) .disabled ).toBe(false); }); - it('should show the dialog close button', async () => { + it('should show the dialog close button', () => { expect(renderResult.getByTestId('euiFlyoutCloseButton')).not.toBeNull(); }); @@ -688,7 +691,7 @@ describe('When on the Trusted Apps Page', () => { ).toBe(false); }); - it('should show API errors in the form', async () => { + it('should show API errors in the form', () => { expect(renderResult.container.querySelector('.euiForm__errors')).not.toBeNull(); }); }); diff --git a/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.test.tsx b/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.test.tsx index a6b545045a6272..f0198092ec1be8 100644 --- a/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.test.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.test.tsx @@ -9,11 +9,15 @@ import React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; import { OverviewEmpty } from '.'; import { useIngestEnabledCheck } from '../../../common/hooks/endpoint/ingest_enabled'; + +const endpointPackageVersion = '0.19.1'; + jest.mock('../../../common/lib/kibana'); jest.mock('../../../management/pages/endpoint_hosts/view/hooks', () => ({ useIngestUrl: jest .fn() .mockReturnValue({ appId: 'ingestAppId', appPath: 'ingestPath', url: 'ingestUrl' }), + useEndpointSelector: jest.fn().mockReturnValue({ endpointPackageVersion }), })); jest.mock('../../../common/hooks/endpoint/ingest_enabled', () => ({ @@ -57,7 +61,7 @@ describe('OverviewEmpty', () => { fill: false, label: 'Add Endpoint Security', onClick: undefined, - url: '/app/home#/tutorial_directory/security', + url: `#/integrations/endpoint-${endpointPackageVersion}/add-integration`, }, }); }); diff --git a/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.tsx b/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.tsx index 6a77271e987715..028871d7be19d8 100644 --- a/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/overview_empty/index.tsx @@ -7,6 +7,7 @@ import React, { useMemo } from 'react'; import { omit } from 'lodash/fp'; +import { createStructuredSelector } from 'reselect'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiLink } from '@elastic/eui'; @@ -14,18 +15,33 @@ import * as i18nCommon from '../../../common/translations'; import { EmptyPage, EmptyPageActionsProps } from '../../../common/components/empty_page'; import { useKibana } from '../../../common/lib/kibana'; import { ADD_DATA_PATH } from '../../../../common/constants'; -import { useIngestUrl } from '../../../management/pages/endpoint_hosts/view/hooks'; +import { + useEndpointSelector, + useIngestUrl, +} from '../../../management/pages/endpoint_hosts/view/hooks'; import { useNavigateToAppEventHandler } from '../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; import { useIngestEnabledCheck } from '../../../common/hooks/endpoint/ingest_enabled'; +import { CreateStructuredSelector } from '../../../common/store'; +import { endpointPackageVersion as useEndpointPackageVersion } from '../../../management/pages/endpoint_hosts/store/selectors'; const OverviewEmptyComponent: React.FC = () => { const { http, docLinks } = useKibana().services; const basePath = http.basePath.get(); - const { appId: ingestAppId, appPath: ingestPath, url: ingestUrl } = useIngestUrl( - 'integrations?category=security' - ); - const handleOnClick = useNavigateToAppEventHandler(ingestAppId, { path: ingestPath }); + const selector = (createStructuredSelector as CreateStructuredSelector)({ + endpointPackageVersion: useEndpointPackageVersion, + }); + const { endpointPackageVersion } = useEndpointSelector(selector); + const { url: ingestUrl } = useIngestUrl(''); + + const endpointIntegrationUrlPath = endpointPackageVersion + ? `/endpoint-${endpointPackageVersion}/add-integration` + : ''; + const endpointIntegrationUrl = `#/integrations${endpointIntegrationUrlPath}`; + const handleEndpointClick = useNavigateToAppEventHandler('fleet', { + path: endpointIntegrationUrl, + }); const { allEnabled: isIngestEnabled } = useIngestEnabledCheck(); + const emptyPageActions: EmptyPageActionsProps = useMemo( () => ({ elasticAgent: { @@ -42,13 +58,13 @@ const OverviewEmptyComponent: React.FC = () => { }, endpoint: { label: i18nCommon.EMPTY_ACTION_ENDPOINT, - url: `${basePath}${ADD_DATA_PATH}`, + url: endpointIntegrationUrl, description: i18nCommon.EMPTY_ACTION_ENDPOINT_DESCRIPTION, - onClick: handleOnClick, + onClick: handleEndpointClick, fill: false, }, }), - [basePath, ingestUrl, handleOnClick] + [basePath, ingestUrl, endpointIntegrationUrl, handleEndpointClick] ); const emptyPageIngestDisabledActions = useMemo( diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts index d2fad90d9e7d60..f5d3b30bf15faa 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts @@ -6,7 +6,6 @@ */ import { createHash } from 'crypto'; -import { deflate } from 'zlib'; import type { Entry, EntryNested, @@ -21,9 +20,7 @@ import { } from '@kbn/securitysolution-list-constants'; import { ExceptionListClient } from '../../../../../lists/server'; import { - internalArtifactCompleteSchema, InternalArtifactCompleteSchema, - InternalArtifactSchema, TranslatedEntry, translatedEntry as translatedEntryType, translatedEntryMatchAnyMatcher, @@ -60,28 +57,6 @@ export async function buildArtifact( }; } -export async function maybeCompressArtifact( - uncompressedArtifact: InternalArtifactSchema -): Promise { - const compressedArtifact = { ...uncompressedArtifact }; - if (internalArtifactCompleteSchema.is(uncompressedArtifact)) { - const compressedArtifactBody = await compressExceptionList( - Buffer.from(uncompressedArtifact.body, 'base64') - ); - compressedArtifact.body = compressedArtifactBody.toString('base64'); - compressedArtifact.encodedSize = compressedArtifactBody.byteLength; - compressedArtifact.compressionAlgorithm = 'zlib'; - compressedArtifact.encodedSha256 = createHash('sha256') - .update(compressedArtifactBody) - .digest('hex'); - } - return compressedArtifact; -} - -export function isCompressed(artifact: InternalArtifactSchema) { - return artifact.compressionAlgorithm === 'zlib'; -} - export async function getFilteredEndpointExceptionList( eClient: ExceptionListClient, schemaVersion: string, @@ -297,15 +272,3 @@ function translateEntry( } } } - -export async function compressExceptionList(buffer: Buffer): Promise { - return new Promise((resolve, reject) => { - deflate(buffer, function (err, buf) { - if (err) { - reject(err); - } else { - resolve(buf); - } - }); - }); -} diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.test.ts index 2eb72566bb4764..3948c51f6c5d8f 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.test.ts @@ -37,8 +37,8 @@ describe('manifest', () => { let ARTIFACT_COPY_TRUSTED_APPS_WINDOWS: InternalArtifactCompleteSchema; beforeAll(async () => { - ARTIFACTS = await getMockArtifacts({ compress: true }); - ARTIFACTS_COPY = await getMockArtifacts({ compress: true }); + ARTIFACTS = await getMockArtifacts(); + ARTIFACTS_COPY = await getMockArtifacts(); ARTIFACT_EXCEPTIONS_MACOS = ARTIFACTS[0]; ARTIFACT_EXCEPTIONS_WINDOWS = ARTIFACTS[1]; ARTIFACT_EXCEPTIONS_LINUX = ARTIFACTS[2]; diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.ts index 43d4fc49161bb5..7c1906cdd7a88e 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest.ts @@ -12,6 +12,7 @@ import { InternalArtifactSchema, InternalManifestSchema, InternalManifestEntrySchema, + InternalArtifactCompleteSchema, } from '../../schemas/artifacts'; import { ManifestSchemaVersion, @@ -139,6 +140,27 @@ export class Manifest { return this.allEntries.get(getArtifactId(artifact))?.specificTargetPolicies; } + /** + * Replaces an artifact from all the collections. + * + * @param artifact An InternalArtifactCompleteSchema representing the artifact. + */ + public replaceArtifact(artifact: InternalArtifactCompleteSchema) { + const existingEntry = this.allEntries.get(getArtifactId(artifact)); + if (existingEntry) { + existingEntry.entry = new ManifestEntry(artifact); + + this.allEntries.set(getArtifactId(artifact), existingEntry); + this.defaultEntries.set(getArtifactId(artifact), existingEntry.entry); + + existingEntry.specificTargetPolicies.forEach((policyId) => { + const entries = this.policySpecificEntries.get(policyId) || new Map(); + entries.set(existingEntry.entry.getDocId(), existingEntry.entry); + this.policySpecificEntries.set(policyId, entries); + }); + } + } + public diff(manifest: Manifest): ManifestDiff { const diff: ManifestDiff = { additions: [], diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest_entry.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest_entry.test.ts index 99f08103ece065..c60ccca5253b70 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest_entry.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/manifest_entry.test.ts @@ -15,7 +15,7 @@ describe('manifest_entry', () => { let manifestEntry: ManifestEntry; beforeAll(async () => { - artifact = await getInternalArtifactMock('windows', 'v1', { compress: true }); + artifact = await getInternalArtifactMock('windows', 'v1'); manifestEntry = new ManifestEntry(artifact); }); @@ -35,7 +35,7 @@ describe('manifest_entry', () => { test('Correct sha256 is returned', () => { expect(manifestEntry.getEncodedSha256()).toEqual( - '975382ab55d019cbab0bbac207a54e2a7d489fad6e8f6de34fc6402e5ef37b1e' + '96b76a1a911662053a1562ac14c4ff1e87c2ff550d6fe52e1e0b3790526597d3' ); expect(manifestEntry.getDecodedSha256()).toEqual( '96b76a1a911662053a1562ac14c4ff1e87c2ff550d6fe52e1e0b3790526597d3' @@ -43,7 +43,7 @@ describe('manifest_entry', () => { }); test('Correct size is returned', () => { - expect(manifestEntry.getEncodedSize()).toEqual(147); + expect(manifestEntry.getEncodedSize()).toEqual(432); expect(manifestEntry.getDecodedSize()).toEqual(432); }); @@ -59,12 +59,12 @@ describe('manifest_entry', () => { test('Correct record is returned', () => { expect(manifestEntry.getRecord()).toEqual({ - compression_algorithm: 'zlib', + compression_algorithm: 'none', encryption_algorithm: 'none', decoded_sha256: '96b76a1a911662053a1562ac14c4ff1e87c2ff550d6fe52e1e0b3790526597d3', - encoded_sha256: '975382ab55d019cbab0bbac207a54e2a7d489fad6e8f6de34fc6402e5ef37b1e', + encoded_sha256: '96b76a1a911662053a1562ac14c4ff1e87c2ff550d6fe52e1e0b3790526597d3', decoded_size: 432, - encoded_size: 147, + encoded_size: 432, relative_url: '/api/fleet/artifacts/endpoint-exceptionlist-windows-v1/96b76a1a911662053a1562ac14c4ff1e87c2ff550d6fe52e1e0b3790526597d3', }); diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts index b74492103dbdc4..2071d4b8c27b71 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts @@ -49,7 +49,7 @@ describe('When migrating artifacts to fleet', () => { type: '', id: 'abc123', references: [], - attributes: await getInternalArtifactMock('windows', 'v1', { compress: true }), + attributes: await getInternalArtifactMock('windows', 'v1'), }, ]) ); diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/mocks.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/mocks.ts index cda42bdf3f585e..172e4656b97549 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/mocks.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/mocks.ts @@ -17,49 +17,49 @@ import { import { ArtifactConstants } from './common'; import { Manifest } from './manifest'; -export const getMockArtifacts = async (opts?: { compress: boolean }) => { +export const getMockArtifacts = async () => { return Promise.all([ // Exceptions items ...ArtifactConstants.SUPPORTED_OPERATING_SYSTEMS.map>( async (os) => { - return getInternalArtifactMock(os, 'v1', opts); + return getInternalArtifactMock(os, 'v1'); } ), // Trusted Apps items ...ArtifactConstants.SUPPORTED_TRUSTED_APPS_OPERATING_SYSTEMS.map< Promise >(async (os) => { - return getInternalArtifactMock(os, 'v1', opts, ArtifactConstants.GLOBAL_TRUSTED_APPS_NAME); + return getInternalArtifactMock(os, 'v1', ArtifactConstants.GLOBAL_TRUSTED_APPS_NAME); }), ]); }; -export const getMockArtifactsWithDiff = async (opts?: { compress: boolean }) => { +export const getMockArtifactsWithDiff = async () => { return Promise.all( ArtifactConstants.SUPPORTED_OPERATING_SYSTEMS.map>( async (os) => { if (os === 'macos') { return getInternalArtifactMockWithDiffs(os, 'v1'); } - return getInternalArtifactMock(os, 'v1', opts); + return getInternalArtifactMock(os, 'v1'); } ) ); }; -export const getEmptyMockArtifacts = async (opts?: { compress: boolean }) => { +export const getEmptyMockArtifacts = async () => { return Promise.all( ArtifactConstants.SUPPORTED_OPERATING_SYSTEMS.map>( async (os) => { - return getEmptyInternalArtifactMock(os, 'v1', opts); + return getEmptyInternalArtifactMock(os, 'v1'); } ) ); }; -export const getMockManifest = async (opts?: { compress: boolean }) => { +export const getMockManifest = async () => { const manifest = new Manifest(); - const artifacts = await getMockArtifacts(opts); + const artifacts = await getMockArtifacts(); artifacts.forEach((artifact) => manifest.addEntry(artifact)); return manifest; }; diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.test.ts index 03b2f831ba7b57..b6fd384cdd6462 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.test.ts @@ -106,7 +106,7 @@ describe('task', () => { let ARTIFACT_TRUSTED_APPS_MACOS: InternalArtifactCompleteSchema; beforeAll(async () => { - const artifacts = await getMockArtifacts({ compress: true }); + const artifacts = await getMockArtifacts(); ARTIFACT_EXCEPTIONS_MACOS = artifacts[0]; ARTIFACT_EXCEPTIONS_WINDOWS = artifacts[1]; ARTIFACT_TRUSTED_APPS_MACOS = artifacts[2]; @@ -167,7 +167,7 @@ describe('task', () => { expect(manifestManager.getLastComputedManifest).toHaveBeenCalled(); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(lastManifest); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([], newManifest); expect(manifestManager.commit).not.toHaveBeenCalled(); expect(manifestManager.tryDispatch).toHaveBeenCalledWith(newManifest); expect(manifestManager.deleteArtifacts).toHaveBeenCalledWith([]); @@ -192,10 +192,10 @@ describe('task', () => { expect(manifestManager.getLastComputedManifest).toHaveBeenCalled(); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(lastManifest); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ - ARTIFACT_EXCEPTIONS_MACOS, - ARTIFACT_TRUSTED_APPS_MACOS, - ]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_EXCEPTIONS_MACOS, ARTIFACT_TRUSTED_APPS_MACOS], + newManifest + ); expect(manifestManager.commit).not.toHaveBeenCalled(); expect(manifestManager.tryDispatch).not.toHaveBeenCalled(); expect(manifestManager.deleteArtifacts).not.toHaveBeenCalled(); @@ -221,10 +221,10 @@ describe('task', () => { expect(manifestManager.getLastComputedManifest).toHaveBeenCalled(); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(lastManifest); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ - ARTIFACT_EXCEPTIONS_MACOS, - ARTIFACT_TRUSTED_APPS_MACOS, - ]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_EXCEPTIONS_MACOS, ARTIFACT_TRUSTED_APPS_MACOS], + newManifest + ); expect(manifestManager.commit).toHaveBeenCalledWith(newManifest); expect(manifestManager.tryDispatch).not.toHaveBeenCalled(); expect(manifestManager.deleteArtifacts).not.toHaveBeenCalled(); @@ -251,10 +251,10 @@ describe('task', () => { expect(manifestManager.getLastComputedManifest).toHaveBeenCalled(); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(lastManifest); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ - ARTIFACT_EXCEPTIONS_MACOS, - ARTIFACT_TRUSTED_APPS_MACOS, - ]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_EXCEPTIONS_MACOS, ARTIFACT_TRUSTED_APPS_MACOS], + newManifest + ); expect(manifestManager.commit).toHaveBeenCalledWith(newManifest); expect(manifestManager.tryDispatch).toHaveBeenCalledWith(newManifest); expect(manifestManager.deleteArtifacts).not.toHaveBeenCalled(); @@ -284,7 +284,10 @@ describe('task', () => { expect(manifestManager.getLastComputedManifest).toHaveBeenCalled(); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(lastManifest); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ARTIFACT_TRUSTED_APPS_MACOS]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_TRUSTED_APPS_MACOS], + newManifest + ); expect(manifestManager.commit).toHaveBeenCalledWith(newManifest); expect(manifestManager.tryDispatch).toHaveBeenCalledWith(newManifest); expect(manifestManager.deleteArtifacts).toHaveBeenCalledWith([ARTIFACT_ID_1]); @@ -314,7 +317,7 @@ describe('task', () => { expect(manifestManager.getLastComputedManifest).toHaveBeenCalled(); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(lastManifest); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([], newManifest); expect(manifestManager.commit).toHaveBeenCalledWith(newManifest); expect(manifestManager.tryDispatch).toHaveBeenCalledWith(newManifest); expect(manifestManager.deleteArtifacts).toHaveBeenCalledWith([]); diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.ts index fc6d00d0c3e4fb..8588a30aceb897 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/task.ts @@ -130,7 +130,8 @@ export class ManifestTask { const diff = newManifest.diff(oldManifest); const persistErrors = await manifestManager.pushArtifacts( - diff.additions as InternalArtifactCompleteSchema[] + diff.additions as InternalArtifactCompleteSchema[], + newManifest ); if (persistErrors.length) { reportErrors(this.logger, persistErrors); diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/actions/status.ts b/x-pack/plugins/security_solution/server/endpoint/routes/actions/status.ts index faaf41962a96cf..66bb51b459c12d 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/actions/status.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/actions/status.ts @@ -10,7 +10,7 @@ import { TypeOf } from '@kbn/config-schema'; import { EndpointAction, EndpointActionResponse, - PendingActionsResponse, + EndpointPendingActions, } from '../../../../common/endpoint/types'; import { AGENT_ACTIONS_INDEX } from '../../../../../fleet/common'; import { ActionStatusRequestSchema } from '../../../../common/endpoint/schema/actions'; @@ -99,7 +99,7 @@ export const actionStatusRequestHandler = function ( const actionResponses = responseResults.body?.hits?.hits?.map((a) => a._source!) || []; // respond with action-count per agent - const response = agentIDs.map((aid) => { + const response: EndpointPendingActions[] = agentIDs.map((aid) => { const responseIDsFromAgent = actionResponses .filter((r) => r.agent_id === aid) .map((r) => r.action_id); @@ -115,8 +115,8 @@ export const actionStatusRequestHandler = function ( acc[cur] = 1; } return acc; - }, {} as PendingActionsResponse['pending_actions']), - } as PendingActionsResponse; + }, {} as EndpointPendingActions['pending_actions']), + }; }); return res.ok({ diff --git a/x-pack/plugins/security_solution/server/endpoint/schemas/artifacts/saved_objects.mock.ts b/x-pack/plugins/security_solution/server/endpoint/schemas/artifacts/saved_objects.mock.ts index 1975c2a92cc16f..7137c94ec71d20 100644 --- a/x-pack/plugins/security_solution/server/endpoint/schemas/artifacts/saved_objects.mock.ts +++ b/x-pack/plugins/security_solution/server/endpoint/schemas/artifacts/saved_objects.mock.ts @@ -5,33 +5,13 @@ * 2.0. */ -import { - buildArtifact, - maybeCompressArtifact, - isCompressed, - ArtifactConstants, -} from '../../lib/artifacts'; +import { buildArtifact, ArtifactConstants } from '../../lib/artifacts'; import { getTranslatedExceptionListMock } from './lists.mock'; -import { - InternalManifestSchema, - internalArtifactCompleteSchema, - InternalArtifactCompleteSchema, -} from './saved_objects'; - -const compressArtifact = async (artifact: InternalArtifactCompleteSchema) => { - const compressedArtifact = await maybeCompressArtifact(artifact); - if (!isCompressed(compressedArtifact)) { - throw new Error(`Unable to compress artifact: ${artifact.identifier}`); - } else if (!internalArtifactCompleteSchema.is(compressedArtifact)) { - throw new Error(`Incomplete artifact detected: ${artifact.identifier}`); - } - return compressedArtifact; -}; +import { InternalManifestSchema, InternalArtifactCompleteSchema } from './saved_objects'; export const getInternalArtifactMock = async ( os: string, schemaVersion: string, - opts?: { compress: boolean }, artifactName: string = ArtifactConstants.GLOBAL_ALLOWLIST_NAME ): Promise => { const artifact = await buildArtifact( @@ -40,23 +20,21 @@ export const getInternalArtifactMock = async ( os, artifactName ); - return opts?.compress ? compressArtifact(artifact) : artifact; + return artifact; }; export const getEmptyInternalArtifactMock = async ( os: string, schemaVersion: string, - opts?: { compress: boolean }, artifactName: string = ArtifactConstants.GLOBAL_ALLOWLIST_NAME ): Promise => { const artifact = await buildArtifact({ entries: [] }, schemaVersion, os, artifactName); - return opts?.compress ? compressArtifact(artifact) : artifact; + return artifact; }; export const getInternalArtifactMockWithDiffs = async ( os: string, - schemaVersion: string, - opts?: { compress: boolean } + schemaVersion: string ): Promise => { const mock = getTranslatedExceptionListMock(); mock.entries.pop(); @@ -66,7 +44,7 @@ export const getInternalArtifactMockWithDiffs = async ( os, ArtifactConstants.GLOBAL_ALLOWLIST_NAME ); - return opts?.compress ? compressArtifact(artifact) : artifact; + return artifact; }; export const getInternalManifestMock = (): InternalManifestSchema => ({ diff --git a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.test.ts b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.test.ts index 1dcac108338bb7..740068a836d057 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.test.ts @@ -29,7 +29,7 @@ describe('artifact_client', () => { }); test('can create artifact', async () => { - const artifact = await getInternalArtifactMock('linux', 'v1', { compress: true }); + const artifact = await getInternalArtifactMock('linux', 'v1'); await artifactClient.createArtifact(artifact); expect(fleetArtifactClient.createArtifact).toHaveBeenCalledWith({ identifier: artifact.identifier, diff --git a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.ts b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.ts index ef48ed1dd43f67..c0930980dffb9f 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/artifact_client.ts @@ -5,13 +5,9 @@ * 2.0. */ -import { inflate as _inflate } from 'zlib'; -import { promisify } from 'util'; import { InternalArtifactCompleteSchema } from '../../schemas/artifacts'; import { Artifact, ArtifactsClientInterface } from '../../../../../fleet/server'; -const inflateAsync = promisify(_inflate); - export interface EndpointArtifactClientInterface { getArtifact(id: string): Promise; @@ -56,12 +52,8 @@ export class EndpointArtifactClient implements EndpointArtifactClientInterface { async createArtifact( artifact: InternalArtifactCompleteSchema ): Promise { - // FIXME:PT refactor to make this more efficient by passing through the uncompressed artifact content - // Artifact `.body` is compressed/encoded. We need it decoded and as a string - const artifactContent = await inflateAsync(Buffer.from(artifact.body, 'base64')); - const createdArtifact = await this.fleetArtifacts.createArtifact({ - content: artifactContent.toString(), + content: Buffer.from(artifact.body, 'base64').toString(), identifier: artifact.identifier, type: this.parseArtifactId(artifact.identifier).type, }); diff --git a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts index e0bbfc351a20f1..87a73e0130113f 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts @@ -140,7 +140,7 @@ export const getManifestManagerMock = ( case ManifestManagerMockType.InitialSystemState: return null; case ManifestManagerMockType.NormalFlow: - return getMockManifest({ compress: true }); + return getMockManifest(); } }); diff --git a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.test.ts b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.test.ts index 7719dbf30c72bf..e3dc66c20bb671 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { inflateSync } from 'zlib'; import { savedObjectsClientMock } from 'src/core/server/mocks'; import { ENDPOINT_LIST_ID, @@ -27,7 +26,6 @@ import { import { ManifestConstants, getArtifactId, - isCompressed, translateToEndpointExceptions, Manifest, } from '../../../lib/artifacts'; @@ -40,10 +38,8 @@ import { import { ManifestManager } from './manifest_manager'; import { EndpointArtifactClientInterface } from '../artifact_client'; -const uncompressData = async (data: Buffer) => JSON.parse(await inflateSync(data).toString()); - -const uncompressArtifact = async (artifact: InternalArtifactSchema) => - uncompressData(Buffer.from(artifact.body!, 'base64')); +const getArtifactObject = (artifact: InternalArtifactSchema) => + JSON.parse(Buffer.from(artifact.body!, 'base64').toString()); describe('ManifestManager', () => { const TEST_POLICY_ID_1 = 'c6d16e42-c32d-4dce-8a88-113cfe276ad1'; @@ -77,7 +73,7 @@ describe('ManifestManager', () => { let ARTIFACT_TRUSTED_APPS_WINDOWS: InternalArtifactCompleteSchema; beforeAll(async () => { - ARTIFACTS = await getMockArtifacts({ compress: true }); + ARTIFACTS = await getMockArtifacts(); ARTIFACTS_BY_ID = { [ARTIFACT_ID_EXCEPTIONS_MACOS]: ARTIFACTS[0], [ARTIFACT_ID_EXCEPTIONS_WINDOWS]: ARTIFACTS[1], @@ -270,10 +266,9 @@ describe('ManifestManager', () => { expect(artifacts.length).toBe(9); expect(getArtifactIds(artifacts)).toStrictEqual(SUPPORTED_ARTIFACT_NAMES); - expect(artifacts.every(isCompressed)).toBe(true); for (const artifact of artifacts) { - expect(await uncompressArtifact(artifact)).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifact)).toStrictEqual({ entries: [] }); expect(manifest.isDefaultArtifact(artifact)).toBe(true); expect(manifest.getArtifactTargetPolicies(artifact)).toStrictEqual( new Set([TEST_POLICY_ID_1]) @@ -308,21 +303,20 @@ describe('ManifestManager', () => { expect(artifacts.length).toBe(9); expect(getArtifactIds(artifacts)).toStrictEqual(SUPPORTED_ARTIFACT_NAMES); - expect(artifacts.every(isCompressed)).toBe(true); - expect(await uncompressArtifact(artifacts[0])).toStrictEqual({ + expect(getArtifactObject(artifacts[0])).toStrictEqual({ entries: translateToEndpointExceptions([exceptionListItem], 'v1'), }); - expect(await uncompressArtifact(artifacts[1])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[2])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[3])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[4])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[5])).toStrictEqual({ + expect(getArtifactObject(artifacts[1])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[2])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[3])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[4])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[5])).toStrictEqual({ entries: translateToEndpointExceptions([trustedAppListItem], 'v1'), }); - expect(await uncompressArtifact(artifacts[6])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[7])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[8])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[6])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[7])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[8])).toStrictEqual({ entries: [] }); for (const artifact of artifacts) { expect(manifest.isDefaultArtifact(artifact)).toBe(true); @@ -364,19 +358,18 @@ describe('ManifestManager', () => { expect(artifacts.length).toBe(9); expect(getArtifactIds(artifacts)).toStrictEqual(SUPPORTED_ARTIFACT_NAMES); - expect(artifacts.every(isCompressed)).toBe(true); expect(artifacts[0]).toStrictEqual(oldManifest.getAllArtifacts()[0]); - expect(await uncompressArtifact(artifacts[1])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[2])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[3])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[4])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[5])).toStrictEqual({ + expect(getArtifactObject(artifacts[1])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[2])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[3])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[4])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[5])).toStrictEqual({ entries: translateToEndpointExceptions([trustedAppListItem], 'v1'), }); - expect(await uncompressArtifact(artifacts[6])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[7])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[8])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[6])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[7])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[8])).toStrictEqual({ entries: [] }); for (const artifact of artifacts) { expect(manifest.isDefaultArtifact(artifact)).toBe(true); @@ -426,27 +419,26 @@ describe('ManifestManager', () => { expect(artifacts.length).toBe(10); expect(getArtifactIds(artifacts)).toStrictEqual(SUPPORTED_ARTIFACT_NAMES); - expect(artifacts.every(isCompressed)).toBe(true); - expect(await uncompressArtifact(artifacts[0])).toStrictEqual({ + expect(getArtifactObject(artifacts[0])).toStrictEqual({ entries: translateToEndpointExceptions([exceptionListItem], 'v1'), }); - expect(await uncompressArtifact(artifacts[1])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[2])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[3])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[4])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[5])).toStrictEqual({ + expect(getArtifactObject(artifacts[1])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[2])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[3])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[4])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[5])).toStrictEqual({ entries: translateToEndpointExceptions([trustedAppListItem], 'v1'), }); - expect(await uncompressArtifact(artifacts[6])).toStrictEqual({ + expect(getArtifactObject(artifacts[6])).toStrictEqual({ entries: translateToEndpointExceptions( [trustedAppListItem, trustedAppListItemPolicy2], 'v1' ), }); - expect(await uncompressArtifact(artifacts[7])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[8])).toStrictEqual({ entries: [] }); - expect(await uncompressArtifact(artifacts[9])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[7])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[8])).toStrictEqual({ entries: [] }); + expect(getArtifactObject(artifacts[9])).toStrictEqual({ entries: [] }); for (const artifact of artifacts.slice(0, 5)) { expect(manifest.isDefaultArtifact(artifact)).toBe(true); @@ -520,9 +512,13 @@ describe('ManifestManager', () => { const context = buildManifestManagerContextMock({}); const artifactClient = context.artifactClient as jest.Mocked; const manifestManager = new ManifestManager(context); + const newManifest = ManifestManager.createDefaultManifest(); await expect( - manifestManager.pushArtifacts([ARTIFACT_EXCEPTIONS_MACOS, ARTIFACT_EXCEPTIONS_WINDOWS]) + manifestManager.pushArtifacts( + [ARTIFACT_EXCEPTIONS_MACOS, ARTIFACT_EXCEPTIONS_WINDOWS], + newManifest + ) ).resolves.toStrictEqual([]); expect(artifactClient.createArtifact).toHaveBeenCalledTimes(2); @@ -533,17 +529,18 @@ describe('ManifestManager', () => { ...ARTIFACT_EXCEPTIONS_WINDOWS, }); expect( - await uncompressData(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_MACOS))!) - ).toStrictEqual(await uncompressArtifact(ARTIFACT_EXCEPTIONS_MACOS)); + JSON.parse(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_MACOS))!.toString()) + ).toStrictEqual(getArtifactObject(ARTIFACT_EXCEPTIONS_MACOS)); expect( - await uncompressData(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_WINDOWS))!) - ).toStrictEqual(await uncompressArtifact(ARTIFACT_EXCEPTIONS_WINDOWS)); + JSON.parse(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_WINDOWS))!.toString()) + ).toStrictEqual(getArtifactObject(ARTIFACT_EXCEPTIONS_WINDOWS)); }); test('Returns errors for partial failures', async () => { const context = buildManifestManagerContextMock({}); const artifactClient = context.artifactClient as jest.Mocked; const manifestManager = new ManifestManager(context); + const newManifest = ManifestManager.createDefaultManifest(); const error = new Error(); const { body, ...incompleteArtifact } = ARTIFACT_TRUSTED_APPS_MACOS; @@ -558,11 +555,14 @@ describe('ManifestManager', () => { ); await expect( - manifestManager.pushArtifacts([ - ARTIFACT_EXCEPTIONS_MACOS, - ARTIFACT_EXCEPTIONS_WINDOWS, - incompleteArtifact as InternalArtifactCompleteSchema, - ]) + manifestManager.pushArtifacts( + [ + ARTIFACT_EXCEPTIONS_MACOS, + ARTIFACT_EXCEPTIONS_WINDOWS, + incompleteArtifact as InternalArtifactCompleteSchema, + ], + newManifest + ) ).resolves.toStrictEqual([ error, new Error(`Incomplete artifact: ${ARTIFACT_ID_TRUSTED_APPS_MACOS}`), @@ -573,8 +573,8 @@ describe('ManifestManager', () => { ...ARTIFACT_EXCEPTIONS_MACOS, }); expect( - await uncompressData(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_MACOS))!) - ).toStrictEqual(await uncompressArtifact(ARTIFACT_EXCEPTIONS_MACOS)); + JSON.parse(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_MACOS))!.toString()) + ).toStrictEqual(getArtifactObject(ARTIFACT_EXCEPTIONS_MACOS)); expect(context.cache.get(getArtifactId(ARTIFACT_EXCEPTIONS_WINDOWS))).toBeUndefined(); }); }); @@ -843,10 +843,7 @@ describe('ManifestManager', () => { artifacts: toArtifactRecords({ [ARTIFACT_NAME_EXCEPTIONS_MACOS]: await getEmptyInternalArtifactMock( 'macos', - 'v1', - { - compress: true, - } + 'v1' ), }), manifest_version: '1.0.0', diff --git a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.ts b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.ts index 6c25b6152938f7..27108a03f34033 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.ts @@ -25,9 +25,7 @@ import { getEndpointEventFiltersList, getEndpointExceptionList, getEndpointTrustedAppsList, - isCompressed, Manifest, - maybeCompressArtifact, } from '../../../lib/artifacts'; import { InternalArtifactCompleteSchema, @@ -239,13 +237,16 @@ export class ManifestManager { * Writes new artifact SO. * * @param artifact An InternalArtifactCompleteSchema representing the artifact. - * @returns {Promise} An error, if encountered, or null. + * @returns {Promise<[Error | null, InternalArtifactCompleteSchema | undefined]>} An array with the error if encountered or null and the generated artifact or null. */ - protected async pushArtifact(artifact: InternalArtifactCompleteSchema): Promise { + protected async pushArtifact( + artifact: InternalArtifactCompleteSchema + ): Promise<[Error | null, InternalArtifactCompleteSchema | undefined]> { const artifactId = getArtifactId(artifact); + let fleetArtifact; try { // Write the artifact SO - await this.artifactClient.createArtifact(artifact); + fleetArtifact = await this.artifactClient.createArtifact(artifact); // Cache the compressed body of the artifact this.cache.set(artifactId, Buffer.from(artifact.body, 'base64')); @@ -253,26 +254,32 @@ export class ManifestManager { if (this.savedObjectsClient.errors.isConflictError(err)) { this.logger.debug(`Tried to create artifact ${artifactId}, but it already exists.`); } else { - return err; + return [err, undefined]; } } - return null; + return [null, fleetArtifact]; } /** * Writes new artifact SOs. * * @param artifacts An InternalArtifactCompleteSchema array representing the artifacts. + * @param newManifest A Manifest representing the new manifest * @returns {Promise} Any errors encountered. */ - public async pushArtifacts(artifacts: InternalArtifactCompleteSchema[]): Promise { + public async pushArtifacts( + artifacts: InternalArtifactCompleteSchema[], + newManifest: Manifest + ): Promise { const errors: Error[] = []; for (const artifact of artifacts) { if (internalArtifactCompleteSchema.is(artifact)) { - const err = await this.pushArtifact(artifact); + const [err, fleetArtifact] = await this.pushArtifact(artifact); if (err) { errors.push(err); + } else if (fleetArtifact) { + newManifest.replaceArtifact(fleetArtifact); } } else { errors.push(new Error(`Incomplete artifact: ${getArtifactId(artifact)}`)); @@ -372,16 +379,10 @@ export class ManifestManager { for (const result of results) { await iterateArtifactsBuildResult(result, async (artifact, policyId) => { - let artifactToAdd = baselineManifest.getArtifact(getArtifactId(artifact)) || artifact; - - if (!isCompressed(artifactToAdd)) { - artifactToAdd = await maybeCompressArtifact(artifactToAdd); - - if (!isCompressed(artifactToAdd)) { - throw new Error(`Unable to compress artifact: ${getArtifactId(artifactToAdd)}`); - } else if (!internalArtifactCompleteSchema.is(artifactToAdd)) { - throw new Error(`Incomplete artifact detected: ${getArtifactId(artifactToAdd)}`); - } + const artifactToAdd = baselineManifest.getArtifact(getArtifactId(artifact)) || artifact; + artifactToAdd.compressionAlgorithm = 'none'; + if (!internalArtifactCompleteSchema.is(artifactToAdd)) { + throw new Error(`Incomplete artifact detected: ${getArtifactId(artifactToAdd)}`); } manifest.addEntry(artifactToAdd, policyId); diff --git a/x-pack/plugins/security_solution/server/fleet_integration/fleet_integration.test.ts b/x-pack/plugins/security_solution/server/fleet_integration/fleet_integration.test.ts index c0dc3a9343a7d8..1edcef6dec7224 100644 --- a/x-pack/plugins/security_solution/server/fleet_integration/fleet_integration.test.ts +++ b/x-pack/plugins/security_solution/server/fleet_integration/fleet_integration.test.ts @@ -100,7 +100,7 @@ describe('ingest_integration tests ', () => { let ARTIFACT_TRUSTED_APPS_WINDOWS: InternalArtifactCompleteSchema; beforeAll(async () => { - const artifacts = await getMockArtifacts({ compress: true }); + const artifacts = await getMockArtifacts(); ARTIFACT_EXCEPTIONS_MACOS = artifacts[0]; ARTIFACT_EXCEPTIONS_WINDOWS = artifacts[1]; ARTIFACT_TRUSTED_APPS_MACOS = artifacts[3]; @@ -147,7 +147,10 @@ describe('ingest_integration tests ', () => { ); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ARTIFACT_EXCEPTIONS_MACOS]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_EXCEPTIONS_MACOS], + newManifest + ); expect(manifestManager.commit).not.toHaveBeenCalled(); }); @@ -170,7 +173,10 @@ describe('ingest_integration tests ', () => { ); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ARTIFACT_EXCEPTIONS_MACOS]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_EXCEPTIONS_MACOS], + newManifest + ); expect(manifestManager.commit).toHaveBeenCalledWith(newManifest); }); @@ -197,10 +203,10 @@ describe('ingest_integration tests ', () => { ); expect(manifestManager.buildNewManifest).toHaveBeenCalledWith(); - expect(manifestManager.pushArtifacts).toHaveBeenCalledWith([ - ARTIFACT_EXCEPTIONS_MACOS, - ARTIFACT_TRUSTED_APPS_MACOS, - ]); + expect(manifestManager.pushArtifacts).toHaveBeenCalledWith( + [ARTIFACT_EXCEPTIONS_MACOS, ARTIFACT_TRUSTED_APPS_MACOS], + newManifest + ); expect(manifestManager.commit).toHaveBeenCalledWith(newManifest); }); diff --git a/x-pack/plugins/security_solution/server/fleet_integration/handlers/create_policy_artifact_manifest.ts b/x-pack/plugins/security_solution/server/fleet_integration/handlers/create_policy_artifact_manifest.ts index 8c2d612709ff33..2440a0a93187da 100644 --- a/x-pack/plugins/security_solution/server/fleet_integration/handlers/create_policy_artifact_manifest.ts +++ b/x-pack/plugins/security_solution/server/fleet_integration/handlers/create_policy_artifact_manifest.ts @@ -25,7 +25,8 @@ const getManifest = async (logger: Logger, manifestManager: ManifestManager): Pr // Persist new artifacts const persistErrors = await manifestManager.pushArtifacts( - newManifest.getAllArtifacts() as InternalArtifactCompleteSchema[] + newManifest.getAllArtifacts() as InternalArtifactCompleteSchema[], + newManifest ); if (persistErrors.length) { reportErrors(logger, persistErrors); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/__snapshots__/get_signals_template.test.ts.snap b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/__snapshots__/get_signals_template.test.ts.snap index 1abe55b782c328..4f060746b92b0c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/__snapshots__/get_signals_template.test.ts.snap +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/__snapshots__/get_signals_template.test.ts.snap @@ -7,7 +7,7 @@ Object { ], "mappings": Object { "_meta": Object { - "version": 35, + "version": 45, }, "dynamic": false, "properties": Object { @@ -365,6 +365,19 @@ Object { }, }, }, + "data_stream": Object { + "properties": Object { + "dataset": Object { + "type": "keyword", + }, + "namespace": Object { + "type": "keyword", + }, + "type": Object { + "type": "keyword", + }, + }, + }, "destination": Object { "properties": Object { "address": Object { @@ -1907,6 +1920,54 @@ Object { }, }, }, + "orchestrator": Object { + "properties": Object { + "api_version": Object { + "ignore_above": 1024, + "type": "keyword", + }, + "cluster": Object { + "properties": Object { + "name": Object { + "ignore_above": 1024, + "type": "keyword", + }, + "url": Object { + "ignore_above": 1024, + "type": "keyword", + }, + "version": Object { + "ignore_above": 1024, + "type": "keyword", + }, + }, + }, + "namespace": Object { + "ignore_above": 1024, + "type": "keyword", + }, + "organization": Object { + "ignore_above": 1024, + "type": "keyword", + }, + "resource": Object { + "properties": Object { + "name": Object { + "ignore_above": 1024, + "type": "keyword", + }, + "type": Object { + "ignore_above": 1024, + "type": "keyword", + }, + }, + }, + "type": Object { + "ignore_above": 1024, + "type": "keyword", + }, + }, + }, "organization": Object { "properties": Object { "id": Object { @@ -4467,6 +4528,6 @@ Object { }, }, }, - "version": 35, + "version": 45, } `; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json index 2967f4cb725e74..3d24384680f575 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/ecs_mapping.json @@ -1,10 +1,8 @@ { - "index_patterns": [ - "try-ecs-*" - ], + "index_patterns": ["try-ecs-*"], "mappings": { "_meta": { - "version": "1.9.0" + "version": "1.10.0" }, "date_detection": false, "dynamic_templates": [ @@ -331,6 +329,19 @@ } } }, + "data_stream": { + "properties": { + "dataset": { + "type": "keyword" + }, + "namespace": { + "type": "keyword" + }, + "type": { + "type": "keyword" + } + } + }, "destination": { "properties": { "address": { @@ -1802,6 +1813,54 @@ } } }, + "orchestrator": { + "properties": { + "api_version": { + "ignore_above": 1024, + "type": "keyword" + }, + "cluster": { + "properties": { + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "url": { + "ignore_above": 1024, + "type": "keyword" + }, + "version": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "namespace": { + "ignore_above": 1024, + "type": "keyword" + }, + "organization": { + "ignore_above": 1024, + "type": "keyword" + }, + "resource": { + "properties": { + "name": { + "ignore_above": 1024, + "type": "keyword" + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "type": { + "ignore_above": 1024, + "type": "keyword" + } + } + }, "organization": { "properties": { "id": { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.test.ts index 9c39ad4ee35982..4691db1b19595e 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.test.ts @@ -43,6 +43,49 @@ describe('get_signals_template', () => { expect(template.settings.mapping.total_fields.limit).toBeGreaterThanOrEqual(10000); }); + // If you see this test fail, you should track down any and all "constant_keyword" in your ecs_mapping.json and replace + // those with "keyword". The paths that fail in the array below will be something like: + // - Expected - 1 + // + Received + 5 + // + // - Array [] + // + Array [ + // + "mappings.properties.data_stream.properties.dataset", + // + "mappings.properties.data_stream.properties.namespace", + // + "mappings.properties.data_stream.properties.type", + // + ] + // which means that in your ecs_mapping you have paths such as "mappings.properties.data_stream.properties.dataset" which + // contain a constant_keyword which needs to be replaced with a normal keyword instead. + // + // The reason why we deviate from ECS standards here is because when you have a many to 1 relationship where you have + // several different indexes with different "constant_keyword" values you cannot copy them over into a single "constant_keyword". + // Instead you have to use "keyword". This test was first introduced when ECS 1.10 came out and data_stream.* values which had + // "constant_keyword" fields and we needed to change those to be "keyword" instead. + test('it should NOT have any "constant_keyword" and instead those should be replaced with regular "keyword" in the mapping', () => { + const template = getSignalsTemplate('test-index'); + + // Small recursive function to find any values of "constant_keyword" and mark which fields it was found on and then error on those fields + // The matchers from jest such as jest.toMatchObject do not support recursion, so I have to write it here: + // https://github.com/facebook/jest/issues/2506 + const recursiveConstantKeywordFound = (path: string, inputTemplate: object): string[] => + Object.entries(inputTemplate).reduce((accum, [key, innerValue]) => { + if (typeof innerValue === 'object') { + return [ + ...accum, + ...recursiveConstantKeywordFound(path !== '' ? `${path}.${key}` : key, innerValue), + ]; + } else { + if (key === 'type' && innerValue === 'constant_keyword') { + return [...accum, path]; + } else { + return accum; + } + } + }, []); + const constantKeywordsFound = recursiveConstantKeywordFound('', template); + expect(constantKeywordsFound).toEqual([]); + }); + test('it should match snapshot', () => { const template = getSignalsTemplate('test-index'); expect(template).toMatchSnapshot(); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts index 0318218ed59001..53035ebf28cd78 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template.ts @@ -22,7 +22,7 @@ import otherMapping from './other_mappings.json'; incremented by 10 in order to add "room" for the aforementioned patch release */ -export const SIGNALS_TEMPLATE_VERSION = 35; +export const SIGNALS_TEMPLATE_VERSION = 45; export const MIN_EQL_RULE_INDEX_VERSION = 2; export const getSignalsTemplate = (index: string) => { diff --git a/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts new file mode 100644 index 00000000000000..c68e307dbec03f --- /dev/null +++ b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.test.ts @@ -0,0 +1,939 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { CapacityEstimationParams, estimateCapacity } from './capacity_estimation'; +import { HealthStatus, RawMonitoringStats } from './monitoring_stats_stream'; + +describe('estimateCapacity', () => { + test('estimates the max throughput per minute based on the workload and the assumed kibana instances', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 60, + per_hour: 0, + per_day: 0, + }, + }, + { + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 0, + recurring: 100, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: 1, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: 200, + }); + }); + + test('reduces the available capacity per kibana when average task duration exceeds the poll interval', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 60, + per_hour: 0, + per_day: 0, + }, + }, + { + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 2400, + p90: 2500, + p95: 3200, + p99: 3500, + }, + non_recurring: { + p50: 1400, + p90: 1500, + p95: 2200, + p99: 3500, + }, + recurring: { + p50: 8345, + p90: 140651.5, + p95: 249199, + p99: 253150, + }, + }, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 0, + recurring: 100, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: 1, + minutes_to_drain_overdue: 0, + // on average it takes at least 50% of tasks 2 polling cycles before they complete + // this reduces the overall throughput of task manager + max_throughput_per_minute: 100, + }); + }); + + test('estimates the max throughput per minute when duration by persistence is empty', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 60, + per_hour: 0, + per_day: 0, + }, + }, + { + execution: { + duration: {}, + duration_by_persistence: {}, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 0, + recurring: 100, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: 1, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: 200, + }); + }); + + test('estimates the max throughput per minute based on the workload and the assumed kibana instances when there are tasks that repeat each hour or day', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 0, + per_hour: 12000, + per_day: 200, + }, + }, + { + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 0, + recurring: 100, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: 1, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: 200, + }); + }); + + test('estimates the max throughput available when there are no active Kibana', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + // 0 active tasks at this moment in time, so no owners identifiable + owner_ids: 0, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 60, + per_hour: 0, + per_day: 0, + }, + }, + { + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 0, + recurring: 100, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: 1, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: 200, + }); + }); + + test('estimates the max throughput available to handle the workload when there are multiple active kibana instances', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 3, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 150, + per_hour: 60, + per_day: 0, + }, + }, + { + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 0, + recurring: 100, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: 3, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: 3 * 200, // 3 kibana, 200tpm each + avg_required_throughput_per_minute: 150 + 1, // 150 every minute, plus 60 every hour + avg_required_throughput_per_minute_per_kibana: Math.ceil((150 + 1) / 3), + }); + }); + + test('estimates the max throughput available to handle the workload and historical non-recurring tasks when there are multiple active kibana instances', async () => { + const provisionedKibanaInstances = 2; + // 50% for non-recurring/epehemral + a 3rd of recurring task workload + const expectedAverageRequiredCapacityPerKibana = 200 * 0.5 + (150 + 1) / 2; + + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: provisionedKibanaInstances, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 150, + per_hour: 60, + per_day: 0, + }, + }, + { + load: { + p50: 40, + // assume running at 100% capacity + p90: 100, + p95: 100, + p99: 100, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + persistence: { + // 50% of tasks are non-recurring/ephemeral executions in the system in recent history + ephemeral: 25, + non_recurring: 25, + recurring: 50, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value.observed + ).toMatchObject({ + observed_kibana_instances: provisionedKibanaInstances, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: provisionedKibanaInstances * 200, // 2 kibana, 200tpm each + avg_required_throughput_per_minute_per_kibana: Math.ceil( + expectedAverageRequiredCapacityPerKibana + ), + avg_required_throughput_per_minute: Math.ceil( + provisionedKibanaInstances * expectedAverageRequiredCapacityPerKibana + ), // same as above but for both instances + }); + }); + + test('estimates the min required kibana instances when there is sufficient capacity for recurring but not for non-recurring/ephemeral', async () => { + const provisionedKibanaInstances = 2; + const recurringTasksPerMinute = 251; + // 50% for non-recurring/epehemral + half of recurring task workload + // there is insufficent capacity for this, but this is what the workload requires of the Kibana instances + const expectedAverageRequiredCapacityPerKibanaCurrently = + 200 * 0.5 + recurringTasksPerMinute / provisionedKibanaInstances; + const expectedAverageRequiredCapacityPerKibanaOnceThereAreEnoughServers = + // the non-recurring task load should now be shared between 3 server instead of 2 + (200 * 0.5 * provisionedKibanaInstances) / (provisionedKibanaInstances + 1) + + // so will the recurring tasks + recurringTasksPerMinute / (provisionedKibanaInstances + 1); + + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: provisionedKibanaInstances, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: recurringTasksPerMinute, + per_hour: 0, + per_day: 0, + }, + }, + { + load: { + p50: 40, + // assume running at 100% capacity + p90: 100, + p95: 100, + p99: 100, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + persistence: { + // 50% of tasks are non-recurring/ephemeral executions in the system in recent history + ephemeral: 25, + non_recurring: 25, + recurring: 50, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ).value + ).toMatchObject({ + observed: { + observed_kibana_instances: provisionedKibanaInstances, + minutes_to_drain_overdue: 0, + max_throughput_per_minute: provisionedKibanaInstances * 200, // 2 kibana, 200tpm each + avg_recurring_required_throughput_per_minute: Math.ceil(recurringTasksPerMinute), + avg_required_throughput_per_minute_per_kibana: Math.ceil( + expectedAverageRequiredCapacityPerKibanaCurrently + ), + avg_required_throughput_per_minute: Math.ceil( + provisionedKibanaInstances * expectedAverageRequiredCapacityPerKibanaCurrently + ), // same as above bt for both instances + }, + proposed: { + provisioned_kibana: provisionedKibanaInstances + 1, + min_required_kibana: provisionedKibanaInstances, + avg_recurring_required_throughput_per_minute_per_kibana: Math.ceil( + recurringTasksPerMinute / (provisionedKibanaInstances + 1) + ), + avg_required_throughput_per_minute_per_kibana: Math.ceil( + expectedAverageRequiredCapacityPerKibanaOnceThereAreEnoughServers + ), + }, + }); + }); + + test('marks estimated capacity as OK state when workload and load suggest capacity is sufficient', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 170, + per_hour: 0, + per_day: 0, + }, + }, + { + load: { + p50: 40, + // as avg p90 load is only 50%, it seems we have sufficient + // capacity, but if we saw a higher load (say 80% here), it would fail + // as status would be Warn (as seen in a previous test) + p90: 50, + p95: 80, + p99: 80, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // 20% average of non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 20, + recurring: 80, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ) + ).toMatchObject({ + status: 'OK', + timestamp: expect.any(String), + value: expect.any(Object), + }); + }); + + test('marks estimated capacity as Warning state when capacity is insufficient for recent spikes of non-recurring workload, but sufficient for the recurring workload', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 175, + per_hour: 0, + per_day: 0, + }, + }, + { + load: { + p50: 40, + p90: 100, + p95: 100, + p99: 100, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // no non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 20, + recurring: 80, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ) + ).toMatchObject({ + status: 'warn', + timestamp: expect.any(String), + value: expect.any(Object), + }); + }); + + test('marks estimated capacity as Error state when workload and load suggest capacity is insufficient', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 210, + per_hour: 0, + per_day: 0, + }, + }, + { + load: { + p50: 80, + p90: 100, + p95: 100, + p99: 100, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + // 20% average of non-recurring executions in the system in recent history + persistence: { + ephemeral: 0, + non_recurring: 20, + recurring: 80, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ) + ).toMatchObject({ + status: 'error', + timestamp: expect.any(String), + value: expect.any(Object), + }); + }); + + test('recommmends a 20% increase in kibana when a spike in non-recurring tasks forces recurring task capacity to zero', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 28, + per_hour: 27, + per_day: 2, + }, + }, + { + load: { + p50: 80, + p90: 100, + p95: 100, + p99: 100, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + persistence: { + recurring: 0, + non_recurring: 70, + ephemeral: 30, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ) + ).toMatchObject({ + status: 'warn', + timestamp: expect.any(String), + value: { + observed: { + observed_kibana_instances: 1, + avg_recurring_required_throughput_per_minute: 29, + // we obesrve 100% capacity on non-recurring/ephemeral tasks, which is 200tpm + // and add to that the 29tpm for recurring tasks + avg_required_throughput_per_minute_per_kibana: 229, + }, + proposed: { + provisioned_kibana: 2, + min_required_kibana: 1, + avg_recurring_required_throughput_per_minute_per_kibana: 15, + // once 2 kibana are provisioned, avg_required_throughput_per_minute_per_kibana is divided by 2, hence 115 + avg_required_throughput_per_minute_per_kibana: 115, + }, + }, + }); + }); + + test('recommmends a 20% increase in kibana when a spike in non-recurring tasks in a system with insufficient capacity even for recurring tasks', async () => { + expect( + estimateCapacity( + mockStats( + { max_workers: 10, poll_interval: 3000 }, + { + owner_ids: 1, + overdue_non_recurring: 0, + capacity_requirments: { + per_minute: 210, + per_hour: 0, + per_day: 0, + }, + }, + { + load: { + p50: 80, + p90: 100, + p95: 100, + p99: 100, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + persistence: { + recurring: 0, + non_recurring: 70, + ephemeral: 30, + }, + result_frequency_percent_as_number: {}, + }, + } + ) + ) + ).toMatchObject({ + status: 'error', + timestamp: expect.any(String), + value: { + observed: { + observed_kibana_instances: 1, + avg_recurring_required_throughput_per_minute: 210, + // we obesrve 100% capacity on non-recurring/ephemeral tasks, which is 200tpm + // and add to that the 210tpm for recurring tasks + avg_required_throughput_per_minute_per_kibana: 410, + }, + proposed: { + // we propose provisioning 3 instances for recurring + non-recurring/ephemeral + provisioned_kibana: 3, + // but need at least 2 for recurring + min_required_kibana: 2, + avg_recurring_required_throughput_per_minute_per_kibana: 210 / 3, + // once 3 kibana are provisioned, avg_required_throughput_per_minute_per_kibana is divided by 3, hence 137 + avg_required_throughput_per_minute_per_kibana: Math.ceil(410 / 3), + }, + }, + }); + }); +}); + +function mockStats( + configuration: Partial['configuration']['value']> = {}, + workload: Partial['workload']['value']> = {}, + runtime: Partial['runtime']['value']> = {} +): CapacityEstimationParams { + return { + configuration: { + status: HealthStatus.OK, + timestamp: new Date().toISOString(), + value: { + max_workers: 0, + poll_interval: 0, + max_poll_inactivity_cycles: 10, + request_capacity: 1000, + monitored_aggregated_stats_refresh_rate: 5000, + monitored_stats_running_average_window: 50, + monitored_task_execution_thresholds: { + default: { + error_threshold: 90, + warn_threshold: 80, + }, + custom: {}, + }, + ...configuration, + }, + }, + workload: { + status: HealthStatus.OK, + timestamp: new Date().toISOString(), + value: { + count: 4, + task_types: { + actions_telemetry: { count: 2, status: { idle: 2 } }, + alerting_telemetry: { count: 1, status: { idle: 1 } }, + session_cleanup: { count: 1, status: { idle: 1 } }, + }, + schedule: [], + overdue: 0, + overdue_non_recurring: 0, + estimated_schedule_density: [], + non_recurring: 20, + owner_ids: 2, + capacity_requirments: { + per_minute: 150, + per_hour: 360, + per_day: 820, + }, + ...workload, + }, + }, + runtime: { + status: HealthStatus.OK, + timestamp: new Date().toISOString(), + value: { + drift: { + p50: 4, + p90: 6, + p95: 6, + p99: 6, + }, + drift_by_type: {}, + load: { + p50: 40, + p90: 60, + p95: 60, + p99: 60, + }, + execution: { + duration: {}, + duration_by_persistence: { + ephemeral: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + non_recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + recurring: { + p50: 400, + p90: 500, + p95: 1200, + p99: 1500, + }, + }, + persistence: { + ephemeral: 0, + non_recurring: 30, + recurring: 70, + }, + result_frequency_percent_as_number: {}, + }, + polling: { + last_successful_poll: new Date().toISOString(), + duration: [], + claim_conflicts: [], + claim_mismatches: [], + result_frequency_percent_as_number: [], + }, + ...runtime, + }, + }, + }; +} diff --git a/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts new file mode 100644 index 00000000000000..35eb0dfca7a6bc --- /dev/null +++ b/x-pack/plugins/task_manager/server/monitoring/capacity_estimation.ts @@ -0,0 +1,253 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { mapValues } from 'lodash'; +import stats from 'stats-lite'; +import { JsonObject } from 'src/plugins/kibana_utils/common'; +import { RawMonitoringStats, RawMonitoredStat, HealthStatus } from './monitoring_stats_stream'; +import { AveragedStat } from './task_run_calcultors'; +import { TaskPersistenceTypes } from './task_run_statistics'; +import { asErr, asOk, map, Result } from '../lib/result_type'; + +export interface CapacityEstimationStat extends JsonObject { + observed: { + observed_kibana_instances: number; + max_throughput_per_minute: number; + max_throughput_per_minute_per_kibana: number; + minutes_to_drain_overdue: number; + avg_required_throughput_per_minute: number; + avg_required_throughput_per_minute_per_kibana: number; + avg_recurring_required_throughput_per_minute: number; + avg_recurring_required_throughput_per_minute_per_kibana: number; + }; + proposed: { + provisioned_kibana: number; + min_required_kibana: number; + avg_recurring_required_throughput_per_minute_per_kibana: number; + avg_required_throughput_per_minute_per_kibana: number; + }; +} + +export type CapacityEstimationParams = Omit< + Required, + 'capacity_estimation' +>; + +function isCapacityEstimationParams( + capacityStats: RawMonitoringStats['stats'] +): capacityStats is CapacityEstimationParams { + return !!(capacityStats.configuration && capacityStats.runtime && capacityStats.workload); +} + +export function estimateCapacity( + capacityStats: CapacityEstimationParams +): RawMonitoredStat { + const workload = capacityStats.workload.value; + // if there are no active owners right now, assume there's at least 1 + const assumedKibanaInstances = Math.max(workload.owner_ids, 1); + + const { + load: { p90: averageLoadPercentage }, + execution: { duration_by_persistence: durationByPersistence }, + } = capacityStats.runtime.value; + const { + recurring: percentageOfExecutionsUsedByRecurringTasks, + non_recurring: percentageOfExecutionsUsedByNonRecurringTasks, + } = capacityStats.runtime.value.execution.persistence; + const { overdue, capacity_requirments: capacityRequirments } = workload; + const { + poll_interval: pollInterval, + max_workers: maxWorkers, + } = capacityStats.configuration.value; + + /** + * On average, how many polling cycles does it take to execute a task? + * If this is higher than the polling cycle, then a whole cycle is wasted as + * we won't use the worker until the next cycle. + */ + const averagePollIntervalsPerExecution = Math.ceil( + map( + getAverageDuration(durationByPersistence), + (averageDuration) => Math.max(averageDuration, pollInterval), + () => pollInterval + ) / pollInterval + ); + + /** + * Given the current configuration how much task capacity do we have? + */ + const capacityPerMinutePerKibana = Math.round( + ((60 * 1000) / (averagePollIntervalsPerExecution * pollInterval)) * maxWorkers + ); + + /** + * If our assumption about the number of Kibana is correct - how much capacity do we have available? + */ + const assumedCapacityAvailablePerMinute = capacityPerMinutePerKibana * assumedKibanaInstances; + + /** + * assuming this Kibana is representative what capacity has historically been used for the + * different types at busy times (load at p90) + */ + const averageCapacityUsedByPersistedTasksPerKibana = percentageOf( + capacityPerMinutePerKibana, + percentageOf( + averageLoadPercentage, + percentageOfExecutionsUsedByRecurringTasks + percentageOfExecutionsUsedByNonRecurringTasks + ) + ); + /** + * On average, how much of this kibana's capacity has been historically used to execute + * non-recurring and ephemeral tasks + */ + const averageCapacityUsedByNonRecurringAndEphemeralTasksPerKibana = percentageOf( + capacityPerMinutePerKibana, + percentageOf(averageLoadPercentage, 100 - percentageOfExecutionsUsedByRecurringTasks) + ); + + /** + * On average, how much of this kibana's capacity has been historically available + * for recurring tasks + */ + const averageCapacityAvailableForRecurringTasksPerKibana = + capacityPerMinutePerKibana - averageCapacityUsedByNonRecurringAndEphemeralTasksPerKibana; + + /** + * At times a cluster might experience spikes of NonRecurring/Ephemeral tasks which swamp Task Manager + * causing it to spend all its capacity on NonRecurring/Ephemeral tasks, which makes it much harder + * to estimate the required capacity. + * This is easy to identify as load will usually max out or all the workers are busy executing non-recurring + * or ephemeral tasks, and none are running recurring tasks. + */ + const hasTooLittleCapacityToEstimateRequiredNonRecurringCapacity = + averageLoadPercentage === 100 || averageCapacityAvailableForRecurringTasksPerKibana === 0; + + /** + * On average, how many tasks per minute does this cluster need to execute? + */ + const averageRecurringRequiredPerMinute = + capacityRequirments.per_minute + + capacityRequirments.per_hour / 60 + + capacityRequirments.per_day / 24 / 60; + + /** + * how many Kibana are needed solely for the recurring tasks + */ + const minRequiredKibanaInstancesForRecurringTasks = Math.ceil( + averageRecurringRequiredPerMinute / capacityPerMinutePerKibana + ); + + /** + * assuming each kibana only has as much capacity for recurring tasks as this kibana has historically + * had available - how many kibana are needed to handle the current recurring workload? + */ + const minRequiredKibanaInstances = Math.ceil( + hasTooLittleCapacityToEstimateRequiredNonRecurringCapacity + ? /* + if load is at 100% or there's no capacity for recurring tasks at the moment, then it's really difficult for us to assess how + much capacity is needed for non-recurring tasks at normal times. This might be representative, but it might + also be a spike and we have no way of knowing that. We'll recommend people scale up by 20% and go from there. */ + minRequiredKibanaInstancesForRecurringTasks * 1.2 + : averageRecurringRequiredPerMinute / averageCapacityAvailableForRecurringTasksPerKibana + ); + + /** + * Assuming the `minRequiredKibanaInstances` Kibana instances are provisioned - how much + * of their throughput would we expect to be used by the recurring task workload + */ + const averageRecurringRequiredPerMinutePerKibana = + averageRecurringRequiredPerMinute / minRequiredKibanaInstances; + + /** + * assuming the historical capacity needed for ephemeral and non-recurring tasks, plus + * the amount we know each kibana would need for recurring tasks, how much capacity would + * each kibana need if following the minRequiredKibanaInstances? + */ + const averageRequiredThroughputPerMinutePerKibana = + averageCapacityUsedByNonRecurringAndEphemeralTasksPerKibana * + (assumedKibanaInstances / minRequiredKibanaInstances) + + averageRecurringRequiredPerMinute / minRequiredKibanaInstances; + + const assumedAverageRecurringRequiredThroughputPerMinutePerKibana = + averageRecurringRequiredPerMinute / assumedKibanaInstances; + /** + * assuming the historical capacity needed for ephemeral and non-recurring tasks, plus + * the amount we know each kibana would need for recurring tasks, how much capacity would + * each kibana need if the assumed current number were correct? + */ + const assumedRequiredThroughputPerMinutePerKibana = + averageCapacityUsedByNonRecurringAndEphemeralTasksPerKibana + + averageRecurringRequiredPerMinute / assumedKibanaInstances; + + return { + status: + assumedRequiredThroughputPerMinutePerKibana < capacityPerMinutePerKibana + ? HealthStatus.OK + : assumedAverageRecurringRequiredThroughputPerMinutePerKibana < capacityPerMinutePerKibana + ? HealthStatus.Warning + : HealthStatus.Error, + timestamp: new Date().toISOString(), + value: { + observed: mapValues( + { + observed_kibana_instances: assumedKibanaInstances, + max_throughput_per_minute_per_kibana: capacityPerMinutePerKibana, + max_throughput_per_minute: assumedCapacityAvailablePerMinute, + minutes_to_drain_overdue: + overdue / (assumedKibanaInstances * averageCapacityUsedByPersistedTasksPerKibana), + avg_recurring_required_throughput_per_minute: averageRecurringRequiredPerMinute, + avg_recurring_required_throughput_per_minute_per_kibana: assumedAverageRecurringRequiredThroughputPerMinutePerKibana, + avg_required_throughput_per_minute: + assumedRequiredThroughputPerMinutePerKibana * assumedKibanaInstances, + avg_required_throughput_per_minute_per_kibana: assumedRequiredThroughputPerMinutePerKibana, + }, + Math.ceil + ), + proposed: mapValues( + { + provisioned_kibana: minRequiredKibanaInstances, + min_required_kibana: minRequiredKibanaInstancesForRecurringTasks, + avg_recurring_required_throughput_per_minute_per_kibana: averageRecurringRequiredPerMinutePerKibana, + avg_required_throughput_per_minute_per_kibana: averageRequiredThroughputPerMinutePerKibana, + }, + Math.ceil + ), + }, + }; +} + +export function withCapacityEstimate( + monitoredStats: RawMonitoringStats['stats'] +): RawMonitoringStats['stats'] { + if (isCapacityEstimationParams(monitoredStats)) { + return { + ...monitoredStats, + capacity_estimation: estimateCapacity(monitoredStats), + }; + } + return monitoredStats; +} + +function percentageOf(val: number, percentage: number) { + return Math.round((percentage * val) / 100); +} + +function getAverageDuration( + durations: Partial> +): Result { + const result = stats.mean( + [ + durations.ephemeral?.p50 ?? 0, + durations.non_recurring?.p50 ?? 0, + durations.recurring?.p50 ?? 0, + ].filter((val) => val > 0) + ); + if (isNaN(result)) { + return asErr(result); + } + return asOk(result); +} diff --git a/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.ts b/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.ts index 885c48a2165b1b..8338bf3197162e 100644 --- a/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.ts +++ b/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.ts @@ -15,6 +15,7 @@ import { TaskPollingLifecycle } from '../polling_lifecycle'; import { createWorkloadAggregator, summarizeWorkloadStat, + SummarizedWorkloadStat, WorkloadStat, } from './workload_statistics'; import { @@ -27,6 +28,7 @@ import { ConfigStat, createConfigurationAggregator } from './configuration_stati import { TaskManagerConfig } from '../config'; import { AggregatedStatProvider } from './runtime_statistics_aggregator'; import { ManagedConfiguration } from '../lib/create_managed_configuration'; +import { CapacityEstimationStat, withCapacityEstimate } from './capacity_estimation'; export { AggregatedStatProvider, AggregatedStat } from './runtime_statistics_aggregator'; @@ -49,7 +51,8 @@ interface MonitoredStat { timestamp: string; value: T; } -type RawMonitoredStat = MonitoredStat & { + +export type RawMonitoredStat = MonitoredStat & { status: HealthStatus; }; @@ -57,8 +60,9 @@ export interface RawMonitoringStats { last_update: string; stats: { configuration?: RawMonitoredStat; - workload?: RawMonitoredStat; + workload?: RawMonitoredStat; runtime?: RawMonitoredStat; + capacity_estimation?: RawMonitoredStat; }; } @@ -120,33 +124,35 @@ export function summarizeMonitoringStats( }: MonitoringStats, config: TaskManagerConfig ): RawMonitoringStats { + const summarizedStats = withCapacityEstimate({ + ...(configuration + ? { + configuration: { + ...configuration, + status: HealthStatus.OK, + }, + } + : {}), + ...(runtime + ? { + runtime: { + timestamp: runtime.timestamp, + ...summarizeTaskRunStat(runtime.value, config), + }, + } + : {}), + ...(workload + ? { + workload: { + timestamp: workload.timestamp, + ...summarizeWorkloadStat(workload.value), + }, + } + : {}), + }); + return { last_update, - stats: { - ...(configuration - ? { - configuration: { - ...configuration, - status: HealthStatus.OK, - }, - } - : {}), - ...(runtime - ? { - runtime: { - timestamp: runtime.timestamp, - ...summarizeTaskRunStat(runtime.value, config), - }, - } - : {}), - ...(workload - ? { - workload: { - timestamp: workload.timestamp, - ...summarizeWorkloadStat(workload.value), - }, - } - : {}), - }, + stats: summarizedStats, }; } diff --git a/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts b/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts index 7040d5acd4eaf3..38fdc89278e893 100644 --- a/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts @@ -387,6 +387,149 @@ describe('Task Run Statistics', () => { }); }); + test('frequency of executed tasks by their persistence', async () => { + const events$ = new Subject(); + + const taskPollingLifecycle = taskPollingLifecycleMock.create({ + events$: events$ as Observable, + }); + + const runningAverageWindowSize = 5; + const taskRunAggregator = createTaskRunAggregator( + taskPollingLifecycle, + runningAverageWindowSize + ); + + return new Promise((resolve, reject) => { + taskRunAggregator + .pipe( + // skip initial stat which is just initialized data which + // ensures we don't stall on combineLatest + skip(1), + // Use 'summarizeTaskRunStat' to receive summarize stats + map(({ key, value }: AggregatedStat) => ({ + key, + value: summarizeTaskRunStat( + value, + getTaskManagerConfig({ + monitored_task_execution_thresholds: { + custom: { + 'alerting:test': { + error_threshold: 59, + warn_threshold: 39, + }, + }, + }, + }) + ).value, + })), + take(10), + bufferCount(10) + ) + .subscribe((taskStats: Array>) => { + try { + /** + * At any given time we only keep track of the last X Polling Results + * In the tests this is ocnfiugured to a window size of 5 + */ + expect(taskStats.map((taskStat) => taskStat.value.execution.persistence)) + .toMatchInlineSnapshot(` + Array [ + Object { + "ephemeral": 0, + "non_recurring": 100, + "recurring": 0, + }, + Object { + "ephemeral": 0, + "non_recurring": 100, + "recurring": 0, + }, + Object { + "ephemeral": 0, + "non_recurring": 67, + "recurring": 33, + }, + Object { + "ephemeral": 0, + "non_recurring": 75, + "recurring": 25, + }, + Object { + "ephemeral": 0, + "non_recurring": 80, + "recurring": 20, + }, + Object { + "ephemeral": 0, + "non_recurring": 60, + "recurring": 40, + }, + Object { + "ephemeral": 0, + "non_recurring": 40, + "recurring": 60, + }, + Object { + "ephemeral": 0, + "non_recurring": 60, + "recurring": 40, + }, + Object { + "ephemeral": 0, + "non_recurring": 60, + "recurring": 40, + }, + Object { + "ephemeral": 0, + "non_recurring": 40, + "recurring": 60, + }, + ] + `); + resolve(); + } catch (e) { + reject(e); + } + }); + + events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Success)); + events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Success)); + events$.next( + mockTaskRunEvent( + { schedule: { interval: '3s' } }, + { start: 0, stop: 0 }, + TaskRunResult.Success + ) + ); + events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Failed)); + events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Failed)); + events$.next( + mockTaskRunEvent( + { schedule: { interval: '3s' } }, + { start: 0, stop: 0 }, + TaskRunResult.Failed + ) + ); + events$.next( + mockTaskRunEvent( + { schedule: { interval: '3s' } }, + { start: 0, stop: 0 }, + TaskRunResult.RetryScheduled + ) + ); + events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.RetryScheduled)); + events$.next(mockTaskRunEvent({}, { start: 0, stop: 0 }, TaskRunResult.Success)); + events$.next( + mockTaskRunEvent( + { schedule: { interval: '3s' } }, + { start: 0, stop: 0 }, + TaskRunResult.Success + ) + ); + }); + }); + test('returns polling stats', async () => { const expectedTimestamp: string[] = []; const events$ = new Subject(); diff --git a/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.ts b/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.ts index 3185d3c449c32c..eb6cb0796c33cc 100644 --- a/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.ts +++ b/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.ts @@ -7,7 +7,7 @@ import { combineLatest, Observable } from 'rxjs'; import { filter, startWith, map } from 'rxjs/operators'; -import { JsonObject } from 'src/plugins/kibana_utils/common'; +import { JsonObject, JsonValue } from 'src/plugins/kibana_utils/common'; import { isNumber, mapValues } from 'lodash'; import { AggregatedStatProvider, AggregatedStat } from './runtime_statistics_aggregator'; import { TaskLifecycleEvent } from '../polling_lifecycle'; @@ -36,6 +36,16 @@ import { HealthStatus } from './monitoring_stats_stream'; import { TaskPollingLifecycle } from '../polling_lifecycle'; import { TaskExecutionFailureThreshold, TaskManagerConfig } from '../config'; +export enum TaskPersistence { + Recurring = 'recurring', + NonRecurring = 'non_recurring', + Ephemeral = 'ephemeral', +} + +function persistenceOf(task: ConcreteTaskInstance) { + return task.schedule ? TaskPersistence.Recurring : TaskPersistence.NonRecurring; +} + interface FillPoolStat extends JsonObject { last_successful_poll: string; last_polling_delay: string; @@ -48,7 +58,9 @@ interface FillPoolStat extends JsonObject { interface ExecutionStat extends JsonObject { duration: Record; + duration_by_persistence: Record; result_frequency_percent_as_number: Record; + persistence: TaskPersistence[]; } export interface TaskRunStat extends JsonObject { @@ -79,6 +91,11 @@ interface ResultFrequency extends JsonObject { [TaskRunResult.RetryScheduled]: number; [TaskRunResult.Failed]: number; } +export interface TaskPersistenceTypes extends JsonObject { + [TaskPersistence.Recurring]: T; + [TaskPersistence.NonRecurring]: T; + [TaskPersistence.Ephemeral]: T; +} type ResultFrequencySummary = ResultFrequency & { status: HealthStatus; @@ -89,7 +106,9 @@ export interface SummarizedTaskRunStat extends JsonObject { load: AveragedStat; execution: { duration: Record; + duration_by_persistence: Record; result_frequency_percent_as_number: Record; + persistence: TaskPersistenceTypes; }; polling: FillPoolRawStat | Omit; } @@ -100,7 +119,7 @@ export function createTaskRunAggregator( ): AggregatedStatProvider { const taskRunEventToStat = createTaskRunEventToStat(runningAverageWindowSize); const taskRunEvents$: Observable< - Pick + Pick > = taskPollingLifecycle.events.pipe( filter((taskEvent: TaskLifecycleEvent) => isTaskRunEvent(taskEvent) && hasTiming(taskEvent)), map((taskEvent: TaskLifecycleEvent) => { @@ -202,7 +221,16 @@ export function createTaskRunAggregator( startWith({ drift: [], drift_by_type: {}, - execution: { duration: {}, result_frequency_percent_as_number: {} }, + execution: { + duration: {}, + duration_by_persistence: { + [TaskPersistence.Recurring]: [], + [TaskPersistence.NonRecurring]: [], + [TaskPersistence.Ephemeral]: [], + }, + result_frequency_percent_as_number: {}, + persistence: [], + }, }) ), taskManagerLoadStatEvents$.pipe(startWith({ load: [] })), @@ -243,8 +271,12 @@ function hasTiming(taskEvent: TaskLifecycleEvent) { function createTaskRunEventToStat(runningAverageWindowSize: number) { const driftQueue = createRunningAveragedStat(runningAverageWindowSize); + const taskPersistenceQueue = createRunningAveragedStat(runningAverageWindowSize); const driftByTaskQueue = createMapOfRunningAveragedStats(runningAverageWindowSize); const taskRunDurationQueue = createMapOfRunningAveragedStats(runningAverageWindowSize); + const taskRunDurationByPersistenceQueue = createMapOfRunningAveragedStats( + runningAverageWindowSize + ); const resultFrequencyQueue = createMapOfRunningAveragedStats( runningAverageWindowSize ); @@ -252,13 +284,17 @@ function createTaskRunEventToStat(runningAverageWindowSize: number) { task: ConcreteTaskInstance, timing: TaskTiming, result: TaskRunResult - ): Omit => { + ): Pick => { const drift = timing!.start - task.runAt.getTime(); + const duration = timing!.stop - timing!.start; + const persistence = persistenceOf(task); return { drift: driftQueue(drift), drift_by_type: driftByTaskQueue(task.taskType, drift), execution: { - duration: taskRunDurationQueue(task.taskType, timing!.stop - timing!.start), + persistence: taskPersistenceQueue(persistence), + duration: taskRunDurationQueue(task.taskType, duration), + duration_by_persistence: taskRunDurationByPersistenceQueue(persistence as string, duration), result_frequency_percent_as_number: resultFrequencyQueue(task.taskType, result), }, }; @@ -279,6 +315,11 @@ const DEFAULT_POLLING_FREQUENCIES = { [FillPoolResult.RunningAtCapacity]: 0, [FillPoolResult.PoolFilled]: 0, }; +const DEFAULT_PERSISTENCE_FREQUENCIES = { + [TaskPersistence.Recurring]: 0, + [TaskPersistence.NonRecurring]: 0, + [TaskPersistence.Ephemeral]: 0, +}; export function summarizeTaskRunStat( { @@ -298,7 +339,12 @@ export function summarizeTaskRunStat( // eslint-disable-next-line @typescript-eslint/naming-convention drift_by_type, load, - execution: { duration, result_frequency_percent_as_number: executionResultFrequency }, + execution: { + duration, + duration_by_persistence: durationByPersistence, + persistence, + result_frequency_percent_as_number: executionResultFrequency, + }, }: TaskRunStat, config: TaskManagerConfig ): { value: SummarizedTaskRunStat; status: HealthStatus } { @@ -323,6 +369,13 @@ export function summarizeTaskRunStat( load: calculateRunningAverage(load), execution: { duration: mapValues(duration, (typedDurations) => calculateRunningAverage(typedDurations)), + duration_by_persistence: mapValues(durationByPersistence, (typedDurations) => + calculateRunningAverage(typedDurations) + ), + persistence: { + ...DEFAULT_PERSISTENCE_FREQUENCIES, + ...calculateFrequency(persistence), + }, result_frequency_percent_as_number: mapValues( executionResultFrequency, (typedResultFrequencies, taskType) => diff --git a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts index f3ee21bc7d7704..e88144f2b4a355 100644 --- a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts @@ -61,6 +61,12 @@ describe('Workload Statistics Aggregator', () => { doc_count_error_upper_bound: 0, sum_other_doc_count: 0, }, + nonRecurringTasks: { + doc_count: 13, + }, + ownerIds: { + value: 1, + }, // The `FiltersAggregate` doesn't cover the case of a nested `AggregationsAggregationContainer`, in which `FiltersAggregate` // would not have a `buckets` property, but rather a keyed property that's inferred from the request. // @ts-expect-error @@ -68,6 +74,9 @@ describe('Workload Statistics Aggregator', () => { doc_count: 0, overdue: { doc_count: 0, + nonRecurring: { + doc_count: 0, + }, }, scheduleDensity: { buckets: [ @@ -114,6 +123,14 @@ describe('Workload Statistics Aggregator', () => { field: 'task.schedule.interval', }, }, + nonRecurringTasks: { + missing: { field: 'task.schedule' }, + }, + ownerIds: { + cardinality: { + field: 'task.ownerId', + }, + }, idleTasks: { filter: { term: { 'task.status': 'idle' }, @@ -146,6 +163,11 @@ describe('Workload Statistics Aggregator', () => { 'task.runAt': { lt: 'now' }, }, }, + aggs: { + nonRecurring: { + missing: { field: 'task.schedule' }, + }, + }, }, }, }, @@ -238,6 +260,12 @@ describe('Workload Statistics Aggregator', () => { }, ], }, + nonRecurringTasks: { + doc_count: 13, + }, + ownerIds: { + value: 1, + }, // The `FiltersAggregate` doesn't cover the case of a nested `AggregationsAggregationContainer`, in which `FiltersAggregate` // would not have a `buckets` property, but rather a keyed property that's inferred from the request. // @ts-expect-error @@ -245,6 +273,9 @@ describe('Workload Statistics Aggregator', () => { doc_count: 13, overdue: { doc_count: 6, + nonRecurring: { + doc_count: 6, + }, }, scheduleDensity: { buckets: [ @@ -496,6 +527,115 @@ describe('Workload Statistics Aggregator', () => { }); }); + test('returns an estimate of the workload by task type', async () => { + // poll every 3 seconds + const pollingIntervalInSeconds = 3; + + const taskStore = taskStoreMock.create({}); + taskStore.aggregate.mockResolvedValue( + asApiResponse({ + hits: { + hits: [], + max_score: 0, + total: { value: 4, relation: 'eq' }, + }, + took: 1, + timed_out: false, + _shards: { + total: 1, + successful: 1, + skipped: 1, + failed: 0, + }, + aggregations: { + schedule: { + doc_count_error_upper_bound: 0, + sum_other_doc_count: 0, + buckets: [ + // repeats each cycle + { + key: `${pollingIntervalInSeconds}s`, + doc_count: 1, + }, + { + key: `10s`, // 6 times per minute + doc_count: 20, + }, + { + key: `60s`, // 1 times per minute + doc_count: 10, + }, + { + key: '15m', // 4 times per hour + doc_count: 90, + }, + { + key: '720m', // 2 times per day + doc_count: 10, + }, + { + key: '3h', // 8 times per day + doc_count: 100, + }, + ], + }, + taskType: { + doc_count_error_upper_bound: 0, + sum_other_doc_count: 0, + buckets: [], + }, + nonRecurringTasks: { + doc_count: 13, + }, + ownerIds: { + value: 3, + }, + // The `FiltersAggregate` doesn't cover the case of a nested `AggregationContainer`, in which `FiltersAggregate` + // would not have a `buckets` property, but rather a keyed property that's inferred from the request. + // @ts-expect-error + idleTasks: { + doc_count: 13, + overdue: { + doc_count: 6, + nonRecurring: { + doc_count: 0, + }, + }, + scheduleDensity: { + buckets: [ + mockHistogram(0, 7 * 3000 + 500, 60 * 1000, 3000, [2, 2, 5, 0, 0, 0, 0, 0, 0, 1]), + ], + }, + }, + }, + }) + ); + + const workloadAggregator = createWorkloadAggregator( + taskStore, + of(true), + 10, + pollingIntervalInSeconds * 1000, + loggingSystemMock.create().get() + ); + + return new Promise((resolve) => { + workloadAggregator.pipe(first()).subscribe((result) => { + expect(result.key).toEqual('workload'); + + expect(result.value).toMatchObject({ + capacity_requirments: { + // these are buckets of required capacity, rather than aggregated requirmenets. + per_minute: 150, + per_hour: 360, + per_day: 820, + }, + }); + resolve(); + }); + }); + }); + test('recovery after errors occurrs at the next interval', async () => { const refreshInterval = 1000; diff --git a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts index e251ce07679ffb..669f6198325485 100644 --- a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts +++ b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts @@ -16,6 +16,7 @@ import { parseIntervalAsSecond, asInterval, parseIntervalAsMillisecond } from '. import { AggregationResultOf } from '../../../../../typings/elasticsearch'; import { HealthStatus } from './monitoring_stats_stream'; import { TaskStore } from '../task_store'; +import { createRunningAveragedStat } from './task_run_calcultors'; interface StatusStat extends JsonObject { [status: string]: number; @@ -27,12 +28,27 @@ interface TaskTypeStat extends JsonObject { }; } -export interface WorkloadStat extends JsonObject { +interface RawWorkloadStat extends JsonObject { count: number; task_types: TaskTypeStat; schedule: Array<[string, number]>; + non_recurring: number; overdue: number; + overdue_non_recurring: number; estimated_schedule_density: number[]; + capacity_requirments: CapacityRequirments; +} + +export interface WorkloadStat extends RawWorkloadStat { + owner_ids: number[]; +} +export interface SummarizedWorkloadStat extends RawWorkloadStat { + owner_ids: number; +} +export interface CapacityRequirments extends JsonObject { + per_minute: number; + per_hour: number; + per_day: number; } export interface WorkloadAggregation { @@ -109,6 +125,8 @@ export function createWorkloadAggregator( MAX_SHCEDULE_DENSITY_BUCKETS ); + const ownerIdsQueue = createRunningAveragedStat(scheduleDensityBuckets); + return combineLatest([timer(0, refreshInterval), elasticsearchAndSOAvailability$]).pipe( filter(([, areElasticsearchAndSOAvailable]) => areElasticsearchAndSOAvailable), mergeMap(() => @@ -125,6 +143,14 @@ export function createWorkloadAggregator( schedule: { terms: { field: 'task.schedule.interval' }, }, + nonRecurringTasks: { + missing: { field: 'task.schedule' }, + }, + ownerIds: { + cardinality: { + field: 'task.ownerId', + }, + }, idleTasks: { filter: { term: { 'task.status': 'idle' }, @@ -163,6 +189,11 @@ export function createWorkloadAggregator( 'task.runAt': { lt: 'now' }, }, }, + aggs: { + nonRecurring: { + missing: { field: 'task.schedule' }, + }, + }, }, }, }, @@ -181,13 +212,51 @@ export function createWorkloadAggregator( } const taskTypes = aggregations.taskType.buckets; - const schedules = aggregations.schedule.buckets; + const nonRecurring = aggregations.nonRecurringTasks.doc_count; + const ownerIds = aggregations.ownerIds.value; const { - overdue: { doc_count: overdue }, + overdue: { + doc_count: overdue, + nonRecurring: { doc_count: overdueNonRecurring }, + }, scheduleDensity: { buckets: [scheduleDensity] = [] } = {}, } = aggregations.idleTasks; + const { schedules, cadence } = aggregations.schedule.buckets.reduce( + (accm, schedule) => { + const parsedSchedule = { + interval: schedule.key as string, + asSeconds: parseIntervalAsSecond(schedule.key as string), + count: schedule.doc_count, + }; + accm.schedules.push(parsedSchedule); + if (parsedSchedule.asSeconds <= 60) { + accm.cadence.perMinute += + parsedSchedule.count * Math.round(60 / parsedSchedule.asSeconds); + } else if (parsedSchedule.asSeconds <= 3600) { + accm.cadence.perHour += + parsedSchedule.count * Math.round(3600 / parsedSchedule.asSeconds); + } else { + accm.cadence.perDay += + parsedSchedule.count * Math.round((3600 * 24) / parsedSchedule.asSeconds); + } + return accm; + }, + { + cadence: { + perMinute: 0, + perHour: 0, + perDay: 0, + }, + schedules: [] as Array<{ + interval: string; + asSeconds: number; + count: number; + }>, + } + ); + const summary: WorkloadStat = { count, task_types: mapValues(keyBy(taskTypes, 'key'), ({ doc_count: docCount, status }) => { @@ -196,19 +265,23 @@ export function createWorkloadAggregator( status: mapValues(keyBy(status.buckets, 'key'), 'doc_count'), }; }), + non_recurring: nonRecurring, + owner_ids: ownerIdsQueue(ownerIds), schedule: schedules - .sort( - (scheduleLeft, scheduleRight) => - parseIntervalAsSecond(scheduleLeft.key as string) - - parseIntervalAsSecond(scheduleRight.key as string) - ) - .map((schedule) => [schedule.key as string, schedule.doc_count]), + .sort((scheduleLeft, scheduleRight) => scheduleLeft.asSeconds - scheduleRight.asSeconds) + .map((schedule) => [schedule.interval, schedule.count]), overdue, + overdue_non_recurring: overdueNonRecurring, estimated_schedule_density: padBuckets( scheduleDensityBuckets, pollInterval, scheduleDensity ), + capacity_requirments: { + per_minute: cadence.perMinute, + per_hour: cadence.perHour, + per_day: cadence.perDay, + }, }; return { key: 'workload', @@ -344,9 +417,14 @@ export function estimateRecurringTaskScheduling( export function summarizeWorkloadStat( workloadStats: WorkloadStat -): { value: WorkloadStat; status: HealthStatus } { +): { value: SummarizedWorkloadStat; status: HealthStatus } { return { - value: workloadStats, + value: { + ...workloadStats, + // assume the largest number we've seen of active owner IDs + // matches the number of active Task Managers in the cluster + owner_ids: Math.max(...workloadStats.owner_ids), + }, status: HealthStatus.OK, }; } @@ -365,6 +443,12 @@ export interface WorkloadAggregationResponse { taskType: TaskTypeAggregation; schedule: ScheduleAggregation; idleTasks: IdleTasksAggregation; + nonRecurringTasks: { + doc_count: number; + }; + ownerIds: { + value: number; + }; [otherAggs: string]: estypes.AggregationsAggregate; } export interface TaskTypeAggregation extends estypes.AggregationsFiltersAggregate { @@ -415,6 +499,9 @@ export interface IdleTasksAggregation extends estypes.AggregationsFiltersAggrega }; overdue: { doc_count: number; + nonRecurring: { + doc_count: number; + }; }; } diff --git a/x-pack/plugins/task_manager/server/routes/health.test.ts b/x-pack/plugins/task_manager/server/routes/health.test.ts index 0a9671d9ac37e9..ae883585e7085e 100644 --- a/x-pack/plugins/task_manager/server/routes/health.test.ts +++ b/x-pack/plugins/task_manager/server/routes/health.test.ts @@ -15,7 +15,7 @@ import { mockHandlerArguments } from './_mock_handler_arguments'; import { sleep } from '../test_utils'; import { loggingSystemMock } from '../../../../../src/core/server/mocks'; import { Logger } from '../../../../../src/core/server'; -import { MonitoringStats, summarizeMonitoringStats } from '../monitoring'; +import { MonitoringStats, RawMonitoringStats, summarizeMonitoringStats } from '../monitoring'; import { ServiceStatusLevels } from 'src/core/server'; import { configSchema, TaskManagerConfig } from '../config'; @@ -72,7 +72,7 @@ describe('healthRoute', () => { id, timestamp: expect.any(String), status: expect.any(String), - ...summarizeMonitoringStats(mockStat, getTaskManagerConfig({})), + ...ignoreCapacityEstimation(summarizeMonitoringStats(mockStat, getTaskManagerConfig({}))), }); const secondDebug = JSON.parse( @@ -82,13 +82,15 @@ describe('healthRoute', () => { id, timestamp: expect.any(String), status: expect.any(String), - ...summarizeMonitoringStats(skippedMockStat, getTaskManagerConfig({})), + ...ignoreCapacityEstimation( + summarizeMonitoringStats(skippedMockStat, getTaskManagerConfig({})) + ), }); expect(secondDebug).toMatchObject({ id, timestamp: expect.any(String), status: expect.any(String), - ...summarizeMonitoringStats(nextMockStat, getTaskManagerConfig({})), + ...ignoreCapacityEstimation(summarizeMonitoringStats(nextMockStat, getTaskManagerConfig({}))), }); expect(logger.debug).toHaveBeenCalledTimes(2); @@ -127,27 +129,29 @@ describe('healthRoute', () => { expect(await handler(context, req, res)).toMatchObject({ body: { status: 'error', - ...summarizeMonitoringStats( - mockHealthStats({ - last_update: expect.any(String), - stats: { - configuration: { - timestamp: expect.any(String), - }, - workload: { - timestamp: expect.any(String), - }, - runtime: { - timestamp: expect.any(String), - value: { - polling: { - last_successful_poll: expect.any(String), + ...ignoreCapacityEstimation( + summarizeMonitoringStats( + mockHealthStats({ + last_update: expect.any(String), + stats: { + configuration: { + timestamp: expect.any(String), + }, + workload: { + timestamp: expect.any(String), + }, + runtime: { + timestamp: expect.any(String), + value: { + polling: { + last_successful_poll: expect.any(String), + }, }, }, }, - }, - }), - getTaskManagerConfig({}) + }), + getTaskManagerConfig({}) + ) ), }, }); @@ -196,27 +200,29 @@ describe('healthRoute', () => { expect(await handler(context, req, res)).toMatchObject({ body: { status: 'error', - ...summarizeMonitoringStats( - mockHealthStats({ - last_update: expect.any(String), - stats: { - configuration: { - timestamp: expect.any(String), - }, - workload: { - timestamp: expect.any(String), - }, - runtime: { - timestamp: expect.any(String), - value: { - polling: { - last_successful_poll: expect.any(String), + ...ignoreCapacityEstimation( + summarizeMonitoringStats( + mockHealthStats({ + last_update: expect.any(String), + stats: { + configuration: { + timestamp: expect.any(String), + }, + workload: { + timestamp: expect.any(String), + }, + runtime: { + timestamp: expect.any(String), + value: { + polling: { + last_successful_poll: expect.any(String), + }, }, }, }, - }, - }), - getTaskManagerConfig() + }), + getTaskManagerConfig() + ) ), }, }); @@ -262,98 +268,113 @@ describe('healthRoute', () => { expect(await handler(context, req, res)).toMatchObject({ body: { status: 'error', - ...summarizeMonitoringStats( - mockHealthStats({ - last_update: expect.any(String), - stats: { - configuration: { - timestamp: expect.any(String), - }, - workload: { - timestamp: expect.any(String), - }, - runtime: { - timestamp: expect.any(String), - value: { - polling: { - last_successful_poll, + ...ignoreCapacityEstimation( + summarizeMonitoringStats( + mockHealthStats({ + last_update: expect.any(String), + stats: { + configuration: { + timestamp: expect.any(String), + }, + workload: { + timestamp: expect.any(String), + }, + runtime: { + timestamp: expect.any(String), + value: { + polling: { + last_successful_poll, + }, }, }, }, - }, - }), - getTaskManagerConfig() + }), + getTaskManagerConfig() + ) ), }, }); }); }); +function ignoreCapacityEstimation(stats: RawMonitoringStats) { + stats.stats.capacity_estimation = expect.any(Object); + return stats; +} + function mockHealthStats(overrides = {}) { - return (merge( - { - last_update: new Date().toISOString(), - stats: { - configuration: { - timestamp: new Date().toISOString(), - value: { - value: { - max_workers: 10, - poll_interval: 6000000, - max_poll_inactivity_cycles: 10, - request_capacity: 1000, - monitored_aggregated_stats_refresh_rate: 5000, - monitored_stats_running_average_window: 50, - monitored_task_execution_thresholds: { - default: { - error_threshold: 90, - warn_threshold: 80, - }, - custom: {}, - }, + const stub: MonitoringStats = { + last_update: new Date().toISOString(), + stats: { + configuration: { + timestamp: new Date().toISOString(), + value: { + max_workers: 10, + poll_interval: 3000, + max_poll_inactivity_cycles: 10, + request_capacity: 1000, + monitored_aggregated_stats_refresh_rate: 5000, + monitored_stats_running_average_window: 50, + monitored_task_execution_thresholds: { + default: { + error_threshold: 90, + warn_threshold: 80, }, + custom: {}, }, }, - workload: { - timestamp: new Date().toISOString(), - value: { - count: 4, - taskTypes: { - actions_telemetry: { count: 2, status: { idle: 2 } }, - alerting_telemetry: { count: 1, status: { idle: 1 } }, - session_cleanup: { count: 1, status: { idle: 1 } }, - }, - schedule: {}, - overdue: 0, - estimatedScheduleDensity: [], + }, + workload: { + timestamp: new Date().toISOString(), + value: { + count: 4, + task_types: { + actions_telemetry: { count: 2, status: { idle: 2 } }, + alerting_telemetry: { count: 1, status: { idle: 1 } }, + session_cleanup: { count: 1, status: { idle: 1 } }, + }, + schedule: [], + overdue: 0, + overdue_non_recurring: 0, + estimatedScheduleDensity: [], + non_recurring: 20, + owner_ids: [0, 0, 0, 1, 2, 0, 0, 2, 2, 2, 1, 2, 1, 1], + estimated_schedule_density: [], + capacity_requirments: { + per_minute: 150, + per_hour: 360, + per_day: 820, }, }, - runtime: { - timestamp: new Date().toISOString(), - value: { - drift: [1000, 60000], - load: [0, 100, 75], - execution: { - duration: [], - result_frequency_percent_as_number: [], - }, - polling: { - last_successful_poll: new Date().toISOString(), - duration: [500, 400, 3000], - claim_conflicts: [0, 100, 75], - claim_mismatches: [0, 100, 75], - result_frequency_percent_as_number: [ - 'NoTasksClaimed', - 'NoTasksClaimed', - 'NoTasksClaimed', - ], - }, + }, + runtime: { + timestamp: new Date().toISOString(), + value: { + drift: [1000, 60000], + drift_by_type: {}, + load: [0, 100, 75], + execution: { + duration: {}, + duration_by_persistence: {}, + persistence: [], + result_frequency_percent_as_number: {}, + }, + polling: { + last_successful_poll: new Date().toISOString(), + duration: [500, 400, 3000], + claim_conflicts: [0, 100, 75], + claim_mismatches: [0, 100, 75], + result_frequency_percent_as_number: [ + 'NoTasksClaimed', + 'NoTasksClaimed', + 'NoTasksClaimed', + ], }, }, }, }, - overrides - ) as unknown) as MonitoringStats; + }; + return (merge(stub, overrides) as unknown) as MonitoringStats; } async function getLatest(stream$: Observable) { diff --git a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json index 7c96dce3fac7f5..8e52450d393b03 100644 --- a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json +++ b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @@ -2162,6 +2162,12 @@ "description": "Number of times the user opened one of the in-product help popovers." } }, + "toggle_fullscreen_formula": { + "type": "long", + "_meta": { + "description": "Number of times the user toggled fullscreen mode on formula." + } + }, "indexpattern_field_info_click": { "type": "long" }, @@ -2371,6 +2377,12 @@ "_meta": { "description": "Number of times the moving average function was selected" } + }, + "indexpattern_dimension_operation_formula": { + "type": "long", + "_meta": { + "description": "Number of times the formula function was selected" + } } } }, @@ -2385,6 +2397,12 @@ "description": "Number of times the user opened one of the in-product help popovers." } }, + "toggle_fullscreen_formula": { + "type": "long", + "_meta": { + "description": "Number of times the user toggled fullscreen mode on formula." + } + }, "indexpattern_field_info_click": { "type": "long" }, @@ -2594,6 +2612,12 @@ "_meta": { "description": "Number of times the moving average function was selected" } + }, + "indexpattern_dimension_operation_formula": { + "type": "long", + "_meta": { + "description": "Number of times the formula function was selected" + } } } }, @@ -2666,6 +2690,12 @@ }, "lnsMetric": { "type": "long" + }, + "formula": { + "type": "long", + "_meta": { + "description": "Number of saved lens visualizations which are using at least one formula" + } } } }, @@ -2709,6 +2739,12 @@ }, "lnsMetric": { "type": "long" + }, + "formula": { + "type": "long", + "_meta": { + "description": "Number of saved lens visualizations which are using at least one formula" + } } } }, @@ -2752,6 +2788,12 @@ }, "lnsMetric": { "type": "long" + }, + "formula": { + "type": "long", + "_meta": { + "description": "Number of saved lens visualizations which are using at least one formula" + } } } } diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 4bc03b4ba6e2aa..e47dfdf986eee7 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -7003,20 +7003,7 @@ "xpack.canvas.workpadHeaderRefreshControlSettings.refreshAriaLabel": "エレメントを更新", "xpack.canvas.workpadHeaderRefreshControlSettings.refreshTooltip": "データを更新", "xpack.canvas.workpadHeaderShareMenu.copyPDFMessage": "{PDF}生成{URL}がクリップボードにコピーされました。", - "xpack.canvas.workpadHeaderShareMenu.copyReportingConfigMessage": "レポート構成がクリップボードにコピーされました", "xpack.canvas.workpadHeaderShareMenu.copyShareConfigMessage": "共有マークアップがクリップボードにコピーされました", - "xpack.canvas.workpadHeaderShareMenu.exportPDFErrorMessage": "'{workpadName}'の{PDF}を作成できませんでした", - "xpack.canvas.workpadHeaderShareMenu.exportPDFMessage": "{PDF}をエクスポートしています。管理で進捗を確認できます。", - "xpack.canvas.workpadHeaderShareMenu.exportPDFTitle": "ワークパッド '{workpadName}' の {PDF} エクスポート", - "xpack.canvas.workpadHeaderShareMenu.FullPageLayoutHelpText": "枠線とフッターロゴを削除", - "xpack.canvas.workpadHeaderShareMenu.FullPageLayoutLabel": "全ページレイアウト", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelAdvancedOptionsLabel": "高度なオプション", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyAriaLabel": "この {URL} を使用してスクリプトから、または Watcher で {PDF} を生成することもできます。{URL}をクリップボードにコピーするにはEnterキーを押してください。", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyButtonLabel": "{POST} {URL}をコピー", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyDescription": "{POST} {URL}をコピーして{KIBANA}外またはWatcherから生成を実行することもできます。", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateButtonLabel": "{PDF}を生成", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateDescription": "ワークパッドのサイズによって、{PDF} の生成には数分かかる場合があります。", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelOptionsLabel": "オプション", "xpack.canvas.workpadHeaderShareMenu.shareDownloadJSONTitle": "{JSON} をダウンロード", "xpack.canvas.workpadHeaderShareMenu.shareDownloadPDFTitle": "{PDF}レポート", "xpack.canvas.workpadHeaderShareMenu.shareMenuButtonLabel": "共有", @@ -7979,7 +7966,7 @@ "xpack.enterpriseSearch.roleMapping.filterRoleMappingsPlaceholder": "ロールをフィルタリング...", "xpack.enterpriseSearch.roleMapping.individualAuthProviderLabel": "個別の認証プロバイダーを選択", "xpack.enterpriseSearch.roleMapping.manageRoleMappingTitle": "ロールマッピングを管理", - "xpack.enterpriseSearch.roleMapping.moResults.message": "'{filterValue}'の結果が見つかりません。", + "xpack.enterpriseSearch.roleMapping.noResults.message": "の結果が見つかりません。", "xpack.enterpriseSearch.roleMapping.newRoleMappingTitle": "ロールマッピングを追加", "xpack.enterpriseSearch.roleMapping.roleLabel": "ロール", "xpack.enterpriseSearch.roleMapping.roleMappingsTitle": "ユーザーとロール", @@ -8808,8 +8795,6 @@ "xpack.fleet.agentDetailsIntegrations.viewLogsButton": "ログを表示", "xpack.fleet.agentEnrollment.agentDescription": "Elastic エージェントをホストに追加し、データを収集して、Elastic Stack に送信します。", "xpack.fleet.agentEnrollment.agentsNotInitializedText": "エージェントを登録する前に、{link}。", - "xpack.fleet.agentEnrollment.cancelButtonLabel": "キャンセル", - "xpack.fleet.agentEnrollment.continueButtonLabel": "続行", "xpack.fleet.agentEnrollment.copyPolicyButton": "クリップボードにコピー", "xpack.fleet.agentEnrollment.copyRunInstructionsButton": "クリップボードにコピー", "xpack.fleet.agentEnrollment.downloadDescription": "Elasticエージェントダウンロードページでは、エージェントバイナリと検証署名をダウンロードできます。", @@ -14061,7 +14046,6 @@ "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixLabel": "分類混同行列", "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixPredictedLabel": "予測されたクラス", "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTestingHelpText": "データセットをテストするための正規化された混同行列", - "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTooltip": "マルチクラス混同行列には、分析が実際のクラスで正しくデータポイントを分類した発生数と、別のクラスで誤分類した発生数が含まれます。", "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTrainingHelpText": "データセットを学習するための正規化された混同行列", "xpack.ml.dataframe.analytics.classificationExploration.evaluateJobStatusLabel": "ジョブ状態", "xpack.ml.dataframe.analytics.classificationExploration.evaluateSectionAvgRecallTooltip": "平均再現率は、実際のクラスメンバーのデータポイントのうち正しくクラスメンバーとして特定された数を示します。", @@ -17325,10 +17309,6 @@ "xpack.observability.alertsTable.viewInAppButtonLabel": "アプリで表示", "xpack.observability.alertsTitle": "アラート", "xpack.observability.breadcrumbs.observability": "オブザーバビリティ", - "xpack.observability.cases.breadcrumb": "ケース", - "xpack.observability.casesDisclaimerText": "これは将来のケースのホームです。", - "xpack.observability.casesDisclaimerTitle": "まもなくリリース", - "xpack.observability.casesTitle": "ケース", "xpack.observability.emptySection.apps.alert.description": "503 エラーが累積していますか?サービスは応答していますか?CPUとRAMの使用量が跳ね上がっていますか?このような警告を、事後にではなく、発生と同時に把握しましょう。", "xpack.observability.emptySection.apps.alert.link": "アラートの作成", "xpack.observability.emptySection.apps.alert.title": "アラートが見つかりません。", @@ -17879,14 +17859,10 @@ "xpack.reporting.panelContent.generateButtonLabel": "{reportingType} を生成", "xpack.reporting.panelContent.generationTimeDescription": "{objectType} のサイズによって、{reportingType} の作成には数分かかる場合があります。", "xpack.reporting.panelContent.howToCallGenerationDescription": "POST URL をコピーして Kibana 外または ウォッチャー から生成を実行することもできます。", - "xpack.reporting.panelContent.noPermissionToGenerateReportDescription": "このレポートを生成するパーミッションがありません。", - "xpack.reporting.panelContent.notification.cantReachServerDescription": "サーバーと通信できません。再試行してください。", "xpack.reporting.panelContent.notification.reportingErrorTitle": "レポートエラー", "xpack.reporting.panelContent.saveWorkDescription": "レポートの生成前に変更内容を保存してください。", "xpack.reporting.panelContent.successfullyQueuedReportNotificationDescription": "{path}で進捗状況を追跡", "xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle": "{objectType} のレポートキュー", - "xpack.reporting.panelContent.whatCanBeExportedWarningDescription": "初めに変更内容を保存してください", - "xpack.reporting.panelContent.whatCanBeExportedWarningTitle": "保存された {objectType} のみエクスポートできます", "xpack.reporting.pdfFooterImageDescription": "PDFのフッターに使用するカスタム画像です", "xpack.reporting.pdfFooterImageLabel": "PDFフッター画像", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage": "レポートには、スプレッドシートアプリケーションで式と解釈される可能性のある文字が含まれています。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 46bdb83c42528b..3ab6203b489425 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -7051,20 +7051,7 @@ "xpack.canvas.workpadHeaderRefreshControlSettings.refreshAriaLabel": "刷新元素", "xpack.canvas.workpadHeaderRefreshControlSettings.refreshTooltip": "刷新数据", "xpack.canvas.workpadHeaderShareMenu.copyPDFMessage": "{PDF} 生成 {URL} 已复制到您的剪贴板。", - "xpack.canvas.workpadHeaderShareMenu.copyReportingConfigMessage": "已将报告配置复制到剪贴板", "xpack.canvas.workpadHeaderShareMenu.copyShareConfigMessage": "已将共享标记复制到剪贴板", - "xpack.canvas.workpadHeaderShareMenu.exportPDFErrorMessage": "无法为“{workpadName}”创建 {PDF}", - "xpack.canvas.workpadHeaderShareMenu.exportPDFMessage": "正在导出 {PDF}。可以在“管理”中跟踪进度。", - "xpack.canvas.workpadHeaderShareMenu.exportPDFTitle": "Workpad“{workpadName}”的 {PDF} 导出", - "xpack.canvas.workpadHeaderShareMenu.FullPageLayoutHelpText": "删除边框和页脚徽标", - "xpack.canvas.workpadHeaderShareMenu.FullPageLayoutLabel": "全页面布局", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelAdvancedOptionsLabel": "高级选项", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyAriaLabel": "或者,也可以从脚本或使用此 {URL} 通过 Watcher 生成 {PDF}。按 Enter 键可将 {URL} 复制到剪贴板。", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyButtonLabel": "复制 {POST} {URL}", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelCopyDescription": "或者,复制此 {POST} {URL} 以从 {KIBANA} 外部或从 Watcher 调用生成。", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateButtonLabel": "生成 {PDF}", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelGenerateDescription": "{PDF} 可能会花费一两分钟生成,具体取决于 Workpad 的大小。", - "xpack.canvas.workpadHeaderShareMenu.pdfPanelOptionsLabel": "选项", "xpack.canvas.workpadHeaderShareMenu.shareDownloadJSONTitle": "下载为 {JSON}", "xpack.canvas.workpadHeaderShareMenu.shareDownloadPDFTitle": "{PDF} 报告", "xpack.canvas.workpadHeaderShareMenu.shareMenuButtonLabel": "共享", @@ -8047,7 +8034,7 @@ "xpack.enterpriseSearch.roleMapping.filterRoleMappingsPlaceholder": "筛选角色......", "xpack.enterpriseSearch.roleMapping.individualAuthProviderLabel": "选择单个身份验证提供程序", "xpack.enterpriseSearch.roleMapping.manageRoleMappingTitle": "管理角色映射", - "xpack.enterpriseSearch.roleMapping.moResults.message": "找不到“{filterValue}”的结果", + "xpack.enterpriseSearch.roleMapping.noResults.message": "找不到的结果", "xpack.enterpriseSearch.roleMapping.newRoleMappingTitle": "添加角色映射", "xpack.enterpriseSearch.roleMapping.roleLabel": "角色", "xpack.enterpriseSearch.roleMapping.roleMappingsTitle": "用户和角色", @@ -8885,8 +8872,6 @@ "xpack.fleet.agentDetailsIntegrations.viewLogsButton": "查看日志", "xpack.fleet.agentEnrollment.agentDescription": "将 Elastic 代理添加到您的主机,以收集数据并将其发送到 Elastic Stack。", "xpack.fleet.agentEnrollment.agentsNotInitializedText": "注册代理前,请{link}。", - "xpack.fleet.agentEnrollment.cancelButtonLabel": "取消", - "xpack.fleet.agentEnrollment.continueButtonLabel": "继续", "xpack.fleet.agentEnrollment.copyPolicyButton": "复制到剪贴板", "xpack.fleet.agentEnrollment.copyRunInstructionsButton": "复制到剪贴板", "xpack.fleet.agentEnrollment.downloadDescription": "可从 Elastic 代理下载页面下载代理二进制文件及其验证签名。", @@ -14243,7 +14228,6 @@ "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixLabel": "分类混淆矩阵", "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixPredictedLabel": "预测类", "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTestingHelpText": "用于测试数据集的标准化混淆矩阵", - "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTooltip": "多类混淆矩阵包含分析使用数据点的实际类正确分类数据点的次数以及分析使用其他类错误分类这些数据点的次数", "xpack.ml.dataframe.analytics.classificationExploration.confusionMatrixTrainingHelpText": "用于训练数据集的标准化混淆矩阵", "xpack.ml.dataframe.analytics.classificationExploration.evaluateJobStatusLabel": "作业状态", "xpack.ml.dataframe.analytics.classificationExploration.evaluateSectionAvgRecallTooltip": "平均召回率显示作为实际类成员的数据点有多少个已被正确标识为类成员。", @@ -17562,10 +17546,6 @@ "xpack.observability.alertsTable.viewInAppButtonLabel": "在应用中查看", "xpack.observability.alertsTitle": "告警", "xpack.observability.breadcrumbs.observability": "可观测性", - "xpack.observability.cases.breadcrumb": "案例", - "xpack.observability.casesDisclaimerText": "这是案例的未来之家。", - "xpack.observability.casesDisclaimerTitle": "即将推出", - "xpack.observability.casesTitle": "案例", "xpack.observability.emptySection.apps.alert.description": "503 错误是否越来越多?服务是否响应?CPU 和 RAM 利用率是否激增?实时查看警告,而不是事后再进行剖析。", "xpack.observability.emptySection.apps.alert.link": "创建告警", "xpack.observability.emptySection.apps.alert.title": "未找到告警。", @@ -18120,14 +18100,10 @@ "xpack.reporting.panelContent.generateButtonLabel": "生成 {reportingType}", "xpack.reporting.panelContent.generationTimeDescription": "{reportingType} 可能会花费 1 或 2 分钟生成,取决于 {objectType} 的大小。", "xpack.reporting.panelContent.howToCallGenerationDescription": "或者,复制此 POST URL 以从 Kibana 外部或从 Watcher 调用生成。", - "xpack.reporting.panelContent.noPermissionToGenerateReportDescription": "您无权生成此报告。", - "xpack.reporting.panelContent.notification.cantReachServerDescription": "无法访问服务器。请重试。", "xpack.reporting.panelContent.notification.reportingErrorTitle": "报告错误", "xpack.reporting.panelContent.saveWorkDescription": "请在生成报告之前保存您的工作。", "xpack.reporting.panelContent.successfullyQueuedReportNotificationDescription": "在 {path} 中跟踪其进度", "xpack.reporting.panelContent.successfullyQueuedReportNotificationTitle": "已为 {objectType} 排队报告", - "xpack.reporting.panelContent.whatCanBeExportedWarningDescription": "请先保存您的工作", - "xpack.reporting.panelContent.whatCanBeExportedWarningTitle": "只会导出保存的 {objectType}", "xpack.reporting.pdfFooterImageDescription": "要在 PDF 的页脚中使用的定制图像", "xpack.reporting.pdfFooterImageLabel": "PDF 页脚图像", "xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage": "报告包含电子表格应用程序可解释为公式的字符。", diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/health_check.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/health_check.test.tsx index 44c950a5000405..b998067424edd1 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/health_check.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/health_check.test.tsx @@ -184,7 +184,7 @@ describe('health check', () => { const action = queryByText(/Learn/i); expect(action!.textContent).toMatchInlineSnapshot(`"Learn how.(opens in a new tab or window)"`); expect(action!.getAttribute('href')).toMatchInlineSnapshot( - `"https://www.elastic.co/guide/en/kibana/mocked-test-branch/alerting-getting-started.html#alerting-setup-prerequisites"` + `"https://www.elastic.co/guide/en/kibana/mocked-test-branch/alerting-setup.html#alerting-prerequisites"` ); }); }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx index 0e1c27c1e67688..3594374a54f167 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx @@ -37,7 +37,7 @@ describe('home', () => { const documentationLink = wrapper.find('[data-test-subj="documentationLink"]'); expect(documentationLink.exists()).toBeTruthy(); expect(documentationLink.first().prop('href')).toEqual( - 'https://www.elastic.co/guide/en/kibana/mocked-test-branch/alert-management.html' + 'https://www.elastic.co/guide/en/kibana/mocked-test-branch/create-and-manage-rules.html' ); }); }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/home.tsx b/x-pack/plugins/triggers_actions_ui/public/application/home.tsx index 20aec6974d395b..3da25cb4cf0d8d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/home.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/home.tsx @@ -90,7 +90,7 @@ export const TriggersActionsUIHome: React.FunctionComponent - + diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx index 1bbffc850ee185..cad4dabbe8275d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx @@ -12,8 +12,14 @@ import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { act } from '@testing-library/react'; import { AlertDetails } from './alert_details'; import { Alert, ActionType, AlertTypeModel, AlertType } from '../../../../types'; -import { EuiTitle, EuiBadge, EuiFlexItem, EuiSwitch, EuiButtonEmpty, EuiText } from '@elastic/eui'; -import { ViewInApp } from './view_in_app'; +import { + EuiBadge, + EuiFlexItem, + EuiSwitch, + EuiButtonEmpty, + EuiText, + EuiPageHeaderProps, +} from '@elastic/eui'; import { ActionGroup, AlertExecutionStatusErrorReasons, @@ -75,13 +81,7 @@ describe('alert_details', () => { expect( shallow( - ).containsMatchingElement( - -

- {alert.name} -

-
- ) + ).find('EuiPageHeader') ).toBeTruthy(); }); @@ -103,7 +103,7 @@ describe('alert_details', () => { expect( shallow( - ).containsMatchingElement({alertType.name}) + ).find({alertType.name}) ).toBeTruthy(); }); @@ -290,7 +290,7 @@ describe('alert_details', () => { expect( shallow( - ).containsMatchingElement() + ).find('ViewInApp') ).toBeTruthy(); }); @@ -309,16 +309,29 @@ describe('alert_details', () => { minimumLicenseRequired: 'basic', enabledInLicense: true, }; - - expect( - shallow( - - ) - .find(EuiButtonEmpty) - .find('[data-test-subj="openEditAlertFlyoutButton"]') - .first() - .exists() - ).toBeTruthy(); + const pageHeaderProps = shallow( + + ) + .find('EuiPageHeader') + .props() as EuiPageHeaderProps; + const rightSideItems = pageHeaderProps.rightSideItems; + expect(!!rightSideItems && rightSideItems[2]!).toMatchInlineSnapshot(` + + + + + + `); }); }); }); @@ -768,20 +781,34 @@ describe('edit button', () => { enabledInLicense: true, }; - expect( - shallow( - + ) + .find('EuiPageHeader') + .props() as EuiPageHeaderProps; + const rightSideItems = pageHeaderProps.rightSideItems; + expect(!!rightSideItems && rightSideItems[2]!).toMatchInlineSnapshot(` + + + - ) - .find(EuiButtonEmpty) - .find('[name="edit"]') - .first() - .exists() - ).toBeTruthy(); + + + `); }); it('should not render an edit button when alert editable but actions arent', () => { @@ -851,20 +878,34 @@ describe('edit button', () => { enabledInLicense: true, }; - expect( - shallow( - + ) + .find('EuiPageHeader') + .props() as EuiPageHeaderProps; + const rightSideItems = pageHeaderProps.rightSideItems; + expect(!!rightSideItems && rightSideItems[2]!).toMatchInlineSnapshot(` + + + - ) - .find(EuiButtonEmpty) - .find('[name="edit"]') - .first() - .exists() - ).toBeTruthy(); + + + `); }); }); @@ -885,7 +926,7 @@ describe('refresh button', () => { }; const requestRefresh = jest.fn(); - const refreshButton = shallow( + const wrapper = mountWithIntl( { {...mockAlertApis} requestRefresh={requestRefresh} /> - ) - .find('[data-test-subj="refreshAlertsButton"]') - .first(); + ); + const refreshButton = wrapper.find('[data-test-subj="refreshAlertsButton"]').first(); expect(refreshButton.exists()).toBeTruthy(); refreshButton.simulate('click'); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx index ba6c77a4403f1d..3e411913520adc 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.tsx @@ -12,14 +12,11 @@ import { useHistory } from 'react-router-dom'; import { EuiPageBody, EuiPageContent, - EuiPageContentHeader, - EuiPageContentHeaderSection, - EuiTitle, + EuiPageHeader, EuiText, EuiFlexGroup, EuiFlexItem, EuiBadge, - EuiPage, EuiPageContentBody, EuiSwitch, EuiCallOut, @@ -45,7 +42,7 @@ import { alertsErrorReasonTranslationsMapping } from '../../alerts_list/translat import { useKibana } from '../../../../common/lib/kibana'; import { alertReducer } from '../../alert_form/alert_reducer'; -type AlertDetailsProps = { +export type AlertDetailsProps = { alert: Alert; alertType: AlertType; actionTypes: ActionType[]; @@ -120,249 +117,245 @@ export const AlertDetails: React.FunctionComponent = ({ } }; + const rightPageHeaderButtons = hasEditButton + ? [ + <> + setEditFlyoutVisibility(true)} + name="edit" + disabled={!alertType.enabledInLicense} + > + + + {editFlyoutVisible && ( + { + setInitialAlert(alert); + setEditFlyoutVisibility(false); + }} + actionTypeRegistry={actionTypeRegistry} + alertTypeRegistry={alertTypeRegistry} + onSave={setAlert} + /> + )} + , + ] + : []; + return ( - - - - - - -

- {alert.name} -

-
-
- - - {hasEditButton ? ( - - <> - {' '} - setEditFlyoutVisibility(true)} - name="edit" - disabled={!alertType.enabledInLicense} - > - - - {editFlyoutVisible && ( - { - setInitialAlert(alert); - setEditFlyoutVisibility(false); - }} - actionTypeRegistry={actionTypeRegistry} - alertTypeRegistry={alertTypeRegistry} - onSave={setAlert} - /> - )} - - - ) : null} + + + + } + rightSideItems={[ + , + + + , + ...rightPageHeaderButtons, + ]} + /> + + + + + +

+ +

+
+ + {alertType.name} +
+ + {uniqueActions && uniqueActions.length ? ( + <> + +

+ +

+
+ + + {uniqueActions.map((action, index) => ( + + + {actionTypesByTypeId[action].name ?? action} + + + ))} + + + ) : null} +
+ + + - - - + { + if (isEnabled) { + setIsEnabled(false); + await disableAlert(alert); + // Reset dismiss if previously clicked + setDissmissAlertErrors(false); + } else { + setIsEnabled(true); + await enableAlert(alert); + } + requestRefresh(); + }} + label={ + + } + /> - + { + if (isMuted) { + setIsMuted(false); + await unmuteAlert(alert); + } else { + setIsMuted(true); + await muteAlert(alert); + } + requestRefresh(); + }} + label={ + + } + /> -
-
- - - - -

- -

-
- - {alertType.name} -
- - {uniqueActions && uniqueActions.length ? ( - <> - -

- -

-
- - - {uniqueActions.map((action, index) => ( - - - {actionTypesByTypeId[action].name ?? action} - - - ))} - - - ) : null} -
- - - - - { - if (isEnabled) { - setIsEnabled(false); - await disableAlert(alert); - // Reset dismiss if previously clicked - setDissmissAlertErrors(false); - } else { - setIsEnabled(true); - await enableAlert(alert); - } - requestRefresh(); - }} - label={ - - } - /> - - - { - if (isMuted) { - setIsMuted(false); - await unmuteAlert(alert); - } else { - setIsMuted(true); - await muteAlert(alert); - } - requestRefresh(); - }} - label={ + + + {alert.enabled && !dissmissAlertErrors && alert.executionStatus.status === 'error' ? ( + + + + + {alert.executionStatus.error?.message} + + + + + setDissmissAlertErrors(true)} + > - } - /> - - - - - {alert.enabled && !dissmissAlertErrors && alert.executionStatus.status === 'error' ? ( - - - - - {alert.executionStatus.error?.message} - - - +
+ + {alert.executionStatus.error?.reason === + AlertExecutionStatusErrorReasons.License && ( - setDissmissAlertErrors(true)} + target="_blank" > - + - {alert.executionStatus.error?.reason === - AlertExecutionStatusErrorReasons.License && ( - - - - - - )} - -
- - - ) : null} - - - {alert.enabled ? ( - - ) : ( - <> - - -

- -

-
- - )} + )} +
+ - - - - + ) : null} + + + {alert.enabled ? ( + + ) : ( + <> + + +

+ +

+
+ + )} +
+
+ + + ); }; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana.test.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana.test.ts index 867440ae0d911b..b14ec26e5c8af1 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana.test.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana.test.ts @@ -182,9 +182,7 @@ describe('Kibana deprecations', () => { component.update(); expect(exists('kibanaRequestError')).toBe(true); - expect(find('kibanaRequestError').text()).toContain( - 'Could not retrieve Kibana deprecations.' - ); + expect(find('kibanaRequestError').text()).toContain('Could not retrieve Kibana deprecations'); }); test('handles deprecation service error', async () => { @@ -217,7 +215,7 @@ describe('Kibana deprecations', () => { // Verify top-level callout renders expect(exists('kibanaPluginError')).toBe(true); expect(find('kibanaPluginError').text()).toContain( - 'Not all Kibana deprecations were retrieved successfully.' + 'Not all Kibana deprecations were retrieved successfully' ); // Open all deprecations diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/coming_soon_prompt.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/coming_soon_prompt.tsx index b7869226a84b0c..14627f0b138b00 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/coming_soon_prompt.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/coming_soon_prompt.tsx @@ -16,7 +16,7 @@ export const ComingSoonPrompt: React.FunctionComponent = () => { const { ELASTIC_WEBSITE_URL } = docLinks; return ( - + - - - {i18nTexts.docLinkText} - , - ]} - > - - - {i18nTexts.backupDataButton.label} - - - - - - tab.id === tabName)} - /> - - - + <> + + {i18nTexts.docLinkText} + , + ]} + > + + + {i18nTexts.backupDataButton.label} + + + + + + + tab.id === tabName)} + /> + ); } ); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecation_errors.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecation_errors.tsx index e6ba83919c31b2..79ada21941b56a 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecation_errors.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecation_errors.tsx @@ -7,44 +7,67 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiCallOut } from '@elastic/eui'; +import { EuiPageContent, EuiEmptyPrompt } from '@elastic/eui'; interface Props { errorType: 'pluginError' | 'requestError'; } const i18nTexts = { - pluginError: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationErrors.pluginErrorMessage', { - defaultMessage: - 'Not all Kibana deprecations were retrieved successfully. This list may be incomplete. Check the Kibana server logs for errors.', - }), - loadingError: i18n.translate( - 'xpack.upgradeAssistant.kibanaDeprecationErrors.loadingErrorMessage', - { - defaultMessage: - 'Could not retrieve Kibana deprecations. Check the Kibana server logs for errors.', - } - ), + pluginError: { + title: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationErrors.pluginErrorTitle', { + defaultMessage: 'Not all Kibana deprecations were retrieved successfully', + }), + description: i18n.translate( + 'xpack.upgradeAssistant.kibanaDeprecationErrors.pluginErrorDescription', + { + defaultMessage: 'Check the Kibana server logs for errors.', + } + ), + }, + loadingError: { + title: i18n.translate('xpack.upgradeAssistant.kibanaDeprecationErrors.loadingErrorTitle', { + defaultMessage: 'Could not retrieve Kibana deprecations', + }), + description: i18n.translate( + 'xpack.upgradeAssistant.kibanaDeprecationErrors.loadingErrorDescription', + { + defaultMessage: 'Check the Kibana server logs for errors.', + } + ), + }, }; export const KibanaDeprecationErrors: React.FunctionComponent = ({ errorType }) => { if (errorType === 'pluginError') { return ( - + > + {i18nTexts.pluginError.title}

} + body={

{i18nTexts.pluginError.description}

} + /> + ); } return ( - + > + {i18nTexts.loadingError.title}} + body={

{i18nTexts.loadingError.description}

} + /> + ); }; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx index a9608109728ba2..31b5c80d5b3773 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/kibana_deprecations/kibana_deprecations.tsx @@ -8,14 +8,7 @@ import React, { useEffect, useState, useCallback } from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; -import { - EuiButtonEmpty, - EuiPageBody, - EuiPageHeader, - EuiPageContent, - EuiPageContentBody, - EuiSpacer, -} from '@elastic/eui'; +import { EuiButtonEmpty, EuiPageContent, EuiPageHeader, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import type { DomainDeprecationDetails } from 'kibana/public'; @@ -135,46 +128,28 @@ export const KibanaDeprecationsContent = withRouter(({ history }: RouteComponent getAllDeprecations(); }, [deprecations, getAllDeprecations]); - const getPageContent = () => { - if (kibanaDeprecations && kibanaDeprecations.length === 0) { - return ( + if (kibanaDeprecations && kibanaDeprecations.length === 0) { + return ( + history.push('/overview')} /> - ); - } - - let content: React.ReactNode; - - if (isLoading) { - content = {i18nTexts.isLoading}; - } else if (kibanaDeprecations?.length) { - content = ( - - ); - } else if (error) { - content = ; - } + + ); + } + if (isLoading) { return ( -
- - {content} -
+ + {i18nTexts.isLoading} + ); - }; - - return ( - - + } else if (kibanaDeprecations?.length) { + return ( +
- - {getPageContent()} - - {stepsModalContent && ( - toggleStepsModal()} modalContent={stepsModalContent} /> - )} - - {resolveModalContent && ( - toggleResolveModal()} - resolveDeprecation={resolveDeprecation} - isResolvingDeprecation={isResolvingDeprecation} - deprecation={resolveModalContent} - /> - )} - - - - ); + + + + + {stepsModalContent && ( + toggleStepsModal()} modalContent={stepsModalContent} /> + )} + + {resolveModalContent && ( + toggleResolveModal()} + resolveDeprecation={resolveDeprecation} + isResolvingDeprecation={isResolvingDeprecation} + deprecation={resolveModalContent} + /> + )} +
+ ); + } else if (error) { + return ; + } + + return null; }); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx index 6b3048b669aa2e..b77d4a337295c2 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/overview.tsx @@ -8,11 +8,9 @@ import React, { FunctionComponent, useEffect } from 'react'; import { - EuiPageContent, EuiPageContentBody, EuiText, EuiPageHeader, - EuiPageBody, EuiButtonEmpty, EuiFlexItem, EuiFlexGroup, @@ -91,72 +89,68 @@ export const DeprecationsOverview: FunctionComponent = ({ history }) => { }, [breadcrumbs]); return ( - - - - {i18nTexts.docLink} - , - ]} - /> - - - <> - -

{i18nTexts.pageDescription}

-
- - - - {/* Remove this in last minor of the current major (e.g., 7.15) */} - - - - - {/* Deprecation stats */} - - - - - - - - - - - - - {/* Deprecation logging */} - - - -

{i18nTexts.deprecationLoggingTitle}

-
- - -

- {i18nTexts.getDeprecationLoggingDescription( - `${nextMajor}.x`, - docLinks.links.elasticsearch.deprecationLogging - )} -

-
- - - - -
-
- -
-
-
+
+ + {i18nTexts.docLink} + , + ]} + /> + + + + + <> + {/* Remove this in last minor of the current major (e.g., 7.15) */} + + + + + {/* Deprecation stats */} + + + + + + + + + + + + + {/* Deprecation logging */} + + + +

{i18nTexts.deprecationLoggingTitle}

+
+ + +

+ {i18nTexts.getDeprecationLoggingDescription( + `${nextMajor}.x`, + docLinks.links.elasticsearch.deprecationLogging + )} +

+
+ + + + +
+
+ +
+
); }; diff --git a/x-pack/plugins/uptime/kibana.json b/x-pack/plugins/uptime/kibana.json index 4d5ab531af7c47..625406c0cb97bd 100644 --- a/x-pack/plugins/uptime/kibana.json +++ b/x-pack/plugins/uptime/kibana.json @@ -1,16 +1,8 @@ { - "configPath": [ - "xpack", - "uptime" - ], + "configPath": ["xpack", "uptime"], "id": "uptime", "kibanaVersion": "kibana", - "optionalPlugins": [ - "data", - "home", - "ml", - "fleet" - ], + "optionalPlugins": ["data", "home", "ml", "fleet"], "requiredPlugins": [ "alerting", "embeddable", @@ -23,12 +15,10 @@ "server": true, "ui": true, "version": "8.0.0", - "requiredBundles": [ - "observability", - "kibanaReact", - "kibanaUtils", - "home", - "data", - "ml" - ] + "requiredBundles": ["observability", "kibanaReact", "kibanaUtils", "home", "data", "ml"], + "owner": { + "name": "Uptime", + "githubTeam": "uptime" + }, + "description": "This plugin visualizes data from from Synthetics and Heartbeat, and integrates with other Observability solutions." } diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/alert_query_bar/query_bar.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/alert_query_bar/query_bar.tsx index 6293dc2ec1d18b..0a0bbadb6216f0 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/alert_query_bar/query_bar.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/alert_query_bar/query_bar.tsx @@ -46,7 +46,7 @@ export const AlertQueryBar = ({ query = '', onChange }: Props) => { }} query={{ query: inputVal, language: 'kuery' }} aria-label={labels.ALERT_KUERY_BAR_ARIA} - data-test-subj="xpack.uptime.alerts.monitorStatus.filterBar" + dataTestSubj="xpack.uptime.alerts.monitorStatus.filterBar" autoSubmit={true} disableLanguageSwitcher={true} isInvalid={!!(inputVal && !query)} diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx index d55f3fb336a9d8..ff2ef4d2359a8e 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx @@ -38,16 +38,19 @@ export const AlertMonitorStatus: React.FC = ({ }) => { const dispatch = useDispatch(); useEffect(() => { - dispatch( - fetchOverviewFilters({ - dateRangeStart: 'now-24h', - dateRangeEnd: 'now', - locations: alertParams.filters?.['observer.geo.name'] ?? [], - ports: alertParams.filters?.['url.port'] ?? [], - tags: alertParams.filters?.tags ?? [], - schemes: alertParams.filters?.['monitor.type'] ?? [], - }) - ); + if (!window.location.pathname.includes('/app/uptime')) { + // filters inside uptime app already loaded + dispatch( + fetchOverviewFilters({ + dateRangeStart: 'now-24h', + dateRangeEnd: 'now', + locations: alertParams.filters?.['observer.geo.name'] ?? [], + ports: alertParams.filters?.['url.port'] ?? [], + tags: alertParams.filters?.tags ?? [], + schemes: alertParams.filters?.['monitor.type'] ?? [], + }) + ); + } }, [alertParams, dispatch]); const overviewFilters = useSelector(overviewFiltersSelector); diff --git a/x-pack/plugins/uptime/server/index.ts b/x-pack/plugins/uptime/server/index.ts index c5427997b60a83..4894c73c625c10 100644 --- a/x-pack/plugins/uptime/server/index.ts +++ b/x-pack/plugins/uptime/server/index.ts @@ -8,6 +8,5 @@ import { PluginInitializerContext } from '../../../../src/core/server'; import { Plugin } from './plugin'; -export { initServerWithKibana, KibanaServer } from './kibana.index'; export const plugin = (initializerContext: PluginInitializerContext) => new Plugin(initializerContext); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts index 4aa6ed830059e7..e9ed14fbcddcd7 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts @@ -217,6 +217,7 @@ instanceStateValue: true ruleTypeId: 'test.always-firing', outcome: 'success', message: `alert executed: test.always-firing:${alertId}: 'abc'`, + ruleObject: alertSearchResultWithoutDates, }); break; default: @@ -1249,10 +1250,11 @@ instanceStateValue: true outcome: string; message: string; errorMessage?: string; + ruleObject: any; } async function validateEventLog(params: ValidateEventLogParams): Promise { - const { spaceId, alertId, ruleTypeId, outcome, message, errorMessage } = params; + const { spaceId, alertId, outcome, message, errorMessage, ruleObject } = params; const events: IValidatedEvent[] = await retry.try(async () => { return await getEventLog({ @@ -1293,10 +1295,19 @@ instanceStateValue: true type: 'alert', id: alertId, namespace: spaceId, - type_id: ruleTypeId, + type_id: ruleObject.alertInfo.ruleTypeId, }, ]); + expect(event?.rule).to.eql({ + id: alertId, + license: 'basic', + category: ruleObject.alertInfo.ruleTypeId, + ruleset: ruleObject.alertInfo.producer, + namespace: spaceId, + name: ruleObject.alertInfo.name, + }); + expect(event?.message).to.eql(message); if (errorMessage) { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts index d5e55a66ecf086..5d13d641367a4c 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts @@ -81,6 +81,13 @@ export default function eventLogTests({ getService }: FtrProviderContext) { errorMessage: 'Unable to decrypt attribute "apiKey"', status: 'error', reason: 'decrypt', + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: spaceId, + }, }); }); }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts index c1f6bcb9e15100..781967ff5596a9 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts @@ -134,6 +134,14 @@ export default function eventLogTests({ getService }: FtrProviderContext) { outcome: 'success', message: `alert executed: test.patternFiring:${alertId}: 'abc'`, status: executeStatuses[executeCount++], + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + name: response.body.name, + }, }); break; case 'execute-action': @@ -146,6 +154,14 @@ export default function eventLogTests({ getService }: FtrProviderContext) { message: `alert: test.patternFiring:${alertId}: 'abc' instanceId: 'instance' scheduled actionGroup: 'default' action: test.noop:${createdAction.id}`, instanceId: 'instance', actionGroupId: 'default', + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + name: response.body.name, + }, }); break; case 'new-instance': @@ -181,6 +197,14 @@ export default function eventLogTests({ getService }: FtrProviderContext) { instanceId: 'instance', actionGroupId: 'default', shouldHaveEventEnd, + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + name: response.body.name, + }, }); } }); @@ -279,6 +303,14 @@ export default function eventLogTests({ getService }: FtrProviderContext) { outcome: 'success', message: `alert executed: test.patternFiring:${alertId}: 'abc'`, status: executeStatuses[executeCount++], + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + name: response.body.name, + }, }); break; case 'execute-action': @@ -294,6 +326,14 @@ export default function eventLogTests({ getService }: FtrProviderContext) { message: `alert: test.patternFiring:${alertId}: 'abc' instanceId: 'instance' scheduled actionGroup(subgroup): 'default(${event?.kibana?.alerting?.action_subgroup})' action: test.noop:${createdAction.id}`, instanceId: 'instance', actionGroupId: 'default', + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + name: response.body.name, + }, }); break; case 'new-instance': @@ -332,6 +372,14 @@ export default function eventLogTests({ getService }: FtrProviderContext) { instanceId: 'instance', actionGroupId: 'default', shouldHaveEventEnd, + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + name: response.body.name, + }, }); } }); @@ -374,6 +422,13 @@ export default function eventLogTests({ getService }: FtrProviderContext) { errorMessage: 'this alert is intended to fail', status: 'error', reason: 'execute', + rule: { + id: alertId, + category: response.body.rule_type_id, + license: 'basic', + ruleset: 'alertsFixture', + namespace: Spaces.space1.id, + }, }); }); }); @@ -397,10 +452,21 @@ interface ValidateEventLogParams { actionGroupId?: string; instanceId?: string; reason?: string; + rule: { + id: string; + name?: string; + version?: string; + category?: string; + reference?: string; + author?: string[]; + license?: string; + ruleset?: string; + namespace?: string; + }; } export function validateEvent(event: IValidatedEvent, params: ValidateEventLogParams): void { - const { spaceId, savedObjects, outcome, message, errorMessage } = params; + const { spaceId, savedObjects, outcome, message, errorMessage, rule } = params; const { status, actionGroupId, instanceId, reason, shouldHaveEventEnd } = params; if (status) { @@ -456,6 +522,8 @@ export function validateEvent(event: IValidatedEvent, params: ValidateEventLogPa expect(event?.message).to.eql(message); + expect(event?.rule).to.eql(rule); + if (errorMessage) { expect(event?.error?.message).to.eql(errorMessage); } diff --git a/x-pack/test/api_integration/apis/features/features/features.ts b/x-pack/test/api_integration/apis/features/features/features.ts index 25f38222bfb6cb..275626664bef07 100644 --- a/x-pack/test/api_integration/apis/features/features/features.ts +++ b/x-pack/test/api_integration/apis/features/features/features.ts @@ -114,6 +114,7 @@ export default function ({ getService }: FtrProviderContext) { 'infrastructure', 'logs', 'maps', + 'observabilityCases', 'uptime', 'siem', 'fleet', diff --git a/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts b/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts index d299795826c266..4a0545049a76e4 100644 --- a/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts +++ b/x-pack/test/api_integration/apis/ml/jobs/datafeed_preview.ts @@ -72,13 +72,10 @@ export default ({ getService }: FtrProviderContext) => { .send({ job, datafeed }) .expect(200); - expect(body.hits.total.value).to.eql(3207, 'Response body total hits should be 3207'); - expect(Array.isArray(body.hits?.hits[0]?.fields?.airline)).to.eql( - true, - 'Response body airlines should be an array' - ); + expect(body.length).to.eql(1000, 'Response body total hits should be 1000'); + expect(typeof body[0]?.airline).to.eql('string', 'Response body airlines should be a string'); - const airlines: string[] = body.hits.hits.map((a: any) => a.fields.airline[0]); + const airlines: string[] = body.map((a: any) => a.airline); expect(airlines.length).to.not.eql(0, 'airlines length should not be 0'); expect(airlines.every((a) => isUpperCase(a))).to.eql( true, @@ -112,13 +109,10 @@ export default ({ getService }: FtrProviderContext) => { .send({ job, datafeed }) .expect(200); - expect(body.hits.total.value).to.eql(300, 'Response body total hits should be 300'); - expect(Array.isArray(body.hits?.hits[0]?.fields?.airline)).to.eql( - true, - 'Response body airlines should be an array' - ); + expect(body.length).to.eql(1000, 'Response body total hits should be 1000'); + expect(typeof body[0]?.airline).to.eql('string', 'Response body airlines should be a string'); - const airlines: string[] = body.hits.hits.map((a: any) => a.fields.airline[0]); + const airlines: string[] = body.map((a: any) => a.airline); expect(airlines.length).to.not.eql(0, 'airlines length should not be 0'); expect(airlines.every((a) => a === 'AAL')).to.eql( true, @@ -157,13 +151,10 @@ export default ({ getService }: FtrProviderContext) => { .send({ job, datafeed }) .expect(200); - expect(body.hits.total.value).to.eql(3207, 'Response body total hits should be 3207'); - expect(Array.isArray(body.hits?.hits[0]?.fields?.lowercase_airline)).to.eql( - true, - 'Response body airlines should be an array' - ); + expect(body.length).to.eql(1000, 'Response body total hits should be 1000'); + expect(typeof body[0]?.airline).to.eql('string', 'Response body airlines should be a string'); - const airlines: string[] = body.hits.hits.map((a: any) => a.fields.lowercase_airline[0]); + const airlines: string[] = body.map((a: any) => a.lowercase_airline); expect(airlines.length).to.not.eql(0, 'airlines length should not be 0'); expect(isLowerCase(airlines[0])).to.eql( true, @@ -205,13 +196,10 @@ export default ({ getService }: FtrProviderContext) => { .send({ job, datafeed }) .expect(200); - expect(body.hits.total.value).to.eql(300, 'Response body total hits should be 300'); - expect(Array.isArray(body.hits?.hits[0]?.fields?.airline)).to.eql( - true, - 'Response body airlines should be an array' - ); + expect(body.length).to.eql(1000, 'Response body total hits should be 1000'); + expect(typeof body[0]?.airline).to.eql('string', 'Response body airlines should be a string'); - const airlines: string[] = body.hits.hits.map((a: any) => a.fields.airline[0]); + const airlines: string[] = body.map((a: any) => a.airline); expect(airlines.length).to.not.eql(0, 'airlines length should not be 0'); expect(isLowerCase(airlines[0])).to.eql( true, diff --git a/x-pack/test/api_integration/apis/security/privileges.ts b/x-pack/test/api_integration/apis/security/privileges.ts index 45b19ae3fe6fee..2468bfec633210 100644 --- a/x-pack/test/api_integration/apis/security/privileges.ts +++ b/x-pack/test/api_integration/apis/security/privileges.ts @@ -60,6 +60,7 @@ export default function ({ getService }: FtrProviderContext) { canvas: ['all', 'read', 'minimal_all', 'minimal_read', 'generate_report'], infrastructure: ['all', 'read'], logs: ['all', 'read'], + observabilityCases: ['all', 'read'], uptime: ['all', 'read'], apm: ['all', 'read'], ml: ['all', 'read'], diff --git a/x-pack/test/api_integration/apis/security/privileges_basic.ts b/x-pack/test/api_integration/apis/security/privileges_basic.ts index 0893bb49cd2159..25266da2cdfb34 100644 --- a/x-pack/test/api_integration/apis/security/privileges_basic.ts +++ b/x-pack/test/api_integration/apis/security/privileges_basic.ts @@ -33,6 +33,7 @@ export default function ({ getService }: FtrProviderContext) { maps: ['all', 'read'], canvas: ['all', 'read'], infrastructure: ['all', 'read'], + observabilityCases: ['all', 'read'], logs: ['all', 'read'], uptime: ['all', 'read'], apm: ['all', 'read'], diff --git a/x-pack/test/apm_api_integration/tests/index.ts b/x-pack/test/apm_api_integration/tests/index.ts index 7c38f37093fa43..813e0e4f3cdb89 100644 --- a/x-pack/test/apm_api_integration/tests/index.ts +++ b/x-pack/test/apm_api_integration/tests/index.ts @@ -84,6 +84,7 @@ export default function apmApiIntegrationTests(providerContext: FtrProviderConte describe('services/annotations', function () { loadTestFile(require.resolve('./services/annotations')); + loadTestFile(require.resolve('./services/derived_annotations')); }); describe('services/service_details', function () { diff --git a/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts b/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts new file mode 100644 index 00000000000000..2ff4eb7e733066 --- /dev/null +++ b/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts @@ -0,0 +1,181 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { APIReturnType } from '../../../../plugins/apm/public/services/rest/createCallApmApi'; +import { createApmApiSupertest } from '../../common/apm_api_supertest'; +import { FtrProviderContext } from '../../common/ftr_provider_context'; +import { registry } from '../../common/registry'; + +export default function annotationApiTests({ getService }: FtrProviderContext) { + const supertestRead = createApmApiSupertest(getService('supertestAsApmReadUser')); + const es = getService('es'); + + const dates = [ + new Date('2021-02-01T00:00:00.000Z'), + new Date('2021-02-01T01:00:00.000Z'), + new Date('2021-02-01T02:00:00.000Z'), + new Date('2021-02-01T03:00:00.000Z'), + ]; + + const indexName = 'apm-8.0.0-transaction'; + + registry.when( + 'Derived deployment annotations with a basic license', + { config: 'basic', archives: [] }, + () => { + describe('when there are multiple service versions', () => { + let response: APIReturnType<'GET /api/apm/services/{serviceName}/annotation/search'>; + + before(async () => { + const { body: indexExists } = await es.indices.exists({ index: indexName }); + if (indexExists) { + await es.indices.delete({ + index: indexName, + }); + } + + await es.indices.create({ + index: indexName, + body: { + mappings: { + properties: { + service: { + properties: { + name: { + type: 'keyword', + }, + version: { + type: 'keyword', + }, + environment: { + type: 'keyword', + }, + }, + }, + transaction: { + properties: { + type: { + type: 'keyword', + }, + duration: { + type: 'long', + }, + }, + }, + observer: { + properties: { + version_major: { + type: 'byte', + }, + }, + }, + processor: { + properties: { + event: { + type: 'keyword', + }, + }, + }, + }, + }, + }, + }); + + const docs = dates.flatMap((date, index) => { + const baseAnnotation = { + transaction: { + type: 'request', + duration: 1000000, + }, + + service: { + name: 'opbeans-java', + environment: 'production', + version: index + 1, + }, + observer: { + version_major: 8, + }, + processor: { + event: 'transaction', + }, + }; + return [ + { + ...baseAnnotation, + '@timestamp': date.toISOString(), + }, + { + ...baseAnnotation, + '@timestamp': new Date(date.getTime() + 30000), + }, + { + ...baseAnnotation, + '@timestamp': new Date(date.getTime() + 60000), + }, + ]; + }); + + await es.bulk({ + index: indexName, + body: docs.flatMap((doc) => [{ index: {} }, doc]), + refresh: true, + }); + + response = ( + await supertestRead({ + endpoint: 'GET /api/apm/services/{serviceName}/annotation/search', + params: { + path: { + serviceName: 'opbeans-java', + }, + query: { + start: dates[1].toISOString(), + end: dates[2].toISOString(), + environment: 'production', + }, + }, + }) + ).body; + }); + + it('annotations are displayed for the service versions in the given time range', async () => { + expect(response.annotations.length).to.be(2); + expect(response.annotations[0]['@timestamp']).to.be(dates[1].getTime()); + expect(response.annotations[1]['@timestamp']).to.be(dates[2].getTime()); + + expectSnapshot(response.annotations[0]).toMatchInline(` + Object { + "@timestamp": 1612141200000, + "id": "2", + "text": "2", + "type": "version", + } + `); + }); + + it('annotations are not displayed for the service versions outside of the given time range', () => { + expect( + response.annotations.some((annotation) => { + return ( + annotation['@timestamp'] !== dates[0].getTime() && + annotation['@timestamp'] !== dates[2].getTime() + ); + }) + ); + }); + + after(async () => { + await es.indices.delete({ + index: indexName, + }); + }); + }); + } + ); +} diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/patch_configure.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/patch_configure.ts index 323b1b377e5555..0e92456b66c859 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/patch_configure.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/patch_configure.ts @@ -8,14 +8,16 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { ObjectRemover as ActionsRemover } from '../../../../../alerting_api_integration/common/lib'; +import { ConnectorTypes } from '../../../../../../plugins/cases/common/api'; import { - getConfigurationRequest, removeServerGeneratedPropertiesFromSavedObject, getConfigurationOutput, deleteConfiguration, createConfiguration, updateConfiguration, + getConfigurationRequest, + getConfiguration, } from '../../../../common/lib/utils'; import { secOnly, @@ -52,6 +54,39 @@ export default ({ getService }: FtrProviderContext): void => { expect(data).to.eql({ ...getConfigurationOutput(true), closure_type: 'close-by-pushing' }); }); + it('should update mapping when changing connector', async () => { + const configuration = await createConfiguration(supertest); + await updateConfiguration(supertest, configuration.id, { + connector: { + id: 'serviceNowITSM', + name: 'ServiceNow ITSM', + type: ConnectorTypes.serviceNowITSM, + fields: null, + }, + version: configuration.version, + }); + const newConfiguration = await getConfiguration({ supertest }); + + expect(configuration.mappings).to.eql([]); + expect(newConfiguration[0].mappings).to.eql([ + { + action_type: 'overwrite', + source: 'title', + target: 'short_description', + }, + { + action_type: 'overwrite', + source: 'description', + target: 'description', + }, + { + action_type: 'append', + source: 'comments', + target: 'work_notes', + }, + ]); + }); + it('should not patch a configuration with unsupported connector type', async () => { const configuration = await createConfiguration(supertest); await updateConfiguration( diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/post_configure.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/post_configure.ts index 44ec24f688f201..fd9e8611db44ad 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/post_configure.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/configure/post_configure.ts @@ -60,20 +60,135 @@ export default ({ getService }: FtrProviderContext): void => { expect(configuration.length).to.be(1); }); - it('should return an error when failing to get mapping', async () => { + it('should return an empty mapping when they type is none', async () => { const postRes = await createConfiguration( supertest, getConfigurationRequest({ id: 'not-exists', name: 'not-exists', - type: ConnectorTypes.jira, + type: ConnectorTypes.none, }) ); - expect(postRes.error).to.not.be(null); expect(postRes.mappings).to.eql([]); }); + it('should return the correct mapping for Jira', async () => { + const postRes = await createConfiguration( + supertest, + getConfigurationRequest({ + id: 'jira', + name: 'Jira', + type: ConnectorTypes.jira, + }) + ); + + expect(postRes.mappings).to.eql([ + { + action_type: 'overwrite', + source: 'title', + target: 'summary', + }, + { + action_type: 'overwrite', + source: 'description', + target: 'description', + }, + { + action_type: 'append', + source: 'comments', + target: 'comments', + }, + ]); + }); + + it('should return the correct mapping for IBM Resilient', async () => { + const postRes = await createConfiguration( + supertest, + getConfigurationRequest({ + id: 'resilient', + name: 'Resilient', + type: ConnectorTypes.resilient, + }) + ); + + expect(postRes.mappings).to.eql([ + { + action_type: 'overwrite', + source: 'title', + target: 'name', + }, + { + action_type: 'overwrite', + source: 'description', + target: 'description', + }, + { + action_type: 'append', + source: 'comments', + target: 'comments', + }, + ]); + }); + + it('should return the correct mapping for ServiceNow ITSM', async () => { + const postRes = await createConfiguration( + supertest, + getConfigurationRequest({ + id: 'serviceNowITSM', + name: 'ServiceNow ITSM', + type: ConnectorTypes.serviceNowITSM, + }) + ); + + expect(postRes.mappings).to.eql([ + { + action_type: 'overwrite', + source: 'title', + target: 'short_description', + }, + { + action_type: 'overwrite', + source: 'description', + target: 'description', + }, + { + action_type: 'append', + source: 'comments', + target: 'work_notes', + }, + ]); + }); + + it('should return the correct mapping for ServiceNow SecOps', async () => { + const postRes = await createConfiguration( + supertest, + getConfigurationRequest({ + id: 'serviceNowSIR', + name: 'ServiceNow SecOps', + type: ConnectorTypes.serviceNowSIR, + }) + ); + + expect(postRes.mappings).to.eql([ + { + action_type: 'overwrite', + source: 'title', + target: 'short_description', + }, + { + action_type: 'overwrite', + source: 'description', + target: 'description', + }, + { + action_type: 'append', + source: 'comments', + target: 'work_notes', + }, + ]); + }); + it('should not create a configuration when missing connector.id', async () => { await createConfiguration( supertest, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts index 491f7bb9c417e5..2294d51537fb13 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_ml.ts @@ -23,6 +23,7 @@ import { deleteListsIndex, importFile, } from '../../../lists_api_integration/utils'; +import { SIGNALS_TEMPLATE_VERSION } from '../../../../plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template'; // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { @@ -127,7 +128,7 @@ export default ({ getService }: FtrProviderContext) => { host: { name: ['mothra'] }, event: { kind: 'signal' }, signal: { - _meta: { version: 35 }, + _meta: { version: SIGNALS_TEMPLATE_VERSION }, parents: [ { id: diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts index 755847e8b645d8..e6a835462619c1 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts @@ -27,6 +27,7 @@ import { import { getCreateThreatMatchRulesSchemaMock } from '../../../../plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.mock'; import { getThreatMatchingSchemaPartialMock } from '../../../../plugins/security_solution/common/detection_engine/schemas/response/rules_schema.mocks'; +import { SIGNALS_TEMPLATE_VERSION } from '../../../../plugins/security_solution/server/lib/detection_engine/routes/index/get_signals_template'; const format = (value: unknown): string => JSON.stringify(value, null, 2); @@ -201,7 +202,7 @@ export default ({ getService }: FtrProviderContext) => { }, signal: { _meta: { - version: 35, + version: SIGNALS_TEMPLATE_VERSION, }, ancestors: [ { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts index 0c274a8f4678bb..d5f287e78268eb 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/finalize_signals_migrations.ts @@ -47,8 +47,7 @@ export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); const supertestWithoutAuth = getService('supertestWithoutAuth'); - // FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/99915 - describe.skip('Finalizing signals migrations', () => { + describe('Finalizing signals migrations', () => { let legacySignalsIndexName: string; let outdatedSignalsIndexName: string; let createdMigrations: CreateResponse[]; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts index 0ba0749e75b08e..c3dbd24ae9f046 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts @@ -853,7 +853,7 @@ export default ({ getService }: FtrProviderContext) => { 'host.id': '8cc95778cce5407c809480e8e32ad76b', event: { kind: 'signal' }, signal: { - _meta: { version: 35 }, + _meta: { version: SIGNALS_TEMPLATE_VERSION }, parents: [ { depth: 0, @@ -1011,7 +1011,7 @@ export default ({ getService }: FtrProviderContext) => { 'host.id': '8cc95778cce5407c809480e8e32ad76b', event: { kind: 'signal' }, signal: { - _meta: { version: 35 }, + _meta: { version: SIGNALS_TEMPLATE_VERSION }, parents: [ { depth: 0, @@ -1101,7 +1101,7 @@ export default ({ getService }: FtrProviderContext) => { 'process.name': 'sshd', event: { kind: 'signal' }, signal: { - _meta: { version: 35 }, + _meta: { version: SIGNALS_TEMPLATE_VERSION }, parents: [ { depth: 0, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts index 6bb00c55f690e1..5c726a177bb601 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_signals_migration_status.ts @@ -19,8 +19,7 @@ export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); const supertestWithoutAuth = getService('supertestWithoutAuth'); - // FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/99915 - describe.skip('Signals migration status', () => { + describe('Signals migration status', () => { let legacySignalsIndexName: string; beforeEach(async () => { await createSignalsIndex(supertest); diff --git a/x-pack/test/functional/apps/lens/formula.ts b/x-pack/test/functional/apps/lens/formula.ts new file mode 100644 index 00000000000000..e9e5051c006f02 --- /dev/null +++ b/x-pack/test/functional/apps/lens/formula.ts @@ -0,0 +1,198 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const find = getService('find'); + const listingTable = getService('listingTable'); + const browser = getService('browser'); + const testSubjects = getService('testSubjects'); + + describe('lens formula', () => { + it('should transition from count to formula', async () => { + await PageObjects.visualize.gotoVisualizationLandingPage(); + await listingTable.searchForItemWithName('lnsXYvis'); + await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); + await PageObjects.lens.goToTimeRange(); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', + operation: 'average', + field: 'bytes', + keepOpen: true, + }); + + await PageObjects.lens.switchToFormula(); + await PageObjects.header.waitUntilLoadingHasFinished(); + // .echLegendItem__title is the only viable way of getting the xy chart's + // legend item(s), so we're using a class selector here. + // 4th item is the other bucket + expect(await find.allByCssSelector('.echLegendItem')).to.have.length(3); + }); + + it('should update and delete a formula', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `count(kql=`, + keepOpen: true, + }); + + const input = await find.activeElement(); + await input.type('*'); + + await PageObjects.header.waitUntilLoadingHasFinished(); + expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('14,005'); + }); + + it('should insert single quotes and escape when needed to create valid KQL', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `count(kql=`, + keepOpen: true, + }); + + let input = await find.activeElement(); + await input.type(' '); + await input.pressKeys(browser.keys.ARROW_LEFT); + await input.type(`Men's Clothing`); + + await PageObjects.common.sleep(100); + + let element = await find.byCssSelector('.monaco-editor'); + expect(await element.getVisibleText()).to.equal(`count(kql='Men\\'s Clothing ')`); + + await PageObjects.lens.typeFormula('count(kql='); + input = await find.activeElement(); + await input.type(`Men\'s Clothing`); + + element = await find.byCssSelector('.monaco-editor'); + expect(await element.getVisibleText()).to.equal(`count(kql='Men\\'s Clothing')`); + }); + + it('should persist a broken formula on close', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + // Close immediately + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `asdf`, + }); + + expect(await PageObjects.lens.getErrorCount()).to.eql(1); + }); + + it('should keep the formula when entering expanded mode', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + // Close immediately + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `count()`, + keepOpen: true, + }); + + await PageObjects.lens.toggleFullscreen(); + + const element = await find.byCssSelector('.monaco-editor'); + expect(await element.getVisibleText()).to.equal('count()'); + }); + + it('should allow an empty formula combined with a valid formula', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `count()`, + }); + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + }); + + await PageObjects.header.waitUntilLoadingHasFinished(); + expect(await PageObjects.lens.getErrorCount()).to.eql(0); + }); + + it('should duplicate a moving average formula and be a valid table', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_rows > lns-empty-dimension', + operation: 'date_histogram', + field: '@timestamp', + }); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `moving_average(sum(bytes), window=5`, + keepOpen: true, + }); + await PageObjects.lens.closeDimensionEditor(); + + await PageObjects.lens.dragDimensionToDimension( + 'lnsDatatable_metrics > lns-dimensionTrigger', + 'lnsDatatable_metrics > lns-empty-dimension' + ); + expect(await PageObjects.lens.getDatatableCellText(1, 1)).to.eql('222420'); + expect(await PageObjects.lens.getDatatableCellText(1, 2)).to.eql('222420'); + }); + + it('should keep the formula if the user does not fully transition to a quick function', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchToVisualization('lnsDatatable'); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsDatatable_metrics > lns-empty-dimension', + operation: 'formula', + formula: `count()`, + keepOpen: true, + }); + + await PageObjects.lens.switchToQuickFunctions(); + await testSubjects.click(`lns-indexPatternDimension-min incompatible`); + await PageObjects.common.sleep(1000); + await PageObjects.lens.closeDimensionEditor(); + + expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_metrics', 0)).to.eql( + 'count()' + ); + }); + }); +} diff --git a/x-pack/test/functional/apps/lens/index.ts b/x-pack/test/functional/apps/lens/index.ts index 1efceace8b1676..99b75bdabe6c4a 100644 --- a/x-pack/test/functional/apps/lens/index.ts +++ b/x-pack/test/functional/apps/lens/index.ts @@ -41,6 +41,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./geo_field')); loadTestFile(require.resolve('./lens_reporting')); loadTestFile(require.resolve('./lens_tagging')); + loadTestFile(require.resolve('./formula')); // has to be last one in the suite because it overrides saved objects loadTestFile(require.resolve('./rollup')); diff --git a/x-pack/test/functional/apps/lens/smokescreen.ts b/x-pack/test/functional/apps/lens/smokescreen.ts index 2a4d56bbea791a..5d775f154c9430 100644 --- a/x-pack/test/functional/apps/lens/smokescreen.ts +++ b/x-pack/test/functional/apps/lens/smokescreen.ts @@ -172,10 +172,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('indexPattern-dimension-formatDecimals'); + await PageObjects.lens.closeDimensionEditor(); + expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Test of label' ); - await PageObjects.lens.closeDimensionEditor(); }); it('should be able to add very long labels and still be able to remove a dimension', async () => { @@ -587,6 +588,57 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); }); + it('should not leave an incomplete column in the visualization config with field-based operation', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', + operation: 'min', + }); + + expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + undefined + ); + }); + + it('should not leave an incomplete column in the visualization config with reference-based operations', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', + operation: 'date_histogram', + field: '@timestamp', + }); + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', + operation: 'moving_average', + field: 'Records', + }); + + expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + 'Moving average of Count of records' + ); + + await PageObjects.lens.configureDimension({ + dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', + operation: 'median', + isPreviousIncompatible: true, + keepOpen: true, + }); + + expect(await PageObjects.lens.isDimensionEditorOpen()).to.eql(true); + + await PageObjects.lens.closeDimensionEditor(); + + expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + undefined + ); + }); + it('should transition from unique count to last value', async () => { await PageObjects.visualize.navigateToNewVisualization(); await PageObjects.visualize.clickVisType('lens'); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js index 02f65fd5579da0..9c03faf72eff1f 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js @@ -249,7 +249,8 @@ export default function ({ getService, getPageObjects }) { }); }); - describe('with only online nodes', () => { + // FLAKY: https://github.com/elastic/kibana/issues/100438 + describe.skip('with only online nodes', () => { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { diff --git a/x-pack/test/functional/apps/observability/feature_controls/index.ts b/x-pack/test/functional/apps/observability/feature_controls/index.ts new file mode 100644 index 00000000000000..53fba574134438 --- /dev/null +++ b/x-pack/test/functional/apps/observability/feature_controls/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('feature controls', function () { + this.tags('skipFirefox'); + loadTestFile(require.resolve('./observability_security')); + }); +} diff --git a/x-pack/test/functional/apps/observability/feature_controls/observability_security.ts b/x-pack/test/functional/apps/observability/feature_controls/observability_security.ts new file mode 100644 index 00000000000000..d27f1acdd3e317 --- /dev/null +++ b/x-pack/test/functional/apps/observability/feature_controls/observability_security.ts @@ -0,0 +1,216 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const security = getService('security'); + const PageObjects = getPageObjects([ + 'common', + 'observability', + 'error', + 'security', + 'spaceSelector', + ]); + const appsMenu = getService('appsMenu'); + const testSubjects = getService('testSubjects'); + describe('observability security feature controls', function () { + this.tags(['skipFirefox']); + before(async () => { + await esArchiver.load('x-pack/test/functional/es_archives/cases/default'); + }); + + after(async () => { + await esArchiver.unload('x-pack/test/functional/es_archives/cases/default'); + }); + + describe('observability cases all privileges', () => { + before(async () => { + await security.role.create('cases_observability_all_role', { + elasticsearch: { cluster: [], indices: [], run_as: [] }, + kibana: [ + { spaces: ['*'], base: [], feature: { observabilityCases: ['all'], logs: ['all'] } }, + ], + }); + + await security.user.create('cases_observability_all_user', { + password: 'cases_observability_all_user-password', + roles: ['cases_observability_all_role'], + full_name: 'test user', + }); + + await PageObjects.security.forceLogout(); + + await PageObjects.security.login( + 'cases_observability_all_user', + 'cases_observability_all_user-password', + { + expectSpaceSelector: false, + } + ); + }); + + after(async () => { + await PageObjects.security.forceLogout(); + await Promise.all([ + security.role.delete('cases_observability_all_role'), + security.user.delete('cases_observability_all_user'), + ]); + }); + + it('shows observability/cases navlink', async () => { + const navLinks = (await appsMenu.readLinks()).map((link) => link.text).slice(0, 2); + expect(navLinks).to.eql(['Overview', 'Cases']); + }); + + it(`landing page shows "Create new case" button`, async () => { + await PageObjects.common.navigateToActualUrl('observabilityCases'); + await PageObjects.observability.expectCreateCaseButtonEnabled(); + }); + + it(`doesn't show read-only badge`, async () => { + await PageObjects.observability.expectNoReadOnlyCallout(); + }); + + it(`allows a case to be created`, async () => { + await PageObjects.common.navigateToActualUrl('observabilityCases'); + + await testSubjects.click('createNewCaseBtn'); + + await PageObjects.observability.expectCreateCase(); + }); + + it(`allows a case to be edited`, async () => { + await PageObjects.common.navigateToUrl( + 'observabilityCases', + '4c32e6b0-c3c5-11eb-b389-3fadeeafa60f', + { + shouldUseHashForSubUrl: false, + } + ); + await PageObjects.observability.expectAddCommentButton(); + }); + }); + + describe('observability cases read-only privileges', () => { + before(async () => { + await security.role.create('cases_observability_read_role', { + elasticsearch: { cluster: [], indices: [], run_as: [] }, + kibana: [ + { + spaces: ['*'], + base: [], + feature: { observabilityCases: ['read'], logs: ['all'] }, + }, + ], + }); + + await security.user.create('cases_observability_read_user', { + password: 'cases_observability_read_user-password', + roles: ['cases_observability_read_role'], + full_name: 'test user', + }); + + await PageObjects.security.login( + 'cases_observability_read_user', + 'cases_observability_read_user-password', + { + expectSpaceSelector: false, + } + ); + }); + + after(async () => { + await security.role.delete('cases_observability_read_role'); + await security.user.delete('cases_observability_read_user'); + }); + + it('shows observability/cases navlink', async () => { + const navLinks = (await appsMenu.readLinks()).map((link) => link.text).slice(0, 2); + expect(navLinks).to.eql(['Overview', 'Cases']); + }); + + it(`landing page shows disabled "Create new case" button`, async () => { + await PageObjects.common.navigateToActualUrl('observabilityCases'); + await PageObjects.observability.expectCreateCaseButtonDisabled(); + }); + + it(`shows read-only callout`, async () => { + await PageObjects.observability.expectReadOnlyCallout(); + }); + + it(`does not allow a case to be created`, async () => { + await PageObjects.common.navigateToUrl('observabilityCases', 'create', { + shouldUseHashForSubUrl: false, + }); + + // expect redirection to observability cases landing + await PageObjects.observability.expectCreateCaseButtonDisabled(); + }); + + it(`does not allow a case to be edited`, async () => { + await PageObjects.common.navigateToUrl( + 'observabilityCases', + '4c32e6b0-c3c5-11eb-b389-3fadeeafa60f', + { + shouldUseHashForSubUrl: false, + } + ); + await PageObjects.observability.expectAddCommentButtonDisabled(); + }); + }); + + describe('no observability privileges', () => { + before(async () => { + await security.role.create('no_observability_privileges_role', { + elasticsearch: { cluster: [], indices: [], run_as: [] }, + kibana: [ + { + feature: { + discover: ['all'], + }, + spaces: ['*'], + }, + ], + }); + + await security.user.create('no_observability_privileges_user', { + password: 'no_observability_privileges_user-password', + roles: ['no_observability_privileges_role'], + full_name: 'test user', + }); + + await PageObjects.security.login( + 'no_observability_privileges_user', + 'no_observability_privileges_user-password', + { + expectSpaceSelector: false, + } + ); + }); + + after(async () => { + await security.role.delete('no_observability_privileges_role'); + await security.user.delete('no_observability_privileges_user'); + }); + + it(`returns a 403`, async () => { + await PageObjects.common.navigateToActualUrl('observabilityCases'); + await PageObjects.observability.expectForbidden(); + }); + + it.skip(`create new case returns a 403`, async () => { + await PageObjects.common.navigateToUrl('observabilityCases', 'create', { + shouldUseHashForSubUrl: false, + }); + await PageObjects.observability.expectForbidden(); + }); + }); + }); +} diff --git a/x-pack/test/functional/apps/observability/index.ts b/x-pack/test/functional/apps/observability/index.ts new file mode 100644 index 00000000000000..b7f03b5f27bae4 --- /dev/null +++ b/x-pack/test/functional/apps/observability/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { + describe('Observability specs', function () { + this.tags('ciGroup6'); + loadTestFile(require.resolve('./feature_controls')); + }); +} diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 20487047a3a56d..2679bb55ad341c 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -60,6 +60,7 @@ export default async function ({ readConfigFile }) { resolve(__dirname, './apps/reporting_management'), resolve(__dirname, './apps/management'), resolve(__dirname, './apps/reporting'), + resolve(__dirname, './apps/observability'), // This license_management file must be last because it is destructive. resolve(__dirname, './apps/license_management'), @@ -94,6 +95,7 @@ export default async function ({ readConfigFile }) { '--xpack.discoverEnhanced.actions.exploreDataInContextMenu.enabled=true', '--timelion.ui.enabled=true', '--savedObjects.maxImportPayloadBytes=10485760', // for OSS test management/_import_objects + '--xpack.observability.unsafe.cases.enabled=true', ], }, uiSettings: { diff --git a/x-pack/test/functional/es_archives/cases/default/data.json.gz b/x-pack/test/functional/es_archives/cases/default/data.json.gz new file mode 100644 index 00000000000000..9ec4efad4bdfc7 Binary files /dev/null and b/x-pack/test/functional/es_archives/cases/default/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/cases/default/mappings.json b/x-pack/test/functional/es_archives/cases/default/mappings.json new file mode 100644 index 00000000000000..28d9daff50d94f --- /dev/null +++ b/x-pack/test/functional/es_archives/cases/default/mappings.json @@ -0,0 +1,322 @@ +{ + "type": "index", + "value": { + "aliases": { + ".kibana": { + } + }, + "index": ".kibana_1", + "mappings": { + "properties": { + "cases": { + "properties": { + "closed_at": { + "type": "date" + }, + "closed_by": { + "properties": { + "username": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "connector": { + "properties": { + "fields": { + "properties": { + "key": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "value": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "id": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "name": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "type": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "created_at": { + "type": "date" + }, + "created_by": { + "properties": { + "email": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "full_name": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "username": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "description": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "external_service": { + "properties": { + "connector_id": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "connector_name": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "external_id": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "external_title": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "external_url": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "pushed_at": { + "type": "date" + }, + "pushed_by": { + "properties": { + "username": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + } + } + }, + "owner": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "settings": { + "properties": { + "syncAlerts": { + "type": "boolean" + } + } + }, + "status": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "tags": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "title": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "type": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "updated_at": { + "type": "date" + }, + "updated_by": { + "properties": { + "email": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "full_name": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "username": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + } + } + }, + "coreMigrationVersion": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "migrationVersion": { + "properties": { + "cases": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + } + } + }, + "type": { + "fields": { + "keyword": { + "ignore_above": 256, + "type": "keyword" + } + }, + "type": "text" + }, + "updated_at": { + "type": "date" + } + } + }, + "settings": { + "index": { + "auto_expand_replicas": "0-1", + "number_of_replicas": "1", + "number_of_shards": "1" + } + } + } +} diff --git a/x-pack/test/functional/page_objects/index.ts b/x-pack/test/functional/page_objects/index.ts index a362fd7e4b7c2a..5c3d9b680fc412 100644 --- a/x-pack/test/functional/page_objects/index.ts +++ b/x-pack/test/functional/page_objects/index.ts @@ -16,6 +16,7 @@ import { GrokDebuggerPageObject } from './grok_debugger_page'; import { WatcherPageObject } from './watcher_page'; import { ReportingPageObject } from './reporting_page'; import { AccountSettingsPageObject } from './account_settings_page'; +import { ObservabilityPageProvider } from './observability_page'; import { InfraHomePageProvider } from './infra_home_page'; import { InfraLogsPageProvider } from './infra_logs_page'; import { GisPageObject } from './gis_page'; @@ -82,4 +83,5 @@ export const pageObjects = { navigationalSearch: NavigationalSearchPageObject, banners: BannersPageObject, detections: DetectionsPageObject, + observability: ObservabilityPageProvider, }; diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index c0111afad28932..b2790d0f7a08ef 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -42,6 +42,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont return await testSubjects.findAll('lnsFieldListPanelField'); }, + async isLensPageOrFail() { + return await testSubjects.existOrFail('lnsApp'); + }, + /** * Move the date filter to the specified time range, defaults to * a range that has data in our dataset. @@ -88,7 +92,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont * @param title - the title of the list item to be clicked */ clickVisualizeListItemTitle(title: string) { - return testSubjects.click(`visListingTitleLink-${title}`); + return retry.try(async () => { + await testSubjects.click(`visListingTitleLink-${title}`); + await this.isLensPageOrFail(); + }); }, /** @@ -107,6 +114,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont isPreviousIncompatible?: boolean; keepOpen?: boolean; palette?: string; + formula?: string; }, layerIndex = 0 ) { @@ -114,10 +122,15 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await testSubjects.click(`lns-layerPanel-${layerIndex} > ${opts.dimension}`); await testSubjects.exists(`lns-indexPatternDimension-${opts.operation}`); }); - const operationSelector = opts.isPreviousIncompatible - ? `lns-indexPatternDimension-${opts.operation} incompatible` - : `lns-indexPatternDimension-${opts.operation}`; - await testSubjects.click(operationSelector); + + if (opts.operation === 'formula') { + await this.switchToFormula(); + } else { + const operationSelector = opts.isPreviousIncompatible + ? `lns-indexPatternDimension-${opts.operation} incompatible` + : `lns-indexPatternDimension-${opts.operation}`; + await testSubjects.click(operationSelector); + } if (opts.field) { const target = await testSubjects.find('indexPattern-dimension-field'); @@ -125,6 +138,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await comboBox.setElement(target, opts.field); } + if (opts.formula) { + await this.typeFormula(opts.formula); + } + if (opts.palette) { await this.setPalette(opts.palette); } @@ -357,7 +374,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await retry.try(async () => { await testSubjects.click('lns-palettePicker'); const currentPalette = await ( - await find.byCssSelector('[aria-selected=true]') + await find.byCssSelector('[role=option][aria-selected=true]') ).getAttribute('id'); expect(currentPalette).to.equal(palette); }); @@ -379,6 +396,18 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont }); }, + async isDimensionEditorOpen() { + return await testSubjects.exists('lns-indexPattern-dimensionContainerBack'); + }, + + // closes the dimension editor flyout + async closeDimensionEditor() { + await retry.try(async () => { + await testSubjects.click('lns-indexPattern-dimensionContainerBack'); + await testSubjects.missingOrFail('lns-indexPattern-dimensionContainerBack'); + }); + }, + async enableTimeShift() { await testSubjects.click('indexPattern-advanced-popover'); await retry.try(async () => { @@ -398,14 +427,6 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await testSubjects.click('errorFixAction'); }, - // closes the dimension editor flyout - async closeDimensionEditor() { - await retry.try(async () => { - await testSubjects.click('lns-indexPattern-dimensionContainerBack'); - await testSubjects.missingOrFail('lns-indexPattern-dimensionContainerBack'); - }); - }, - async isTopLevelAggregation() { return await testSubjects.isEuiSwitchChecked('indexPattern-nesting-switch'); }, @@ -549,7 +570,8 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont }); } const errors = await testSubjects.findAll('configuration-failure-error'); - return errors?.length ?? 0; + const expressionErrors = await testSubjects.findAll('expression-failure'); + return (errors?.length ?? 0) + (expressionErrors?.length ?? 0); }, async searchOnChartSwitch(subVisualizationId: string, searchTerm?: string) { @@ -1025,5 +1047,27 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont ); await PageObjects.header.waitUntilLoadingHasFinished(); }, + + async switchToQuickFunctions() { + await testSubjects.click('lens-dimensionTabs-quickFunctions'); + }, + + async switchToFormula() { + await testSubjects.click('lens-dimensionTabs-formula'); + }, + + async toggleFullscreen() { + await testSubjects.click('lnsFormula-fullscreen'); + }, + + async typeFormula(formula: string) { + // Formula takes time to open + await PageObjects.common.sleep(500); + await find.byCssSelector('.monaco-editor'); + await find.clickByCssSelectorWhenNotDisabled('.monaco-editor'); + const input = await find.activeElement(); + await input.clearValueWithKeyboard(); + await input.type(formula); + }, }); } diff --git a/x-pack/test/functional/page_objects/observability_page.ts b/x-pack/test/functional/page_objects/observability_page.ts new file mode 100644 index 00000000000000..95016c31d10541 --- /dev/null +++ b/x-pack/test/functional/page_objects/observability_page.ts @@ -0,0 +1,59 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; + +import { FtrProviderContext } from '../ftr_provider_context'; + +export function ObservabilityPageProvider({ getService, getPageObjects }: FtrProviderContext) { + const testSubjects = getService('testSubjects'); + const find = getService('find'); + + return { + async expectCreateCaseButtonEnabled() { + const button = await testSubjects.find('createNewCaseBtn', 20000); + const disabledAttr = await button.getAttribute('disabled'); + expect(disabledAttr).to.be(null); + }, + + async expectCreateCaseButtonDisabled() { + const button = await testSubjects.find('createNewCaseBtn', 20000); + const disabledAttr = await button.getAttribute('disabled'); + expect(disabledAttr).to.be('true'); + }, + + async expectReadOnlyCallout() { + await testSubjects.existOrFail('case-callout-e41900b01c9ef0fa81dd6ff326083fb3'); + }, + + async expectNoReadOnlyCallout() { + await testSubjects.missingOrFail('case-callout-e41900b01c9ef0fa81dd6ff326083fb3'); + }, + + async expectCreateCase() { + await testSubjects.existOrFail('case-creation-form-steps'); + }, + + async expectAddCommentButton() { + const button = await testSubjects.find('submit-comment', 20000); + const disabledAttr = await button.getAttribute('disabled'); + expect(disabledAttr).to.be(null); + }, + + async expectAddCommentButtonDisabled() { + const button = await testSubjects.find('submit-comment', 20000); + const disabledAttr = await button.getAttribute('disabled'); + expect(disabledAttr).to.be('true'); + }, + + async expectForbidden() { + const h2 = await find.byCssSelector('body', 20000); + const text = await h2.getVisibleText(); + expect(text).to.contain('Kibana feature privileges required'); + }, + }; +} diff --git a/x-pack/test/functional/page_objects/reporting_page.ts b/x-pack/test/functional/page_objects/reporting_page.ts index e8999999ce50b6..742d41031004bc 100644 --- a/x-pack/test/functional/page_objects/reporting_page.ts +++ b/x-pack/test/functional/page_objects/reporting_page.ts @@ -91,7 +91,7 @@ export class ReportingPageObject extends FtrService { } async getQueueReportError() { - return await this.testSubjects.exists('queueReportError'); + return await this.testSubjects.exists('errorToastMessage'); } async getGenerateReportButton() { diff --git a/x-pack/test/functional/page_objects/security_page.ts b/x-pack/test/functional/page_objects/security_page.ts index 437749d31c15e3..85382465d974ed 100644 --- a/x-pack/test/functional/page_objects/security_page.ts +++ b/x-pack/test/functional/page_objects/security_page.ts @@ -207,10 +207,7 @@ export class SecurityPageObject extends FtrService { } if (expectedResult === 'chrome') { - await this.find.byCssSelector( - '[data-test-subj="kibanaChrome"] .kbnAppWrapper:not(.kbnAppWrapper--hiddenChrome)', - 20000 - ); + await this.find.byCssSelector('[data-test-subj="userMenuButton"]', 20000); this.log.debug(`Finished login process currentUrl = ${await this.browser.getCurrentUrl()}`); } } diff --git a/x-pack/test/functional/services/ml/alerting.ts b/x-pack/test/functional/services/ml/alerting.ts index 327a0e574f0fde..241ffde6f7628e 100644 --- a/x-pack/test/functional/services/ml/alerting.ts +++ b/x-pack/test/functional/services/ml/alerting.ts @@ -94,10 +94,10 @@ export function MachineLearningAlertingProvider( await this.assertPreviewCalloutVisible(); }, - async checkPreview(expectedMessage: string) { + async checkPreview(expectedMessagePattern: RegExp) { await this.clickPreviewButton(); const previewMessage = await testSubjects.getVisibleText('mlAnomalyAlertPreviewMessage'); - expect(previewMessage).to.eql(expectedMessage); + expect(previewMessage).to.match(expectedMessagePattern); }, async assertPreviewCalloutVisible() { diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index 9a96b1ec372dc5..317f2dfe605143 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -541,7 +541,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { }, async waitForDatafeedToNotExist(datafeedId: string) { - await retry.waitForWithTimeout(`'${datafeedId}' to exist`, 5 * 1000, async () => { + await retry.waitForWithTimeout(`'${datafeedId}' to not exist`, 5 * 1000, async () => { if ((await this.datafeedExist(datafeedId)) === false) { return true; } else { diff --git a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts index 0f5e12f226c0ed..63326448ec1e51 100644 --- a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts @@ -92,6 +92,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); after(async () => { + await ml.api.deleteAnomalyDetectionJobES(testJobId); await ml.api.cleanMlIndices(); await ml.alerting.cleanAnomalyDetectionRules(); }); @@ -119,7 +120,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await ml.alerting.assertPreviewButtonState(false); await ml.alerting.setTestInterval('2y'); await ml.alerting.assertPreviewButtonState(true); - await ml.alerting.checkPreview('Found 13 anomalies in the last 2y.'); + + // don't check the exact number provided by the backend, just make sure it's > 0 + await ml.alerting.checkPreview(/Found [1-9]\d* anomalies in the last 2y/); await ml.testExecution.logTestStep('should create an alert'); await pageObjects.triggersActionsUI.setAlertName('ml-test-alert'); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts index 34e08ad257f849..8cf92f77d939c7 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts @@ -136,7 +136,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('renders the alert details', async () => { const headingText = await pageObjects.alertDetailsUI.getHeadingText(); - expect(headingText).to.be(`test-alert-${testRunUuid}`); + expect(headingText.includes(`test-alert-${testRunUuid}`)).to.be(true); const alertType = await pageObjects.alertDetailsUI.getAlertType(); expect(alertType).to.be(`Always Firing`); @@ -279,7 +279,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(toastTitle).to.eql(`Updated '${updatedAlertName}'`); const headingText = await pageObjects.alertDetailsUI.getHeadingText(); - expect(headingText).to.be(updatedAlertName); + expect(headingText.includes(updatedAlertName)).to.be(true); }); it('should reset alert when canceling an edit', async () => { diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts index a631bf3781d09a..7d235d9e181082 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/alert_flyout.ts @@ -6,11 +6,12 @@ */ import expect from '@kbn/expect'; +import { delay } from 'bluebird'; + import { FtrProviderContext } from '../../ftr_provider_context'; export default ({ getPageObjects, getService }: FtrProviderContext) => { - // FLAKY: https://github.com/elastic/kibana/issues/88177 - describe.skip('uptime alerts', () => { + describe('uptime alerts', () => { const pageObjects = getPageObjects(['common', 'uptime']); const supertest = getService('supertest'); const retry = getService('retry'); @@ -91,11 +92,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // put the fetch code in a retry block with a timeout. let alert: any; await retry.tryForTime(60 * 1000, async () => { + // add a delay before next call to not overload the server + await delay(1500); const apiResponse = await supertest.get('/api/alerts/_find?search=uptime-test'); const alertsFromThisTest = apiResponse.body.data.filter( ({ name }: { name: string }) => name === 'uptime-test' ); - expect(alertsFromThisTest).to.have.length(1); + expect(alertsFromThisTest.length >= 1).to.be(true); alert = alertsFromThisTest[0]; }); @@ -124,7 +127,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(timerangeUnit).to.be('h'); expect(timerangeCount).to.be(1); expect(JSON.stringify(filters)).to.eql( - `{"url.port":["5678"],"observer.geo.name":["mpls"],"monitor.type":["http"],"tags":[]}` + `{"tags":[],"url.port":["5678"],"observer.geo.name":["mpls"],"monitor.type":["http"]}` ); } finally { await supertest.delete(`/api/alerts/alert/${id}`).set('kbn-xsrf', 'true').expect(204); diff --git a/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/public/plugin.ts b/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/public/plugin.ts index 48a3aca742c72c..fc51740e829009 100644 --- a/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/public/plugin.ts +++ b/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/public/plugin.ts @@ -8,7 +8,7 @@ import React from 'react'; import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public'; import { PluginSetupContract as AlertingSetup } from '../../../../../../plugins/alerting/public'; -import { AlertType, SanitizedAlert } from '../../../../../../plugins/alerting/common'; +import { SanitizedAlert } from '../../../../../../plugins/alerting/common'; import { TriggersAndActionsUIPublicPluginSetup } from '../../../../../../plugins/triggers_actions_ui/public'; export type Setup = void; @@ -24,7 +24,7 @@ export class AlertingFixturePlugin implements Plugin `/rule/${alert.id}` + (alert: SanitizedAlert) => `/rule/${alert.id}` ); triggersActionsUi.alertTypeRegistry.register({ diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/health_route.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/health_route.ts index d99c1dac9a25e9..2626ef2421f0b8 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/health_route.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/health_route.ts @@ -27,7 +27,14 @@ interface MonitoringStats { task_types: Record; schedule: Array<[string, number]>; overdue: number; + non_recurring: number; + owner_ids: number; estimated_schedule_density: number[]; + capacity_requirments: { + per_minute: number; + per_hour: number; + per_day: number; + }; }; }; runtime: { @@ -38,6 +45,7 @@ interface MonitoringStats { load: Record; execution: { duration: Record>; + persistence: Record; result_frequency_percent_as_number: Record>; }; polling: { @@ -49,6 +57,27 @@ interface MonitoringStats { }; }; }; + capacity_estimation: { + timestamp: string; + value: { + observed: { + observed_kibana_instances: number; + max_throughput_per_minute: number; + max_throughput_per_minute_per_kibana: number; + minutes_to_drain_overdue: number; + avg_required_throughput_per_minute: number; + avg_required_throughput_per_minute_per_kibana: number; + avg_recurring_required_throughput_per_minute: number; + avg_recurring_required_throughput_per_minute_per_kibana: number; + }; + proposed: { + min_required_kibana: number; + avg_recurring_required_throughput_per_minute_per_kibana: number; + avg_required_throughput_per_minute: number; + avg_required_throughput_per_minute_per_kibana: number; + }; + }; + }; }; } @@ -155,12 +184,44 @@ export default function ({ getService }: FtrProviderContext) { }); it('should return a breakdown of idleTasks in the task manager workload', async () => { + const { + capacity_estimation: { + value: { observed, proposed }, + }, + } = (await getHealth()).stats; + + expect(typeof observed.observed_kibana_instances).to.eql('number'); + expect(typeof observed.max_throughput_per_minute).to.eql('number'); + expect(typeof observed.max_throughput_per_minute_per_kibana).to.eql('number'); + expect(typeof observed.minutes_to_drain_overdue).to.eql('number'); + expect(typeof observed.avg_required_throughput_per_minute).to.eql('number'); + expect(typeof observed.avg_required_throughput_per_minute_per_kibana).to.eql('number'); + expect(typeof observed.avg_recurring_required_throughput_per_minute).to.eql('number'); + expect(typeof observed.avg_recurring_required_throughput_per_minute_per_kibana).to.eql( + 'number' + ); + + expect(typeof proposed.min_required_kibana).to.eql('number'); + expect(typeof proposed.avg_recurring_required_throughput_per_minute_per_kibana).to.eql( + 'number' + ); + expect(typeof proposed.avg_required_throughput_per_minute_per_kibana).to.eql('number'); + }); + + it('should return an estimation of task manager capacity', async () => { const { workload: { value: workload }, } = (await getHealth()).stats; expect(typeof workload.overdue).to.eql('number'); + expect(typeof workload.non_recurring).to.eql('number'); + expect(typeof workload.owner_ids).to.eql('number'); + + expect(typeof workload.capacity_requirments.per_minute).to.eql('number'); + expect(typeof workload.capacity_requirments.per_hour).to.eql('number'); + expect(typeof workload.capacity_requirments.per_day).to.eql('number'); + expect(Array.isArray(workload.estimated_schedule_density)).to.eql(true); // test run with the default poll_interval of 3s and a monitored_aggregated_stats_refresh_rate of 5s, @@ -220,6 +281,10 @@ export default function ({ getService }: FtrProviderContext) { expect(typeof execution.duration.sampleTask.p95).to.eql('number'); expect(typeof execution.duration.sampleTask.p99).to.eql('number'); + expect(typeof execution.persistence.ephemeral).to.eql('number'); + expect(typeof execution.persistence.non_recurring).to.eql('number'); + expect(typeof execution.persistence.recurring).to.eql('number'); + expect(typeof execution.result_frequency_percent_as_number.sampleTask.Success).to.eql( 'number' ); diff --git a/x-pack/test/security_functional/tests/oidc/url_capture.ts b/x-pack/test/security_functional/tests/oidc/url_capture.ts index 4c6b68cc3757c6..706189dcb5a2a9 100644 --- a/x-pack/test/security_functional/tests/oidc/url_capture.ts +++ b/x-pack/test/security_functional/tests/oidc/url_capture.ts @@ -43,10 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { deployment.getHostPort() + '/app/management/security/users#some=hash-value' ); - await find.byCssSelector( - '[data-test-subj="kibanaChrome"] .kbnAppWrapper:not(.kbnAppWrapper--hiddenChrome)', - 20000 - ); + await find.byCssSelector('[data-test-subj="userMenuButton"]', 20000); // We need to make sure that both path and hash are respected. const currentURL = parse(await browser.getCurrentUrl()); diff --git a/x-pack/test/security_functional/tests/saml/url_capture.ts b/x-pack/test/security_functional/tests/saml/url_capture.ts index 65d7688472539b..2b0b8690ebab66 100644 --- a/x-pack/test/security_functional/tests/saml/url_capture.ts +++ b/x-pack/test/security_functional/tests/saml/url_capture.ts @@ -43,10 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { deployment.getHostPort() + '/app/management/security/users#some=hash-value' ); - await find.byCssSelector( - '[data-test-subj="kibanaChrome"] .kbnAppWrapper:not(.kbnAppWrapper--hiddenChrome)', - 20000 - ); + await find.byCssSelector('[data-test-subj="userMenuButton"]', 20000); // We need to make sure that both path and hash are respected. const currentURL = parse(await browser.getCurrentUrl()); diff --git a/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js b/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js index 83a759abe337d7..00fce236b5d172 100644 --- a/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js +++ b/x-pack/test/stack_functional_integration/apps/ccs/ccs_discover.js @@ -227,7 +227,6 @@ export default ({ getService, getPageObjects }) => { url: process.env.TEST_KIBANA_URLDATA, certificateAuthorities: config.get('servers.kibana.certificateAuthorities'), uiSettingDefaults: kibanaServer.uiSettings, - importExportDir: config.get('kbnArchiver.directory'), }); const esArchiver = new EsArchiver({ diff --git a/x-pack/test/stack_functional_integration/apps/metricbeat/_metricbeat_dashboard.js b/x-pack/test/stack_functional_integration/apps/metricbeat/_metricbeat_dashboard.js index d86debceb0d1c5..2b25d5ffea6e1a 100644 --- a/x-pack/test/stack_functional_integration/apps/metricbeat/_metricbeat_dashboard.js +++ b/x-pack/test/stack_functional_integration/apps/metricbeat/_metricbeat_dashboard.js @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects, updateBaselines }) { describe('check metricbeat Dashboard', function () { before(async function () { - await esArchiver.load('metricbeat'); + await esArchiver.load('../integration-test/test/es_archives/metricbeat'); // this navigateToActualURL takes the place of navigating to the dashboard landing page, // filtering on the dashboard name, selecting it, setting the timepicker, and going to full screen @@ -44,6 +44,10 @@ export default function ({ getService, getPageObjects, updateBaselines }) { await browser.setScreenshotSize(1000, 1000); }); + after(async function () { + await esArchiver.unload('../integration-test/test/es_archives/metricbeat'); + }); + it('[Metricbeat System] Overview ECS should match snapshot', async function () { try { const percentDifference = await screenshot.compareAgainstBaseline( diff --git a/yarn.lock b/yarn.lock index 167a8500a26eaf..9543f209d6849c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1147,17 +1147,10 @@ dependencies: regenerator-runtime "^0.12.0" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": - version "7.12.5" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" - integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== - dependencies: - regenerator-runtime "^0.13.4" - -"@babel/runtime@^7.13.17": - version "7.13.17" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.17.tgz#8966d1fc9593bf848602f0662d6b4d0069e3a7ec" - integrity sha512-NCdgJEelPTSh+FEFylhnP1ylq848l1z9t9N0j1Lfbcw0+KXGjsTvUmkxy+voLLXB5SOKMbLLx4jxYliGrYQseA== +"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.5.tgz#665450911c6031af38f81db530f387ec04cd9a98" + integrity sha512-121rumjddw9c3NCQ55KGkyE1h/nzWhU/owjhw0l4mQrkzz4x9SGS1X8gFLraHwX7td3Yo4QTL+qj0NcIzN87BA== dependencies: regenerator-runtime "^0.13.4" @@ -2759,7 +2752,7 @@ version "0.0.0" uid "" -"@kbn/server-route-repository@link:packages/kbn-server-route-repository": +"@kbn/server-route-repository@link:bazel-bin/packages/kbn-server-route-repository": version "0.0.0" uid "" @@ -21583,24 +21576,19 @@ point-in-polygon@^1.0.1: resolved "https://registry.yarnpkg.com/point-in-polygon/-/point-in-polygon-1.0.1.tgz#d59b64e8fee41c49458aac82b56718c5957b2af7" integrity sha1-1Ztk6P7kHElFiqyCtWcYxZV7Kvc= -polished@^1.9.2: - version "1.9.2" - resolved "https://registry.yarnpkg.com/polished/-/polished-1.9.2.tgz#d705cac66f3a3ed1bd38aad863e2c1e269baf6b6" - integrity sha512-mPocQrVUSiqQdHNZFGL1iHJmsR/etiv05Nf2oZUbya+GMsQkZVEBl5wonN+Sr/e9zQBEhT6yrMjxAUJ06eyocQ== - -polished@^3.4.4: - version "3.6.5" - resolved "https://registry.yarnpkg.com/polished/-/polished-3.6.5.tgz#dbefdde64c675935ec55119fe2a2ab627ca82e9c" - integrity sha512-VwhC9MlhW7O5dg/z7k32dabcAFW1VI2+7fSe8cE/kXcfL7mVdoa5UxciYGW2sJU78ldDLT6+ROEKIZKFNTnUXQ== +polished@^3.4.4, polished@^3.7.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/polished/-/polished-3.7.2.tgz#ec5ddc17a7d322a574d5e10ddd2a6f01d3e767d1" + integrity sha512-pQKtpZGmsZrW8UUpQMAnR7s3ppHeMQVNyMDKtUyKwuvDmklzcEyM5Kllb3JyE/sE/x7arDmyd35i+4vp99H6sQ== dependencies: - "@babel/runtime" "^7.9.2" + "@babel/runtime" "^7.12.5" polished@^4.0.5: - version "4.1.2" - resolved "https://registry.yarnpkg.com/polished/-/polished-4.1.2.tgz#c04fcc203e287e2d866e9cfcaf102dae1c01a816" - integrity sha512-jq4t3PJUpVRcveC53nnbEX35VyQI05x3tniwp26WFdm1dwaNUBHAi5awa/roBlwQxx1uRhwNSYeAi/aMbfiJCQ== + version "4.1.3" + resolved "https://registry.yarnpkg.com/polished/-/polished-4.1.3.tgz#7a3abf2972364e7d97770b827eec9a9e64002cfc" + integrity sha512-ocPAcVBUOryJEKe0z2KLd1l9EBa1r5mSwlKpExmrLzsnIzJo4axsoU9O2BjOTkDGDT4mZ0WFE5XKTlR3nLnZOA== dependencies: - "@babel/runtime" "^7.13.17" + "@babel/runtime" "^7.14.0" popper.js@^1.14.4: version "1.15.0"