diff --git a/.buildkite/pipeline-resource-definitions/kibana-fips-daily.yml b/.buildkite/pipeline-resource-definitions/kibana-fips-daily.yml new file mode 100644 index 0000000000000..32f78b24e8d23 --- /dev/null +++ b/.buildkite/pipeline-resource-definitions/kibana-fips-daily.yml @@ -0,0 +1,38 @@ +# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json +apiVersion: backstage.io/v1alpha1 +kind: Resource +metadata: + name: bk-kibana-fips-daily + description: Run Kibana FIPS smoke tests + links: + - title: Pipeline link + url: https://buildkite.com/elastic/kibana-fips +spec: + type: buildkite-pipeline + owner: group:kibana-operations + system: buildkite + implementation: + apiVersion: buildkite.elastic.dev/v1 + kind: Pipeline + metadata: + name: kibana / fips + description: Run Kibana FIPS smoke tests + spec: + env: + SLACK_NOTIFICATIONS_CHANNEL: "#kibana-operations-alerts" + ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true" + repository: elastic/kibana + branch_configuration: main + default_branch: main + pipeline_file: ".buildkite/pipelines/fips.yml" + provider_settings: + trigger_mode: none + schedules: + daily: + branch: main + cronline: 0 9 * * * America/New_York + teams: + kibana-operations: + access_level: MANAGE_BUILD_AND_READ + everyone: + access_level: READ_ONLY diff --git a/.buildkite/pipeline-resource-definitions/locations.yml b/.buildkite/pipeline-resource-definitions/locations.yml index 6c470728e68e8..2cc1439713e48 100644 --- a/.buildkite/pipeline-resource-definitions/locations.yml +++ b/.buildkite/pipeline-resource-definitions/locations.yml @@ -12,6 +12,7 @@ spec: - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-es-serverless-snapshots.yml - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-es-snapshots.yml - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-esql-grammar-sync.yml + - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-fips-daily.yml - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-flaky.yml - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-fleet-packages-daily.yml - https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-migration-staging.yml diff --git a/.buildkite/pipelines/fips.yml b/.buildkite/pipelines/fips.yml new file mode 100644 index 0000000000000..44e44ac69d8a4 --- /dev/null +++ b/.buildkite/pipelines/fips.yml @@ -0,0 +1,32 @@ +env: + DISABLE_CI_STATS_SHIPPING: "true" +steps: + - command: .buildkite/scripts/steps/build_kibana.sh + label: Build Kibana Distribution and Plugins + agents: + image: family/kibana-ubuntu-2004 + imageProject: elastic-images-qa + provider: gcp + machineType: n2-standard-16 + preemptible: true + key: build + if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''" + timeout_in_minutes: 60 + retry: + automatic: + - exit_status: "-1" + limit: 3 + + - wait + + - command: TEST_PACKAGE=fips .buildkite/scripts/steps/package_testing/test.sh + label: "Smoke testing for FIPS" + agents: + image: family/kibana-ubuntu-2004 + imageProject: elastic-images-qa + provider: gcp + enableNestedVirtualization: true + localSsds: 1 + localSsdInterface: nvme + machineType: n2-standard-4 + timeout_in_minutes: 600 diff --git a/.buildkite/scripts/steps/fips/build.sh b/.buildkite/scripts/steps/fips/build.sh old mode 100644 new mode 100755 diff --git a/.buildkite/scripts/steps/fips/smoke_test.sh b/.buildkite/scripts/steps/fips/smoke_test.sh new file mode 100755 index 0000000000000..7026c7bab941c --- /dev/null +++ b/.buildkite/scripts/steps/fips/smoke_test.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +if [ -z "$KIBANA_BUILD_LOCATION" ]; then + export KIBANA_BUILD_LOCATION="/usr/share/kibana" +fi + +# a FTR failure will result in the script returning an exit code of 10 +exitCode=0 + +configs=( + "x-pack/test/reporting_functional/reporting_and_security.config.ts" + "x-pack/test/saved_object_api_integration/security_and_spaces/config_trial.ts" + "x-pack/test/alerting_api_integration/security_and_spaces/group1/config.ts" + "x-pack/test/alerting_api_integration/security_and_spaces/group2/config.ts" + "x-pack/test/alerting_api_integration/security_and_spaces/group3/config.ts" + "x-pack/test/alerting_api_integration/security_and_spaces/group4/config.ts" + "x-pack/test/functional/apps/saved_objects_management/config.ts" + "x-pack/test/functional/apps/user_profiles/config.ts" + "x-pack/test/functional/apps/security/config.ts" +) + +cd /home/vagrant/kibana + +for config in "${configs[@]}"; do + set +e + node /home/vagrant/kibana/scripts/functional_tests \ + --bail \ + --kibana-install-dir "$KIBANA_BUILD_LOCATION" \ + --config="$config" + lastCode=$? + set -e + + if [ $lastCode -ne 0 ]; then + exitCode=10 + echo "FTR exited with code $lastCode" + echo "^^^ +++" + + if [[ "$failedConfigs" ]]; then + failedConfigs="${failedConfigs}"$'\n'"$config" + else + failedConfigs="$config" + fi + fi +done + +if [[ "$failedConfigs" ]]; then + echo "$failedConfigs" >/home/vagrant/ftr_failed_configs +fi + +echo "--- FIPS smoke test complete" + +exit $exitCode diff --git a/.buildkite/scripts/steps/package_testing/test.sh b/.buildkite/scripts/steps/package_testing/test.sh index c16d5cf98b5f5..99750529815c8 100755 --- a/.buildkite/scripts/steps/package_testing/test.sh +++ b/.buildkite/scripts/steps/package_testing/test.sh @@ -21,17 +21,25 @@ elif [[ "$TEST_PACKAGE" == "rpm" ]]; then elif [[ "$TEST_PACKAGE" == "docker" ]]; then download_artifact "kibana-$KIBANA_PKG_VERSION*-docker-image.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}" KIBANA_IP_ADDRESS="192.168.56.7" +elif [[ "$TEST_PACKAGE" == "fips" ]]; then + download_artifact kibana-default.tar.gz . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}" + download_artifact kibana-default-plugins.tar.gz . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}" fi cd .. export VAGRANT_CWD=$PWD/test/package -vagrant up "$TEST_PACKAGE" --no-provision -node scripts/es snapshot \ - -E network.bind_host=127.0.0.1,192.168.56.1 \ - -E discovery.type=single-node \ - --license=trial & -while ! timeout 1 bash -c "echo > /dev/tcp/localhost/9200"; do sleep 30; done +if [[ "$TEST_PACKAGE" == "fips" ]]; then + vagrant up "$TEST_PACKAGE" +else + vagrant up "$TEST_PACKAGE" --no-provision + + node scripts/es snapshot \ + -E network.bind_host=127.0.0.1,192.168.56.1 \ + -E discovery.type=single-node \ + --license=trial & + while ! timeout 1 bash -c "echo > /dev/tcp/localhost/9200"; do sleep 30; done +fi function echoKibanaLogs { if [[ "$TEST_PACKAGE" == "deb" ]] || [[ "$TEST_PACKAGE" == "rpm" ]]; then @@ -47,13 +55,25 @@ function echoKibanaLogs { } trap "echoKibanaLogs" EXIT -vagrant provision "$TEST_PACKAGE" +if [[ "$TEST_PACKAGE" == "fips" ]]; then + set +e + vagrant ssh $TEST_PACKAGE -t -c "/home/vagrant/kibana/.buildkite/scripts/steps/fips/smoke_test.sh" + vagrant ssh $TEST_PACKAGE -t -c "cat /home/vagrant/ftr_failed_configs 2>/dev/null" >ftr_failed_configs + set -e + + if [ -s ftr_failed_configs ]; then + buildkite-agent meta-data set "ftr-failed-configs" <./ftr_failed_configs + fi +else + vagrant provision "$TEST_PACKAGE" + + export TEST_BROWSER_HEADLESS=1 + export TEST_KIBANA_URL="http://elastic:changeme@$KIBANA_IP_ADDRESS:5601" + export TEST_ES_URL="http://elastic:changeme@192.168.56.1:9200" -export TEST_BROWSER_HEADLESS=1 -export TEST_KIBANA_URL="http://elastic:changeme@$KIBANA_IP_ADDRESS:5601" -export TEST_ES_URL="http://elastic:changeme@192.168.56.1:9200" + echo "--- FTR - Reporting" -cd x-pack + cd x-pack -echo "--- FTR - Reporting" -node scripts/functional_test_runner.js --config test/functional/apps/visualize/config.ts --include-tag=smoke --quiet + node scripts/functional_test_runner.js --config test/functional/apps/visualize/config.ts --include-tag=smoke --quiet +fi diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index 0f94a76d87f71..12f020175fd4e 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -182,6 +182,7 @@ export function createTestEsCluster< } = options; const clusterName = `${CI_PARALLEL_PROCESS_PREFIX}${customClusterName}`; + const isFIPSMode = process.env.FTR_FIPS_MODE === '1'; const defaultEsArgs = [ `cluster.name=${clusterName}`, @@ -192,7 +193,12 @@ export function createTestEsCluster< : ['discovery.type=single-node']), ]; - const esArgs = assignArgs(defaultEsArgs, customEsArgs); + const esArgs = assignArgs( + defaultEsArgs, + // ML has issues running in FIPS mode due to custom OpenSSL + // Remove after https://github.com/elastic/kibana-operations/issues/96 + isFIPSMode ? [...customEsArgs, 'xpack.ml.enabled=false'] : customEsArgs + ); const config = { version: esTestConfig.getVersion(), diff --git a/test/functional/apps/discover/group1/_errors.ts b/test/functional/apps/discover/group1/_errors.ts index 6f0a7ba96b7ad..0d3e20fba11ce 100644 --- a/test/functional/apps/discover/group1/_errors.ts +++ b/test/functional/apps/discover/group1/_errors.ts @@ -38,7 +38,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); }); - describe('not found', () => { + // FLAKY: https://github.com/elastic/kibana/issues/166291 + describe.skip('not found', () => { it('should redirect to main page when trying to access invalid route', async () => { await PageObjects.common.navigateToUrl('discover', '#/invalid-route', { useActualUrl: true, diff --git a/test/package/Vagrantfile b/test/package/Vagrantfile index 4872da5d2afae..73be8e0a32659 100644 --- a/test/package/Vagrantfile +++ b/test/package/Vagrantfile @@ -36,4 +36,23 @@ Vagrant.configure("2") do |config| end docker.vm.network "private_network", ip: "192.168.56.7" end + + config.vm.define "fips" do |fips| + fips.vm.synced_folder '../../', '/home/vagrant/kibana', SharedFoldersEnableSymlinksCreate: false + fips.vm.provider :virtualbox do |vb| + vb.memory = 4096 + vb.cpus = 2 + end + fips.vm.box = 'generic/rhel9' + fips.vm.provision "shell", inline: <<-SHELL + echo "export OPENSSL_MODULES=/usr/local/lib64/ossl-modules" >> /etc/profile.d/kibana-fips-env.sh + echo "export TEST_BROWSER_HEADLESS=1" >> /etc/profile.d/kibana-fips-env.sh + echo "export ES_TMPDIR=/home/vagrant/kibana/.es/tmp" >> /etc/profile.d/kibana-fips-env.sh + # Remove after https://github.com/elastic/kibana-operations/issues/96 + echo "export FTR_FIPS_MODE=1" >> /etc/profile.d/kibana-fips-env.sh + SHELL + fips.vm.provision "ansible" do |ansible| + ansible.playbook = "fips.yml" + end + end end diff --git a/test/package/fips.yml b/test/package/fips.yml new file mode 100644 index 0000000000000..ae62b386c0cde --- /dev/null +++ b/test/package/fips.yml @@ -0,0 +1,12 @@ +- name: test kibana fips docker package + hosts: fips + vars: + kibana_dist_path: "/usr/share/kibana" + kibana_src_path: "/home/vagrant/kibana" + nvm_ver: "0.39.7" + openssl_sha: "sha256:6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e" + openssl_ver: "3.0.8" + roles: + - upgrade_yum_packages + - install_kibana_fips + - assert_fips_enabled diff --git a/test/package/roles/assert_fips_enabled/tasks/main.yml b/test/package/roles/assert_fips_enabled/tasks/main.yml new file mode 100644 index 0000000000000..936d43c49026a --- /dev/null +++ b/test/package/roles/assert_fips_enabled/tasks/main.yml @@ -0,0 +1,11 @@ +- name: register kibana node getFips + command: "{{ kibana_dist_path }}/node/bin/node --enable-fips --openssl-config={{ kibana_dist_path }}/config/nodejs.cnf -p 'crypto.getFips()'" + register: kibana_node_fips + +- debug: + msg: "{{ kibana_node_fips }}" + +- name: assert FIPS enabled + assert: + that: + - kibana_node_fips.stdout == "1" diff --git a/test/package/roles/install_kibana_fips/tasks/main.yml b/test/package/roles/install_kibana_fips/tasks/main.yml new file mode 100644 index 0000000000000..3bfe729f73bd1 --- /dev/null +++ b/test/package/roles/install_kibana_fips/tasks/main.yml @@ -0,0 +1,133 @@ +- name: gather ansible processor facts + setup: + gather_subset: + - "!all" + - "!min" + - "processor_cores" + when: ansible_processor_vcpus is not defined + +- name: fix /var/log permissions for kibana + become: yes + file: + path: /var/log + state: directory + recurse: true + mode: "0777" + +- name: create tmp dir for ES + file: + path: "{{ kibana_src_path }}/.es/tmp" + state: directory + +- name: slurp kibana node version + slurp: + src: "{{ kibana_src_path }}/.node-version" + register: node_ver_file + +- name: set kibana node version + set_fact: + node_version: "{{ node_ver_file['content'] | b64decode | trim }}" + +- name: install nvm + shell: + chdir: "$HOME" + cmd: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v{{ nvm_ver }}/install.sh | bash + +- name: install kibana node version + shell: + chdir: "$HOME/.nvm" + cmd: "source nvm.sh && nvm install {{ node_version }}" + args: + executable: /bin/bash + +- name: "ensure {{ kibana_dist_path }} dir exists" + become: yes + file: + path: "{{ kibana_dist_path }}" + state: directory + mode: "0777" + +- name: find kibana distribution + find: + paths: /packages/ + patterns: kibana-default.tar.gz + register: kibana_tar + +- name: extract kibana distribution + become: yes + unarchive: + src: "{{ kibana_tar.files[0].path }}" + dest: "{{ kibana_dist_path }}" + remote_src: yes + extra_opts: ["--strip-components=1"] + +- name: find kibana plugins distribution + find: + paths: /packages/ + patterns: kibana-default-plugins.tar.gz + register: kibana_plugins_tar + +- name: extract kibana plugins distribution + become: yes + unarchive: + src: "{{ kibana_plugins_tar.files[0].path }}" + dest: "{{ kibana_dist_path }}" + remote_src: yes + +- name: copy kibana yml configuration + become: yes + template: + src: templates/fips/kibana.yml + dest: "{{ kibana_dist_path }}/config/kibana.yml" + register: config + +- name: copy FIPS node.options + become: yes + template: + src: templates/fips/node.options + dest: "{{ kibana_dist_path }}/config/node.options" + +- name: copy FIPS openssl config + become: yes + template: + src: templates/fips/nodejs.cnf + dest: "{{ kibana_dist_path }}/config/nodejs.cnf" + +- name: download FIPS certified OpenSSL + become: yes + retries: 5 + delay: 10 + get_url: + url: "https://www.openssl.org/source/openssl-{{ openssl_ver }}.tar.gz" + dest: "{{ kibana_dist_path }}/openssl-{{ openssl_ver }}.tar.gz" + checksum: "{{ openssl_sha }}" + +- name: extract OpenSSL + become: yes + unarchive: + src: "{{ kibana_dist_path }}/openssl-{{ openssl_ver }}.tar.gz" + dest: "{{ kibana_dist_path }}" + remote_src: yes + +- name: configure OpenSSL for FIPS + become: yes + shell: + chdir: "{{ kibana_dist_path }}/openssl-{{ openssl_ver }}" + cmd: ./Configure enable-fips + +- name: compile OpenSSL with FIPS + become: yes + make: + chdir: "{{ kibana_dist_path }}/openssl-{{ openssl_ver }}" + jobs: "{{ ansible_facts['processor_vcpus'] }}" + +- name: install OpenSSL with FIPS + become: yes + make: + chdir: "{{ kibana_dist_path }}/openssl-{{ openssl_ver }}" + target: install + +- name: link OpenSSL package + become: yes + shell: + cmd: ldconfig /usr/local/lib64/ diff --git a/test/package/templates/fips/kibana.yml b/test/package/templates/fips/kibana.yml new file mode 100644 index 0000000000000..d33cb21c383cb --- /dev/null +++ b/test/package/templates/fips/kibana.yml @@ -0,0 +1,16 @@ +server.host: 0.0.0.0 + +elasticsearch.username: "{{ elasticsearch_username }}" +elasticsearch.password: "{{ elasticsearch_password }}" + +logging: + appenders: + file: + type: file + fileName: /var/log/kibana/kibana.log + layout: + type: json + root: + appenders: + - default + - file diff --git a/test/package/templates/fips/node.options b/test/package/templates/fips/node.options new file mode 100644 index 0000000000000..b01af3c27a7b3 --- /dev/null +++ b/test/package/templates/fips/node.options @@ -0,0 +1,4 @@ +--max-old-space-size=812 +--unhandled-rejections=warn +--enable-fips +--openssl-config=/usr/share/kibana/config/nodejs.cnf \ No newline at end of file diff --git a/test/package/templates/fips/nodejs.cnf b/test/package/templates/fips/nodejs.cnf new file mode 100644 index 0000000000000..bd8fece6674d7 --- /dev/null +++ b/test/package/templates/fips/nodejs.cnf @@ -0,0 +1,28 @@ +########################################################################## +## ## +## This OpenSSL config is only loaded when running Kibana in FIPS mode. ## +## ## +## See: ## +## https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md ## +## https://www.openssl.org/docs/man3.0/man7/fips_module.html ## +## ## +########################################################################## + +nodejs_conf = nodejs_init +.include /usr/local/ssl/fipsmodule.cnf + +[nodejs_init] +providers = provider_sect +alg_section = algorithm_sect + +[provider_sect] +default = default_sect +# The fips section name should match the section name inside the +# included fipsmodule.cnf. +fips = fips_sect + +[default_sect] +activate = 1 + +[algorithm_sect] +default_properties = fips=yes \ No newline at end of file diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/api/actions.ts b/x-pack/packages/ml/aiops_log_rate_analysis/api/actions.ts index 2348b32c32f8d..4c17f28c932b3 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/api/actions.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/api/actions.ts @@ -12,8 +12,6 @@ import type { SignificantItemGroupHistogram, } from '@kbn/ml-agg-utils'; -import type { AiopsLogRateAnalysisApiVersion as ApiVersion } from './schema'; - export const API_ACTION_NAME = { /** @since API v2 */ ADD_SIGNIFICANT_ITEMS: 'add_significant_items', @@ -23,13 +21,6 @@ export const API_ACTION_NAME = { ADD_SIGNIFICANT_ITEMS_GROUP: 'add_significant_items_group', /** @since API v2 */ ADD_SIGNIFICANT_ITEMS_GROUP_HISTOGRAM: 'add_significant_items_group_histogram', - /** @deprecated since API v2 */ - ADD_SIGNIFICANT_TERMS: 'add_significant_terms', - /** @deprecated since API v2 */ - ADD_SIGNIFICANT_TERMS_HISTOGRAM: 'add_significant_terms_histogram', - /** @deprecated since API v2 */ - ADD_SIGNIFICANT_TERMS_GROUP: 'add_significant_terms_group', - /** @deprecated since API v2 */ ADD_SIGNIFICANT_TERMS_GROUP_HISTOGRAM: 'add_significant_terms_group_histogram', ADD_ERROR: 'add_error', PING: 'ping', @@ -41,108 +32,60 @@ export const API_ACTION_NAME = { } as const; export type ApiActionName = typeof API_ACTION_NAME[keyof typeof API_ACTION_NAME]; -interface ApiActionAddSignificantItems { - type: T extends '1' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_TERMS - : T extends '2' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS - : never; +interface ApiActionAddSignificantItems { + type: typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS; payload: SignificantItem[]; } -export function addSignificantItemsAction( - payload: ApiActionAddSignificantItems['payload'], - version: T -): ApiActionAddSignificantItems { - if (version === '1') { - return { - type: API_ACTION_NAME.ADD_SIGNIFICANT_TERMS, - payload, - } as ApiActionAddSignificantItems; - } - +export function addSignificantItemsAction( + payload: ApiActionAddSignificantItems['payload'] +): ApiActionAddSignificantItems { return { type: API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS, payload, - } as ApiActionAddSignificantItems; + }; } -interface ApiActionAddSignificantItemsHistogram { - type: T extends '1' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_TERMS_HISTOGRAM - : T extends '2' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_HISTOGRAM - : never; +interface ApiActionAddSignificantItemsHistogram { + type: typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_HISTOGRAM; payload: SignificantItemHistogram[]; } -export function addSignificantItemsHistogramAction( - payload: ApiActionAddSignificantItemsHistogram['payload'], - version: T -): ApiActionAddSignificantItemsHistogram { - if (version === '1') { - return { - type: API_ACTION_NAME.ADD_SIGNIFICANT_TERMS_HISTOGRAM, - payload, - } as ApiActionAddSignificantItemsHistogram; - } - +export function addSignificantItemsHistogramAction( + payload: ApiActionAddSignificantItemsHistogram['payload'] +): ApiActionAddSignificantItemsHistogram { return { type: API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_HISTOGRAM, payload, - } as ApiActionAddSignificantItemsHistogram; + }; } -interface ApiActionAddSignificantItemsGroup { - type: T extends '1' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_TERMS_GROUP - : T extends '2' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_GROUP - : never; +interface ApiActionAddSignificantItemsGroup { + type: typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_GROUP; payload: SignificantItemGroup[]; } -export function addSignificantItemsGroupAction( - payload: ApiActionAddSignificantItemsGroup['payload'], - version: T -): ApiActionAddSignificantItemsGroup { - if (version === '1') { - return { - type: API_ACTION_NAME.ADD_SIGNIFICANT_TERMS_GROUP, - payload, - } as ApiActionAddSignificantItemsGroup; - } - +export function addSignificantItemsGroupAction( + payload: ApiActionAddSignificantItemsGroup['payload'] +): ApiActionAddSignificantItemsGroup { return { type: API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_GROUP, payload, - } as ApiActionAddSignificantItemsGroup; + }; } -interface ApiActionAddSignificantItemsGroupHistogram { - type: T extends '1' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_TERMS_GROUP_HISTOGRAM - : T extends '2' - ? typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_GROUP_HISTOGRAM - : never; +interface ApiActionAddSignificantItemsGroupHistogram { + type: typeof API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_GROUP_HISTOGRAM; payload: SignificantItemGroupHistogram[]; } -export function addSignificantItemsGroupHistogramAction( - payload: ApiActionAddSignificantItemsGroupHistogram['payload'], - version: T -): ApiActionAddSignificantItemsGroupHistogram { - if (version === '1') { - return { - type: API_ACTION_NAME.ADD_SIGNIFICANT_TERMS_GROUP_HISTOGRAM, - payload, - } as ApiActionAddSignificantItemsGroupHistogram; - } - +export function addSignificantItemsGroupHistogramAction( + payload: ApiActionAddSignificantItemsGroupHistogram['payload'] +): ApiActionAddSignificantItemsGroupHistogram { return { type: API_ACTION_NAME.ADD_SIGNIFICANT_ITEMS_GROUP_HISTOGRAM, payload, - } as ApiActionAddSignificantItemsGroupHistogram; + }; } interface ApiActionAddError { @@ -225,11 +168,11 @@ export function setZeroDocsFallback( }; } -export type AiopsLogRateAnalysisApiAction = - | ApiActionAddSignificantItems - | ApiActionAddSignificantItemsGroup - | ApiActionAddSignificantItemsHistogram - | ApiActionAddSignificantItemsGroupHistogram +export type AiopsLogRateAnalysisApiAction = + | ApiActionAddSignificantItems + | ApiActionAddSignificantItemsGroup + | ApiActionAddSignificantItemsHistogram + | ApiActionAddSignificantItemsGroupHistogram | ApiActionAddError | ApiActionPing | ApiActionResetAll diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/api/schema.ts b/x-pack/packages/ml/aiops_log_rate_analysis/api/schema.ts index a7fbcfd303b55..fae5d17c67fdb 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/api/schema.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/api/schema.ts @@ -5,17 +5,12 @@ * 2.0. */ -import type { AiopsLogRateAnalysisSchemaV1 } from './schema_v1'; import type { AiopsLogRateAnalysisSchemaV2 } from './schema_v2'; -export type AiopsLogRateAnalysisApiVersion = '1' | '2'; +export type AiopsLogRateAnalysisApiVersion = '2'; const LATEST_API_VERSION: AiopsLogRateAnalysisApiVersion = '2'; export type AiopsLogRateAnalysisSchema< T extends AiopsLogRateAnalysisApiVersion = typeof LATEST_API_VERSION -> = T extends '1' - ? AiopsLogRateAnalysisSchemaV1 - : T extends '2' - ? AiopsLogRateAnalysisSchemaV2 - : never; +> = T extends '2' ? AiopsLogRateAnalysisSchemaV2 : never; diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v1.ts b/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v1.ts deleted file mode 100644 index de059bca1235e..0000000000000 --- a/x-pack/packages/ml/aiops_log_rate_analysis/api/schema_v1.ts +++ /dev/null @@ -1,42 +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 type { TypeOf } from '@kbn/config-schema'; -import { schema } from '@kbn/config-schema'; - -export const aiopsLogRateAnalysisSchemaV1 = schema.object({ - start: schema.number(), - end: schema.number(), - searchQuery: schema.string(), - timeFieldName: schema.string(), - includeFrozen: schema.maybe(schema.boolean()), - grouping: schema.maybe(schema.boolean()), - /** Analysis selection time ranges */ - baselineMin: schema.number(), - baselineMax: schema.number(), - deviationMin: schema.number(), - deviationMax: schema.number(), - /** The index to query for log rate analysis */ - index: schema.string(), - /** Settings to override headers derived compression and flush fix */ - compressResponse: schema.maybe(schema.boolean()), - flushFix: schema.maybe(schema.boolean()), - /** Overrides to skip steps of the analysis with existing data */ - overrides: schema.maybe( - schema.object({ - loaded: schema.maybe(schema.number()), - remainingFieldCandidates: schema.maybe(schema.arrayOf(schema.string())), - // TODO Improve schema - significantTerms: schema.maybe(schema.arrayOf(schema.any())), - regroupOnly: schema.maybe(schema.boolean()), - }) - ), - /** Probability used for the random sampler aggregations */ - sampleProbability: schema.maybe(schema.number()), -}); - -export type AiopsLogRateAnalysisSchemaV1 = TypeOf; diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.test.ts b/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.test.ts index bd318e6de0875..ea1c33e569fce 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.test.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.test.ts @@ -38,24 +38,21 @@ describe('streamReducer', () => { it('adds significant item, then resets all state again', () => { const state1 = streamReducer( initialState, - addSignificantItemsAction( - [ - { - key: 'the-field-name:the-field-value', - type: 'keyword', - fieldName: 'the-field-name', - fieldValue: 'the-field-value', - doc_count: 10, - bg_count: 100, - total_doc_count: 1000, - total_bg_count: 10000, - score: 0.1, - pValue: 0.01, - normalizedScore: 0.123, - }, - ], - '2' - ) + addSignificantItemsAction([ + { + key: 'the-field-name:the-field-value', + type: 'keyword', + fieldName: 'the-field-name', + fieldValue: 'the-field-value', + doc_count: 10, + bg_count: 100, + total_doc_count: 1000, + total_bg_count: 10000, + score: 0.1, + pValue: 0.01, + normalizedScore: 0.123, + }, + ]) ); expect(state1.significantItems).toHaveLength(1); @@ -66,14 +63,14 @@ describe('streamReducer', () => { }); it('adds significant items and groups, then resets groups only', () => { - const state1 = streamReducer(initialState, addSignificantItemsAction(significantTerms, '2')); + const state1 = streamReducer(initialState, addSignificantItemsAction(significantTerms)); expect(state1.significantItems).toHaveLength(4); expect(state1.significantItemsGroups).toHaveLength(0); const state2 = streamReducer( state1, - addSignificantItemsGroupAction(finalSignificantItemGroups, '2') + addSignificantItemsGroupAction(finalSignificantItemGroups) ); expect(state2.significantItems).toHaveLength(4); diff --git a/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.ts b/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.ts index 2e3117b4326e8..ca6148c133cca 100644 --- a/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.ts +++ b/x-pack/packages/ml/aiops_log_rate_analysis/api/stream_reducer.ts @@ -10,7 +10,7 @@ import type { SignificantItem, SignificantItemGroup } from '@kbn/ml-agg-utils'; import type { AiopsLogRateAnalysisApiAction } from './actions'; import { API_ACTION_NAME } from './actions'; -interface StreamState { +export interface StreamState { ccsWarning: boolean; significantItems: SignificantItem[]; significantItemsGroups: SignificantItemGroup[]; @@ -34,7 +34,7 @@ export const initialState: StreamState = { export function streamReducer( state: StreamState, - action: AiopsLogRateAnalysisApiAction<'2'> | Array> + action: AiopsLogRateAnalysisApiAction | AiopsLogRateAnalysisApiAction[] ): StreamState { if (Array.isArray(action)) { return action.reduce(streamReducer, state); diff --git a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx index d62685ab2bce3..2531a47419dc4 100644 --- a/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx +++ b/x-pack/plugins/aiops/public/components/log_categorization/log_categorization_page.tsx @@ -311,7 +311,6 @@ export const LogCategorizationPage: FC = ({ embeddin = ({ - dataView, timeRange, esSearchQuery = DEFAULT_SEARCH_QUERY, stickyHistogram, @@ -93,6 +90,8 @@ export const LogRateAnalysisContent: FC = ({ onWindowParametersChange, embeddingOrigin, }) => { + const { dataView } = useDataSource(); + const [windowParameters, setWindowParameters] = useState(); const [isBrushCleared, setIsBrushCleared] = useState(true); const [logRateAnalysisType, setLogRateAnalysisType] = useState( @@ -272,7 +271,6 @@ export const LogRateAnalysisContent: FC = ({ {showLogRateAnalysisResults && ( = ({ stickyHistogram }) => { = ({ stickyHistogram }) => { /> = ({ - dataView, analysisType = LOG_RATE_ANALYSIS_TYPE.SPIKE, earliest, isBrushCleared, @@ -139,6 +137,7 @@ export const LogRateAnalysisResults: FC = ({ embeddingOrigin, }) => { const { analytics, http } = useAiopsAppContext(); + const { dataView } = useDataSource(); // Store the performance metric's start time using a ref // to be able to track it across rerenders. @@ -485,7 +484,6 @@ export const LogRateAnalysisResults: FC = ({ significantItems={data.significantItems} groupTableItems={groupTableItems} loading={isRunning} - dataView={dataView} timeRangeMs={timeRangeMs} searchQuery={searchQuery} barColorOverride={barColorOverride} @@ -497,7 +495,6 @@ export const LogRateAnalysisResults: FC = ({ = ({ significantItems, - dataView, loading, isExpandedRow, searchQuery, @@ -84,6 +81,7 @@ export const LogRateAnalysisResultsTable: FC = }) => { const euiTheme = useEuiTheme(); const primaryBackgroundColor = useEuiBackgroundColor('primary'); + const { dataView } = useDataSource(); const dataViewId = dataView.id; const { diff --git a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx index aefe170fc4b5b..2d5acb8057679 100644 --- a/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx +++ b/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx @@ -30,10 +30,11 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import type { SignificantItem } from '@kbn/ml-agg-utils'; import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker'; -import type { DataView } from '@kbn/data-views-plugin/public'; import { stringHash } from '@kbn/ml-string-hash'; import { useLogRateAnalysisStateContext, type GroupTableItem } from '@kbn/aiops-components'; +import { useDataSource } from '../../hooks/use_data_source'; + import { MiniHistogram } from '../mini_histogram'; import { getFailedTransactionsCorrelationImpactLabel } from './get_failed_transactions_correlation_impact_label'; @@ -60,7 +61,6 @@ interface LogRateAnalysisResultsTableProps { loading: boolean; searchQuery: estypes.QueryDslQueryContainer; timeRangeMs: TimeRangeMs; - dataView: DataView; /** Optional color override for the default bar color for charts */ barColorOverride?: string; /** Optional color override for the highlighted bar color for charts */ @@ -72,13 +72,14 @@ export const LogRateAnalysisResultsGroupsTable: FC { + const { dataView } = useDataSource(); + const [pageIndex, setPageIndex] = useState(0); const [pageSize, setPageSize] = useState(10); const [sortField, setSortField] = useState<'docCount' | 'pValue'>( @@ -125,7 +126,6 @@ export const LogRateAnalysisResultsGroupsTable: FC void; } -export const SearchPanel: FC = ({ - dataView, - searchString, - searchQueryLanguage, - setSearchParams, -}) => { +export const SearchPanel: FC = ({ searchString, searchQueryLanguage, setSearchParams }) => { const { uiSettings, unifiedSearch: { @@ -48,6 +43,7 @@ export const SearchPanel: FC = ({ notifications: { toasts }, data: { query: queryManager }, } = useAiopsAppContext(); + const { dataView } = useDataSource(); // The internal state of the input query bar updated on every key stroke. const [searchInput, setSearchInput] = useState({ diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/grouping_handler.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/grouping_handler.ts index 233aa62985bef..5266858e6d3bc 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/grouping_handler.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/grouping_handler.ts @@ -46,7 +46,6 @@ export const groupingHandlerFactory = logDebugMessage, logger, stateHandler, - version, }: ResponseStreamFetchOptions) => async ( significantCategories: SignificantItem[], @@ -134,7 +133,7 @@ export const groupingHandlerFactory = const maxItems = Math.max(...significantItemGroups.map((g) => g.group.length)); if (maxItems > 1) { - responseStream.push(addSignificantItemsGroupAction(significantItemGroups, version)); + responseStream.push(addSignificantItemsGroupAction(significantItemGroups)); } stateHandler.loaded(PROGRESS_STEP_GROUPING, false); @@ -203,15 +202,6 @@ export const groupingHandlerFactory = doc_count: 0, }; - if (version === '1') { - return { - key: o.key, - key_as_string: o.key_as_string ?? '', - doc_count_significant_term: current.doc_count, - doc_count_overall: Math.max(0, o.doc_count - current.doc_count), - }; - } - return { key: o.key, key_as_string: o.key_as_string ?? '', @@ -221,15 +211,12 @@ export const groupingHandlerFactory = }) ?? []; responseStream.push( - addSignificantItemsGroupHistogramAction( - [ - { - id: cpg.id, - histogram, - }, - ], - version - ) + addSignificantItemsGroupHistogramAction([ + { + id: cpg.id, + histogram, + }, + ]) ); } }, MAX_CONCURRENT_QUERIES); diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/histogram_handler.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/histogram_handler.ts index 077c2162a30fd..1a61edde6864b 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/histogram_handler.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/histogram_handler.ts @@ -41,7 +41,6 @@ export const histogramHandlerFactory = requestBody, responseStream, stateHandler, - version, }: ResponseStreamFetchOptions) => async ( fieldValuePairsCount: number, @@ -132,14 +131,6 @@ export const histogramHandlerFactory = ) ?? { doc_count: 0, }; - if (version === '1') { - return { - key: o.key, - key_as_string: o.key_as_string ?? '', - doc_count_significant_term: current.doc_count, - doc_count_overall: Math.max(0, o.doc_count - current.doc_count), - }; - } return { key: o.key, @@ -154,16 +145,13 @@ export const histogramHandlerFactory = stateHandler.loaded((1 / fieldValuePairsCount) * PROGRESS_STEP_HISTOGRAMS, false); pushHistogramDataLoadingState(); responseStream.push( - addSignificantItemsHistogramAction( - [ - { - fieldName, - fieldValue, - histogram, - }, - ], - version - ) + addSignificantItemsHistogramAction([ + { + fieldName, + fieldValue, + histogram, + }, + ]) ); } }, MAX_CONCURRENT_QUERIES); @@ -237,15 +225,6 @@ export const histogramHandlerFactory = doc_count: 0, }; - if (version === '1') { - return { - key: o.key, - key_as_string: o.key_as_string ?? '', - doc_count_significant_term: current.doc_count, - doc_count_overall: Math.max(0, o.doc_count - current.doc_count), - }; - } - return { key: o.key, key_as_string: o.key_as_string ?? '', @@ -259,16 +238,13 @@ export const histogramHandlerFactory = stateHandler.loaded((1 / fieldValuePairsCount) * PROGRESS_STEP_HISTOGRAMS, false); pushHistogramDataLoadingState(); responseStream.push( - addSignificantItemsHistogramAction( - [ - { - fieldName, - fieldValue, - histogram, - }, - ], - version - ) + addSignificantItemsHistogramAction([ + { + fieldName, + fieldValue, + histogram, + }, + ]) ); } } diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/significant_items_handler.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/significant_items_handler.ts index 6fb9f97cde4ef..aa2aa1944e64a 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/significant_items_handler.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/significant_items_handler.ts @@ -38,7 +38,6 @@ export const significantItemsHandlerFactory = requestBody, responseStream, stateHandler, - version, }: ResponseStreamFetchOptions) => async ({ fieldCandidates, @@ -54,21 +53,11 @@ export const significantItemsHandlerFactory = const significantCategories: SignificantItem[] = []; - if (version === '1') { - significantCategories.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'1'>).overrides?.significantTerms?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN - ) ?? []) - ); - } - - if (version === '2') { - significantCategories.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN - ) ?? []) - ); - } + significantCategories.push( + ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( + (d) => d.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN + ) ?? []) + ); // Get significant categories of text fields if (textFieldCandidates.length > 0) { @@ -85,27 +74,17 @@ export const significantItemsHandlerFactory = ); if (significantCategories.length > 0) { - responseStream.push(addSignificantItemsAction(significantCategories, version)); + responseStream.push(addSignificantItemsAction(significantCategories)); } } const significantTerms: SignificantItem[] = []; - if (version === '1') { - significantTerms.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'1'>).overrides?.significantTerms?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.KEYWORD - ) ?? []) - ); - } - - if (version === '2') { - significantTerms.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.KEYWORD - ) ?? []) - ); - } + significantTerms.push( + ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( + (d) => d.type === SIGNIFICANT_ITEM_TYPE.KEYWORD + ) ?? []) + ); const fieldsToSample = new Set(); @@ -157,7 +136,7 @@ export const significantItemsHandlerFactory = }); significantTerms.push(...pValues); - responseStream.push(addSignificantItemsAction(pValues, version)); + responseStream.push(addSignificantItemsAction(pValues)); } responseStream.push( diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/top_items_handler.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/top_items_handler.ts index cc15c8b616995..f29b372116f48 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/top_items_handler.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/analysis_handlers/top_items_handler.ts @@ -39,7 +39,6 @@ export const topItemsHandlerFactory = requestBody, responseStream, stateHandler, - version, }: ResponseStreamFetchOptions) => async ({ fieldCandidates, @@ -55,21 +54,11 @@ export const topItemsHandlerFactory = const topCategories: SignificantItem[] = []; - if (version === '1') { - topCategories.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'1'>).overrides?.significantTerms?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN - ) ?? []) - ); - } - - if (version === '2') { - topCategories.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN - ) ?? []) - ); - } + topCategories.push( + ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( + (d) => d.type === SIGNIFICANT_ITEM_TYPE.LOG_PATTERN + ) ?? []) + ); // Get categories of text fields if (textFieldCandidates.length > 0) { @@ -86,27 +75,17 @@ export const topItemsHandlerFactory = ); if (topCategories.length > 0) { - responseStream.push(addSignificantItemsAction(topCategories, version)); + responseStream.push(addSignificantItemsAction(topCategories)); } } const topTerms: SignificantItem[] = []; - if (version === '1') { - topTerms.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'1'>).overrides?.significantTerms?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.KEYWORD - ) ?? []) - ); - } - - if (version === '2') { - topTerms.push( - ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( - (d) => d.type === SIGNIFICANT_ITEM_TYPE.KEYWORD - ) ?? []) - ); - } + topTerms.push( + ...((requestBody as AiopsLogRateAnalysisSchema<'2'>).overrides?.significantItems?.filter( + (d) => d.type === SIGNIFICANT_ITEM_TYPE.KEYWORD + ) ?? []) + ); const fieldsToSample = new Set(); @@ -158,7 +137,7 @@ export const topItemsHandlerFactory = }); topTerms.push(...fetchedTopTerms); - responseStream.push(addSignificantItemsAction(fetchedTopTerms, version)); + responseStream.push(addSignificantItemsAction(fetchedTopTerms)); } responseStream.push( diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/define_route.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/define_route.ts index de9df4aa5bdab..77fedfafb1896 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/define_route.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/define_route.ts @@ -9,7 +9,6 @@ import type { CoreStart, IRouter } from '@kbn/core/server'; import type { Logger } from '@kbn/logging'; import type { DataRequestHandlerContext } from '@kbn/data-plugin/server'; import type { UsageCounter } from '@kbn/usage-collection-plugin/server'; -import { aiopsLogRateAnalysisSchemaV1 } from '@kbn/aiops-log-rate-analysis/api/schema_v1'; import { aiopsLogRateAnalysisSchemaV2 } from '@kbn/aiops-log-rate-analysis/api/schema_v2'; import { AIOPS_API_ENDPOINT } from '@kbn/aiops-common/constants'; @@ -35,17 +34,6 @@ export const defineRoute = ( path: AIOPS_API_ENDPOINT.LOG_RATE_ANALYSIS, access: 'internal', }) - .addVersion( - { - version: '1', - validate: { - request: { - body: aiopsLogRateAnalysisSchemaV1, - }, - }, - }, - routeHandlerFactory('1', license, logger, coreStart, usageCounter) - ) .addVersion( { version: '2', diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_factory.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_factory.ts index b676836adfa96..57e97ade7fb12 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_factory.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_factory.ts @@ -56,7 +56,7 @@ export interface ResponseStreamFetchOptions extends Respon responseStream: { end: () => void; endWithUpdatedLoadingState: () => void; - push: StreamFactoryReturnType>['push']; + push: StreamFactoryReturnType['push']; pushPingWithTimeout: () => void; pushError: (msg: string) => void; }; @@ -97,14 +97,14 @@ export const responseStreamFactory = (options: ResponseStr end: streamEnd, push, responseWithHeaders, - } = streamFactory>( + } = streamFactory( headers, logger, requestBody.compressResponse, requestBody.flushFix ); - const pushPingWithTimeout = streamPushPingWithTimeoutFactory(state, push, logDebugMessage); + const pushPingWithTimeout = streamPushPingWithTimeoutFactory(state, push, logDebugMessage); const end = streamEndFactory(state, streamEnd, logDebugMessage); const endWithUpdatedLoadingState = streamEndWithUpdatedLoadingStateFactory(end, push); const pushError = streamPushErrorFactory(push, logDebugMessage); diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_end_with_updated_loading_state.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_end_with_updated_loading_state.ts index 3ecb08fba480b..7765f6679d38d 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_end_with_updated_loading_state.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_end_with_updated_loading_state.ts @@ -13,7 +13,6 @@ import { updateLoadingStateAction, type AiopsLogRateAnalysisApiAction, } from '@kbn/aiops-log-rate-analysis/api/actions'; -import type { AiopsLogRateAnalysisApiVersion as ApiVersion } from '@kbn/aiops-log-rate-analysis/api/schema'; /** * Helper function that will push a message to the stream that it's done and @@ -21,9 +20,9 @@ import type { AiopsLogRateAnalysisApiVersion as ApiVersion } from '@kbn/aiops-lo * This is implemented as a factory that receives the necessary dependencies * which then returns the actual helper function. */ -export const streamEndWithUpdatedLoadingStateFactory = ( +export const streamEndWithUpdatedLoadingStateFactory = ( streamEndCallback: () => void, - push: StreamFactoryReturnType>['push'] + push: StreamFactoryReturnType['push'] ) => { return function endWithUpdatedLoadingState() { push( diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_error.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_error.ts index 87978b2561a35..92c3fb3661ae8 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_error.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_error.ts @@ -7,7 +7,6 @@ import type { StreamFactoryReturnType } from '@kbn/ml-response-stream/server'; -import type { AiopsLogRateAnalysisApiVersion as ApiVersion } from '@kbn/aiops-log-rate-analysis/api/schema'; import { addErrorAction, type AiopsLogRateAnalysisApiAction, @@ -20,8 +19,8 @@ import type { LogDebugMessage } from './log_debug_message'; * This is implemented as a factory that receives the necessary dependencies * which then returns the actual helper function. */ -export const streamPushErrorFactory = ( - push: StreamFactoryReturnType>['push'], +export const streamPushErrorFactory = ( + push: StreamFactoryReturnType['push'], logDebugMessage: LogDebugMessage ) => { return function pushError(m: string) { diff --git a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_ping_with_timeout.ts b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_ping_with_timeout.ts index d570da39f277e..bcedc82d5f5c4 100644 --- a/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_ping_with_timeout.ts +++ b/x-pack/plugins/aiops/server/routes/log_rate_analysis/response_stream_utils/stream_push_ping_with_timeout.ts @@ -11,7 +11,6 @@ import { pingAction, type AiopsLogRateAnalysisApiAction, } from '@kbn/aiops-log-rate-analysis/api/actions'; -import type { AiopsLogRateAnalysisApiVersion as ApiVersion } from '@kbn/aiops-log-rate-analysis/api/schema'; import type { LogDebugMessage } from './log_debug_message'; import type { StateHandler } from './state_handler'; @@ -24,9 +23,9 @@ const PING_FREQUENCY = 10000; * This is implemented as a factory that receives the necessary dependencies * which then returns the actual helper function. */ -export const streamPushPingWithTimeoutFactory = ( +export const streamPushPingWithTimeoutFactory = ( stateHandler: StateHandler, - push: StreamFactoryReturnType>['push'], + push: StreamFactoryReturnType['push'], logDebugMessage: LogDebugMessage ) => { return function pushPingWithTimeout() { 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 55aa3247aaa7a..5f5b069fe75e7 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 @@ -1972,7 +1972,7 @@ describe('Task Runner', () => { expect(loggerCallPrefix[0].trim()).toMatchInlineSnapshot( `"Executing Rule default:test:1 has resulted in Error: GENERIC ERROR MESSAGE"` ); - expect(loggerMeta?.tags).toEqual(['test', '1', 'rule-run-failed']); + expect(loggerMeta?.tags).toEqual(['test', '1', 'rule-run-failed', 'framework-error']); expect(loggerMeta?.error?.stack_trace).toBeDefined(); expect(logger.error).toBeCalledTimes(1); expect(getErrorSource(runnerResult.taskRunError as Error)).toBe(TaskErrorSource.FRAMEWORK); @@ -3353,7 +3353,7 @@ describe('Task Runner', () => { ); expect(logger.error).toHaveBeenCalledWith( 'Executing Rule test:1 has resulted in the following error(s): an error occurred,second error occurred', - { tags: ['test', '1', 'rule-run-failed'] } + { tags: ['test', '1', 'rule-run-failed', 'framework-error'] } ); }); 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 c5993fe8bc560..627f88bab4e69 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts @@ -687,18 +687,16 @@ export class TaskRunner< const { errors: errorsFromLastRun } = this.ruleResult.getLastRunResults(); if (errorsFromLastRun.length > 0) { const isUserError = !errorsFromLastRun.some((lastRunError) => !lastRunError.userError); + const errorSource = isUserError ? TaskErrorSource.USER : TaskErrorSource.FRAMEWORK; const lasRunErrorMessages = errorsFromLastRun .map((lastRunError) => lastRunError.message) .join(','); const errorMessage = `Executing Rule ${this.ruleType.id}:${ruleId} has resulted in the following error(s): ${lasRunErrorMessages}`; this.logger.error(errorMessage, { - tags: [this.ruleType.id, ruleId, 'rule-run-failed'], + tags: [this.ruleType.id, ruleId, 'rule-run-failed', `${errorSource}-error`], }); return { - taskRunError: createTaskRunError( - new Error(errorMessage), - isUserError ? TaskErrorSource.USER : TaskErrorSource.FRAMEWORK - ), + taskRunError: createTaskRunError(new Error(errorMessage), errorSource), }; } @@ -711,11 +709,15 @@ export class TaskRunner< (ruleRunStateWithMetrics: RuleTaskStateAndMetrics) => transformRunStateToTaskState(ruleRunStateWithMetrics), (err: ElasticsearchError) => { + const errorSource = `${getErrorSource(err)}-error`; + if (isAlertSavedObjectNotFoundError(err, ruleId)) { const message = `Executing Rule ${spaceId}:${ this.ruleType.id }:${ruleId} has resulted in Error: ${getEsErrorMessage(err)}`; - this.logger.debug(message); + this.logger.debug(message, { + tags: [this.ruleType.id, ruleId, 'rule-run-failed', errorSource], + }); } else { const error = this.stackTraceLog ? this.stackTraceLog.message : err; const stack = this.stackTraceLog ? this.stackTraceLog.stackTrace : err.stack; @@ -723,7 +725,7 @@ export class TaskRunner< this.ruleType.id }:${ruleId} has resulted in Error: ${getEsErrorMessage(error)} - ${stack ?? ''}`; this.logger.error(message, { - tags: [this.ruleType.id, ruleId, 'rule-run-failed'], + tags: [this.ruleType.id, ruleId, 'rule-run-failed', errorSource], error: { stack_trace: stack }, }); } diff --git a/x-pack/plugins/cases/public/components/all_cases/status_filter.test.tsx b/x-pack/plugins/cases/public/components/all_cases/status_filter.test.tsx index e544cc905cf72..d1bb46c7b8717 100644 --- a/x-pack/plugins/cases/public/components/all_cases/status_filter.test.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/status_filter.test.tsx @@ -19,7 +19,8 @@ const LABELS = { inProgress: i18n.STATUS_IN_PROGRESS, }; -describe('StatusFilter', () => { +// FLAKY: https://github.com/elastic/kibana/issues/177334 +describe.skip('StatusFilter', () => { const onChange = jest.fn(); const defaultProps = { selectedOptionKeys: [], diff --git a/x-pack/plugins/security_solution/public/cases/pages/index.tsx b/x-pack/plugins/security_solution/public/cases/pages/index.tsx index 29f149f3988a9..27cccce70c9a2 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/index.tsx @@ -11,7 +11,7 @@ import type { CaseViewRefreshPropInterface } from '@kbn/cases-plugin/common'; import { CaseMetricsFeature } from '@kbn/cases-plugin/common'; import { useUiSetting$ } from '@kbn/kibana-react-plugin/public'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { DocumentDetailsRightPanelKey } from '../../flyout/document_details/right'; +import { DocumentDetailsRightPanelKey } from '../../flyout/document_details/shared/constants/panel_keys'; import { useTourContext } from '../../common/components/guided_onboarding_tour'; import { AlertsCasesTourSteps, diff --git a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx index 7454db7c1e484..a9810a03960fd 100644 --- a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx @@ -14,7 +14,7 @@ import { useUiSetting$ } from '@kbn/kibana-react-plugin/public'; import { useKibana } from '../../../lib/kibana'; import { timelineActions } from '../../../../timelines/store'; import { ENABLE_EXPANDABLE_FLYOUT_SETTING } from '../../../../../common/constants'; -import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/right'; +import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/shared/constants/panel_keys'; import type { SetEventsDeleted, SetEventsLoading, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx index efd1870d31c87..ae7707e971131 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx @@ -8,7 +8,7 @@ import type { FC } from 'react'; import React, { useCallback } from 'react'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { DocumentDetailsRightPanelKey } from '../right'; +import { DocumentDetailsRightPanelKey } from '../shared/constants/panel_keys'; import { useBasicDataFromDetailsData } from '../../../timelines/components/side_panel/event_details/helpers'; import { EndpointIsolateSuccess } from '../../../common/components/endpoint/host_isolation'; import { useHostIsolationTools } from '../../../timelines/components/side_panel/event_details/use_host_isolation_tools'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/index.tsx index b56282a542646..7d9d682b1fe0a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/index.tsx @@ -11,9 +11,6 @@ import type { FlyoutPanelProps } from '@kbn/expandable-flyout'; import { PanelContent } from './content'; import { PanelHeader } from './header'; -export const DocumentDetailsIsolateHostPanelKey: IsolateHostPanelProps['key'] = - 'document-details-isolate-host'; - export interface IsolateHostPanelProps extends FlyoutPanelProps { key: 'document-details-isolate-host'; params?: { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx index 25b076eaa3d4a..fc644c99e297c 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx @@ -9,6 +9,7 @@ import type { FC } from 'react'; import React, { memo, useMemo } from 'react'; import type { FlyoutPanelProps, PanelPath } from '@kbn/expandable-flyout'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { DocumentDetailsLeftPanelKey } from '../shared/constants/panel_keys'; import { useKibana } from '../../../common/lib/kibana'; import { PanelHeader } from './header'; import { PanelContent } from './content'; @@ -20,7 +21,6 @@ import { useLeftPanelContext } from './context'; import { LeftPanelTour } from './components/tour'; export type LeftPanelPaths = 'visualize' | 'insights' | 'investigation' | 'response'; -export const DocumentDetailsLeftPanelKey: LeftPanelProps['key'] = 'document-details-left'; export const LeftPanelVisualizeTab: LeftPanelPaths = 'visualize'; export const LeftPanelInsightsTab: LeftPanelPaths = 'insights'; export const LeftPanelInvestigationTab: LeftPanelPaths = 'investigation'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx index d47631f4de98d..a60c98f46bdd2 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/insights_tab.tsx @@ -22,7 +22,8 @@ import { INSIGHTS_TAB_CORRELATIONS_BUTTON_TEST_ID, } from './test_ids'; import { useLeftPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelInsightsTab } from '..'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '..'; import { ENTITIES_TAB_ID, EntitiesDetails } from '../components/entities_details'; import { THREAT_INTELLIGENCE_TAB_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/visualize_tab.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/visualize_tab.tsx index bc365e3f149dd..22a5e52c1d4a0 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/visualize_tab.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/tabs/visualize_tab.tsx @@ -13,7 +13,8 @@ import { useExpandableFlyoutApi, useExpandableFlyoutState } from '@kbn/expandabl import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { useLeftPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelVisualizeTab } from '..'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelVisualizeTab } from '..'; import { VISUALIZE_TAB_BUTTON_GROUP_TEST_ID, VISUALIZE_TAB_GRAPH_ANALYZER_BUTTON_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/preview/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/preview/index.tsx index 5bc4ebf31ab40..1d0080f795d80 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/preview/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/preview/index.tsx @@ -13,7 +13,6 @@ import { panels } from './panels'; export type PreviewPanelPaths = 'rule-preview' | 'alert-reason-preview'; export const RulePreviewPanel: PreviewPanelPaths = 'rule-preview'; export const AlertReasonPreviewPanel: PreviewPanelPaths = 'alert-reason-preview'; -export const DocumentDetailsPreviewPanelKey: PreviewPanelProps['key'] = 'document-details-preview'; export interface PreviewPanelProps extends FlyoutPanelProps { key: 'document-details-preview'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx index 4b17ac6667c66..856c3ec51f364 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx @@ -17,7 +17,7 @@ import { AlertDescription } from './alert_description'; import { RightPanelContext } from '../context'; import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data'; import type { TimelineEventsDetailsItem } from '@kbn/timelines-plugin/common'; -import { DocumentDetailsPreviewPanelKey } from '../../preview'; +import { DocumentDetailsPreviewPanelKey } from '../../shared/constants/panel_keys'; import { TestProviders } from '../../../../common/mock'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx index b3c4ac7a2ce6b..1b649700f3bb2 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.tsx @@ -21,11 +21,8 @@ import { ALERT_DESCRIPTION_TITLE_TEST_ID, RULE_SUMMARY_BUTTON_TEST_ID, } from './test_ids'; -import { - DocumentDetailsPreviewPanelKey, - type PreviewPanelProps, - RulePreviewPanel, -} from '../../preview'; +import { DocumentDetailsPreviewPanelKey } from '../../shared/constants/panel_keys'; +import { type PreviewPanelProps, RulePreviewPanel } from '../../preview'; /** * Displays the rule description of a signal document. diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx index ad2cdb8b06f6b..bb4fcdc79bb83 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx @@ -13,7 +13,8 @@ import { RightPanelContext } from '../context'; import { TestProviders } from '../../../../common/mock'; import { CorrelationsOverview } from './correlations_overview'; import { CORRELATIONS_TAB_ID } from '../../left/components/correlations_details'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { CORRELATIONS_RELATED_ALERTS_BY_ANCESTRY_TEST_ID, CORRELATIONS_RELATED_ALERTS_BY_SAME_SOURCE_EVENT_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx index 9595b9160ccbb..e6bf84f039c52 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx @@ -25,7 +25,8 @@ import { RelatedCases } from './related_cases'; import { useShowRelatedCases } from '../../shared/hooks/use_show_related_cases'; import { CORRELATIONS_TEST_ID } from './test_ids'; import { useRightPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelInsightsTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { CORRELATIONS_TAB_ID } from '../../left/components/correlations_details'; import { useTimelineDataFilters } from '../../../../timelines/containers/use_timeline_data_filters'; import { isActiveTimeline } from '../../../../helpers'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx index df6f5fbfc93ce..7d150c0850c81 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx @@ -15,7 +15,8 @@ import { useRightPanelContext } from '../context'; import { getField } from '../../shared/utils'; import { HostEntityOverview } from './host_entity_overview'; import { UserEntityOverview } from './user_entity_overview'; -import { DocumentDetailsLeftPanelKey, LeftPanelInsightsTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; /** diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx index baa98fd757054..5c2446a6b407b 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx @@ -14,7 +14,8 @@ import { } from './test_ids'; import { HighlightedFieldsCell } from './highlighted_fields_cell'; import { RightPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelInsightsTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { TestProviders } from '../../../../common/mock'; import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { useGetEndpointDetails } from '../../../../management/hooks'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx index eabc825789e3f..2ae8991094164 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx @@ -18,7 +18,8 @@ import { HOST_NAME_FIELD_NAME, USER_NAME_FIELD_NAME, } from '../../../../timelines/components/timeline/body/renderers/constants'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { HIGHLIGHTED_FIELDS_AGENT_STATUS_CELL_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx index c7e757919574b..40008e52b820d 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx @@ -21,7 +21,8 @@ import { RightPanelContext } from '../context'; import { mockContextValue } from '../mocks/mock_context'; import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser'; import { useExpandableFlyoutApi, type ExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { useRiskScore } from '../../../../entity_analytics/api/hooks/use_risk_score'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx index d9568de7bf4dc..117206d0f63fe 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx @@ -50,7 +50,8 @@ import { ENTITIES_HOST_OVERVIEW_LINK_TEST_ID, ENTITIES_HOST_OVERVIEW_LOADING_TEST_ID, } from './test_ids'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { RiskScoreDocTooltip } from '../../../../overview/components/common'; const HOST_ICON = 'storage'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx index d57492990b882..a1292e66a6c2f 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx @@ -19,7 +19,8 @@ import { mockContextValue } from '../mocks/mock_context'; import type { ExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { useInvestigationGuide } from '../../shared/hooks/use_investigation_guide'; -import { LeftPanelInvestigationTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInvestigationTab } from '../../left'; jest.mock('../../shared/hooks/use_investigation_guide'); jest.mock('@kbn/expandable-flyout', () => ({ useExpandableFlyoutApi: jest.fn() })); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.tsx index 8adecb6ac0560..4b19af37fcfea 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.tsx @@ -11,7 +11,8 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useInvestigationGuide } from '../../shared/hooks/use_investigation_guide'; import { useRightPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelInvestigationTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInvestigationTab } from '../../left'; import { INVESTIGATION_GUIDE_BUTTON_TEST_ID, INVESTIGATION_GUIDE_LOADING_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx index ee081caa006be..f516ddb0860d7 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx @@ -9,7 +9,8 @@ import { render } from '@testing-library/react'; import { TestProviders } from '../../../../common/mock'; import { RightPanelContext } from '../context'; import { PREVALENCE_TEST_ID } from './test_ids'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import React from 'react'; import { PrevalenceOverview } from './prevalence_overview'; import { PREVALENCE_TAB_ID } from '../../left/components/prevalence_details'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx index a2c05e8cf28d1..527e2f16e0f60 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx @@ -14,7 +14,8 @@ import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import { usePrevalence } from '../../shared/hooks/use_prevalence'; import { PREVALENCE_TEST_ID } from './test_ids'; import { useRightPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelInsightsTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { PREVALENCE_TAB_ID } from '../../left/components/prevalence_details'; import { InsightsSummaryRow } from './insights_summary_row'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx index bac24388a1c6b..46e9230830f33 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx @@ -13,7 +13,7 @@ import { Reason } from './reason'; import { RightPanelContext } from '../context'; import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data'; import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser'; -import { DocumentDetailsPreviewPanelKey } from '../../preview'; +import { DocumentDetailsPreviewPanelKey } from '../../shared/constants/panel_keys'; import { TestProviders } from '../../../../common/mock'; import { i18n } from '@kbn/i18n'; import { type ExpandableFlyoutApi, useExpandableFlyoutApi } from '@kbn/expandable-flyout'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx index 0ac7e5f0eb2ff..5400052295c22 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.tsx @@ -14,7 +14,8 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useKibana } from '../../../../common/lib/kibana'; import { getField } from '../../shared/utils'; -import { AlertReasonPreviewPanel, DocumentDetailsPreviewPanelKey } from '../../preview'; +import { DocumentDetailsPreviewPanelKey } from '../../shared/constants/panel_keys'; +import { AlertReasonPreviewPanel } from '../../preview'; import { REASON_DETAILS_PREVIEW_BUTTON_TEST_ID, REASON_DETAILS_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/response_button.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/response_button.tsx index 32fa9cd8dec6a..36b941886383f 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/response_button.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/response_button.tsx @@ -9,7 +9,8 @@ import { EuiButton } from '@elastic/eui'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { FormattedMessage } from '@kbn/i18n-react'; import { useRightPanelContext } from '../context'; -import { DocumentDetailsLeftPanelKey, LeftPanelResponseTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelResponseTab } from '../../left'; import { RESPONSE_BUTTON_TEST_ID } from './test_ids'; /** diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx index 7faf7609a269c..9cb6da0b929f8 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx @@ -11,7 +11,8 @@ import { useExpandableFlyoutApi, type ExpandableFlyoutApi } from '@kbn/expandabl import { RightPanelContext } from '../context'; import { TestProviders } from '../../../../common/mock'; import { ThreatIntelligenceOverview } from './threat_intelligence_overview'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { useFetchThreatIntelligence } from '../hooks/use_fetch_threat_intelligence'; import { THREAT_INTELLIGENCE_TAB_ID } from '../../left/components/threat_intelligence_details'; import { INSIGHTS_THREAT_INTELLIGENCE_TEST_ID } from './test_ids'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx index a16da1bbf647c..351c09f71d3f7 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx @@ -15,7 +15,8 @@ import { useFetchThreatIntelligence } from '../hooks/use_fetch_threat_intelligen import { InsightsSummaryRow } from './insights_summary_row'; import { useRightPanelContext } from '../context'; import { INSIGHTS_THREAT_INTELLIGENCE_TEST_ID } from './test_ids'; -import { DocumentDetailsLeftPanelKey, LeftPanelInsightsTab } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { THREAT_INTELLIGENCE_TAB_ID } from '../../left/components/threat_intelligence_details'; /** diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx index 423619d59f13a..35a5cc1e5d379 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx @@ -15,8 +15,10 @@ import { getLeftSectionTourSteps, } from '../../shared/utils/tour_step_config'; import { getField } from '../../shared/utils'; -import { DocumentDetailsRightPanelKey } from '..'; -import { DocumentDetailsLeftPanelKey } from '../../left'; +import { + DocumentDetailsLeftPanelKey, + DocumentDetailsRightPanelKey, +} from '../../shared/constants/panel_keys'; import { EventKind } from '../../shared/constants/event_kinds'; import { useIsTimelineFlyoutOpen } from '../../shared/hooks/use_is_timeline_flyout_open'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx index c608f50878fe8..a57fad465feb9 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx @@ -20,7 +20,8 @@ import { useObservedUserDetails } from '../../../../explore/users/containers/use import { mockContextValue } from '../mocks/mock_context'; import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser'; import { RightPanelContext } from '../context'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { useRiskScore } from '../../../../entity_analytics/api/hooks/use_risk_score'; import { type ExpandableFlyoutApi, useExpandableFlyoutApi } from '@kbn/expandable-flyout'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx index 5293536f54011..ef9dbb588f2a6 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx @@ -19,7 +19,8 @@ import { css } from '@emotion/css'; import { getOr } from 'lodash/fp'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { LeftPanelInsightsTab, DocumentDetailsLeftPanelKey } from '../../left'; +import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; +import { LeftPanelInsightsTab } from '../../left'; import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { useRightPanelContext } from '../context'; import type { DescriptionList } from '../../../../../common/utility_types'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx index f1cbd4fbc9685..23166706c177e 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/index.tsx @@ -9,6 +9,7 @@ import type { FC } from 'react'; import React, { memo, useEffect } from 'react'; import type { FlyoutPanelProps, PanelPath } from '@kbn/expandable-flyout'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { DocumentDetailsRightPanelKey } from '../shared/constants/panel_keys'; import { useTabs } from './hooks/use_tabs'; import { FLYOUT_STORAGE_KEYS } from '../shared/constants/local_storage'; import { useKibana } from '../../../common/lib/kibana'; @@ -22,7 +23,6 @@ import { PanelFooter } from './footer'; import { useFlyoutIsExpandable } from './hooks/use_flyout_is_expandable'; export type RightPanelPaths = 'overview' | 'table' | 'json'; -export const DocumentDetailsRightPanelKey: RightPanelProps['key'] = 'document-details-right'; export interface RightPanelProps extends FlyoutPanelProps { key: 'document-details-right'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx index d484e2e2a0204..110f6892309ef 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx @@ -11,7 +11,7 @@ import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { useKibana } from '../../../common/lib/kibana'; import { HeaderActions } from './components/header_actions'; import { FlyoutNavigation } from '../../shared/components/flyout_navigation'; -import { DocumentDetailsLeftPanelKey } from '../left'; +import { DocumentDetailsLeftPanelKey } from '../shared/constants/panel_keys'; import { useRightPanelContext } from './context'; interface PanelNavigationProps { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/shared/constants/panel_keys.ts b/x-pack/plugins/security_solution/public/flyout/document_details/shared/constants/panel_keys.ts new file mode 100644 index 0000000000000..ec2d59791524e --- /dev/null +++ b/x-pack/plugins/security_solution/public/flyout/document_details/shared/constants/panel_keys.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 { IsolateHostPanelProps } from '../../isolate_host'; +import type { LeftPanelProps } from '../../left'; +import type { PreviewPanelProps } from '../../preview'; +import type { RightPanelProps } from '../../right'; + +export const DocumentDetailsRightPanelKey: RightPanelProps['key'] = 'document-details-right'; +export const DocumentDetailsLeftPanelKey: LeftPanelProps['key'] = 'document-details-left'; +export const DocumentDetailsPreviewPanelKey: PreviewPanelProps['key'] = 'document-details-preview'; +export const DocumentDetailsIsolateHostPanelKey: IsolateHostPanelProps['key'] = + 'document-details-isolate-host'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/shared/hooks/url/expandable_flyout_state_from_event_meta.ts b/x-pack/plugins/security_solution/public/flyout/document_details/shared/hooks/url/expandable_flyout_state_from_event_meta.ts index d80d6f5983b89..0d9e97fe2d427 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/shared/hooks/url/expandable_flyout_state_from_event_meta.ts +++ b/x-pack/plugins/security_solution/public/flyout/document_details/shared/hooks/url/expandable_flyout_state_from_event_meta.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { DocumentDetailsRightPanelKey } from '../../../right'; +import { DocumentDetailsRightPanelKey } from '../../constants/panel_keys'; interface RedirectParams { index: string; diff --git a/x-pack/plugins/security_solution/public/flyout/index.tsx b/x-pack/plugins/security_solution/public/flyout/index.tsx index 49681180b7415..f312125df0ab7 100644 --- a/x-pack/plugins/security_solution/public/flyout/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/index.tsx @@ -8,20 +8,23 @@ import React, { memo } from 'react'; import { ExpandableFlyout, type ExpandableFlyoutProps } from '@kbn/expandable-flyout'; import { useEuiTheme } from '@elastic/eui'; -import type { IsolateHostPanelProps } from './document_details/isolate_host'; import { - IsolateHostPanel, DocumentDetailsIsolateHostPanelKey, -} from './document_details/isolate_host'; + DocumentDetailsLeftPanelKey, + DocumentDetailsPreviewPanelKey, + DocumentDetailsRightPanelKey, +} from './document_details/shared/constants/panel_keys'; +import type { IsolateHostPanelProps } from './document_details/isolate_host'; +import { IsolateHostPanel } from './document_details/isolate_host'; import { IsolateHostPanelProvider } from './document_details/isolate_host/context'; import type { RightPanelProps } from './document_details/right'; -import { RightPanel, DocumentDetailsRightPanelKey } from './document_details/right'; +import { RightPanel } from './document_details/right'; import { RightPanelProvider } from './document_details/right/context'; import type { LeftPanelProps } from './document_details/left'; -import { LeftPanel, DocumentDetailsLeftPanelKey } from './document_details/left'; +import { LeftPanel } from './document_details/left'; import { LeftPanelProvider } from './document_details/left/context'; import type { PreviewPanelProps } from './document_details/preview'; -import { PreviewPanel, DocumentDetailsPreviewPanelKey } from './document_details/preview'; +import { PreviewPanel } from './document_details/preview'; import { PreviewPanelProvider } from './document_details/preview/context'; import type { UserPanelExpandableFlyoutProps } from './entity_details/user_right'; import { UserPanel, UserPanelKey } from './entity_details/user_right'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/side_panel/hooks/use_detail_panel.tsx b/x-pack/plugins/security_solution/public/timelines/components/side_panel/hooks/use_detail_panel.tsx index 7167ab106634a..a419c1cdca0be 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/side_panel/hooks/use_detail_panel.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/side_panel/hooks/use_detail_panel.tsx @@ -22,7 +22,7 @@ import { timelineDefaults } from '../../../store/defaults'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; import { DetailsPanel as DetailsPanelComponent } from '..'; import { ENABLE_EXPANDABLE_FLYOUT_SETTING } from '../../../../../common/constants'; -import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/right'; +import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/shared/constants/panel_keys'; export interface UseDetailPanelConfig { entityType?: EntityType; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/stateful_event.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/stateful_event.tsx index 0cd34f01fed33..d95bd56182848 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/stateful_event.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/stateful_event.tsx @@ -12,7 +12,7 @@ import { isEventBuildingBlockType } from '@kbn/securitysolution-data-table'; import { useUiSetting$ } from '@kbn/kibana-react-plugin/public'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { DocumentDetailsRightPanelKey } from '../../../../../flyout/document_details/right'; +import { DocumentDetailsRightPanelKey } from '../../../../../flyout/document_details/shared/constants/panel_keys'; import { ENABLE_EXPANDABLE_FLYOUT_SETTING } from '../../../../../../common/constants'; import { useDeepEqualSelector } from '../../../../../common/hooks/use_selector'; import type { diff --git a/x-pack/plugins/task_manager/server/metrics/create_aggregator.test.ts b/x-pack/plugins/task_manager/server/metrics/create_aggregator.test.ts index 92b2fe958b1b3..d5d51671fafc6 100644 --- a/x-pack/plugins/task_manager/server/metrics/create_aggregator.test.ts +++ b/x-pack/plugins/task_manager/server/metrics/create_aggregator.test.ts @@ -120,6 +120,7 @@ describe('createAggregator', () => { value: { success: 1, total: 1, + total_errors: 0, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -129,6 +130,7 @@ describe('createAggregator', () => { value: { success: 2, total: 2, + total_errors: 0, duration: { counts: [2], values: [100] }, duration_values: [10, 10], }, @@ -138,6 +140,7 @@ describe('createAggregator', () => { value: { success: 3, total: 3, + total_errors: 0, duration: { counts: [3], values: [100] }, duration_values: [10, 10, 10], }, @@ -147,6 +150,7 @@ describe('createAggregator', () => { value: { success: 4, total: 4, + total_errors: 0, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }, @@ -156,6 +160,7 @@ describe('createAggregator', () => { value: { success: 4, total: 5, + total_errors: 1, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }, @@ -165,6 +170,7 @@ describe('createAggregator', () => { value: { success: 5, total: 6, + total_errors: 1, duration: { counts: [5], values: [100] }, duration_values: [10, 10, 10, 10, 10], }, @@ -174,6 +180,7 @@ describe('createAggregator', () => { value: { success: 6, total: 7, + total_errors: 1, duration: { counts: [6], values: [100] }, duration_values: [10, 10, 10, 10, 10, 10], }, @@ -183,6 +190,7 @@ describe('createAggregator', () => { value: { success: 7, total: 8, + total_errors: 1, duration: { counts: [7], values: [100] }, duration_values: [10, 10, 10, 10, 10, 10, 10], }, @@ -192,6 +200,7 @@ describe('createAggregator', () => { value: { success: 8, total: 9, + total_errors: 1, duration: { counts: [8], values: [100] }, duration_values: [10, 10, 10, 10, 10, 10, 10, 10], }, @@ -201,6 +210,7 @@ describe('createAggregator', () => { value: { success: 8, total: 10, + total_errors: 2, duration: { counts: [8], values: [100] }, duration_values: [10, 10, 10, 10, 10, 10, 10, 10], }, @@ -210,6 +220,7 @@ describe('createAggregator', () => { value: { success: 9, total: 11, + total_errors: 2, duration: { counts: [9], values: [100] }, duration_values: [10, 10, 10, 10, 10, 10, 10, 10, 10], }, @@ -267,6 +278,7 @@ describe('createAggregator', () => { value: { success: 1, total: 1, + total_errors: 0, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -276,6 +288,7 @@ describe('createAggregator', () => { value: { success: 2, total: 2, + total_errors: 0, duration: { counts: [2], values: [100] }, duration_values: [10, 10], }, @@ -285,6 +298,7 @@ describe('createAggregator', () => { value: { success: 3, total: 3, + total_errors: 0, duration: { counts: [3], values: [100] }, duration_values: [10, 10, 10], }, @@ -294,6 +308,7 @@ describe('createAggregator', () => { value: { success: 4, total: 4, + total_errors: 0, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }, @@ -303,6 +318,7 @@ describe('createAggregator', () => { value: { success: 4, total: 5, + total_errors: 1, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }, @@ -312,6 +328,7 @@ describe('createAggregator', () => { value: { success: 5, total: 6, + total_errors: 1, duration: { counts: [5], values: [100] }, duration_values: [10, 10, 10, 10, 10], }, @@ -322,6 +339,7 @@ describe('createAggregator', () => { value: { success: 1, total: 1, + total_errors: 0, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -331,6 +349,7 @@ describe('createAggregator', () => { value: { success: 1, total: 2, + total_errors: 1, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -340,6 +359,7 @@ describe('createAggregator', () => { value: { success: 1, total: 3, + total_errors: 2, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -349,6 +369,7 @@ describe('createAggregator', () => { value: { success: 2, total: 4, + total_errors: 2, duration: { counts: [2], values: [100] }, duration_values: [10, 10], }, @@ -358,6 +379,7 @@ describe('createAggregator', () => { value: { success: 3, total: 5, + total_errors: 2, duration: { counts: [3], values: [100] }, duration_values: [10, 10, 10], }, @@ -423,6 +445,7 @@ describe('createAggregator', () => { value: { success: 1, total: 1, + total_errors: 0, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -432,6 +455,7 @@ describe('createAggregator', () => { value: { success: 2, total: 2, + total_errors: 0, duration: { counts: [2], values: [100] }, duration_values: [10, 10], }, @@ -441,6 +465,7 @@ describe('createAggregator', () => { value: { success: 3, total: 3, + total_errors: 0, duration: { counts: [3], values: [100] }, duration_values: [10, 10, 10], }, @@ -450,6 +475,7 @@ describe('createAggregator', () => { value: { success: 4, total: 4, + total_errors: 0, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }, @@ -459,6 +485,7 @@ describe('createAggregator', () => { value: { success: 4, total: 5, + total_errors: 1, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }, @@ -468,6 +495,7 @@ describe('createAggregator', () => { value: { success: 5, total: 6, + total_errors: 1, duration: { counts: [5], values: [100] }, duration_values: [10, 10, 10, 10, 10], }, @@ -478,6 +506,7 @@ describe('createAggregator', () => { value: { success: 1, total: 1, + total_errors: 0, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -487,6 +516,7 @@ describe('createAggregator', () => { value: { success: 1, total: 2, + total_errors: 1, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -496,6 +526,7 @@ describe('createAggregator', () => { value: { success: 1, total: 3, + total_errors: 2, duration: { counts: [1], values: [100] }, duration_values: [10], }, @@ -505,6 +536,7 @@ describe('createAggregator', () => { value: { success: 2, total: 4, + total_errors: 2, duration: { counts: [2], values: [100] }, duration_values: [10, 10], }, @@ -514,6 +546,7 @@ describe('createAggregator', () => { value: { success: 3, total: 5, + total_errors: 2, duration: { counts: [3], values: [100] }, duration_values: [10, 10, 10], }, diff --git a/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.test.ts b/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.test.ts index 0874940675287..cfad963b20a65 100644 --- a/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.test.ts +++ b/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.test.ts @@ -46,6 +46,7 @@ describe('TaskClaimMetricsAggregator', () => { expect(taskClaimMetricsAggregator.collect()).toEqual({ success: 0, total: 0, + total_errors: 0, duration: { counts: [], values: [] }, duration_values: [], }); @@ -55,6 +56,7 @@ describe('TaskClaimMetricsAggregator', () => { expect(taskClaimMetricsAggregator.initialMetric()).toEqual({ success: 0, total: 0, + total_errors: 0, duration: { counts: [], values: [] }, duration_values: [], }); @@ -66,6 +68,7 @@ describe('TaskClaimMetricsAggregator', () => { expect(taskClaimMetricsAggregator.collect()).toEqual({ success: 2, total: 2, + total_errors: 0, duration: { counts: [2], values: [100] }, duration_values: [10, 10], }); @@ -77,6 +80,7 @@ describe('TaskClaimMetricsAggregator', () => { expect(taskClaimMetricsAggregator.collect()).toEqual({ success: 0, total: 2, + total_errors: 2, duration: { counts: [], values: [] }, duration_values: [], }); @@ -93,6 +97,7 @@ describe('TaskClaimMetricsAggregator', () => { expect(taskClaimMetricsAggregator.collect()).toEqual({ success: 4, total: 7, + total_errors: 3, duration: { counts: [4], values: [100] }, duration_values: [10, 10, 10, 10], }); @@ -101,6 +106,7 @@ describe('TaskClaimMetricsAggregator', () => { expect(taskClaimMetricsAggregator.collect()).toEqual({ success: 0, total: 0, + total_errors: 0, duration: { counts: [], values: [] }, duration_values: [], }); diff --git a/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.ts b/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.ts index 486a3f9aa5fd7..104565def0daa 100644 --- a/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.ts +++ b/x-pack/plugins/task_manager/server/metrics/task_claim_metrics_aggregator.ts @@ -18,6 +18,7 @@ const HDR_HISTOGRAM_BUCKET_SIZE = 100; // 100 millis enum TaskClaimKeys { SUCCESS = 'success', TOTAL = 'total', + TOTAL_ERRORS = 'total_errors', } interface TaskClaimCounts extends JsonObject { [TaskClaimKeys.SUCCESS]: number; @@ -59,6 +60,8 @@ export class TaskClaimMetricsAggregator implements ITaskMetricsAggregator { + // Failing: See https://github.com/elastic/kibana/issues/177215 + describe.skip('rule', async () => { const objectRemover = new ObjectRemover(supertest); let connectorId: string; const transformId = 'test_transform_01'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/install_resources.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/install_resources.ts index 3867ac2494198..b4d153d0a760c 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/install_resources.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/alerts_as_data/install_resources.ts @@ -18,7 +18,8 @@ export default function createAlertsAsDataInstallResourcesTest({ getService }: F const legacyAlertMappings = mappingFromFieldMap(legacyAlertFieldMap, 'strict'); const ecsMappings = mappingFromFieldMap(ecsFieldMap, 'strict'); - describe('install alerts as data resources', () => { + // Failing: See https://github.com/elastic/kibana/issues/181296 + describe.skip('install alerts as data resources', () => { it('should install common alerts as data resources on startup', async () => { const ilmPolicyName = '.alerts-ilm-policy'; const frameworkComponentTemplateName = '.alerts-framework-mappings'; diff --git a/x-pack/test/api_integration/apis/aiops/log_rate_analysis_full_analysis.ts b/x-pack/test/api_integration/apis/aiops/log_rate_analysis_full_analysis.ts index 02086bbfe8b1c..b1a9fe2effb49 100644 --- a/x-pack/test/api_integration/apis/aiops/log_rate_analysis_full_analysis.ts +++ b/x-pack/test/api_integration/apis/aiops/log_rate_analysis_full_analysis.ts @@ -56,7 +56,7 @@ export default ({ getService }: FtrProviderContext) => { expect(typeof d.type).to.be('string'); }); - const addSignificantItemsActions = getAddSignificationItemsActions(data, apiVersion); + const addSignificantItemsActions = getAddSignificationItemsActions(data); expect(addSignificantItemsActions.length).to.greaterThan( 0, 'Expected significant items actions to be greater than 0.' @@ -73,7 +73,7 @@ export default ({ getService }: FtrProviderContext) => { 'Significant items do not match expected values.' ); - const histogramActions = getHistogramActions(data, apiVersion); + const histogramActions = getHistogramActions(data); const histograms = histogramActions.flatMap((d) => d.payload); // for each significant term we should get a histogram expect(histogramActions.length).to.be(significantItems.length); @@ -85,7 +85,7 @@ export default ({ getService }: FtrProviderContext) => { ); }); - const groupActions = getGroupActions(data, apiVersion); + const groupActions = getGroupActions(data); const groups = groupActions.flatMap((d) => d.payload); const actualGroups = orderBy(groups, ['docCount'], ['desc']); @@ -98,7 +98,7 @@ export default ({ getService }: FtrProviderContext) => { )}, got ${JSON.stringify(actualGroups)}` ); - const groupHistogramActions = getGroupHistogramActions(data, apiVersion); + const groupHistogramActions = getGroupHistogramActions(data); const groupHistograms = groupHistogramActions.flatMap((d) => d.payload); // for each significant terms group we should get a histogram expect(groupHistograms.length).to.be(groups.length); diff --git a/x-pack/test/api_integration/apis/aiops/log_rate_analysis_groups_only.ts b/x-pack/test/api_integration/apis/aiops/log_rate_analysis_groups_only.ts index 340f450a5f717..d3a7aaed19a40 100644 --- a/x-pack/test/api_integration/apis/aiops/log_rate_analysis_groups_only.ts +++ b/x-pack/test/api_integration/apis/aiops/log_rate_analysis_groups_only.ts @@ -37,24 +37,13 @@ export default ({ getService }: FtrProviderContext) => { getLogRateAnalysisTestData().forEach((testData) => { let overrides: AiopsLogRateAnalysisSchema['overrides'] = {}; - if (apiVersion === '1') { - overrides = { - loaded: 0, - remainingFieldCandidates: [], - significantTerms: testData.expected.significantItems, - regroupOnly: true, - } as AiopsLogRateAnalysisSchema['overrides']; - } - - if (apiVersion === '2') { - overrides = { - loaded: 0, - remainingFieldCandidates: [], - significantItems: testData.expected - .significantItems as AiopsLogRateAnalysisSchemaSignificantItem[], - regroupOnly: true, - } as AiopsLogRateAnalysisSchema['overrides']; - } + overrides = { + loaded: 0, + remainingFieldCandidates: [], + significantItems: testData.expected + .significantItems as AiopsLogRateAnalysisSchemaSignificantItem[], + regroupOnly: true, + } as AiopsLogRateAnalysisSchema['overrides']; describe(`with v${apiVersion} - ${testData.testName}`, () => { before(async () => { @@ -78,13 +67,13 @@ export default ({ getService }: FtrProviderContext) => { expect(typeof d.type).to.be('string'); }); - const addSignificantItemsActions = getAddSignificationItemsActions(data, apiVersion); + const addSignificantItemsActions = getAddSignificationItemsActions(data); expect(addSignificantItemsActions.length).to.eql( 0, `Expected significant items actions to be 0, got ${addSignificantItemsActions.length}` ); - const histogramActions = getHistogramActions(data, apiVersion); + const histogramActions = getHistogramActions(data); // for each significant item we should get a histogram expect(histogramActions.length).to.eql( @@ -92,7 +81,7 @@ export default ({ getService }: FtrProviderContext) => { `Expected histogram actions to be 0, got ${histogramActions.length}` ); - const groupActions = getGroupActions(data, apiVersion); + const groupActions = getGroupActions(data); const groups = groupActions.flatMap((d) => d.payload); expect(orderBy(groups, ['docCount'], ['desc'])).to.eql( @@ -102,7 +91,7 @@ export default ({ getService }: FtrProviderContext) => { )}, got ${JSON.stringify(groups)}` ); - const groupHistogramActions = getGroupHistogramActions(data, apiVersion); + const groupHistogramActions = getGroupHistogramActions(data); const groupHistograms = groupHistogramActions.flatMap((d) => d.payload); // for each significant items group we should get a histogram expect(groupHistograms.length).to.be(groups.length); diff --git a/x-pack/test/api_integration/apis/aiops/test_data.ts b/x-pack/test/api_integration/apis/aiops/test_data.ts index 63bf9940d959c..21f628d832c7d 100644 --- a/x-pack/test/api_integration/apis/aiops/test_data.ts +++ b/x-pack/test/api_integration/apis/aiops/test_data.ts @@ -25,7 +25,7 @@ import { import type { TestData } from './types'; -export const API_VERSIONS: ApiVersion[] = ['1', '2']; +export const API_VERSIONS: ApiVersion[] = ['2']; export const getLogRateAnalysisTestData = (): Array> => [ { diff --git a/x-pack/test/api_integration/apis/aiops/test_helpers.ts b/x-pack/test/api_integration/apis/aiops/test_helpers.ts index 5252d14fbb7f7..cf5f1d41ebbce 100644 --- a/x-pack/test/api_integration/apis/aiops/test_helpers.ts +++ b/x-pack/test/api_integration/apis/aiops/test_helpers.ts @@ -5,34 +5,16 @@ * 2.0. */ -import type { AiopsLogRateAnalysisApiVersion as ApiVersion } from '@kbn/aiops-log-rate-analysis/api/schema'; +export const getAddSignificationItemsActions = (data: any[]) => + data.filter((d) => d.type === 'add_significant_items'); -export const getAddSignificationItemsActions = (data: any[], apiVersion: ApiVersion) => - data.filter( - (d) => d.type === (apiVersion === '1' ? 'add_significant_terms' : 'add_significant_items') - ); +export const getHistogramActions = (data: any[]) => + data.filter((d) => d.type === 'add_significant_items_histogram'); -export const getHistogramActions = (data: any[], apiVersion: ApiVersion) => - data.filter( - (d) => - d.type === - (apiVersion === '1' ? 'add_significant_terms_histogram' : 'add_significant_items_histogram') - ); +export const getGroupActions = (data: any[]) => + data.filter((d) => d.type === 'add_significant_items_group'); -export const getGroupActions = (data: any[], apiVersion: ApiVersion) => - data.filter( - (d) => - d.type === - (apiVersion === '1' ? 'add_significant_terms_group' : 'add_significant_items_group') - ); - -export const getGroupHistogramActions = (data: any[], apiVersion: ApiVersion) => - data.filter( - (d) => - d.type === - (apiVersion === '1' - ? 'add_significant_terms_group_histogram' - : 'add_significant_items_group_histogram') - ); +export const getGroupHistogramActions = (data: any[]) => + data.filter((d) => d.type === 'add_significant_items_group_histogram'); export const getErrorActions = (data: any[]) => data.filter((d) => d.type === 'add_error'); diff --git a/x-pack/test/api_integration_basic/apis/aiops/permissions.ts b/x-pack/test/api_integration_basic/apis/aiops/permissions.ts index ed25731ffd5e3..239696215c759 100644 --- a/x-pack/test/api_integration_basic/apis/aiops/permissions.ts +++ b/x-pack/test/api_integration_basic/apis/aiops/permissions.ts @@ -17,7 +17,7 @@ import type { import type { FtrProviderContext } from '../../ftr_provider_context'; -const API_VERSIONS: ApiVersion[] = ['1', '2']; +const API_VERSIONS: ApiVersion[] = ['2']; export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/agg_based/gauge.ts b/x-pack/test/functional/apps/lens/open_in_lens/agg_based/gauge.ts index 8a0cd091bb85d..67f1739a53d9b 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/agg_based/gauge.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/agg_based/gauge.ts @@ -21,7 +21,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const elasticChart = getService('elasticChart'); - describe('Gauge', function describeIndexTests() { + // Failing: See https://github.com/elastic/kibana/issues/181895 + describe.skip('Gauge', function describeIndexTests() { const isNewChartsLibraryEnabled = true; before(async () => { diff --git a/x-pack/test/security_solution_api_integration/test_suites/genai/nlp_cleanup_task/basic_license_essentials_tier/task_execution.ts b/x-pack/test/security_solution_api_integration/test_suites/genai/nlp_cleanup_task/basic_license_essentials_tier/task_execution.ts index 4101599b679cd..c560c1db035ac 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/genai/nlp_cleanup_task/basic_license_essentials_tier/task_execution.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/genai/nlp_cleanup_task/basic_license_essentials_tier/task_execution.ts @@ -10,6 +10,7 @@ import { TaskStatus } from '@kbn/task-manager-plugin/server'; import type { MlGetTrainedModelsResponse } from '@elastic/elasticsearch/lib/api/types'; import { FtrProviderContext } from '../../../../ftr_provider_context'; import { waitFor } from '../../../../../common/utils/security_solution'; +import { SUPPORTED_TRAINED_MODELS } from '../../../../../functional/services/ml/api'; export default ({ getService }: FtrProviderContext): void => { const esSupertest = getService('esSupertest'); @@ -19,8 +20,12 @@ export default ({ getService }: FtrProviderContext): void => { const TASK_ID = 'serverless-security:nlp-cleanup-task:1.0.0'; - // Failing: See https://github.com/elastic/kibana/issues/180703 - describe.skip('@serverless NLP Cleanup Task in Essentials Tier', () => { + const TINY_ELSER = { + ...SUPPORTED_TRAINED_MODELS.TINY_ELSER, + id: SUPPORTED_TRAINED_MODELS.TINY_ELSER.name, + }; + + describe('@serverless NLP Cleanup Task in Essentials Tier', () => { describe('New Essentials Deployment', () => { it('registers and enables NLP Cleanup Task', async () => { const task = await kibanaServer.savedObjects.get({ @@ -30,64 +35,76 @@ export default ({ getService }: FtrProviderContext): void => { expect(task.attributes.enabled).to.eql(true); }); + describe('Model Loading', () => { + before(async () => { + // Make sure the .ml-stats index is created in advance, see https://github.com/elastic/elasticsearch/issues/65846 + await ml.api.assureMlStatsIndexExists(); + // Create a light-weight model that has a `model_type` of `pytorch` + await ml.api.importTrainedModel(TINY_ELSER.name, TINY_ELSER.id); + }); - it('executes NLP Cleanup Task and successfully cleans up only pytorch models', async () => { - // Create a light-weight model that has a `model_type` of `pytorch` - await ml.api.importTrainedModel('pt_tiny_fill_mask', 'pt_tiny_fill_mask'); + after(async () => { + await ml.api.stopAllTrainedModelDeploymentsES(); + await ml.api.deleteAllTrainedModelsES(); + await ml.api.cleanMlIndices(); + await ml.testResources.cleanMLSavedObjects(); + }); - // Poll for model to be imported, this can fail with a 404 till the model is imported - let m1: MlGetTrainedModelsResponse = { count: 0, trained_model_configs: [] }; - await waitFor( - async () => { - const { body, status } = await esSupertest.get(`/_ml/trained_models`); - m1 = body; - return status === 200 && m1.count > 0; - }, - 'waitForModelToBeImported', - logger - ); + it('executes NLP Cleanup Task and successfully cleans up only pytorch models', async () => { + // Poll for model to be imported, this can fail with a 404 till the model is imported + let m1: MlGetTrainedModelsResponse = { count: 0, trained_model_configs: [] }; + await waitFor( + async () => { + const { body, status } = await esSupertest.get(`/_ml/trained_models`); + m1 = body; + return status === 200 && m1.count > 1; + }, + 'waitForModelToBeImported', + logger + ); - // Verify model was created, and default non-pytorch model already exists - expect(m1?.trained_model_configs.some((m) => m.model_type === 'pytorch')).to.eql(true); - expect(m1?.trained_model_configs.some((m) => m.model_type === 'lang_ident')).to.eql(true); + // Verify model was created, and default non-pytorch model already exists + expect(m1?.trained_model_configs.some((m) => m.model_type === 'pytorch')).to.eql(true); + expect(m1?.trained_model_configs.some((m) => m.model_type === 'lang_ident')).to.eql(true); - // Grab the task SO so we can update it to 'run_soon' - // Note: Can't go directly through TaskManager in Serverless at the moment, see: https://github.com/elastic/kibana/issues/179303 - const task = await kibanaServer.savedObjects.get({ - type: 'task', - id: TASK_ID, - }); + // Grab the task SO so we can update it to 'run_soon' + // Note: Can't go directly through TaskManager in Serverless at the moment, see: https://github.com/elastic/kibana/issues/179303 + const task = await kibanaServer.savedObjects.get({ + type: 'task', + id: TASK_ID, + }); - // Update task to 'run_soon', 1s from now - const runAt = new Date(Date.now() + 1000).toISOString(); - await kibanaServer.savedObjects.update({ - type: 'task', - id: 'serverless-security:nlp-cleanup-task:1.0.0', - attributes: { - ...task.attributes, - runAt, - scheduledAt: runAt, - status: TaskStatus.Idle, - }, - }); + // Update task to 'run_soon', 1s from now + const runAt = new Date(Date.now() + 1000).toISOString(); + await kibanaServer.savedObjects.update({ + type: 'task', + id: 'serverless-security:nlp-cleanup-task:1.0.0', + attributes: { + ...task.attributes, + runAt, + scheduledAt: runAt, + status: TaskStatus.Idle, + }, + }); - // Let's wait and see... - let m2: MlGetTrainedModelsResponse = { count: 0, trained_model_configs: [] }; - await waitFor( - async () => { - const { body, status } = await esSupertest.get(`/_ml/trained_models`); - m2 = body; - return ( - status === 200 && !m2.trained_model_configs.some((m) => m.model_type === 'pytorch') - ); - }, - 'waitForModelToBeDeleted', - logger - ); + // Let's wait and see... + let m2: MlGetTrainedModelsResponse = { count: 0, trained_model_configs: [] }; + await waitFor( + async () => { + const { body, status } = await esSupertest.get(`/_ml/trained_models`); + m2 = body; + return ( + status === 200 && !m2.trained_model_configs.some((m) => m.model_type === 'pytorch') + ); + }, + 'waitForModelToBeDeleted', + logger + ); - // Verify model was cleaned up, and non-pytorch model was not cleaned up - expect(m2?.trained_model_configs.some((m) => m.model_type === 'pytorch')).to.eql(false); - expect(m2?.trained_model_configs.some((m) => m.model_type === 'lang_ident')).to.eql(true); + // Verify model was cleaned up, and non-pytorch model was not cleaned up + expect(m2?.trained_model_configs.some((m) => m.model_type === 'pytorch')).to.eql(false); + expect(m2?.trained_model_configs.some((m) => m.model_type === 'lang_ident')).to.eql(true); + }); }); }); }); diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts index 6786f82a6fabe..58e1eec24b423 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts @@ -16,7 +16,8 @@ import { export default function (providerContext: FtrProviderContext) { const { loadTestFile, getService, getPageObjects } = providerContext; - describe('endpoint', function () { + // FLAKY: https://github.com/elastic/kibana/issues/180401 + describe.skip('endpoint', function () { const ingestManager = getService('ingestManager'); const log = getService('log'); const endpointTestResources = getService('endpointTestResources');